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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
f88a2617
Commit
f88a2617
authored
Jul 10, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tree ajax log. progress bar & refactoring
parent
1a2bacfb
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
18 deletions
+53
-18
app/assets/images/ajax_loader_tree.gif
app/assets/images/ajax_loader_tree.gif
+0
-0
app/assets/javascripts/application.js
app/assets/javascripts/application.js
+5
-0
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+4
-0
app/helpers/tree_helper.rb
app/helpers/tree_helper.rb
+27
-0
app/views/refs/_tree.html.haml
app/views/refs/_tree.html.haml
+6
-4
app/views/refs/_tree_item.html.haml
app/views/refs/_tree_item.html.haml
+7
-11
app/views/refs/logs_tree.js.haml
app/views/refs/logs_tree.js.haml
+1
-1
app/views/refs/tree.js.haml
app/views/refs/tree.js.haml
+3
-2
No files found.
app/assets/images/ajax_loader_tree.gif
0 → 100644
View file @
f88a2617
6.38 KB
app/assets/javascripts/application.js
View file @
f88a2617
...
@@ -114,3 +114,8 @@ function showDiff(link) {
...
@@ -114,3 +114,8 @@ function showDiff(link) {
return
_chosen
.
apply
(
this
,
[
default_options
]);
return
_chosen
.
apply
(
this
,
[
default_options
]);
}})
}})
})(
jQuery
);
})(
jQuery
);
function
ajaxGet
(
url
)
{
$
.
ajax
({
type
:
"
GET
"
,
url
:
url
,
dataType
:
"
script
"
});
}
app/helpers/application_helper.rb
View file @
f88a2617
...
@@ -134,4 +134,8 @@ module ApplicationHelper
...
@@ -134,4 +134,8 @@ module ApplicationHelper
end
end
active
?
"current"
:
nil
active
?
"current"
:
nil
end
end
def
hexdigest
(
string
)
Digest
::
SHA1
.
hexdigest
string
end
end
end
app/helpers/tree_helper.rb
0 → 100644
View file @
f88a2617
module
TreeHelper
def
tree_icon
(
content
)
if
content
.
is_a?
(
Grit
::
Blob
)
if
content
.
text?
image_tag
"file_txt.png"
elsif
content
.
image?
image_tag
"file_img.png"
else
image_tag
"file_bin.png"
end
else
image_tag
"file_dir.png"
end
end
def
tree_hex_class
(
content
)
"file_
#{
hexdigest
(
content
.
name
)
}
"
end
def
tree_full_path
(
content
)
if
params
[
:path
]
File
.
join
(
params
[
:path
],
content
.
name
)
else
content
.
name
end
end
end
app/views/refs/_tree.html.haml
View file @
f88a2617
...
@@ -29,12 +29,13 @@
...
@@ -29,12 +29,13 @@
%td
%td
%td
%td
-
index
=
0
-
contents
.
select
{
|
i
|
i
.
is_a?
(
Grit
::
Tree
)}.
each
do
|
content
|
-
contents
.
select
{
|
i
|
i
.
is_a?
(
Grit
::
Tree
)}.
each
do
|
content
|
=
render
:partial
=>
"refs/tree_item"
,
:locals
=>
{
:content
=>
content
}
=
render
:partial
=>
"refs/tree_item"
,
:locals
=>
{
:content
=>
content
,
:index
=>
(
index
+=
1
)
}
-
contents
.
select
{
|
i
|
i
.
is_a?
(
Grit
::
Blob
)}.
each
do
|
content
|
-
contents
.
select
{
|
i
|
i
.
is_a?
(
Grit
::
Blob
)}.
each
do
|
content
|
=
render
:partial
=>
"refs/tree_item"
,
:locals
=>
{
:content
=>
content
}
=
render
:partial
=>
"refs/tree_item"
,
:locals
=>
{
:content
=>
content
,
:index
=>
(
index
+=
1
)
}
-
contents
.
select
{
|
i
|
i
.
is_a?
(
Grit
::
Submodule
)}.
each
do
|
content
|
-
contents
.
select
{
|
i
|
i
.
is_a?
(
Grit
::
Submodule
)}.
each
do
|
content
|
=
render
:partial
=>
"refs/submodule_item"
,
:locals
=>
{
:content
=>
content
}
=
render
:partial
=>
"refs/submodule_item"
,
:locals
=>
{
:content
=>
content
,
:index
=>
(
index
+=
1
)
}
-
if
content
=
contents
.
select
{
|
c
|
c
.
is_a?
(
Grit
::
Blob
)
and
c
.
name
=~
/^readme/i
}.
first
-
if
content
=
contents
.
select
{
|
c
|
c
.
is_a?
(
Grit
::
Blob
)
and
c
.
name
=~
/^readme/i
}.
first
.file_holder
#README
.file_holder
#README
...
@@ -58,8 +59,9 @@
...
@@ -58,8 +59,9 @@
});
});
// Load last commit log for each file in tree
$
(
window
).
load
(
function
(){
$
(
window
).
load
(
function
(){
$
.
ajax
({
type
:
"
GET
"
,
url
:
'
#{
@logs_path
}
'
,
dataType
:
"
script
"
}
);
ajaxGet
(
'
#{
@logs_path
}
'
);
});
});
...
...
app/views/refs/_tree_item.html.haml
View file @
f88a2617
-
file
=
params
[
:path
]
?
File
.
join
(
params
[
:path
],
content
.
name
)
:
content
.
name
-
file
=
tree_full_path
(
content
)
%tr
{
:class
=>
"tree-item
file_#{Digest::SHA1.hexdigest(content.name
)}"
,
:url
=>
tree_file_project_ref_path
(
@project
,
@ref
,
file
)
}
%tr
{
:class
=>
"tree-item
#{tree_hex_class(content
)}"
,
:url
=>
tree_file_project_ref_path
(
@project
,
@ref
,
file
)
}
%td
.tree-item-file-name
%td
.tree-item-file-name
-
if
content
.
is_a?
(
Grit
::
Blob
)
=
tree_icon
(
content
)
-
if
content
.
text?
=
image_tag
"file_txt.png"
,
:class
=>
"tree-ico"
-
elsif
content
.
image?
=
image_tag
"file_img.png"
,
:class
=>
"tree-ico"
-
else
=
image_tag
"file_bin.png"
,
:class
=>
"tree-ico"
-
else
=
image_tag
"file_dir.png"
,
:class
=>
"tree-ico"
=
link_to
truncate
(
content
.
name
,
:length
=>
40
),
tree_file_project_ref_path
(
@project
,
@ref
||
@commit
.
id
,
file
),
:remote
=>
:true
=
link_to
truncate
(
content
.
name
,
:length
=>
40
),
tree_file_project_ref_path
(
@project
,
@ref
||
@commit
.
id
,
file
),
:remote
=>
:true
%td
.tree_time_ago.cgray
%td
.tree_time_ago.cgray
-
if
index
==
1
%span
.log_loading
Loading commit data..
=
image_tag
"ajax_loader_tree.gif"
,
:width
=>
14
%td
.tree_commit
%td
.tree_commit
app/views/refs/logs_tree.js.haml
View file @
f88a2617
...
@@ -4,6 +4,6 @@
...
@@ -4,6 +4,6 @@
-
tm
=
@project
.
team_member_by_name_or_email
(
content_commit
.
author_email
,
content_commit
.
author_name
)
-
tm
=
@project
.
team_member_by_name_or_email
(
content_commit
.
author_email
,
content_commit
.
author_name
)
:plain
:plain
var row = $("table.table_
#{
@hex_path
}
tr.file_
#{
Digest
::
SHA1
.
hexdigest
(
file_name
)
}
");
var row = $("table.table_
#{
@hex_path
}
tr.file_
#{
hexdigest
(
file_name
)
}
");
row.find("td.tree_time_ago").html('
#{
escape_javascript
(
time_ago_in_words
(
content_commit
.
committed_date
))
}
ago');
row.find("td.tree_time_ago").html('
#{
escape_javascript
(
time_ago_in_words
(
content_commit
.
committed_date
))
}
ago');
row.find("td.tree_commit").html('
#{
escape_javascript
(
render
(
"tree_commit"
,
:tm
=>
tm
,
:content_commit
=>
content_commit
))
}
');
row.find("td.tree_commit").html('
#{
escape_javascript
(
render
(
"tree_commit"
,
:tm
=>
tm
,
:content_commit
=>
content_commit
))
}
');
app/views/refs/tree.js.haml
View file @
f88a2617
:plain
:plain
// Load Files list
$("#tree-holder").html("
#{
escape_javascript
(
render
(
:partial
=>
"tree"
,
:locals
=>
{
:repo
=>
@repo
,
:commit
=>
@commit
,
:tree
=>
@tree
}))
}
");
$("#tree-holder").html("
#{
escape_javascript
(
render
(
:partial
=>
"tree"
,
:locals
=>
{
:repo
=>
@repo
,
:commit
=>
@commit
,
:tree
=>
@tree
}))
}
");
$("#tree-content-holder").show("slide", { direction: "right" }, 150);
$("#tree-content-holder").show("slide", { direction: "right" }, 150);
$('.project-refs-form #path').val("
#{
params
[
:path
]
}
");
$('.project-refs-form #path').val("
#{
params
[
:path
]
}
");
// Load last commit log for each file in tree
$('#tree-slider').waitForImages(function() {
$('#tree-slider').waitForImages(function() {
$.ajax({type: "GET", url: '
#{
@logs_path
}
', dataType: "script"}
);
ajaxGet('
#{
@logs_path
}
'
);
});
});
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