Skip to content

Commit c6db2b7

Browse files
author
scott Chacon
committed
applied helper patch kindly submitted by skaar <skaar@waste.org>
1 parent e3d0951 commit c6db2b7

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

camping/gitweb.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,28 @@ def self.up
4040
end
4141
end
4242

43+
module GitWeb::Helpers
44+
def inline_data(identifier)
45+
section = "__#{identifier.to_s.upcase}__"
46+
@@inline_data ||= File.read(__FILE__).gsub(/.*__END__/m, '')
47+
data = @@inline_data.match(/(#{section}.)(.*?)((__)|(\Z))/m)
48+
data ? data[2] : nil # return nil if no second found
49+
end
50+
end
51+
4352
module GitWeb::Controllers
4453

4554
class Stylesheet < R '/css/highlight.css'
4655
def get
4756
@headers['Content-Type'] = 'text/css'
48-
ending = File.read(__FILE__).gsub(/.*__END__/m, '')
49-
ending.gsub(/__JS__.*/m, '')
57+
inline_data(:css)
5058
end
5159
end
5260

5361
class JsHighlight < R '/js/highlight.js'
5462
def get
5563
@headers['Content-Type'] = 'text/css'
56-
File.read(__FILE__).gsub(/.*__JS__/m, '')
64+
inline_data(:js)
5765
end
5866
end
5967

@@ -419,6 +427,8 @@ def GitWeb.create
419427

420428
# everything below this line is the css and javascript for syntax-highlighting
421429
__END__
430+
431+
__CSS__
422432
pre.sh_sourceCode {
423433
background-color: white;
424434
color: black;

0 commit comments

Comments
 (0)