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
Boxiang Sun
gitlab-ce
Commits
153f6cd8
Commit
153f6cd8
authored
Oct 14, 2011
by
gitlabhq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring + remove unnecessary feature
parent
2d577cae
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
50 deletions
+36
-50
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+18
-10
app/controllers/commits_controller.rb
app/controllers/commits_controller.rb
+4
-10
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+9
-12
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+0
-8
app/views/commits/index.html.haml
app/views/commits/index.html.haml
+1
-3
app/views/projects/_tree.html.haml
app/views/projects/_tree.html.haml
+3
-6
app/views/projects/_tree_item.html.haml
app/views/projects/_tree_item.html.haml
+1
-1
No files found.
app/controllers/application_controller.rb
View file @
153f6cd8
...
@@ -42,15 +42,23 @@ class ApplicationController < ActionController::Base
...
@@ -42,15 +42,23 @@ class ApplicationController < ActionController::Base
end
end
end
end
def
refs_from_cookie
def
load_refs
if
@project
&&
session
[
:ui
]
&&
@branch
=
unless
params
[
:branch
].
blank?
session
[
:ui
][
@project
.
id
]
params
[
:branch
]
project_session
=
session
[
:ui
][
@project
.
id
]
else
project_session
[
:branch
]
=
nil
if
params
[
:tag
]
nil
params
[
:branch
]
||=
project_session
[
:branch
]
end
params
[
:tag
]
||=
project_session
[
:tag
]
end
@tag
=
unless
params
[
:tag
].
blank?
rescue
params
[
:tag
]
session
[
:ui
]
=
nil
else
nil
end
@ref
=
@branch
||
@tag
||
"master"
end
def
render_404
render
:file
=>
File
.
join
(
Rails
.
root
,
"public"
,
"404"
),
:layout
=>
false
,
:status
=>
"404"
end
end
end
end
app/controllers/commits_controller.rb
View file @
153f6cd8
...
@@ -8,20 +8,14 @@ class CommitsController < ApplicationController
...
@@ -8,20 +8,14 @@ class CommitsController < ApplicationController
before_filter
:authorize_read_project!
before_filter
:authorize_read_project!
def
index
def
index
refs_from_cookie
load_refs
# load @branch, @tag & @ref
@repo
=
project
.
repo
@repo
=
project
.
repo
@branch
=
if
!
params
[
:branch
].
blank?
params
[
:branch
]
elsif
!
params
[
:tag
].
blank?
params
[
:tag
]
else
"master"
end
if
params
[
:path
]
if
params
[
:path
]
@commits
=
@repo
.
log
(
@
branch
,
params
[
:path
],
:max_count
=>
params
[
:limit
]
||
100
,
:skip
=>
params
[
:offset
]
||
0
)
@commits
=
@repo
.
log
(
@
ref
,
params
[
:path
],
:max_count
=>
params
[
:limit
]
||
100
,
:skip
=>
params
[
:offset
]
||
0
)
else
else
@commits
=
@repo
.
commits
(
@
branch
,
params
[
:limit
]
||
100
,
params
[
:offset
]
||
0
)
@commits
=
@repo
.
commits
(
@
ref
,
params
[
:limit
]
||
100
,
params
[
:offset
]
||
0
)
end
end
respond_to
do
|
format
|
respond_to
do
|
format
|
...
...
app/controllers/projects_controller.rb
View file @
153f6cd8
...
@@ -16,7 +16,6 @@ class ProjectsController < ApplicationController
...
@@ -16,7 +16,6 @@ class ProjectsController < ApplicationController
end
end
def
show
def
show
refs_from_cookie
@repo
=
project
.
repo
@repo
=
project
.
repo
@commit
=
@repo
.
commits
.
first
@commit
=
@repo
.
commits
.
first
@tree
=
@commit
.
tree
@tree
=
@commit
.
tree
...
@@ -33,34 +32,30 @@ class ProjectsController < ApplicationController
...
@@ -33,34 +32,30 @@ class ProjectsController < ApplicationController
end
end
def
tree
def
tree
refs_from_cookie
load_refs
# load @branch, @tag & @ref
@repo
=
project
.
repo
@repo
=
project
.
repo
@branch
=
if
!
params
[
:branch
].
blank?
params
[
:branch
]
elsif
!
params
[
:tag
].
blank?
params
[
:tag
]
else
"master"
end
if
params
[
:commit_id
]
if
params
[
:commit_id
]
@commit
=
@repo
.
commits
(
params
[
:commit_id
]).
first
@commit
=
@repo
.
commits
(
params
[
:commit_id
]).
first
else
else
@commit
=
@repo
.
commits
(
@
branch
||
"master"
).
first
@commit
=
@repo
.
commits
(
@
ref
||
"master"
).
first
end
end
@tree
=
@commit
.
tree
@tree
=
@commit
.
tree
@tree
=
@tree
/
params
[
:path
]
if
params
[
:path
]
@tree
=
@tree
/
params
[
:path
]
if
params
[
:path
]
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
# show.html.erb
format
.
html
# show.html.erb
format
.
js
do
format
.
js
do
#
temp solution
#
diasbale cache to allow back button works
response
.
headers
[
"Cache-Control"
]
=
"no-cache, no-store, max-age=0, must-revalidate"
response
.
headers
[
"Cache-Control"
]
=
"no-cache, no-store, max-age=0, must-revalidate"
response
.
headers
[
"Pragma"
]
=
"no-cache"
response
.
headers
[
"Pragma"
]
=
"no-cache"
response
.
headers
[
"Expires"
]
=
"Fri, 01 Jan 1990 00:00:00 GMT"
response
.
headers
[
"Expires"
]
=
"Fri, 01 Jan 1990 00:00:00 GMT"
end
end
format
.
json
{
render
json:
project
}
end
end
rescue
return
render_404
end
end
def
blob
def
blob
...
@@ -73,6 +68,8 @@ class ProjectsController < ApplicationController
...
@@ -73,6 +68,8 @@ class ProjectsController < ApplicationController
else
else
head
(
404
)
head
(
404
)
end
end
rescue
return
render_404
end
end
def
new
def
new
...
...
app/helpers/projects_helper.rb
View file @
153f6cd8
...
@@ -3,12 +3,4 @@ module ProjectsHelper
...
@@ -3,12 +3,4 @@ module ProjectsHelper
cookies
[
"project_view"
]
||=
"tile"
cookies
[
"project_view"
]
||=
"tile"
cookies
[
"project_view"
]
==
type
?
nil
:
"display:none"
cookies
[
"project_view"
]
==
type
?
nil
:
"display:none"
end
end
def
remember_refs
session
[
:ui
]
||=
{}
session
[
:ui
][
@project
.
id
]
=
{
:branch
=>
params
[
:branch
],
:tag
=>
params
[
:tag
]
}
end
end
end
app/views/commits/index.html.haml
View file @
153f6cd8
...
@@ -6,12 +6,10 @@
...
@@ -6,12 +6,10 @@
.left.prepend-1
.left.prepend-1
=
form_tag
project_commits_path
(
@project
),
:method
=>
:get
do
=
form_tag
project_commits_path
(
@project
),
:method
=>
:get
do
=
select_tag
"tag"
,
options_for_select
(
@project
.
tags
,
@
branch
),
:onchange
=>
"this.form.submit();"
,
:class
=>
""
,
:prompt
=>
"Tags"
=
select_tag
"tag"
,
options_for_select
(
@project
.
tags
,
@
tag
),
:onchange
=>
"this.form.submit();"
,
:class
=>
""
,
:prompt
=>
"Tags"
=
text_field_tag
"ssh"
,
@project
.
url_to_repo
,
:class
=>
[
"ssh_project_url"
,
"one_click_select"
]
=
text_field_tag
"ssh"
,
@project
.
url_to_repo
,
:class
=>
[
"ssh_project_url"
,
"one_click_select"
]
.clear
.clear
-
if
params
[
:path
]
-
if
params
[
:path
]
%h3
{
:style
=>
"color:#555"
}
/
#{
params
[
:path
]
}
%h3
{
:style
=>
"color:#555"
}
/
#{
params
[
:path
]
}
%div
{
:id
=>
dom_id
(
@project
)}
%div
{
:id
=>
dom_id
(
@project
)}
=
render
"commits"
=
render
"commits"
-
remember_refs
app/views/projects/_tree.html.haml
View file @
153f6cd8
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
.left.prepend-1
.left.prepend-1
=
form_tag
tree_project_path
(
@project
),
:method
=>
:get
do
=
form_tag
tree_project_path
(
@project
),
:method
=>
:get
do
=
select_tag
"tag"
,
options_for_select
(
@project
.
tags
,
@
branch
),
:onchange
=>
"this.form.submit();"
,
:class
=>
""
,
:prompt
=>
"Tags"
=
select_tag
"tag"
,
options_for_select
(
@project
.
tags
,
@
tag
),
:onchange
=>
"this.form.submit();"
,
:class
=>
""
,
:prompt
=>
"Tags"
=
text_field_tag
"ssh"
,
@project
.
url_to_repo
,
:class
=>
[
"ssh_project_url"
,
"one_click_select"
]
=
text_field_tag
"ssh"
,
@project
.
url_to_repo
,
:class
=>
[
"ssh_project_url"
,
"one_click_select"
]
.clear
.clear
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
-
if
part_path
.
empty?
-
if
part_path
.
empty?
-
part_path
=
part
-
part_path
=
part
\/
\/
=
link_to
truncate
(
part
,
:length
=>
40
),
tree_file_project_path
(
@project
,
:path
=>
part_path
,
:commit_id
=>
@commit
.
try
(
:id
)),
:remote
=>
:true
=
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
#tree-content-holder
#tree-content-holder
-
if
tree
.
is_a?
(
Grit
::
Blob
)
-
if
tree
.
is_a?
(
Grit
::
Blob
)
=
render
:partial
=>
"projects/tree_file"
,
:locals
=>
{
:name
=>
tree
.
name
,
:content
=>
tree
.
data
,
:file
=>
tree
}
=
render
:partial
=>
"projects/tree_file"
,
:locals
=>
{
:name
=>
tree
.
name
,
:content
=>
tree
.
data
,
:file
=>
tree
}
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
%tr
{
:class
=>
"tree-item"
,
:url
=>
tree_file_project_path
(
@project
,
@commit
.
id
,
file
)
}
%tr
{
:class
=>
"tree-item"
,
:url
=>
tree_file_project_path
(
@project
,
@commit
.
id
,
file
)
}
%td
.tree-item-file-name
%td
.tree-item-file-name
=
image_tag
"dir.png"
=
image_tag
"dir.png"
=
link_to
".."
,
tree_file_project_path
(
@project
,
@commit
.
id
,
file
),
:remote
=>
:true
=
link_to
".."
,
tree_file_project_path
(
@project
,
@commit
.
id
,
file
,
:branch
=>
@branch
,
:tag
=>
@tag
),
:remote
=>
:true
%td
%td
%td
%td
...
@@ -45,9 +45,6 @@
...
@@ -45,9 +45,6 @@
-
contents
.
select
{
|
i
|
i
.
is_a?
(
Grit
::
Blob
)}.
each
do
|
content
|
-
contents
.
select
{
|
i
|
i
.
is_a?
(
Grit
::
Blob
)}.
each
do
|
content
|
=
render
:partial
=>
"projects/tree_item"
,
:locals
=>
{
:content
=>
content
}
=
render
:partial
=>
"projects/tree_item"
,
:locals
=>
{
:content
=>
content
}
-
remember_refs
:javascript
:javascript
$
(
function
(){
$
(
function
(){
$
(
'
select#branch
'
).
selectmenu
({
style
:
'
popup
'
,
width
:
200
});
$
(
'
select#branch
'
).
selectmenu
({
style
:
'
popup
'
,
width
:
200
});
...
...
app/views/projects/_tree_item.html.haml
View file @
153f6cd8
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
=
image_tag
"txt.png"
=
image_tag
"txt.png"
-
else
-
else
=
image_tag
"dir.png"
=
image_tag
"dir.png"
=
link_to
truncate
(
content
.
name
,
:length
=>
40
),
tree_file_project_path
(
@project
,
@commit
.
id
,
file
),
:remote
=>
:true
=
link_to
truncate
(
content
.
name
,
:length
=>
40
),
tree_file_project_path
(
@project
,
@commit
.
id
,
file
,
:branch
=>
@branch
,
:tag
=>
@tag
),
:remote
=>
:true
%td
%td
=
time_ago_in_words
(
content_commit
.
committed_date
)
=
time_ago_in_words
(
content_commit
.
committed_date
)
ago
ago
...
...
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