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
af08ed6b
Commit
af08ed6b
authored
Nov 16, 2011
by
gitlabhq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring
parent
f294b8d4
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
96 additions
and
79 deletions
+96
-79
app/assets/stylesheets/style.scss
app/assets/stylesheets/style.scss
+1
-1
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+0
-43
app/controllers/refs_controller.rb
app/controllers/refs_controller.rb
+53
-0
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+1
-1
app/models/project.rb
app/models/project.rb
+4
-0
app/views/commits/_commits.html.haml
app/views/commits/_commits.html.haml
+1
-1
app/views/commits/_diff.html.haml
app/views/commits/_diff.html.haml
+1
-1
app/views/commits/show.html.haml
app/views/commits/show.html.haml
+1
-1
app/views/layouts/project.html.haml
app/views/layouts/project.html.haml
+2
-2
app/views/projects/tree.html.erb
app/views/projects/tree.html.erb
+0
-5
app/views/refs/_tree.html.haml
app/views/refs/_tree.html.haml
+9
-9
app/views/refs/_tree_file.html.haml
app/views/refs/_tree_file.html.haml
+2
-2
app/views/refs/_tree_item.html.haml
app/views/refs/_tree_item.html.haml
+2
-2
app/views/refs/tree.html.haml
app/views/refs/tree.html.haml
+1
-0
app/views/refs/tree.js.haml
app/views/refs/tree.js.haml
+5
-0
config/routes.rb
config/routes.rb
+13
-11
No files found.
app/assets/stylesheets/style.scss
View file @
af08ed6b
...
...
@@ -571,7 +571,7 @@ body.project-page .project-sidebar aside a:first-child{
body
.project-page
.project-sidebar
aside
a
:hover
{
background-color
:
#eee
;}
body
.project-page
.project-sidebar
aside
a
span
.number
{
float
:
right
;
border-radius
:
5px
;
text-shadow
:
none
;
background
:
rgba
(
0
,
0
,
0
,.
12
);
text-align
:
center
;
padding
:
5px
8px
;
position
:
absolute
;
top
:
10px
;
right
:
10px
}
body
.project-page
.project-sidebar
aside
a
.current
{
background-color
:
#79c3e0
;
color
:
white
;
text-shadow
:
none
;
border-color
:
transparent
}
body
.project-page
.project-content
{
padding
:
20px
;
display
:
block
;
margin-left
:
250px
;
min-height
:
4
0
0px
}
body
.project-page
.project-content
{
padding
:
20px
;
display
:
block
;
margin-left
:
250px
;
min-height
:
4
5
0px
}
body
.project-page
.project-content
h2
{
margin-top
:
6px
}
body
.project-page
.project-content
.button.right
{
margin-left
:
20px
}
body
.project-page
table
.commit
a
{
color
:
#{
$blue_link
}
}
...
...
app/controllers/projects_controller.rb
View file @
af08ed6b
...
...
@@ -88,35 +88,6 @@ class ProjectsController < ApplicationController
end
end
#
# Repository preview
#
def
tree
@repo
=
project
.
repo
@commit
=
if
params
[
:commit_id
]
@repo
.
commits
(
params
[
:commit_id
]).
first
else
@repo
.
commits
(
@ref
).
first
end
@tree
=
@commit
.
tree
@tree
=
@tree
/
params
[
:path
]
if
params
[
:path
]
respond_to
do
|
format
|
format
.
html
# show.html.erb
format
.
js
do
# diasbale cache to allow back button works
response
.
headers
[
"Cache-Control"
]
=
"no-cache, no-store, max-age=0, must-revalidate"
response
.
headers
[
"Pragma"
]
=
"no-cache"
response
.
headers
[
"Expires"
]
=
"Fri, 01 Jan 1990 00:00:00 GMT"
end
end
rescue
return
render_404
end
def
graph
@repo
=
project
.
repo
commits
=
Grit
::
Commit
.
find_all
(
@repo
,
nil
,
{
:max_count
=>
650
})
...
...
@@ -145,20 +116,6 @@ class ProjectsController < ApplicationController
end
.
to_json
end
def
blob
@repo
=
project
.
repo
@commit
=
project
.
commit
(
params
[
:commit_id
])
@tree
=
project
.
tree
(
@commit
,
params
[
:path
])
if
@tree
.
is_a?
(
Grit
::
Blob
)
send_data
(
@tree
.
data
,
:type
=>
@tree
.
mime_type
,
:disposition
=>
'inline'
,
:filename
=>
@tree
.
name
)
else
head
(
404
)
end
rescue
return
render_404
end
def
destroy
project
.
destroy
...
...
app/controllers/refs_controller.rb
0 → 100644
View file @
af08ed6b
class
RefsController
<
ApplicationController
before_filter
:project
before_filter
:ref
layout
"project"
# Authorize
before_filter
:add_project_abilities
before_filter
:authorize_read_project!
before_filter
:require_non_empty_project
#
# Repository preview
#
def
tree
@repo
=
project
.
repo
@commit
=
@repo
.
commits
(
@ref
).
first
@tree
=
@commit
.
tree
@tree
=
@tree
/
params
[
:path
]
if
params
[
:path
]
respond_to
do
|
format
|
format
.
html
# show.html.erb
format
.
js
do
# diasbale cache to allow back button works
response
.
headers
[
"Cache-Control"
]
=
"no-cache, no-store, max-age=0, must-revalidate"
response
.
headers
[
"Pragma"
]
=
"no-cache"
response
.
headers
[
"Expires"
]
=
"Fri, 01 Jan 1990 00:00:00 GMT"
end
end
rescue
return
render_404
end
def
blob
@repo
=
project
.
repo
@commit
=
project
.
commit
(
@ref
)
@tree
=
project
.
tree
(
@commit
,
params
[
:path
])
if
@tree
.
is_a?
(
Grit
::
Blob
)
send_data
(
@tree
.
data
,
:type
=>
@tree
.
mime_type
,
:disposition
=>
'inline'
,
:filename
=>
@tree
.
name
)
else
head
(
404
)
end
rescue
return
render_404
end
protected
def
ref
@ref
=
params
[
:id
]
end
end
app/helpers/application_helper.rb
View file @
af08ed6b
...
...
@@ -73,7 +73,7 @@ module ApplicationHelper
project_nav
=
[
{
:label
=>
"
#{
@project
.
code
}
/ Issues"
,
:url
=>
project_issues_path
(
@project
)
},
{
:label
=>
"
#{
@project
.
code
}
/ Wall"
,
:url
=>
wall_project_path
(
@project
)
},
{
:label
=>
"
#{
@project
.
code
}
/ Tree"
,
:url
=>
tree_project_
path
(
@project
)
},
{
:label
=>
"
#{
@project
.
code
}
/ Tree"
,
:url
=>
tree_project_
ref_path
(
@project
,
@project
.
root_ref
)
},
{
:label
=>
"
#{
@project
.
code
}
/ Commits"
,
:url
=>
project_commits_path
(
@project
)
},
{
:label
=>
"
#{
@project
.
code
}
/ Team"
,
:url
=>
team_project_path
(
@project
)
}
]
...
...
app/models/project.rb
View file @
af08ed6b
...
...
@@ -121,6 +121,10 @@ class Project < ActiveRecord::Base
@admins
||=
users_projects
.
includes
(
:user
).
where
(
:admin
=>
true
).
map
(
&
:user
)
end
def
root_ref
"master"
end
def
public?
!
private_flag
end
...
...
app/views/commits/_commits.html.haml
View file @
af08ed6b
...
...
@@ -9,7 +9,7 @@
%data
.commit-button
=
truncate
(
commit
.
id
.
to_s
,
:length
=>
16
)
%i
%data
.commit-browse
{
:onclick
=>
"location.href='#{tree_project_
path(@project, :commit_id =>
commit.id)}';return false;"
}
%data
.commit-browse
{
:onclick
=>
"location.href='#{tree_project_
ref_path(@project,
commit.id)}';return false;"
}
Browse Code
-
if
commit
.
author_email
=
image_tag
gravatar_icon
(
commit
.
author_email
),
:class
=>
"left"
,
:width
=>
40
,
:style
=>
"padding-right:5px;"
...
...
app/views/commits/_diff.html.haml
View file @
af08ed6b
...
...
@@ -9,7 +9,7 @@
-
if
diff
.
deleted_file
%strong
{
:id
=>
"#{diff.b_path}"
}=
diff
.
a_path
-
else
=
link_to
tree_file_project_path
(
@project
,
@commit
.
id
,
diff
.
b_path
)
do
=
link_to
tree_file_project_
ref_
path
(
@project
,
@commit
.
id
,
diff
.
b_path
)
do
%strong
{
:id
=>
"#{diff.b_path}"
}=
diff
.
b_path
%br
/
.diff_file_content
...
...
app/views/commits/show.html.haml
View file @
af08ed6b
...
...
@@ -18,7 +18,7 @@
=
preserve
@commit
.
safe_message
%tr
%td
Tree
%td
=
link_to
'Browse Code'
,
tree_project_
path
(
@project
,
:commit_id
=>
@commit
.
id
)
%td
=
link_to
'Browse Code'
,
tree_project_
ref_path
(
@project
,
@commit
.
id
)
.clear
%br
...
...
app/views/layouts/project.html.haml
View file @
af08ed6b
...
...
@@ -5,7 +5,7 @@
GitLab
#{
" - #{@project.name}"
if
@project
&&
!
@project
.
new_record?
}
=
stylesheet_link_tag
"application"
=
javascript_include_tag
"application"
-
if
current_page?
(
tree_project_
path
(
@project
))
||
current_page?
(
project_commits_path
(
@project
))
-
if
current_page?
(
tree_project_
ref_path
(
@project
,
@project
.
root_ref
))
||
current_page?
(
project_commits_path
(
@project
))
=
auto_discovery_link_tag
(
:atom
,
project_commits_url
(
@project
,
:atom
,
:ref
=>
@ref
,
:private_token
=>
current_user
.
private_token
),
:title
=>
"Recent commits to
#{
@project
.
name
}
:
#{
@ref
}
"
)
-
if
request
.
path
==
project_issues_path
(
@project
)
=
auto_discovery_link_tag
(
:atom
,
project_issues_url
(
@project
,
:atom
,
:private_token
=>
current_user
.
private_token
),
:title
=>
"
#{
@project
.
name
}
issues"
)
...
...
@@ -24,7 +24,7 @@
%input
.git-url.text
{
:id
=>
""
,
:name
=>
""
,
:readonly
=>
""
,
:type
=>
"text"
,
:value
=>
@project
.
url_to_repo
,
:class
=>
"one_click_select"
}
%aside
=
link_to
"Activities"
,
project_path
(
@project
),
:class
=>
current_page?
(
:controller
=>
"projects"
,
:action
=>
"show"
,
:id
=>
@project
)
?
"current"
:
nil
=
link_to
"Tree"
,
tree_project_
path
(
@project
),
:class
=>
current_page?
(
:controller
=>
"projects"
,
:action
=>
"tree"
,
:id
=>
@project
)
?
"current"
:
nil
=
link_to
"Tree"
,
tree_project_
ref_path
(
@project
,
@project
.
root_ref
),
:class
=>
current_page?
(
:controller
=>
"refs"
,
:action
=>
"tree"
,
:project_id
=>
@project
,
:id
=>
@ref
||
@project
.
root_ref
)
?
"current"
:
nil
=
link_to
"Commits"
,
project_commits_path
(
@project
),
:class
=>
current_page?
(
:controller
=>
"commits"
,
:action
=>
"index"
,
:project_id
=>
@project
)
?
"current"
:
nil
=
link_to
"Network graph"
,
graph_project_path
(
@project
),
:class
=>
current_page?
(
:controller
=>
"projects"
,
:action
=>
"graph"
,
:id
=>
@project
)
?
"current"
:
nil
=
link_to
team_project_path
(
@project
),
:class
=>
(
current_page?
(
:controller
=>
"projects"
,
:action
=>
"team"
,
:id
=>
@project
)
||
controller
.
controller_name
==
"team_members"
)
?
"current"
:
nil
do
...
...
app/views/projects/tree.html.erb
deleted
100644 → 0
View file @
f294b8d4
<div>
<div
id=
"tree-holder"
>
<%=
render
:partial
=>
"tree"
,
:locals
=>
{
:repo
=>
@repo
,
:commit
=>
@commit
,
:tree
=>
@tree
}
%>
</div>
</div>
app/views/
project
s/_tree.html.haml
→
app/views/
ref
s/_tree.html.haml
View file @
af08ed6b
...
...
@@ -5,7 +5,7 @@
%h2
.icon
%span
%d
=
link_to
tree_project_
path
(
@project
,
:path
=>
nil
,
:commit_id
=>
@commit
.
try
(
:id
)
),
:remote
=>
true
do
=
link_to
tree_project_
ref_path
(
@project
,
@ref
,
:path
=>
nil
),
:remote
=>
true
do
=
@project
.
name
-
if
params
[
:path
]
-
part_path
=
""
...
...
@@ -14,14 +14,14 @@
-
if
part_path
.
empty?
-
part_path
=
part
\/
=
link_to
truncate
(
part
,
:length
=>
40
),
tree_file_project_
path
(
@project
,
:path
=>
part_path
,
:commit_id
=>
@commit
.
try
(
:id
),
:branch
=>
@branch
,
:tag
=>
@tag
),
:remote
=>
:true
=
link_to
truncate
(
part
,
:length
=>
40
),
tree_file_project_
ref_path
(
@project
,
@ref
,
:path
=>
part_path
),
:remote
=>
:true
.right
=
render
:partial
=>
"projects/refs"
,
:locals
=>
{
:destination
=>
tree_project_
path
(
@project
)
}
.right
=
render
:partial
=>
"projects/refs"
,
:locals
=>
{
:destination
=>
tree_project_
ref_path
(
@project
,
@ref
)
}
.clear
#tree-content-holder
-
if
tree
.
is_a?
(
Grit
::
Blob
)
=
render
:partial
=>
"
project
s/tree_file"
,
:locals
=>
{
:name
=>
tree
.
name
,
:content
=>
tree
.
data
,
:file
=>
tree
}
=
render
:partial
=>
"
ref
s/tree_file"
,
:locals
=>
{
:name
=>
tree
.
name
,
:content
=>
tree
.
data
,
:file
=>
tree
}
-
else
-
contents
=
tree
.
contents
%table
#tree-slider
.round-borders
...
...
@@ -30,20 +30,20 @@
%th
Last Update
%th
Last commit
=
link_to
"history"
,
project_commits_path
(
@project
,
:path
=>
params
[
:path
],
:
branch
=>
params
[
:branch
],
:tag
=>
params
[
:tag
]
),
:class
=>
"right"
=
link_to
"history"
,
project_commits_path
(
@project
,
:path
=>
params
[
:path
],
:
ref
=>
@ref
),
:class
=>
"right"
-
if
params
[
:path
]
-
file
=
File
.
join
(
params
[
:path
],
".."
)
%tr
{
:class
=>
"tree-item"
,
:url
=>
tree_file_project_
path
(
@project
,
@commit
.
id
,
file
)
}
%tr
{
:class
=>
"tree-item"
,
:url
=>
tree_file_project_
ref_path
(
@project
,
@ref
,
file
)
}
%td
.tree-item-file-name
=
image_tag
"dir.png"
=
link_to
".."
,
tree_file_project_
path
(
@project
,
@commit
.
id
,
file
,
:branch
=>
@branch
,
:tag
=>
@tag
),
:remote
=>
:true
=
link_to
".."
,
tree_file_project_
ref_path
(
@project
,
@ref
,
file
),
:remote
=>
:true
%td
%td
-
contents
.
select
{
|
i
|
i
.
is_a?
(
Grit
::
Tree
)}.
each
do
|
content
|
=
render
:partial
=>
"
project
s/tree_item"
,
:locals
=>
{
:content
=>
content
}
=
render
:partial
=>
"
ref
s/tree_item"
,
:locals
=>
{
:content
=>
content
}
-
contents
.
select
{
|
i
|
i
.
is_a?
(
Grit
::
Blob
)}.
each
do
|
content
|
=
render
:partial
=>
"
project
s/tree_item"
,
:locals
=>
{
:content
=>
content
}
=
render
:partial
=>
"
ref
s/tree_item"
,
:locals
=>
{
:content
=>
content
}
:javascript
$
(
function
(){
...
...
app/views/
project
s/_tree_file.html.haml
→
app/views/
ref
s/_tree_file.html.haml
View file @
af08ed6b
...
...
@@ -3,8 +3,8 @@
.view_file_header
%strong
=
name
=
link_to
"raw"
,
blob_project_
path
(
@project
,
:commit_id
=>
@commit
.
id
,
:path
=>
params
[
:path
]
),
:class
=>
"right"
,
:target
=>
"_blank"
=
link_to
"history"
,
project_commits_path
(
@project
,
:path
=>
params
[
:path
],
:
branch
=>
params
[
:branch
],
:tag
=>
params
[
:tag
]
),
:class
=>
"right"
,
:style
=>
"margin-right:10px;"
=
link_to
"raw"
,
blob_project_
ref_path
(
@project
,
@ref
,
:path
=>
params
[
:path
]
),
:class
=>
"right"
,
:target
=>
"_blank"
=
link_to
"history"
,
project_commits_path
(
@project
,
:path
=>
params
[
:path
],
:
ref
=>
@ref
),
:class
=>
"right"
,
:style
=>
"margin-right:10px;"
%br
/
-
if
file
.
text?
.view_file_content
...
...
app/views/
project
s/_tree_item.html.haml
→
app/views/
ref
s/_tree_item.html.haml
View file @
af08ed6b
-
file
=
params
[
:path
]
?
File
.
join
(
params
[
:path
],
content
.
name
)
:
content
.
name
-
content_commit
=
@project
.
repo
.
log
(
@commit
.
id
,
file
,
:max_count
=>
1
).
last
-
return
unless
content_commit
%tr
{
:class
=>
"tree-item"
,
:url
=>
tree_file_project_
path
(
@project
,
@commit
.
id
,
file
)
}
%tr
{
:class
=>
"tree-item"
,
:url
=>
tree_file_project_
ref_path
(
@project
,
@ref
,
file
)
}
%td
.tree-item-file-name
-
if
content
.
is_a?
(
Grit
::
Blob
)
=
image_tag
"txt.png"
-
else
=
image_tag
"dir.png"
=
link_to
truncate
(
content
.
name
,
:length
=>
40
),
tree_file_project_
path
(
@project
,
@commit
.
id
,
file
,
:branch
=>
@branch
,
:tag
=>
@tag
),
:remote
=>
:true
=
link_to
truncate
(
content
.
name
,
:length
=>
40
),
tree_file_project_
ref_path
(
@project
,
@ref
||
@commit
.
id
,
file
),
:remote
=>
:true
%td
=
time_ago_in_words
(
content_commit
.
committed_date
)
ago
...
...
app/views/refs/tree.html.haml
0 → 100644
View file @
af08ed6b
#tree-holder
=
render
:partial
=>
"tree"
,
:locals
=>
{
:repo
=>
@repo
,
:commit
=>
@commit
,
:tree
=>
@tree
}
app/views/refs/tree.js.haml
0 → 100644
View file @
af08ed6b
:plain
$("#tree-holder table").hide("slide", { direction: "left" }, 150, function(){
$("#tree-holder").html("
#{
escape_javascript
(
render
(
:partial
=>
"tree"
,
:locals
=>
{
:repo
=>
@repo
,
:commit
=>
@commit
,
:tree
=>
@tree
}))
}
");
$("#tree-holder table").show("slide", { direction: "right" }, 150);
});
config/routes.rb
View file @
af08ed6b
...
...
@@ -30,22 +30,24 @@ Gitlab::Application.routes.draw do
resources
:projects
,
:except
=>
[
:new
,
:create
,
:index
],
:path
=>
"/"
do
member
do
get
"tree"
get
"blob"
get
"team"
get
"wall"
get
"graph"
end
resources
:refs
,
:only
=>
[],
:path
=>
"/"
do
member
do
get
"tree"
get
"blob"
# tree viewer
get
"tree/:commit_id"
=>
"projects#tree"
get
"tree/:commit_id/:path"
=>
"projects#tree"
,
get
"tree/:path"
=>
"refs#tree"
,
:as
=>
:tree_file
,
:constraints
=>
{
:id
=>
/[a-zA-Z0-9_\-]+/
,
:commit_id
=>
/[a-zA-Z0-9]+/
,
:path
=>
/.*/
}
end
end
resources
:snippets
...
...
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