summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-03 09:26:38 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-03 09:26:38 +0300
commit94390fc7b42e92d4e1d38c8392a2e310a256c4ca (patch)
tree59ea43b8a0de43727b841c2d55b250411b024f48 /app/controllers
parent88abe66c27504bcda71fd0ddbeb22d0115b8c09f (diff)
downloadgitlab-ce-94390fc7b42e92d4e1d38c8392a2e310a256c4ca.tar.gz
Proper routing. blobs for blobs, raw for send_data
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/blob_controller.rb11
-rw-r--r--app/controllers/raw_controller.rb25
2 files changed, 26 insertions, 10 deletions
diff --git a/app/controllers/blob_controller.rb b/app/controllers/blob_controller.rb
index 530b72fee7f..3547dfe2323 100644
--- a/app/controllers/blob_controller.rb
+++ b/app/controllers/blob_controller.rb
@@ -8,15 +8,6 @@ class BlobController < ProjectResourceController
before_filter :require_non_empty_project
def show
- if @tree.is_blob?
- send_data(
- @tree.data,
- type: @tree.mime_type,
- disposition: 'inline',
- filename: @tree.name
- )
- else
- not_found!
- end
+ @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path)
end
end
diff --git a/app/controllers/raw_controller.rb b/app/controllers/raw_controller.rb
new file mode 100644
index 00000000000..18b401fe611
--- /dev/null
+++ b/app/controllers/raw_controller.rb
@@ -0,0 +1,25 @@
+# Controller for viewing a file's raw
+class RawController < ProjectResourceController
+ include ExtractsPath
+
+ # Authorize
+ before_filter :authorize_read_project!
+ before_filter :authorize_code_access!
+ before_filter :require_non_empty_project
+
+ def show
+ @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path)
+
+ if @blob.exists?
+ send_data(
+ @blob.data,
+ type: @blob.mime_type,
+ disposition: 'inline',
+ filename: @blob.name
+ )
+ else
+ not_found!
+ end
+ end
+end
+