##// END OF EJS Templates
Fixes diff highlighting (#5199)....
Jean-Philippe Lang -
r3505:4a51f1007491
parent child
Show More
@@ -1,56 +1,56
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2010 Jean-Philippe Lang
2 # Copyright (C) 2006-2010 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 module Redmine
18 module Redmine
19 module SyntaxHighlighting
19 module SyntaxHighlighting
20
20
21 class << self
21 class << self
22 attr_reader :highlighter
22 attr_reader :highlighter
23 delegate :highlight_by_filename, :highlight_by_language, :to => :highlighter
23 delegate :highlight_by_filename, :highlight_by_language, :to => :highlighter
24
24
25 def highlighter=(name)
25 def highlighter=(name)
26 if name.is_a?(Module)
26 if name.is_a?(Module)
27 @highlighter = name
27 @highlighter = name
28 else
28 else
29 @highlighter = const_get(name)
29 @highlighter = const_get(name)
30 end
30 end
31 end
31 end
32 end
32 end
33
33
34 module CodeRay
34 module CodeRay
35 require 'coderay'
35 require 'coderay'
36 require 'coderay/helpers/file_type'
36 require 'coderay/helpers/file_type'
37
37
38 class << self
38 class << self
39 # Highlights +text+ as the content of +filename+
39 # Highlights +text+ as the content of +filename+
40 # Should not return line numbers nor outer pre tag
40 # Should not return line numbers nor outer pre tag
41 def highlight_by_filename(text, filename)
41 def highlight_by_filename(text, filename)
42 language = ::CodeRay::FileType[filename]
42 language = ::CodeRay::FileType[filename]
43 language ? ::CodeRay.scan(text, language).html : ERB::Util.h(text)
43 language ? ::CodeRay.scan(text, language).html : ERB::Util.h(text)
44 end
44 end
45
45
46 # Highlights +text+ using +language+ syntax
46 # Highlights +text+ using +language+ syntax
47 # Should not return outer pre tag
47 # Should not return outer pre tag
48 def highlight_by_language(text, language)
48 def highlight_by_language(text, language)
49 ::CodeRay.scan(text, language).html(:line_numbers => :inline)
49 ::CodeRay.scan(text, language).html(:line_numbers => :inline, :wrap => :span)
50 end
50 end
51 end
51 end
52 end
52 end
53 end
53 end
54
54
55 SyntaxHighlighting.highlighter = 'CodeRay'
55 SyntaxHighlighting.highlighter = 'CodeRay'
56 end
56 end
@@ -1,172 +1,195
1
1
2 div.changeset-changes ul { margin: 0; padding: 0; }
2 div.changeset-changes ul { margin: 0; padding: 0; }
3 div.changeset-changes ul > ul { margin-left: 18px; padding: 0; }
3 div.changeset-changes ul > ul { margin-left: 18px; padding: 0; }
4
4
5 li.change {
5 li.change {
6 list-style-type:none;
6 list-style-type:none;
7 background-image: url(../images/bullet_black.png);
7 background-image: url(../images/bullet_black.png);
8 background-position: 1px 1px;
8 background-position: 1px 1px;
9 background-repeat: no-repeat;
9 background-repeat: no-repeat;
10 padding-top: 1px;
10 padding-top: 1px;
11 padding-bottom: 1px;
11 padding-bottom: 1px;
12 padding-left: 20px;
12 padding-left: 20px;
13 margin: 0;
13 margin: 0;
14 }
14 }
15 li.change.folder { background-image: url(../images/folder_open.png); }
15 li.change.folder { background-image: url(../images/folder_open.png); }
16 li.change.folder.change-A { background-image: url(../images/folder_open_add.png); }
16 li.change.folder.change-A { background-image: url(../images/folder_open_add.png); }
17 li.change.folder.change-M { background-image: url(../images/folder_open_orange.png); }
17 li.change.folder.change-M { background-image: url(../images/folder_open_orange.png); }
18 li.change.change-A { background-image: url(../images/bullet_add.png); }
18 li.change.change-A { background-image: url(../images/bullet_add.png); }
19 li.change.change-M { background-image: url(../images/bullet_orange.png); }
19 li.change.change-M { background-image: url(../images/bullet_orange.png); }
20 li.change.change-C { background-image: url(../images/bullet_blue.png); }
20 li.change.change-C { background-image: url(../images/bullet_blue.png); }
21 li.change.change-R { background-image: url(../images/bullet_purple.png); }
21 li.change.change-R { background-image: url(../images/bullet_purple.png); }
22 li.change.change-D { background-image: url(../images/bullet_delete.png); }
22 li.change.change-D { background-image: url(../images/bullet_delete.png); }
23
23
24 li.change .copied-from { font-style: italic; color: #999; font-size: 0.9em; }
24 li.change .copied-from { font-style: italic; color: #999; font-size: 0.9em; }
25 li.change .copied-from:before { content: " - "}
25 li.change .copied-from:before { content: " - "}
26
26
27 #changes-legend { float: right; font-size: 0.8em; margin: 0; }
27 #changes-legend { float: right; font-size: 0.8em; margin: 0; }
28 #changes-legend li { float: left; background-position: 5px 0; }
28 #changes-legend li { float: left; background-position: 5px 0; }
29
29
30 table.filecontent { border: 1px solid #ccc; border-collapse: collapse; width:98%; background-color: #fafafa; }
30 table.filecontent { border: 1px solid #ccc; border-collapse: collapse; width:98%; background-color: #fafafa; }
31 table.filecontent th { border: 1px solid #ccc; background-color: #eee; }
31 table.filecontent th { border: 1px solid #ccc; background-color: #eee; }
32 table.filecontent th.filename { background-color: #e4e4d4; text-align: left; padding: 0.2em;}
32 table.filecontent th.filename { background-color: #e4e4d4; text-align: left; padding: 0.2em;}
33 table.filecontent tr.spacing th { text-align:center; }
33 table.filecontent tr.spacing th { text-align:center; }
34 table.filecontent tr.spacing td { height: 0.4em; background: #EAF2F5;}
34 table.filecontent tr.spacing td { height: 0.4em; background: #EAF2F5;}
35 table.filecontent th.line-num {
35 table.filecontent th.line-num {
36 border: 1px solid #d7d7d7;
36 border: 1px solid #d7d7d7;
37 font-size: 0.8em;
37 font-size: 0.8em;
38 text-align: right;
38 text-align: right;
39 width: 2%;
39 width: 2%;
40 padding-right: 3px;
40 padding-right: 3px;
41 color: #999;
41 color: #999;
42 }
42 }
43 table.filecontent th.line-num a {
43 table.filecontent th.line-num a {
44 text-decoration: none;
44 text-decoration: none;
45 color: inherit;
45 color: inherit;
46 }
46 }
47 table.filecontent td.line-code pre {
47 table.filecontent td.line-code pre {
48 margin: 0px;
48 margin: 0px;
49 white-space: pre-wrap; /* CSS2.1 compliant */
49 white-space: pre-wrap; /* CSS2.1 compliant */
50 white-space: -moz-pre-wrap; /* Mozilla-based browsers */
50 white-space: -moz-pre-wrap; /* Mozilla-based browsers */
51 white-space: -o-pre-wrap; /* Opera 7+ */
51 white-space: -o-pre-wrap; /* Opera 7+ */
52 }
52 }
53
53
54 /* 12 different colors for the annonate view */
54 /* 12 different colors for the annonate view */
55 table.annotate tr.bloc-0 {background: #FFFFBF;}
55 table.annotate tr.bloc-0 {background: #FFFFBF;}
56 table.annotate tr.bloc-1 {background: #EABFFF;}
56 table.annotate tr.bloc-1 {background: #EABFFF;}
57 table.annotate tr.bloc-2 {background: #BFFFFF;}
57 table.annotate tr.bloc-2 {background: #BFFFFF;}
58 table.annotate tr.bloc-3 {background: #FFD9BF;}
58 table.annotate tr.bloc-3 {background: #FFD9BF;}
59 table.annotate tr.bloc-4 {background: #E6FFBF;}
59 table.annotate tr.bloc-4 {background: #E6FFBF;}
60 table.annotate tr.bloc-5 {background: #BFCFFF;}
60 table.annotate tr.bloc-5 {background: #BFCFFF;}
61 table.annotate tr.bloc-6 {background: #FFBFEF;}
61 table.annotate tr.bloc-6 {background: #FFBFEF;}
62 table.annotate tr.bloc-7 {background: #FFE6BF;}
62 table.annotate tr.bloc-7 {background: #FFE6BF;}
63 table.annotate tr.bloc-8 {background: #FFE680;}
63 table.annotate tr.bloc-8 {background: #FFE680;}
64 table.annotate tr.bloc-9 {background: #AA80FF;}
64 table.annotate tr.bloc-9 {background: #AA80FF;}
65 table.annotate tr.bloc-10 {background: #FFBFDC;}
65 table.annotate tr.bloc-10 {background: #FFBFDC;}
66 table.annotate tr.bloc-11 {background: #BFE4FF;}
66 table.annotate tr.bloc-11 {background: #BFE4FF;}
67
67
68 table.annotate td.revision {
68 table.annotate td.revision {
69 text-align: center;
69 text-align: center;
70 width: 2%;
70 width: 2%;
71 padding-left: 1em;
71 padding-left: 1em;
72 background: inherit;
72 background: inherit;
73 }
73 }
74
74
75 table.annotate td.author {
75 table.annotate td.author {
76 text-align: center;
76 text-align: center;
77 border-right: 1px solid #d7d7d7;
77 border-right: 1px solid #d7d7d7;
78 white-space: nowrap;
78 white-space: nowrap;
79 padding-left: 1em;
79 padding-left: 1em;
80 padding-right: 1em;
80 padding-right: 1em;
81 width: 3%;
81 width: 3%;
82 background: inherit;
82 background: inherit;
83 font-size: 90%;
83 font-size: 90%;
84 }
84 }
85
85
86 table.annotate td.line-code { background-color: #fafafa; }
86 table.annotate td.line-code { background-color: #fafafa; }
87
87
88 div.action_M { background: #fd8 }
88 div.action_M { background: #fd8 }
89 div.action_D { background: #f88 }
89 div.action_D { background: #f88 }
90 div.action_A { background: #bfb }
90 div.action_A { background: #bfb }
91
91
92 /************* CodeRay styles *************/
92 /************* CodeRay styles *************/
93
93 .syntaxhl div {display: inline;}
94 .syntaxhl .no { padding: 2px 4px 2px 4px; background-color: #eee; margin:0 }
94 .syntaxhl .no { padding: 2px 4px 2px 4px; background-color: #eee; margin:0 }
95 .syntaxhl .code pre { overflow: auto }
95 .syntaxhl .code pre { overflow: auto }
96 .syntaxhl .debug { color:white ! important; background:blue ! important; }
96 .syntaxhl .debug { color:white ! important; background:blue ! important; }
97
97
98 .syntaxhl .af { color:#00C }
98 .syntaxhl .af { color:#00C }
99 .syntaxhl .an { color:#007 }
99 .syntaxhl .an { color:#007 }
100 .syntaxhl .at { color:#f08 }
100 .syntaxhl .av { color:#700 }
101 .syntaxhl .av { color:#700 }
101 .syntaxhl .aw { color:#C00 }
102 .syntaxhl .aw { color:#C00 }
102 .syntaxhl .bi { color:#509; font-weight:bold }
103 .syntaxhl .bi { color:#509; font-weight:bold }
103 .syntaxhl .c { color:#666; }
104 .syntaxhl .c { color:#888; }
104
105
105 .syntaxhl .ch { color:#04D }
106 .syntaxhl .ch { color:#04D }
106 .syntaxhl .ch .k { color:#04D }
107 .syntaxhl .ch .k { color:#04D }
107 .syntaxhl .ch .dl { color:#039 }
108 .syntaxhl .ch .dl { color:#039 }
108
109
109 .syntaxhl .cl { color:#B06; font-weight:bold }
110 .syntaxhl .cl { color:#B06; font-weight:bold }
111 .syntaxhl .cm { color:#A08; font-weight:bold }
110 .syntaxhl .co { color:#036; font-weight:bold }
112 .syntaxhl .co { color:#036; font-weight:bold }
111 .syntaxhl .cr { color:#0A0 }
113 .syntaxhl .cr { color:#0A0 }
112 .syntaxhl .cv { color:#369 }
114 .syntaxhl .cv { color:#369 }
115 .syntaxhl .de { color:#B0B; }
113 .syntaxhl .df { color:#099; font-weight:bold }
116 .syntaxhl .df { color:#099; font-weight:bold }
114 .syntaxhl .di { color:#088; font-weight:bold }
117 .syntaxhl .di { color:#088; font-weight:bold }
115 .syntaxhl .dl { color:black }
118 .syntaxhl .dl { color:black }
116 .syntaxhl .do { color:#970 }
119 .syntaxhl .do { color:#970 }
120 .syntaxhl .dt { color:#34b }
117 .syntaxhl .ds { color:#D42; font-weight:bold }
121 .syntaxhl .ds { color:#D42; font-weight:bold }
118 .syntaxhl .e { color:#666; font-weight:bold }
122 .syntaxhl .e { color:#666; font-weight:bold }
119 .syntaxhl .en { color:#800; font-weight:bold }
123 .syntaxhl .en { color:#800; font-weight:bold }
120 .syntaxhl .er { color:#F00; background-color:#FAA }
124 .syntaxhl .er { color:#F00; background-color:#FAA }
121 .syntaxhl .ex { color:#F00; font-weight:bold }
125 .syntaxhl .ex { color:#C00; font-weight:bold }
122 .syntaxhl .fl { color:#60E; font-weight:bold }
126 .syntaxhl .fl { color:#60E; font-weight:bold }
123 .syntaxhl .fu { color:#06B; font-weight:bold }
127 .syntaxhl .fu { color:#06B; font-weight:bold }
124 .syntaxhl .gv { color:#d70; font-weight:bold }
128 .syntaxhl .gv { color:#d70; font-weight:bold }
125 .syntaxhl .hx { color:#058; font-weight:bold }
129 .syntaxhl .hx { color:#058; font-weight:bold }
126 .syntaxhl .i { color:#00D; font-weight:bold }
130 .syntaxhl .i { color:#00D; font-weight:bold }
127 .syntaxhl .ic { color:#B44; font-weight:bold }
131 .syntaxhl .ic { color:#B44; font-weight:bold }
128
132
129 .syntaxhl .il { background: #eee }
133 .syntaxhl .il { background: #ddd; color: black }
130 .syntaxhl .il .il { background: #ddd }
134 .syntaxhl .il .il { background: #ccc }
131 .syntaxhl .il .il .il { background: #ccc }
135 .syntaxhl .il .il .il { background: #bbb }
132 .syntaxhl .il .idl { font-weight: bold; color: #888 }
136 .syntaxhl .il .idl { background: #ddd; font-weight: bold; color: #666 }
137 .syntaxhl .idl { background-color: #bbb; font-weight: bold; color: #666; }
133
138
139 .syntaxhl .im { color:#f00; }
134 .syntaxhl .in { color:#B2B; font-weight:bold }
140 .syntaxhl .in { color:#B2B; font-weight:bold }
135 .syntaxhl .iv { color:#33B }
141 .syntaxhl .iv { color:#33B }
136 .syntaxhl .la { color:#970; font-weight:bold }
142 .syntaxhl .la { color:#970; font-weight:bold }
137 .syntaxhl .lv { color:#963 }
143 .syntaxhl .lv { color:#963 }
138 .syntaxhl .oc { color:#40E; font-weight:bold }
144 .syntaxhl .oc { color:#40E; font-weight:bold }
139 .syntaxhl .of { color:#000; font-weight:bold }
145 .syntaxhl .of { color:#000; font-weight:bold }
140 .syntaxhl .op { }
146 .syntaxhl .op { }
141 .syntaxhl .pc { color:#038; font-weight:bold }
147 .syntaxhl .pc { color:#038; font-weight:bold }
142 .syntaxhl .pd { color:#369; font-weight:bold }
148 .syntaxhl .pd { color:#369; font-weight:bold }
143 .syntaxhl .pp { color:#579 }
149 .syntaxhl .pp { color:#579; }
144 .syntaxhl .pt { color:#339; font-weight:bold }
150 .syntaxhl .ps { color:#00C; font-weight:bold }
145 .syntaxhl .r { color:#080; font-weight:bold }
151 .syntaxhl .pt { color:#074; font-weight:bold }
152 .syntaxhl .r, .kw { color:#080; font-weight:bold }
153
154 .syntaxhl .ke { color: #808; }
155 .syntaxhl .ke .dl { color: #606; }
156 .syntaxhl .ke .ch { color: #80f; }
157 .syntaxhl .vl { color: #088; }
146
158
147 .syntaxhl .rx { background-color:#fff0ff }
159 .syntaxhl .rx { background-color:#fff0ff }
148 .syntaxhl .rx .k { color:#808 }
160 .syntaxhl .rx .k { color:#808 }
149 .syntaxhl .rx .dl { color:#404 }
161 .syntaxhl .rx .dl { color:#404 }
150 .syntaxhl .rx .mod { color:#C2C }
162 .syntaxhl .rx .mod { color:#C2C }
151 .syntaxhl .rx .fu { color:#404; font-weight: bold }
163 .syntaxhl .rx .fu { color:#404; font-weight: bold }
152
164
153 .syntaxhl .s { background-color:#fff0f0 }
165 .syntaxhl .s { background-color:#fff0f0; color: #D20; }
154 .syntaxhl .s .s { background-color:#ffe0e0 }
166 .syntaxhl .s .s { background-color:#ffe0e0 }
155 .syntaxhl .s .s .s { background-color:#ffd0d0 }
167 .syntaxhl .s .s .s { background-color:#ffd0d0 }
156 .syntaxhl .s .k { color:#D20 }
168 .syntaxhl .s .k { }
157 .syntaxhl .s .dl { color:#710 }
169 .syntaxhl .s .ch { color: #b0b; }
170 .syntaxhl .s .dl { color: #710; }
158
171
159 .syntaxhl .sh { background-color:#f0fff0 }
172 .syntaxhl .sh { background-color:#f0fff0; color:#2B2 }
160 .syntaxhl .sh .k { color:#2B2 }
173 .syntaxhl .sh .k { }
161 .syntaxhl .sh .dl { color:#161 }
174 .syntaxhl .sh .dl { color:#161 }
162
175
163 .syntaxhl .sy { color:#A60 }
176 .syntaxhl .sy { color:#A60 }
164 .syntaxhl .sy .k { color:#A60 }
177 .syntaxhl .sy .k { color:#A60 }
165 .syntaxhl .sy .dl { color:#630 }
178 .syntaxhl .sy .dl { color:#630 }
166
179
167 .syntaxhl .ta { color:#070 }
180 .syntaxhl .ta { color:#070 }
168 .syntaxhl .tf { color:#070; font-weight:bold }
181 .syntaxhl .tf { color:#070; font-weight:bold }
169 .syntaxhl .ts { color:#D70; font-weight:bold }
182 .syntaxhl .ts { color:#D70; font-weight:bold }
170 .syntaxhl .ty { color:#339; font-weight:bold }
183 .syntaxhl .ty { color:#339; font-weight:bold }
171 .syntaxhl .v { color:#036 }
184 .syntaxhl .v { color:#036 }
172 .syntaxhl .xt { color:#444 }
185 .syntaxhl .xt { color:#444 }
186
187 .syntaxhl .ins { background: #cfc; }
188 .syntaxhl .del { background: #fcc; }
189 .syntaxhl .chg { color: #aaf; background: #007; }
190 .syntaxhl .head { color: #f8f; background: #505 }
191
192 .syntaxhl .ins .ins { color: #080; font-weight:bold }
193 .syntaxhl .del .del { color: #800; font-weight:bold }
194 .syntaxhl .chg .chg { color: #66f; }
195 .syntaxhl .head .head { color: #f4f; }
General Comments 0
You need to be logged in to leave comments. Login now