GitHub PullRequestReviewCommentEvent at 2014-06-05 08:05:49
Repository: gitlabhq
Actor: houndci
Payload: {"comment":{"url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/comments/13427989","id":13427989,"diff_hunk":"@@ -0,0 +1,47 @@\n+module Projects\n+  class FileService < BaseService\n+    include Rails.application.routes.url_helpers\n+    def initialize(repository, params, root_url)\n+      @repository, @params, @root_url = repository, params.dup, root_url\n+    end\n+\n+    def execute\n+      uploader = FileUploader.new('uploads', upload_path, accepted_files)\n+      file = @params['markdown_file']\n+\n+      if file\n+        alt = file.original_filename\n+        uploader.store!(file)\n+        link = {\n+                 'alt' => File.basename(alt, '.*'),\n+                 'url' => File.join(@root_url, uploader.url),\n+                 'is_image' => image?(file)\n+               }\n+      else\n+        link = nil\n+      end\n+    end\n+\n+  protected\n+    def accepted_files\n+      #insert accepted mime types here (e.g %w(jpg jpeg gif png))\n+    end\n+\n+    def accepted_images\n+      %w(jpg jpeg gif png)\n+    end\n+\n+    def image?(file)\n+      accepted_images.map{ |format| file.content_type.include? format }.any?\n+    end\n+\n+    def upload_path\n+      base_dir = FileUploader.generate_dir\n+      File.join(@repository.path_with_namespace, base_dir)\n+    end\n+\n+    def correct_mime_type?(file)\n+      accepted_files.map{ |format| image.content_type.include? format }.any?","path":"app/services/projects/file_service.rb","position":44,"original_position":44,"commit_id":"206993cc7352d400218e9385c5ed554e7e7feb5c","original_commit_id":"206993cc7352d400218e9385c5ed554e7e7feb5c","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?","gravatar_id":"38d9cefd9971a05bf447f07c6cd332cc","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Space missing to the left of {.","created_at":"2014-06-05T08:05:49Z","updated_at":"2014-06-05T08:05:49Z","html_url":"https://github.com/gitlabhq/gitlabhq/pull/7078#discussion_r13427989","pull_request_url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7078","_links":{"self":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/comments/13427989"},"html":{"href":"https://github.com/gitlabhq/gitlabhq/pull/7078#discussion_r13427989"},"pull_request":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7078"}}}}