Implement simple history.

This commit is contained in:
Tom Preston-Werner
2010-08-02 18:15:41 -06:00
parent 17278fcf09
commit e4fa888c38
7 changed files with 148 additions and 19 deletions
+3
View File
@@ -1,3 +1,6 @@
# stdlib
require 'digest/md5'
# external
require 'grit'
require 'github/markup'
+7
View File
@@ -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)
+77 -1
View File
@@ -487,4 +487,80 @@ label.wiki-label {
.comment-form .comment{
margin:5px 0 0 0;
}
}
/****************************************************************************/
/* 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;
}
@@ -0,0 +1,30 @@
<div class="guide">
<div class="main">
<div class="actions">
<a href="/{{name}}">&laquo; Back</a>
</div>
<h1>History of {{human_name}}</h1>
<table class="commits" cellpadding="0" cellspacing="0">
<tr>
<th colspan="7">
Select any two versions to <input type="button" value="Compare" />
</th>
{{#versions}}
<tr>
<td class="checkbox">
<input type="checkbox" />
</td>
<td class="sha">
<a href="/{{name}}/{{id}}">{{id7}}</a>
</td>
<td nowrap class="author">
<img src="http://www.gravatar.com/avatar/{{gravatar}}?s=16" alt="Gravatar" />
{{author}}
</td>
<td class="message">{{message}}</td>
<td class="date">{{date}}</td>
</tr>
{{/versions}}
</table>
</div>
</div>
+1 -6
View File
@@ -22,11 +22,6 @@
</div>
</div>
<div style="float: right;">
<small>Versions:</small>
<select id="versions_select" name="versions_select">
{{#versions}}
<option {{#selected}}selected="true" {{/selected}}value="/{{name}}/{{id}}">Version {{num}} ({{id7}}) by {{author}}</option>
{{/versions}}
</select>
<a href="/history/{{name}}">View Revision History</a>
</div>
</div>
+30
View File
@@ -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
-12
View File
@@ -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