Add search results page
This commit is contained in:
@@ -134,6 +134,7 @@ module Precious
|
||||
@query = params[:q]
|
||||
wiki = Gollum::Wiki.new(settings.gollum_path)
|
||||
@results = wiki.search @query
|
||||
@name = @query
|
||||
mustache :search
|
||||
end
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ a:hover, a:visited {
|
||||
line-height: normal;
|
||||
margin: 0;
|
||||
padding: 0.08em 0 0 0;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
#head ul.actions {
|
||||
@@ -362,6 +363,45 @@ a:hover, a:visited {
|
||||
}
|
||||
|
||||
|
||||
/* @section search */
|
||||
.results h1 {
|
||||
color: #999;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.results h1 strong {
|
||||
color: #000;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.results #results {
|
||||
border-bottom: 1px solid #ccc;
|
||||
margin-bottom: 2em;
|
||||
padding-bottom: 2em;
|
||||
}
|
||||
|
||||
.results #results ul {
|
||||
margin: 2em 0 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.results #results ul li {
|
||||
font-size: 1.2em;
|
||||
line-height: 1.6em;
|
||||
list-style-position: outside;
|
||||
padding: 0.2em 0;
|
||||
}
|
||||
|
||||
.results #results ul li span.count {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.results p#no-results {
|
||||
font-size: 1.2em;
|
||||
line-height: 1.6em;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
|
||||
/* @control minibutton */
|
||||
ul.actions {
|
||||
@@ -478,6 +518,10 @@ ul.actions {
|
||||
padding: 0.4em 0.6em;
|
||||
}
|
||||
|
||||
#head #searchbar #searchbar-fauxtext input#search-query.ph {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
#head #searchbar #searchbar-fauxtext #search-submit {
|
||||
border: 0;
|
||||
border-left: 1px solid #d4d4d4;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<script type="text/javascript" src="/javascript/jquery.js"></script>
|
||||
<script type="text/javascript" src="/javascript/gollum.js"></script>
|
||||
<script type="text/javascript" src="/javascript/gollum.dialog.js"></script>
|
||||
<script type="text/javascript" src="/javascript/gollum.placeholder.js"></script>
|
||||
<script type="text/javascript" src="/javascript/gollum.fx.js"></script>
|
||||
<!-- TODO: only load this on the edit page -->
|
||||
<script type="text/javascript"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div id="wiki-wrapper" class="page">
|
||||
<div id="head">
|
||||
<h1>Page Title</h1>
|
||||
<h1>{{title}}</h1>
|
||||
<ul class="actions">
|
||||
<li class="minibutton"><a href="/edit/{{escaped_name}}"
|
||||
class="action-edit-page">Edit Page</a></li>
|
||||
|
||||
@@ -1,19 +1,33 @@
|
||||
<div class="guide">
|
||||
<div class="main">
|
||||
<div class="actions">
|
||||
<form action="/search" method="get">
|
||||
<a href="/">Home</a> | <input type="search" name="q" size="10" /> <input type="submit" value="search" />
|
||||
</form>
|
||||
</div>
|
||||
<h1>Search for “{{query}}”</h1>
|
||||
<div class="content wikistyle gollum">
|
||||
{{#has_results}}
|
||||
<ul>
|
||||
{{#results}}
|
||||
<li><a href="/{{name}}">{{name}} ({{count}})</a></li>
|
||||
{{/results}}
|
||||
</ul>
|
||||
{{/has_results}}
|
||||
</div>
|
||||
</div>
|
||||
<div id="wiki-wrapper" class="results">
|
||||
<div id="head">
|
||||
<h1>Search Results for <strong>{{query}}</strong></h1>
|
||||
<ul class="actions">
|
||||
<li class="minibutton"><a href="/edit/{{escaped_name}}"
|
||||
class="action-edit-page">Edit Page</a></li>
|
||||
<li class="minibutton"><a href="/history/{{escaped_name}}"
|
||||
class="action-page-history">Page History</a></li>
|
||||
</ul>
|
||||
{{>searchbar}}
|
||||
</div>
|
||||
<div id="results">
|
||||
|
||||
{{#has_results}}
|
||||
<ul>
|
||||
{{#results}}
|
||||
<li>
|
||||
<a href="/{{name}}">{{name}}</a>
|
||||
<span class="count">({{count}} matches)</span>
|
||||
</li>
|
||||
{{/results}}
|
||||
</ul>
|
||||
{{/has_results}}
|
||||
|
||||
{{#no_results}}
|
||||
<p id="no-results">
|
||||
There are no results for your search <strong>{{query}}</strong>.
|
||||
</p>
|
||||
{{/no_results}}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<div id="searchbar">
|
||||
<form action="/search" method="get" id="search-form">
|
||||
<div id="searchbar-fauxtext">
|
||||
<input type="text" name="q" id="search-query">
|
||||
<input type="text" name="q" id="search-query" value="Search…" autocomplete="off">
|
||||
<a href="#" id="search-submit" title="Search this wiki">
|
||||
<span>Search</span>
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -3,9 +3,17 @@ module Precious
|
||||
class Search < Layout
|
||||
attr_reader :content, :page, :footer, :results, :query
|
||||
|
||||
def title
|
||||
"Search results for " + @query
|
||||
end
|
||||
|
||||
def has_results
|
||||
!@results.empty?
|
||||
end
|
||||
|
||||
def no_results
|
||||
@results.empty?
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user