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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
570f63da
Commit
570f63da
authored
Dec 01, 2011
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
line links for commit diff, css fixed for line diff
parent
b60b7b2e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
133 additions
and
80 deletions
+133
-80
app/assets/stylesheets/application.css
app/assets/stylesheets/application.css
+0
-7
app/assets/stylesheets/commits.css.scss
app/assets/stylesheets/commits.css.scss
+55
-4
app/assets/stylesheets/projects.css.scss
app/assets/stylesheets/projects.css.scss
+9
-7
app/helpers/commits_helper.rb
app/helpers/commits_helper.rb
+16
-13
app/views/commits/_diff.html.haml
app/views/commits/_diff.html.haml
+2
-2
app/views/commits/_diff_head.html.haml
app/views/commits/_diff_head.html.haml
+24
-27
app/views/commits/_text_file.html.haml
app/views/commits/_text_file.html.haml
+27
-20
No files found.
app/assets/stylesheets/application.css
View file @
570f63da
...
...
@@ -49,10 +49,3 @@
.no-padding
{
padding
:
0
!important
;
}
/** COMMIT BLOCK **/
.commit-title
{
display
:
block
;}
.commit-title
{
margin-bottom
:
10px
}
.commit-author
{
color
:
#999
;
font-weight
:
normal
;
font-style
:
italic
;}
.commit-author
strong
{
font-weight
:
bold
;
font-style
:
normal
;}
app/assets/stylesheets/commits.css.scss
View file @
570f63da
...
...
@@ -27,14 +27,44 @@
}
.diff_file_content
{
table
{
border
:none
;
margin
:
0px
;
padding
:
0px
;
}
.old_line
,
.new_line
{
background
:
#ECECEC
;
color
:
#777
;
width
:
35px
;
float
:left
;
margin
:
0px
;
padding
:
0px
;
border
:none
;
background
:
#F7F7F7
;
color
:
#333
;
padding
:
0px
5px
;
border-right
:
1px
solid
#ccc
;
text-align
:right
;
min-width
:
35px
;
max-width
:
35px
;
width
:
35px
;
a
{
float
:left
;
width
:
35px
;
font-weight
:normal
;
&
:hover
{
text-decoration
:underline
;
}
}
}
.line_content
{
white-space
:pre
;
height
:
14px
;
margin
:
0px
;
padding
:
0px
;
border
:none
;
&
.new
{
background
:
#DFD
;
}
&
.old
{
background
:
#FDD
;
}
}
}
...
...
@@ -45,3 +75,24 @@ pre.commit_message {
font-weight
:bold
;
font-size
:
15px
;
}
/** COMMIT BLOCK **/
.commit-title
{
display
:
block
;}
.commit-title
{
margin-bottom
:
10px
}
.commit-author
{
color
:
#999
;
font-weight
:
normal
;
font-style
:
italic
;}
.commit-author
strong
{
font-weight
:
bold
;
font-style
:
normal
;}
/** bordered list **/
ul
.bordered-list
{
margin
:
5px
0px
;
padding
:
0px
;
li
{
padding
:
5px
;
border-bottom
:
1px
solid
#EEE
;
overflow
:
hidden
;
display
:
block
;
margin
:
0px
;
}
}
ul
.bordered-list
li
:last-child
{
border
:none
}
app/assets/stylesheets/projects.css.scss
View file @
570f63da
...
...
@@ -66,11 +66,8 @@ a {
}
}
.view_file
{
border
:
1px
solid
#CCC
;
margin-bottom
:
1em
;
.view_file_header
{
.view_file
.view_file_header
,
.diff_file
.diff_file_header
{
background-image
:
-webkit-gradient
(
linear
,
0
0
,
0
26
,
color-stop
(
0
.076
,
#fefefe
)
,
to
(
#F6F7F8
));
background-image
:
-webkit-linear-gradient
(
#fefefe
7
.6%
,
#F6F7F8
);
background-image
:
-moz-linear-gradient
(
#fefefe
7
.6%
,
#F6F7F8
);
...
...
@@ -81,8 +78,13 @@ a {
text-align
:
left
;
color
:
#666
;
border-bottom
:
1px
solid
#DEE2E3
;
padding
:
.9em
1em
;
}
padding
:
7px
10px
;
}
.view_file
{
border
:
1px
solid
#CCC
;
margin-bottom
:
1em
;
.view_file_content
{
background
:
#fff
;
color
:
#514721
;
...
...
app/helpers/commits_helper.rb
View file @
570f63da
module
CommitsHelper
include
Utils
::
CharEncode
def
diff_line
(
line
,
line_new
=
0
,
line_old
=
0
)
full_line
=
html_escape
(
line
.
gsub
(
/\n/
,
''
))
color
=
if
line
[
0
]
==
"+"
full_line
=
"<span class=
\"
old_line
\"
> </span><span class=
\"
new_line
\"
>
#{
line_new
}
</span> "
+
full_line
"#DFD"
elsif
line
[
0
]
==
"-"
full_line
=
"<span class=
\"
old_line
\"
>
#{
line_old
}
</span><span class=
\"
new_line
\"
> </span> "
+
full_line
"#FDD"
else
full_line
=
"<span class=
\"
old_line
\"
>
#{
line_old
}
</span><span class=
\"
new_line
\"
>
#{
line_new
}
</span> "
+
full_line
"none"
end
raw
"<div style=
\"
white-space:pre;background:
#{
color
}
;
\"
>
#{
full_line
}
</div>"
def
old_line_number
(
line
,
i
)
end
def
new_line_number
(
line
,
i
)
end
def
diff_line_class
(
line
)
if
line
[
0
]
==
"+"
"new"
elsif
line
[
0
]
==
"-"
"old"
else
nil
end
end
def
more_commits_link
...
...
app/views/commits/_diff.html.haml
View file @
570f63da
.file_stats
=
render
"commits/diff_head"
-
@commit
.
diffs
.
each
do
|
diff
|
-
@commit
.
diffs
.
each
_with_index
do
|
diff
,
i
|
-
next
if
diff
.
diff
.
empty?
-
file
=
(
@commit
.
tree
/
diff
.
b_path
)
-
next
unless
file
...
...
@@ -15,7 +15,7 @@
%br
/
.diff_file_content
-
if
file
.
text?
=
render
:partial
=>
"commits/text_file"
,
:locals
=>
{
:diff
=>
diff
}
=
render
:partial
=>
"commits/text_file"
,
:locals
=>
{
:diff
=>
diff
,
:index
=>
i
}
-
elsif
file
.
image?
.diff_file_content_image
%img
{
:src
=>
"data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"
}
...
...
app/views/commits/_diff_head.html.haml
View file @
570f63da
%table
%thead
%th
Files
%ul
.bordered-list
-
@commit
.
diffs
.
each
do
|
diff
|
%tr
%td
-
if
diff
.
deleted_file
%span
.removed_file
%a
{
:href
=>
"##{diff.a_path}"
}
=
diff
.
a_path
=
image_tag
"blueprint_delete.png"
-
elsif
diff
.
renamed_file
%span
.moved_file
%a
{
:href
=>
"##{diff.b_path}"
}
=
diff
.
a_path
=
"->"
=
diff
.
b_path
=
image_tag
"blueprint_notice.png"
-
elsif
diff
.
new_file
%span
.new_file
%a
{
:href
=>
"##{diff.b_path}"
}
=
diff
.
b_path
=
image_tag
"blueprint_add.png"
-
else
%span
.edit_file
%a
{
:href
=>
"##{diff.b_path}"
}
=
diff
.
b_path
=
image_tag
"blueprint_info.png"
%li
-
if
diff
.
deleted_file
%span
.removed_file
%a
{
:href
=>
"##{diff.a_path}"
}
=
diff
.
a_path
=
image_tag
"blueprint_delete.png"
-
elsif
diff
.
renamed_file
%span
.moved_file
%a
{
:href
=>
"##{diff.b_path}"
}
=
diff
.
a_path
=
"->"
=
diff
.
b_path
=
image_tag
"blueprint_notice.png"
-
elsif
diff
.
new_file
%span
.new_file
%a
{
:href
=>
"##{diff.b_path}"
}
=
diff
.
b_path
=
image_tag
"blueprint_add.png"
-
else
%span
.edit_file
%a
{
:href
=>
"##{diff.b_path}"
}
=
diff
.
b_path
=
image_tag
"blueprint_info.png"
app/views/commits/_text_file.html.haml
View file @
570f63da
-
line_old
=
0
-
line_new
=
0
-
lines_arr
=
diff
.
diff
.
lines
.
to_a
-
lines_arr
.
each
do
|
line
|
-
line
=
encode
(
line
)
-
next
if
line
.
match
(
/^--- \/dev\/null/
)
-
next
if
line
.
match
(
/^--- a/
)
-
next
if
line
.
match
(
/^\+\+\+ b/
)
-
if
line
.
match
(
/^@@ -/
)
-
line_old
=
line
.
match
(
/\-[0-9]*/
)[
0
].
to_i
.
abs
rescue
0
-
line_new
=
line
.
match
(
/\+[0-9]*/
)[
0
].
to_i
.
abs
rescue
0
-
next
%table
-
line_old
=
0
-
line_new
=
0
-
lines_arr
=
diff
.
diff
.
lines
.
to_a
-
lines_arr
.
each
do
|
line
|
-
line
=
encode
(
line
)
-
next
if
line
.
match
(
/^--- \/dev\/null/
)
-
next
if
line
.
match
(
/^--- a/
)
-
next
if
line
.
match
(
/^\+\+\+ b/
)
-
if
line
.
match
(
/^@@ -/
)
-
line_old
=
line
.
match
(
/\-[0-9]*/
)[
0
].
to_i
.
abs
rescue
0
-
line_new
=
line
.
match
(
/\+[0-9]*/
)[
0
].
to_i
.
abs
rescue
0
-
next
=
diff_line
(
line
,
line_new
,
line_old
)
-
if
line
[
0
]
==
"+"
-
line_new
+=
1
-
elsif
line
[
0
]
==
"-"
-
line_old
+=
1
-
else
-
line_new
+=
1
-
line_old
+=
1
-
full_line
=
html_escape
(
line
.
gsub
(
/\n/
,
''
))
%tr
.line_holder
%td
.old_line
=
link_to
raw
(
diff_line_class
(
line
)
==
"new"
?
" "
:
line_old
),
"#OLD
#{
index
}
-
#{
line_old
}
"
,
:id
=>
"OLD
#{
index
}
-
#{
line_old
}
"
%td
.new_line
=
link_to
raw
(
diff_line_class
(
line
)
==
"old"
?
" "
:
line_new
)
,
"#NEW
#{
index
}
-
#{
line_new
}
"
,
:id
=>
"NEW
#{
index
}
-
#{
line_new
}
"
%td
.line_content
{
:class
=>
diff_line_class
(
full_line
)}=
raw
"
#{
full_line
}
"
-
if
line
[
0
]
==
"+"
-
line_new
+=
1
-
elsif
line
[
0
]
==
"-"
-
line_old
+=
1
-
else
-
line_new
+=
1
-
line_old
+=
1
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