{"action":"created","comment":{"url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/pulls/comments/34114605","id":34114605,"diff_hunk":"@@ -21,4 +21,162 @@\n \n class FslMelodicOutput < FileCollection\n   Revision_info=CbrainFileRevision[__FILE__] #:nodoc:\n+\n+  has_viewer :name => \"Melodic Viewer\",  :partial => :melodic_viewer\n+\n+  ##################################################################################################\n+  # This method returns the content of an HTML file modified so that it can be\n+  # displayed in the content section of the userfile page.  It\n+  # basically removes some HTML tags (html, body, object, head, title)\n+  # and tweaks the URLs found in <a> and <img> tags.  It is quite\n+  # specific to the HTML pages generated by FSL melodic. A more\n+  # generic implementation would require a complete parsing of the\n+  # HTML code.  It is recursively called for each iframe contained in\n+  # the page.\n+  # Parameters:\n+  #  * file_path: the path of the HTML file whose content will be read, modified and returned. \n+  #  * dir_name: the directory name of the HTML file in the melodic file collection.\n+  ##################################################################################################\n+  \n+  def modified_file_content file_path,dir_name\n+    return nil unless File.exists?(file_path)\n+    lines = Array.new\n+    # The file is processed line by line to speed up substitutions.\n+    File.open(file_path).each do |line|\n+      # Tweaks hrefs.\n+      new_line = tweak_hrefs_in_line line,dir_name\n+      # Tweaks imgs.\n+      new_line = tweak_imgs_in_line new_line,\"#{self.name}/#{dir_name}\"\n+      # Remove specific tags.\n+      new_line = new_line.gsub(/<object.*object>/i,\"\")\n+      new_line = new_line.gsub(/<link.*stylesheet.*>/i,\"\")\n+      new_line = new_line.gsub(/<html>/i,\"\")\n+      new_line = new_line.gsub(/<\\/html>/i,\"\")\n+      new_line = new_line.gsub(/<body>/i,\"\")\n+      new_line = new_line.gsub(/<\\/body>/i,\"\")\n+      new_line = new_line.gsub(/<head>/i,\"\")\n+      new_line = new_line.gsub(/<\\/head>/i,\"\")\n+      new_line = new_line.gsub(/<title>.*<\\/title>/i,\"\")\n+      # Handles iframes.\n+      keep_line = true\n+      new_line.scan(/<IFRAME.*src=(.*) /i) do |x,y|\n+\tframe_path = File.dirname(file_path)+\"/\"+x\n+   \tlines << modified_file_content(frame_path,dir_name)\n+\tkeep_line = false\t\t\t\t\t  \n+      end\n+      lines << new_line if keep_line\n+    end\n+    return lines\n+  end\n+\n+  ##################\n+  # Helper methods #\n+  ##################\n+  \n+  private\n+\n+  # Returns the min of two values.","path":"userfiles/fsl_melodic_output/fsl_melodic_output.rb","position":58,"original_position":58,"commit_id":"28b7ab4cdbc9f78c57c542c5235b256043965db4","original_commit_id":"28b7ab4cdbc9f78c57c542c5235b256043965db4","user":{"login":"natacha-beck","id":777590,"avatar_url":"https://avatars.githubusercontent.com/u/777590?v=3","gravatar_id":"","url":"https://api.github.com/users/natacha-beck","html_url":"https://github.com/natacha-beck","followers_url":"https://api.github.com/users/natacha-beck/followers","following_url":"https://api.github.com/users/natacha-beck/following{/other_user}","gists_url":"https://api.github.com/users/natacha-beck/gists{/gist_id}","starred_url":"https://api.github.com/users/natacha-beck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natacha-beck/subscriptions","organizations_url":"https://api.github.com/users/natacha-beck/orgs","repos_url":"https://api.github.com/users/natacha-beck/repos","events_url":"https://api.github.com/users/natacha-beck/events{/privacy}","received_events_url":"https://api.github.com/users/natacha-beck/received_events","type":"User","site_admin":false},"body":"You can remove min2 and min3. \r\nPut your value in an array ex: \r\na = [1,2,3]\r\na.min # => 1","created_at":"2015-07-08T04:06:28Z","updated_at":"2015-07-08T04:06:28Z","html_url":"https://github.com/aces/cbrain-plugins-fsl/pull/3#discussion_r34114605","pull_request_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/aces/cbrain-plugins-fsl/pulls/comments/34114605"},"html":{"href":"https://github.com/aces/cbrain-plugins-fsl/pull/3#discussion_r34114605"},"pull_request":{"href":"https://api.github.com/repos/aces/cbrain-plugins-fsl/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/pulls/3","id":38688733,"html_url":"https://github.com/aces/cbrain-plugins-fsl/pull/3","diff_url":"https://github.com/aces/cbrain-plugins-fsl/pull/3.diff","patch_url":"https://github.com/aces/cbrain-plugins-fsl/pull/3.patch","issue_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/issues/3","number":3,"state":"open","locked":false,"title":"Updates in FSL melodic (viewer of output files, inputs in CSV file, param cleanup, support for MINC files, handling of non-zero exit codes, added several options.)","user":{"login":"glatard","id":5174953,"avatar_url":"https://avatars.githubusercontent.com/u/5174953?v=3","gravatar_id":"","url":"https://api.github.com/users/glatard","html_url":"https://github.com/glatard","followers_url":"https://api.github.com/users/glatard/followers","following_url":"https://api.github.com/users/glatard/following{/other_user}","gists_url":"https://api.github.com/users/glatard/gists{/gist_id}","starred_url":"https://api.github.com/users/glatard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glatard/subscriptions","organizations_url":"https://api.github.com/users/glatard/orgs","repos_url":"https://api.github.com/users/glatard/repos","events_url":"https://api.github.com/users/glatard/events{/privacy}","received_events_url":"https://api.github.com/users/glatard/received_events","type":"User","site_admin":false},"body":"See ticket #6826 on Redmine.\r\nPlease deploy in production if you agree with the code. \r\n","created_at":"2015-06-26T20:57:21Z","updated_at":"2015-07-08T04:06:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2a958a7329a2564f3c4f63ab5627dd0f39d3d25b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/pulls/3/commits","review_comments_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/pulls/3/comments","review_comment_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/issues/3/comments","statuses_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/statuses/28b7ab4cdbc9f78c57c542c5235b256043965db4","head":{"label":"glatard:master","ref":"master","sha":"28b7ab4cdbc9f78c57c542c5235b256043965db4","user":{"login":"glatard","id":5174953,"avatar_url":"https://avatars.githubusercontent.com/u/5174953?v=3","gravatar_id":"","url":"https://api.github.com/users/glatard","html_url":"https://github.com/glatard","followers_url":"https://api.github.com/users/glatard/followers","following_url":"https://api.github.com/users/glatard/following{/other_user}","gists_url":"https://api.github.com/users/glatard/gists{/gist_id}","starred_url":"https://api.github.com/users/glatard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glatard/subscriptions","organizations_url":"https://api.github.com/users/glatard/orgs","repos_url":"https://api.github.com/users/glatard/repos","events_url":"https://api.github.com/users/glatard/events{/privacy}","received_events_url":"https://api.github.com/users/glatard/received_events","type":"User","site_admin":false},"repo":{"id":36885501,"name":"cbrain-plugins-fsl","full_name":"glatard/cbrain-plugins-fsl","owner":{"login":"glatard","id":5174953,"avatar_url":"https://avatars.githubusercontent.com/u/5174953?v=3","gravatar_id":"","url":"https://api.github.com/users/glatard","html_url":"https://github.com/glatard","followers_url":"https://api.github.com/users/glatard/followers","following_url":"https://api.github.com/users/glatard/following{/other_user}","gists_url":"https://api.github.com/users/glatard/gists{/gist_id}","starred_url":"https://api.github.com/users/glatard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glatard/subscriptions","organizations_url":"https://api.github.com/users/glatard/orgs","repos_url":"https://api.github.com/users/glatard/repos","events_url":"https://api.github.com/users/glatard/events{/privacy}","received_events_url":"https://api.github.com/users/glatard/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/glatard/cbrain-plugins-fsl","description":"FSL models and tasks for CBRAIN","fork":true,"url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl","forks_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/forks","keys_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/teams","hooks_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/hooks","issue_events_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/issues/events{/number}","events_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/events","assignees_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/assignees{/user}","branches_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/branches{/branch}","tags_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/tags","blobs_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/git/refs{/sha}","trees_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/statuses/{sha}","languages_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/languages","stargazers_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/stargazers","contributors_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/contributors","subscribers_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/subscribers","subscription_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/subscription","commits_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/commits{/sha}","git_commits_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/git/commits{/sha}","comments_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/comments{/number}","issue_comment_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/issues/comments{/number}","contents_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/contents/{+path}","compare_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/merges","archive_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/downloads","issues_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/issues{/number}","pulls_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/pulls{/number}","milestones_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/milestones{/number}","notifications_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/labels{/name}","releases_url":"https://api.github.com/repos/glatard/cbrain-plugins-fsl/releases{/id}","created_at":"2015-06-04T17:32:15Z","updated_at":"2015-06-04T17:32:15Z","pushed_at":"2015-07-07T19:19:09Z","git_url":"git://github.com/glatard/cbrain-plugins-fsl.git","ssh_url":"git@github.com:glatard/cbrain-plugins-fsl.git","clone_url":"https://github.com/glatard/cbrain-plugins-fsl.git","svn_url":"https://github.com/glatard/cbrain-plugins-fsl","homepage":null,"size":998,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"aces:master","ref":"master","sha":"d13efb6018ecb70438d90a5fd6caa62a00b0b680","user":{"login":"aces","id":472868,"avatar_url":"https://avatars.githubusercontent.com/u/472868?v=3","gravatar_id":"","url":"https://api.github.com/users/aces","html_url":"https://github.com/aces","followers_url":"https://api.github.com/users/aces/followers","following_url":"https://api.github.com/users/aces/following{/other_user}","gists_url":"https://api.github.com/users/aces/gists{/gist_id}","starred_url":"https://api.github.com/users/aces/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aces/subscriptions","organizations_url":"https://api.github.com/users/aces/orgs","repos_url":"https://api.github.com/users/aces/repos","events_url":"https://api.github.com/users/aces/events{/privacy}","received_events_url":"https://api.github.com/users/aces/received_events","type":"Organization","site_admin":false},"repo":{"id":29207530,"name":"cbrain-plugins-fsl","full_name":"aces/cbrain-plugins-fsl","owner":{"login":"aces","id":472868,"avatar_url":"https://avatars.githubusercontent.com/u/472868?v=3","gravatar_id":"","url":"https://api.github.com/users/aces","html_url":"https://github.com/aces","followers_url":"https://api.github.com/users/aces/followers","following_url":"https://api.github.com/users/aces/following{/other_user}","gists_url":"https://api.github.com/users/aces/gists{/gist_id}","starred_url":"https://api.github.com/users/aces/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aces/subscriptions","organizations_url":"https://api.github.com/users/aces/orgs","repos_url":"https://api.github.com/users/aces/repos","events_url":"https://api.github.com/users/aces/events{/privacy}","received_events_url":"https://api.github.com/users/aces/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aces/cbrain-plugins-fsl","description":"FSL models and tasks for CBRAIN","fork":false,"url":"https://api.github.com/repos/aces/cbrain-plugins-fsl","forks_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/forks","keys_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/teams","hooks_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/hooks","issue_events_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/issues/events{/number}","events_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/events","assignees_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/assignees{/user}","branches_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/branches{/branch}","tags_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/tags","blobs_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/git/refs{/sha}","trees_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/statuses/{sha}","languages_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/languages","stargazers_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/stargazers","contributors_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/contributors","subscribers_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/subscribers","subscription_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/subscription","commits_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/commits{/sha}","git_commits_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/git/commits{/sha}","comments_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/comments{/number}","issue_comment_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/issues/comments{/number}","contents_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/contents/{+path}","compare_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/merges","archive_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/downloads","issues_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/issues{/number}","pulls_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/pulls{/number}","milestones_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/milestones{/number}","notifications_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/labels{/name}","releases_url":"https://api.github.com/repos/aces/cbrain-plugins-fsl/releases{/id}","created_at":"2015-01-13T19:42:59Z","updated_at":"2015-04-21T14:37:40Z","pushed_at":"2015-07-07T19:48:26Z","git_url":"git://github.com/aces/cbrain-plugins-fsl.git","ssh_url":"git@github.com:aces/cbrain-plugins-fsl.git","clone_url":"https://github.com/aces/cbrain-plugins-fsl.git","svn_url":"https://github.com/aces/cbrain-plugins-fsl","homepage":null,"size":1419,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":8,"forks":4,"open_issues":8,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aces/cbrain-plugins-fsl/pulls/3"},"html":{"href":"https://github.com/aces/cbrain-plugins-fsl/pull/3"},"issue":{"href":"https://api.github.com/repos/aces/cbrain-plugins-fsl/issues/3"},"comments":{"href":"https://api.github.com/repos/aces/cbrain-plugins-fsl/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/aces/cbrain-plugins-fsl/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/aces/cbrain-plugins-fsl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aces/cbrain-plugins-fsl/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/aces/cbrain-plugins-fsl/statuses/28b7ab4cdbc9f78c57c542c5235b256043965db4"}}}}