Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
gitlab-ce
Commits
94390fc7
Commit
94390fc7
authored
Apr 03, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proper routing. blobs for blobs, raw for send_data
parent
88abe66c
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
99 additions
and
34 deletions
+99
-34
app/controllers/blob_controller.rb
app/controllers/blob_controller.rb
+1
-10
app/controllers/raw_controller.rb
app/controllers/raw_controller.rb
+25
-0
app/helpers/tree_helper.rb
app/helpers/tree_helper.rb
+1
-1
app/views/blob/_actions.html.haml
app/views/blob/_actions.html.haml
+3
-3
app/views/blob/_blob.html.haml
app/views/blob/_blob.html.haml
+27
-0
app/views/blob/_download.html.haml
app/views/blob/_download.html.haml
+0
-0
app/views/blob/_image.html.haml
app/views/blob/_image.html.haml
+0
-0
app/views/blob/_text.html.haml
app/views/blob/_text.html.haml
+0
-0
app/views/blob/show.html.haml
app/views/blob/show.html.haml
+4
-0
app/views/blob/show.js.haml
app/views/blob/show.js.haml
+10
-0
app/views/tree/_blob.html.haml
app/views/tree/_blob.html.haml
+0
-13
app/views/tree/_blob_item.html.haml
app/views/tree/_blob_item.html.haml
+9
-0
app/views/tree/_tree.html.haml
app/views/tree/_tree.html.haml
+5
-6
config/routes.rb
config/routes.rb
+1
-0
lib/gitlab/git/blob.rb
lib/gitlab/git/blob.rb
+13
-1
No files found.
app/controllers/blob_controller.rb
View file @
94390fc7
...
...
@@ -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
app/controllers/raw_controller.rb
0 → 100644
View file @
94390fc7
# 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
app/helpers/tree_helper.rb
View file @
94390fc7
...
...
@@ -18,7 +18,7 @@ module TreeHelper
render
partial:
'tree/submodule_item'
,
object:
f
else
# Object is a Blob
render
partial:
'tree/
tree
_item'
,
object:
f
,
locals:
{
type:
'file'
}
render
partial:
'tree/
blob
_item'
,
object:
f
,
locals:
{
type:
'file'
}
end
tree
+=
html
if
html
.
present?
...
...
app/views/
tree/_blob
_actions.html.haml
→
app/views/
blob/
_actions.html.haml
View file @
94390fc7
.btn-group.tree-btn-group
-# only show edit link for text files
-
if
@
tree
.
text?
-
if
@
blob
.
text?
=
link_to
"edit"
,
project_edit_tree_path
(
@project
,
@id
),
class:
"btn btn-tiny"
,
disabled:
!
allowed_tree_edit?
=
link_to
"raw"
,
project_
blob
_path
(
@project
,
@id
),
class:
"btn btn-tiny"
,
target:
"_blank"
=
link_to
"raw"
,
project_
raw
_path
(
@project
,
@id
),
class:
"btn btn-tiny"
,
target:
"_blank"
-# only show normal/blame view links for text files
-
if
@
tree
.
text?
-
if
@
blob
.
text?
-
if
current_page?
project_blame_path
(
@project
,
@id
)
=
link_to
"normal view"
,
project_tree_path
(
@project
,
@id
),
class:
"btn btn-tiny"
-
else
...
...
app/views/blob/_blob.html.haml
0 → 100644
View file @
94390fc7
%ul
.breadcrumb
%li
%i
.icon-angle-right
=
link_to
project_tree_path
(
@project
,
@ref
)
do
=
@project
.
path
-
tree_breadcrumbs
(
@tree
,
6
)
do
|
title
,
path
|
\/
%li
-
if
path
=
link_to
truncate
(
title
,
length:
40
),
project_tree_path
(
@project
,
path
)
-
else
=
link_to
title
,
'#'
%div
#tree-content-holder
.tree-content-holder
.file_holder
.file_title
%i
.icon-file
%span
.file_name
=
blob
.
name
%small
=
number_to_human_size
blob
.
size
%span
.options
=
render
"actions"
-
if
blob
.
text?
=
render
"text"
,
blob:
blob
-
elsif
blob
.
image?
=
render
"image"
,
blob:
blob
-
else
=
render
"download"
,
blob:
blob
app/views/
tree/
blob/_download.html.haml
→
app/views/blob/_download.html.haml
View file @
94390fc7
File moved
app/views/
tree/
blob/_image.html.haml
→
app/views/blob/_image.html.haml
View file @
94390fc7
File moved
app/views/
tree/
blob/_text.html.haml
→
app/views/blob/_text.html.haml
View file @
94390fc7
File moved
app/views/blob/show.html.haml
0 → 100644
View file @
94390fc7
%div
.tree-ref-holder
=
render
'shared/ref_switcher'
,
destination:
'tree'
,
path:
@path
%div
#tree-holder
.tree-holder
=
render
'blob'
,
blob:
@blob
app/views/blob/show.js.haml
0 → 100644
View file @
94390fc7
:plain
// Load Files list
$("#tree-holder").html("
#{
escape_javascript
(
render
(
partial:
"blob"
,
locals:
{
blob:
@blob
}))
}
");
$("#tree-content-holder").show("slide", { direction: "right" }, 400);
$('.project-refs-form #path').val("
#{
@path
}
");
// Load last commit log for each file in tree
$('#tree-slider').waitForImages(function() {
ajaxGet('
#{
@logs_path
}
');
});
app/views/tree/_blob.html.haml
deleted
100644 → 0
View file @
88abe66c
.file_holder
.file_title
%i
.icon-file
%span
.file_name
=
blob
.
name
%small
=
number_to_human_size
blob
.
size
%span
.options
=
render
"tree/blob_actions"
-
if
blob
.
text?
=
render
"tree/blob/text"
,
blob:
blob
-
elsif
blob
.
image?
=
render
"tree/blob/image"
,
blob:
blob
-
else
=
render
"tree/blob/download"
,
blob:
blob
app/views/tree/_blob_item.html.haml
0 → 100644
View file @
94390fc7
%tr
{
class:
"tree-item #{tree_hex_class(blob_item)}"
}
%td
.tree-item-file-name
=
tree_icon
(
type
)
%strong
=
link_to
truncate
(
blob_item
.
name
,
length:
40
),
project_blob_path
(
@project
,
tree_join
(
@id
||
@commit
.
id
,
blob_item
.
name
))
%td
.tree_time_ago.cgray
%span
.log_loading.hide
Loading commit data...
=
image_tag
"ajax_loader_tree.gif"
,
width:
14
%td
.tree_commit
{
colspan:
2
}
app/views/tree/_tree.html.haml
View file @
94390fc7
...
...
@@ -39,9 +39,8 @@
%div
.tree_progress
-
unless
tree
.
is_blob?
:javascript
// Load last commit log for each file in tree
$
(
window
).
load
(
function
(){
ajaxGet
(
'
#{
@logs_path
}
'
);
});
:javascript
// Load last commit log for each file in tree
$
(
window
).
load
(
function
(){
ajaxGet
(
'
#{
@logs_path
}
'
);
});
config/routes.rb
View file @
94390fc7
...
...
@@ -170,6 +170,7 @@ Gitlab::Application.routes.draw do
end
resources
:blob
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:raw
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:tree
,
only:
[
:show
],
constraints:
{
id:
/.+/
,
format:
/(html|js)/
}
resources
:edit_tree
,
only:
[
:show
,
:update
],
constraints:
{
id:
/.+/
},
path:
'edit'
resources
:commit
,
only:
[
:show
],
constraints:
{
id:
/[[:alnum:]]{6,40}/
}
...
...
lib/gitlab/git/blob.rb
View file @
94390fc7
...
...
@@ -23,7 +23,19 @@ module Gitlab
end
def
exists?
@raw_blob
raw_blob
end
def
empty?
data
.
blank?
end
def
mode
raw_blob
.
mode
end
def
size
raw_blob
.
size
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment