From e4fa888c38a582326ba0bd47e8d868577a2493f6 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Mon, 2 Aug 2010 18:15:41 -0600 Subject: [PATCH] Implement simple history. --- lib/gollum.rb | 3 + lib/gollum/frontend/app.rb | 7 ++ lib/gollum/frontend/public/css/screen.css | 78 ++++++++++++++++++- .../frontend/templates/history.mustache | 30 +++++++ lib/gollum/frontend/templates/page.mustache | 7 +- lib/gollum/frontend/views/history.rb | 30 +++++++ lib/gollum/frontend/views/page.rb | 12 --- 7 files changed, 148 insertions(+), 19 deletions(-) create mode 100644 lib/gollum/frontend/templates/history.mustache create mode 100644 lib/gollum/frontend/views/history.rb diff --git a/lib/gollum.rb b/lib/gollum.rb index 390b778e..1d82b261 100644 --- a/lib/gollum.rb +++ b/lib/gollum.rb @@ -1,3 +1,6 @@ +# stdlib +require 'digest/md5' + # external require 'grit' require 'github/markup' diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index 65c3bbce..cd814c14 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -78,6 +78,13 @@ module Precious wiki.preview_page("Preview", data, format).formatted_data end + get '/history/:name' do + @name = params[:name] + wiki = Gollum::Wiki.new($path) + @page = wiki.page(@name) + mustache :history + end + get %r{/(.+?)/([0-9a-f]{40})} do name = params[:captures][0] wiki = Gollum::Wiki.new($path) diff --git a/lib/gollum/frontend/public/css/screen.css b/lib/gollum/frontend/public/css/screen.css index 617f963d..7709b0ca 100644 --- a/lib/gollum/frontend/public/css/screen.css +++ b/lib/gollum/frontend/public/css/screen.css @@ -487,4 +487,80 @@ label.wiki-label { .comment-form .comment{ margin:5px 0 0 0; -} \ No newline at end of file +} + +/****************************************************************************/ +/* History +/****************************************************************************/ + +table.commits { + width: 100%; + border-left: 1px solid #ccc; + border-right: 1px solid #ccc; + border-top: 1px solid #ccc; + margin-bottom: 2em; +} + + table.commits tr td { + background-color: #eaf2f5; + } + + table.commits th { + font-weight: normal; + border-bottom: 1px solid #ccc; + padding: .3em .6em; + background-color: #eee; + font-size: 95%; + text-align:left; + } + + table.commits td { + border-bottom: 1px solid #ccc; + padding: .3em .6em; + } + + table.commits td.sha, + table.commits td.message { + font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace; + font-size: 80%; + } + + table.commits td.checkbox { + width: 3%; + } + + table.commits td.sha { + width: 6%; + } + + table.commits td.human { + font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace; + font-size: 80%; + width: 4%; + color: #888; + } + + table.commits td.author { + width: 15%; + font-weight: bold; + } + + table.commits td.author img { + vertical-align: middle; + border: 1px solid #ccc; + padding: 1px; + background-color: white; + } + + table.commits td.message a { + color: black; + } + + table.commits td.message a:hover { + text-decoration: underline; + } + + table.commits td.date { + width: 12%; + text-align: right; + } \ No newline at end of file diff --git a/lib/gollum/frontend/templates/history.mustache b/lib/gollum/frontend/templates/history.mustache new file mode 100644 index 00000000..3166ae09 --- /dev/null +++ b/lib/gollum/frontend/templates/history.mustache @@ -0,0 +1,30 @@ +
+
+
+ « Back +
+

History of {{human_name}}

+ + + + {{#versions}} + + + + + + + + {{/versions}} +
+ Select any two versions to +
+ + + {{id7}} + + Gravatar + {{author}} + {{message}}{{date}}
+
+
\ No newline at end of file diff --git a/lib/gollum/frontend/templates/page.mustache b/lib/gollum/frontend/templates/page.mustache index 321814dc..ce799d27 100644 --- a/lib/gollum/frontend/templates/page.mustache +++ b/lib/gollum/frontend/templates/page.mustache @@ -22,11 +22,6 @@
- Versions: - + View Revision History
diff --git a/lib/gollum/frontend/views/history.rb b/lib/gollum/frontend/views/history.rb new file mode 100644 index 00000000..648db01b --- /dev/null +++ b/lib/gollum/frontend/views/history.rb @@ -0,0 +1,30 @@ +module Precious + module Views + class History < Layout + attr_reader :page + + def human_name + @page.title + end + + def title + "A Page" + end + + def versions + i = @page.versions.size + 1 + @page.versions.map do |v| + i -= 1 + { :id => v.id, + :id7 => v.id[0..6], + :num => i, + :selected => @page.version.id == v.id, + :author => v.author.name, + :message => v.message, + :date => v.committed_date.strftime("%B %d, %Y"), + :gravatar => Digest::MD5.hexdigest(v.author.email) } + end + end + end + end +end diff --git a/lib/gollum/frontend/views/page.rb b/lib/gollum/frontend/views/page.rb index d3681288..e2211da5 100644 --- a/lib/gollum/frontend/views/page.rb +++ b/lib/gollum/frontend/views/page.rb @@ -37,18 +37,6 @@ module Precious @footer ||= @page.footer @footer.format.to_s end - - def versions - i = @page.versions.size + 1 - @page.versions.map do |v| - i -= 1 - { :id => v.id, - :id7 => v.id[0..6], - :num => i, - :selected => @page.version.id == v.id, - :author => v.author.name } - end - end end end end