pagination on the history page
This commit is contained in:
@@ -83,6 +83,8 @@ module Precious
|
|||||||
@name = params[:name]
|
@name = params[:name]
|
||||||
wiki = Gollum::Wiki.new($path)
|
wiki = Gollum::Wiki.new($path)
|
||||||
@page = wiki.page(@name)
|
@page = wiki.page(@name)
|
||||||
|
@page_num = [params[:page].to_i, 1].max
|
||||||
|
@versions = @page.versions :page => @page_num
|
||||||
mustache :history
|
mustache :history
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<th colspan="5">
|
<th colspan="5">
|
||||||
Select any two versions to <input type="submit" value="Compare" />
|
Select any two versions to <input type="submit" value="Compare" />
|
||||||
</th>
|
</th>
|
||||||
|
</tr>
|
||||||
{{#versions}}
|
{{#versions}}
|
||||||
<tr class="commit">
|
<tr class="commit">
|
||||||
<td class="checkbox">
|
<td class="checkbox">
|
||||||
@@ -27,6 +28,10 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{{/versions}}
|
{{/versions}}
|
||||||
</table>
|
</table>
|
||||||
|
<div class="pagination">
|
||||||
|
{{{previous_link}}}
|
||||||
|
{{{next_link}}}
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
module Precious
|
module Precious
|
||||||
module Views
|
module Views
|
||||||
class History < Layout
|
class History < Layout
|
||||||
attr_reader :page
|
attr_reader :page, :page_num
|
||||||
|
|
||||||
def title
|
def title
|
||||||
"History of #{@page.title}"
|
"History of #{@page.title}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def versions
|
def versions
|
||||||
i = @page.versions.size + 1
|
i = @versions.size + 1
|
||||||
@page.versions.map do |v|
|
@versions.map do |v|
|
||||||
i -= 1
|
i -= 1
|
||||||
{ :id => v.id,
|
{ :id => v.id,
|
||||||
:id7 => v.id[0..6],
|
:id7 => v.id[0..6],
|
||||||
@@ -21,6 +21,24 @@ module Precious
|
|||||||
:gravatar => Digest::MD5.hexdigest(v.author.email) }
|
:gravatar => Digest::MD5.hexdigest(v.author.email) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def previous_link
|
||||||
|
label = "« Previous"
|
||||||
|
if @page_num == 1
|
||||||
|
%(<span class="disabled">#{label}</span>)
|
||||||
|
else
|
||||||
|
%(<a href="/history/#{@page.name}?page=#{@page_num-1}" hotkey="h">#{label}</a>)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def next_link
|
||||||
|
label = "Next »"
|
||||||
|
if @versions.size == Gollum::Page.per_page
|
||||||
|
%(<a href="/history/#{@page.name}?page=#{@page_num+1}" hotkey="l">#{label}</a>)
|
||||||
|
else
|
||||||
|
%(<span class="disabled">#{label}</span>)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user