Permalink
Browse files

Added 'All Pages' route and view

  • Loading branch information...
1 parent ad56122 commit d3594f6652384e5eadfe1378e81eb780b1cd0550 Tom Clark committed Apr 9, 2011
@@ -169,6 +169,13 @@ class App < Sinatra::Base
mustache :search
end
+ get '/pages' do
+ wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
+ @results = wiki.pages
+ @ref = wiki.ref
+ mustache :pages
+ end
+
get '/*' do
show_page_or_file(params[:splat].first)
end
@@ -2,6 +2,8 @@
<div id="head">
<h1>{{title}}</h1>
<ul class="actions">
+ <li class="minibutton"><a href="/pages"
+ class="action-all-pages">All Pages</a></li>
<li class="minibutton" class="jaws">
<a href="#" id="minibutton-new-page">New Page</a></li>
<li class="minibutton"><a href="/edit/{{escaped_name}}"
@@ -0,0 +1,35 @@
+<div id="wiki-wrapper" class="results">
+<div id="head">
+ <h1>{{title}}</h1>
+ <ul class="actions">
+ <li class="minibutton"><a href="/"
+ class="action-edit-page">Home</a></li>
+ </ul>
+ {{>searchbar}}
+</div>
+<div id="results">
+
+{{#has_results}}
+ <ul>
+ {{#results}}
+ <li>
+ <a href="/{{name}}">{{name}}</a>
+ </li>
+ {{/results}}
+ </ul>
+{{/has_results}}
+
+{{#no_results}}
+ <p id="no-results">
+ There are no pages in <strong>{{ref}}</strong>.
+ </p>
+{{/no_results}}
+
+</div>
+<div id="footer">
+ <ul class="actions">
+ <li class="minibutton"><a href="#">Back to Top</a></li>
+ </ul>
+</div>
+</div>
+
@@ -0,0 +1,19 @@
+module Precious
+ module Views
+ class Pages < Layout
+ attr_reader :results, :ref
+
+ def title
+ "All pages in #{@ref}"
+ end
+
+ def has_results
+ !@results.empty?
+ end
+
+ def no_results
+ @results.empty?
+ end
+ end
+ end
+end

0 comments on commit d3594f6

Please sign in to comment.