Skip to content

Commit 8c8a30c

Browse files
author
scott Chacon
committed
followed one path, but now I think I'm going to back out
1 parent baf3d42 commit 8c8a30c

File tree

1 file changed

+46
-8
lines changed

1 file changed

+46
-8
lines changed

camping/gitweb.rb

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
require 'camping'
33
require 'git'
44

5+
begin
6+
require 'syntax/convertors/html'
7+
rescue LoadError
8+
end
9+
510
# this is meant to be a git-less web head to your git repo
611
#
712
# install dependencies
@@ -36,6 +41,21 @@ def get
3641
end
3742
end
3843

44+
class Stylesheet < R '/css/highlight.css'
45+
def get
46+
@headers['Content-Type'] = 'text/css'
47+
ending = File.read(__FILE__).gsub(/.*__END__/m, '')
48+
ending.gsub(/__END__.*/m, '')
49+
end
50+
end
51+
52+
class JsHighlight < R '/js/highlight.js'
53+
def get
54+
@headers['Content-Type'] = 'text/css'
55+
File.read(__FILE__).gsub(/.*__JS__/m, '')
56+
end
57+
end
58+
3959
class View < R '/view/(\d+)'
4060
def get repo_id
4161
@repo = Repository.find repo_id
@@ -139,6 +159,11 @@ def get repo_id, tree1, tree2
139159
module GitWeb::Views
140160
def layout
141161
html do
162+
head do
163+
title 'gitweb'
164+
#link :href=>R(Stylesheet), :rel=>'stylesheet', :type=>'text/css'
165+
#script :type => "text/javascript", :language => "JavaScript", :src => R(JsHighlight)
166+
end
142167
style <<-END, :type => 'text/css'
143168
body { color: #333; }
144169
h1 { background: #cce; padding: 10px; margin: 3px; }
@@ -147,6 +172,8 @@ def layout
147172
p { padding: 5px; }
148173
.odd { background: #eee; }
149174
.tag { margin: 5px; padding: 1px 3px; border: 1px solid #8a8; background: #afa;}
175+
.indent { padding: 0px 15px;}
176+
.tip { border-top: 1px solid #aaa; color: #666; padding: 10px; }
150177
END
151178
body do
152179
self << yield
@@ -277,17 +304,28 @@ def blob
277304
end
278305

279306
def diff
280-
a.options 'repo', :href => R(View, @repo)
281-
282-
p { a 'patch', :href => R(Patch, @repo, @tree1, @tree2) }
283-
307+
a.options 'repo', :href => R(View, @repo)
284308
h1 "diff"
285-
p { strong @tree1 + ' : ' + @tree2 }
286-
309+
310+
p { a 'download patch file', :href => R(Patch, @repo, @tree1, @tree2) }
311+
312+
p do
313+
a @tree1, :href => R(Tree, @repo, @tree1)
314+
span.space ' : '
315+
a @tree2, :href => R(Tree, @repo, @tree2)
316+
end
317+
287318
@diff.each do |file|
288319
h3 file.path
289-
pre file.patch
320+
begin
321+
convertor = Syntax::Convertors::HTML.for_syntax "diff"
322+
self << convertor.convert( file.patch )
323+
rescue
324+
div.indent { pre file.patch }
325+
div.tip 'tip: if you run "gem install syntax", this will be highlighted'
326+
end
290327
end
328+
291329
end
292330

293331

@@ -329,4 +367,4 @@ def index
329367

330368
def GitWeb.create
331369
GitWeb::Models.create_schema
332-
end
370+
end

0 commit comments

Comments
 (0)