Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
0f0af191
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0f0af191
编写于
1月 13, 2016
作者:
R
Rubén Dávila
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Little refactor for usage of html_safe. #3945
上级
48c45ba9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
10 addition
and
9 deletion
+10
-9
app/helpers/diff_helper.rb
app/helpers/diff_helper.rb
+5
-4
app/views/projects/blob/diff.html.haml
app/views/projects/blob/diff.html.haml
+1
-1
app/views/projects/diffs/_parallel_view.html.haml
app/views/projects/diffs/_parallel_view.html.haml
+2
-2
lib/gitlab/diff/highlight.rb
lib/gitlab/diff/highlight.rb
+2
-2
未找到文件。
app/helpers/diff_helper.rb
浏览文件 @
0f0af191
module
DiffHelper
BLANK_SPACE
=
" "
.
html_safe
def
diff_view
params
[
:view
]
==
'parallel'
?
'parallel'
:
'inline'
end
...
...
@@ -83,7 +85,7 @@ module DiffHelper
elsif
next_type
==
'old'
||
next_type
.
nil?
# Left side has text removed, right side doesn't have any change
# No next line code, no new line number, no new line text
line
=
[
type
,
line_old
,
full_line
,
line_code
,
next_type
,
nil
,
" "
,
nil
]
line
=
[
type
,
line_old
,
full_line
,
line_code
,
next_type
,
nil
,
BLANK_SPACE
,
nil
]
lines
.
push
(
line
)
end
elsif
type
==
'new'
...
...
@@ -93,7 +95,7 @@ module DiffHelper
next
else
# Change is only on the right side, left side has no change
line
=
[
nil
,
nil
,
" "
,
line_code
,
type
,
line_new
,
full_line
,
line_code
]
line
=
[
nil
,
nil
,
BLANK_SPACE
,
line_code
,
type
,
line_new
,
full_line
,
line_code
]
lines
.
push
(
line
)
end
end
...
...
@@ -113,8 +115,7 @@ module DiffHelper
if
line
.
blank?
" "
.
html_safe
else
# Return line if it isn't a String, it helps when it's Numeric
line
.
is_a?
(
String
)
?
line
.
html_safe
:
line
line
.
html_safe
end
end
...
...
app/views/projects/blob/diff.html.haml
浏览文件 @
0f0af191
...
...
@@ -11,7 +11,7 @@
%td
.old_line.diff-line-num
{
data:
{
linenumber:
line_old
}}
=
link_to
raw
(
line_old
),
"#"
%td
.new_line
=
link_to
raw
(
line_new
)
,
"#"
%td
.line_content.noteable_line
=
"
#{
' '
*
@form
.
indent
}#{
line
}
"
.
html_safe
%td
.line_content.noteable_line
=
=
#{
' '
*
@form
.
indent
}#{
line
}
-
if
@form
.
unfold?
&&
@form
.
bottom?
&&
@form
.
to
<
@blob
.
loc
%tr
.line_holder
{
id:
@form
.
to
}
...
...
app/views/projects/diffs/_parallel_view.html.haml
浏览文件 @
0f0af191
...
...
@@ -20,7 +20,7 @@
=
link_to
raw
(
line_number_left
),
"#
#{
line_code_left
}
"
,
id:
line_code_left
-
if
@comments_allowed
&&
can?
(
current_user
,
:create_note
,
@project
)
=
link_to_new_diff_note
(
line_code_left
,
'old'
)
%td
.line_content
{
class:
"parallel noteable_line #{type_left} #{line_code_left}"
,
"line_code"
=>
line_code_left
}=
line_content_left
.
html_safe
%td
.line_content
{
class:
"parallel noteable_line #{type_left} #{line_code_left}"
,
"line_code"
=>
line_code_left
}=
line_content_left
-
if
type_right
==
'new'
-
new_line_class
=
'new'
...
...
@@ -33,7 +33,7 @@
=
link_to
raw
(
line_number_right
),
"#
#{
new_line_code
}
"
,
id:
new_line_code
-
if
@comments_allowed
&&
can?
(
current_user
,
:create_note
,
@project
)
=
link_to_new_diff_note
(
line_code_right
,
'new'
)
%td
.line_content.parallel
{
class:
"noteable_line #{new_line_class} #{new_line_code}"
,
"line_code"
=>
new_line_code
}=
line_content_right
.
html_safe
%td
.line_content.parallel
{
class:
"noteable_line #{new_line_class} #{new_line_code}"
,
"line_code"
=>
new_line_code
}=
line_content_right
-
if
@reply_allowed
-
comments_left
,
comments_right
=
organize_comments
(
type_left
,
type_right
,
line_code_left
,
line_code_right
)
...
...
lib/gitlab/diff/highlight.rb
浏览文件 @
0f0af191
...
...
@@ -22,7 +22,7 @@ module Gitlab
content
=
blob
.
data
lexer
=
Rouge
::
Lexer
.
guess
(
filename:
file_name
,
source:
content
).
new
rescue
Rouge
::
Lexers
::
PlainText
.
new
formatter
.
format
(
lexer
.
lex
(
content
)).
lines
formatter
.
format
(
lexer
.
lex
(
content
)).
lines
.
map!
(
&
:html_safe
)
end
def
self
.
formatter
...
...
@@ -73,7 +73,7 @@ module Gitlab
# Only update text if line is found. This will prevent
# issues with submodules given the line only exists in diff content.
line
.
text
=
highlighted_line
.
gsub!
(
/\A\s/
,
line_prefix
)
if
highlighted_line
line
.
text
=
highlighted_line
.
gsub!
(
/\A\s/
,
line_prefix
)
.
html_safe
if
highlighted_line
end
@lines
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录