summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-29 10:29:53 -0800
committerscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-29 10:29:53 -0800
commitc6db2b7c34eb98a38047fca8fbef4a39279eaf08 (patch)
tree8c66e5742a21fcfbf2d94b196e7080e4753f45bc
parente3d0951881c5829b525c6e846e356e23a2e084fa (diff)
downloadthird_party-ruby-git-c6db2b7c34eb98a38047fca8fbef4a39279eaf08.tar.gz
third_party-ruby-git-c6db2b7c34eb98a38047fca8fbef4a39279eaf08.tar.xz
third_party-ruby-git-c6db2b7c34eb98a38047fca8fbef4a39279eaf08.zip
applied helper patch kindly submitted by skaar <skaar@waste.org>
-rw-r--r--camping/gitweb.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/camping/gitweb.rb b/camping/gitweb.rb
index 1c8b97a..54ed91c 100644
--- a/camping/gitweb.rb
+++ b/camping/gitweb.rb
@@ -40,20 +40,28 @@ module GitWeb::Models
end
end
+module GitWeb::Helpers
+ def inline_data(identifier)
+ section = "__#{identifier.to_s.upcase}__"
+ @@inline_data ||= File.read(__FILE__).gsub(/.*__END__/m, '')
+ data = @@inline_data.match(/(#{section}.)(.*?)((__)|(\Z))/m)
+ data ? data[2] : nil # return nil if no second found
+ end
+end
+
module GitWeb::Controllers
class Stylesheet < R '/css/highlight.css'
def get
@headers['Content-Type'] = 'text/css'
- ending = File.read(__FILE__).gsub(/.*__END__/m, '')
- ending.gsub(/__JS__.*/m, '')
+ inline_data(:css)
end
end
class JsHighlight < R '/js/highlight.js'
def get
@headers['Content-Type'] = 'text/css'
- File.read(__FILE__).gsub(/.*__JS__/m, '')
+ inline_data(:js)
end
end
@@ -419,6 +427,8 @@ end
# everything below this line is the css and javascript for syntax-highlighting
__END__
+
+__CSS__
pre.sh_sourceCode {
background-color: white;
color: black;