Add help page

This commit is contained in:
Las Zenow 2013-06-01 04:56:35 +02:00
parent 4e703e03ce
commit a6c8355a50
4 changed files with 34 additions and 2 deletions

View file

@ -13,6 +13,7 @@ type Status struct {
About bool
Upload bool
Stats bool
Help bool
}
func GetStatus(w http.ResponseWriter, r *http.Request) Status {
@ -37,6 +38,7 @@ var templates = template.Must(template.ParseFiles(TEMPLATE_PATH+"header.html",
TEMPLATE_PATH+"edit.html",
TEMPLATE_PATH+"settings.html",
TEMPLATE_PATH+"stats.html",
TEMPLATE_PATH+"help.html",
))
func loadTemplate(w http.ResponseWriter, tmpl string, data interface{}) {

View file

@ -78,6 +78,9 @@
<form class="navbar-search pull-right" action="/search/">
<input type="search" class="search-query span3" name="q" {{if .Search}}value="{{.Search}}"{{else}}placeholder="Search"{{end}} />
</form>
<ul class="nav pull-right">
<li {{if .Help}}class="active"{{end}}><a href="/help/">Help</a></li>
</ul>
</div>
</div>
</div>

19
templates/help.html Normal file
View file

@ -0,0 +1,19 @@
{{template "header.html" .S}}
<h4>Advanced Search</h4>
<p>It is possible to search for books in an specific language adding <em>lang:code</em> to the search string. See for example some searches:
<ul>
<li><a href="/search/?q=lang:en hacker">lang:en hacker</a></li>
<li><a href="/search/?q=lang:es">lang:es</a></li>
<li><a href="/search/?q=isaac asimov lang:fr">isaac asimov lang:fr</a></li>
</ul>
</p>
<p>There is other topics than <em>lang</em> that can be used:
<ul>
<li><a href="/search/?q=author:doctorow">author:doctorow</a></li>
<li><a href="/search/?q=subject:computers title:python">subject:computers title:python</a></li>
</ul>
</p>
{{template "footer.html"}}

View file

@ -9,17 +9,24 @@ import (
"strings"
)
type aboutData struct {
type statusData struct {
S Status
}
func aboutHandler(w http.ResponseWriter, r *http.Request, sess *Session) {
var data aboutData
var data statusData
data.S = GetStatus(w, r)
data.S.About = true
loadTemplate(w, "about", data)
}
func helpHandler(w http.ResponseWriter, r *http.Request, sess *Session) {
var data statusData
data.S = GetStatus(w, r)
data.S.Help = true
loadTemplate(w, "help", data)
}
func logoutHandler(w http.ResponseWriter, r *http.Request, sess *Session) {
sess.LogOut()
sess.Notify("Log out!", "Bye bye "+sess.User, "success")
@ -168,6 +175,7 @@ func setUpRouter() {
r.HandleFunc("/edit/{id:[0-9a-fA-F]+}", GatherStats(editHandler))
r.HandleFunc("/save/{id:[0-9a-fA-F]+}", GatherStats(saveHandler)).Methods("POST")
r.HandleFunc("/about/", GatherStats(aboutHandler))
r.HandleFunc("/help/", GatherStats(helpHandler))
r.HandleFunc("/download/{id:[0-9a-fA-F]+}/{epub:.*}", GatherStats(downloadHandler))
r.HandleFunc("/cover/{id:[0-9a-fA-F]+}/{size}/{img:.*}", coverHandler)
r.HandleFunc("/settings/", GatherStats(settingsHandler))