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