Move Search to different template file
(also re-add accidentally deleted catimg)
Cette révision appartient à :
Parent
c0f9c5c1c1
révision
ef9e37c3ac
5 fichiers modifiés avec 86 ajouts et 103 suppressions
Fichier binaire non affiché.
Avant Largeur: | Hauteur: | Taille: 3,1 Kio Après Largeur: | Hauteur: | Taille: 3,2 Kio |
BIN
img/torrents/13.png
Fichier normal
BIN
img/torrents/13.png
Fichier normal
Fichier binaire non affiché.
Après Largeur: | Hauteur: | Taille: 3,1 Kio |
4
main.go
4
main.go
|
@ -103,6 +103,7 @@ func apiViewHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
func searchHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var templates = template.Must(template.New("home").Funcs(funcMap).ParseFiles("templates/index.html", "templates/home.html"))
|
||||
templates.ParseGlob("templates/_*.html") // common
|
||||
vars := mux.Vars(r)
|
||||
page := vars["page"]
|
||||
|
||||
|
@ -184,6 +185,7 @@ func safe(s string) template.URL {
|
|||
|
||||
func faqHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var templates = template.Must(template.New("FAQ").Funcs(funcMap).ParseFiles("templates/index.html", "templates/FAQ.html"))
|
||||
templates.ParseGlob("templates/_*.html") // common
|
||||
err := templates.ExecuteTemplate(w, "index.html", FaqTemplateVariables{Navigation{}, NewSearchForm(), r.URL, mux.CurrentRoute(r)})
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
@ -238,6 +240,7 @@ func rssHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
func viewHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var templates = template.Must(template.ParseFiles("templates/index.html", "templates/view.html"))
|
||||
templates.ParseGlob("templates/_*.html") // common
|
||||
vars := mux.Vars(r)
|
||||
id := vars["id"]
|
||||
|
||||
|
@ -254,6 +257,7 @@ func viewHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
func rootHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var templates = template.Must(template.New("home").Funcs(funcMap).ParseFiles("templates/index.html", "templates/home.html"))
|
||||
templates.ParseGlob("templates/_*.html") // common
|
||||
vars := mux.Vars(r)
|
||||
page := vars["page"]
|
||||
|
||||
|
|
72
templates/_search.html
Fichier normal
72
templates/_search.html
Fichier normal
|
@ -0,0 +1,72 @@
|
|||
{{define "search_common"}}
|
||||
<select name="c" class="form-control input-sm" value>
|
||||
<option value="_">All categories</option>
|
||||
<option value="3_" {{if eq .Search.Category "3_"}}selected{{end}}>Anime</option>
|
||||
<option value="3_12" {{if eq .Search.Category "3_12"}}selected{{end}}>Anime - Anime Music Video</option>
|
||||
<option value="3_5" {{if eq .Search.Category "3_5"}}selected{{end}}>Anime - English-translated</option>
|
||||
<option value="3_13" {{if eq .Search.Category "3_13"}}selected{{end}}>Anime - Non-English-translated</option>
|
||||
<option value="3_6" {{if eq .Search.Category "3_6"}}selected{{end}}>Anime - Raw</option>
|
||||
<option value="2_" {{if eq .Search.Category "2_"}}selected{{end}}>Audio</option>
|
||||
<option value="2_3" {{if eq .Search.Category "2_3"}}selected{{end}}>Audio - Lossless</option>
|
||||
<option value="2_4" {{if eq .Search.Category "2_4"}}selected{{end}}>Audio - Lossy</option>
|
||||
<option value="4_" {{if eq .Search.Category "4_"}}selected{{end}}>Literature</option>
|
||||
<option value="4_7" {{if eq .Search.Category "4_7"}}selected{{end}}>Literature - English-translated</option>
|
||||
<option value="4_8" {{if eq .Search.Category "4_8"}}selected{{end}}>Literature - Raw</option>
|
||||
<option value="4_14" {{if eq .Search.Category "4_14"}}selected{{end}}>Literature - Non-English-translated</option>
|
||||
<option value="5_" {{if eq .Search.Category "5_"}}selected{{end}}>Live Action</option>
|
||||
<option value="5_9" {{if eq .Search.Category "5_9"}}selected{{end}}>Live Action - English-translated</option>
|
||||
<option value="5_10" {{if eq .Search.Category "5_10"}}selected{{end}}>Live Action - Idol/Promotional Video</option>
|
||||
<option value="5_18" {{if eq .Search.Category "5_18"}}selected{{end}}>Live Action - Non-English-translated</option>
|
||||
<option value="5_11" {{if eq .Search.Category "5_11"}}selected{{end}}>Live Action - Raw</option>
|
||||
<option value="6_" {{if eq .Search.Category "6_"}}selected{{end}}>Pictures</option>
|
||||
<option value="6_15" {{if eq .Search.Category "6_15"}}selected{{end}}>Pictures - Graphics</option>
|
||||
<option value="6_16" {{if eq .Search.Category "6_16"}}selected{{end}}>Pictures - Photos</option>
|
||||
<option value="1_" {{if eq .Search.Category "1_"}}selected{{end}}>Software</option>
|
||||
<option value="1_1" {{if eq .Search.Category "1_1"}}selected{{end}}>Software - Applications</option>
|
||||
<option value="1_2" {{if eq .Search.Category "1_2"}}selected{{end}}>Software - Games</option>
|
||||
</select>
|
||||
<select name="s" class="form-control input-sm">
|
||||
<option value="">Search all</option>
|
||||
<option value="2" {{if eq .Search.Status "2"}}selected{{end}}>Remakes</option>
|
||||
<option value="3" {{if eq .Search.Status "3"}}selected{{end}}>Trusted</option>
|
||||
<option value="4" {{if eq .Search.Status "4"}}selected{{end}}>A+</option>
|
||||
</select>
|
||||
{{end}}
|
||||
{{define "search_advanced"}}
|
||||
<select name="sort" class="form-control input-sm">
|
||||
<option value="torrent_id" {{if eq .Search.Sort "torrent_id"}}selected{{end}}>ID</option>
|
||||
<option value="torrent_name" {{if eq .Search.Sort "torrent_name"}}selected{{end}}>Name</option>
|
||||
<option value="date" {{if eq .Search.Sort "date"}}selected{{end}}>Date</option>
|
||||
<option value="downloads" {{if eq .Search.Sort "downloads"}}selected{{end}}>Downloads</option>
|
||||
</select>
|
||||
<select name="order" class="form-control input-sm">
|
||||
<option value="desc" {{if eq .Search.Order "desc"}}selected{{end}}>Descending</option>
|
||||
<option value="asc" {{if eq .Search.Order "asc"}}selected{{end}}>Ascending</option>
|
||||
</select>
|
||||
<select name="max" class="form-control input-sm" value>
|
||||
<option value="5" {{if eq .Navigation.MaxItemPerPage 5}}selected{{end}}>5</option>
|
||||
<option value="10" {{if eq .Navigation.MaxItemPerPage 10}}selected{{end}}>10</option>
|
||||
<option value="15" {{if eq .Navigation.MaxItemPerPage 15}}selected{{end}}>15</option>
|
||||
<option value="20" {{if eq .Navigation.MaxItemPerPage 20}}selected{{end}}>20</option>
|
||||
<option value="25" {{if eq .Navigation.MaxItemPerPage 25}}selected{{end}}>25</option>
|
||||
<option value="30" {{if eq .Navigation.MaxItemPerPage 30}}selected{{end}}>30</option>
|
||||
<option value="35" {{if eq .Navigation.MaxItemPerPage 35}}selected{{end}}>35</option>
|
||||
<option value="40" {{if eq .Navigation.MaxItemPerPage 40}}selected{{end}}>40</option>
|
||||
<option value="45" {{if eq .Navigation.MaxItemPerPage 45}}selected{{end}}>45</option>
|
||||
<option value="50" {{if eq .Navigation.MaxItemPerPage 50}}selected{{end}}>50</option>
|
||||
<option value="70" {{if eq .Navigation.MaxItemPerPage 70}}selected{{end}}>70</option>
|
||||
<option value="100" {{if eq .Navigation.MaxItemPerPage 100}}selected{{end}}>100</option>
|
||||
<option value="150" {{if eq .Navigation.MaxItemPerPage 150}}selected{{end}}>150</option>
|
||||
<option value="200" {{if eq .Navigation.MaxItemPerPage 200}}selected{{end}}>200</option>
|
||||
<option value="300" {{if eq .Navigation.MaxItemPerPage 300}}selected{{end}}>300</option>
|
||||
</select>
|
||||
{{end}}
|
||||
|
||||
{{define "search_button"}}
|
||||
<div class="input-group">
|
||||
<input name="q" class="form-control input-sm" placeholder="Search" type="text" value="{{.Search.Query}}">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-search" aria-hidden="true"></span> Search</button>
|
||||
</span>
|
||||
</div>
|
||||
{{end}}
|
|
@ -42,45 +42,8 @@
|
|||
</ul>
|
||||
<form class="navbar-form navbar-right" role="search" action="/search" method="get">
|
||||
<div class="form-group">
|
||||
|
||||
<select name="c" class="form-control input-sm" value>
|
||||
<option value="_">All categories</option>
|
||||
<option value="3_" {{if eq .Search.Category "3_"}}selected{{end}}>Anime</option>
|
||||
<option value="3_12" {{if eq .Search.Category "3_12"}}selected{{end}}>Anime - Anime Music Video</option>
|
||||
<option value="3_5" {{if eq .Search.Category "3_5"}}selected{{end}}>Anime - English-translated</option>
|
||||
<option value="3_13" {{if eq .Search.Category "3_13"}}selected{{end}}>Anime - Non-English-translated</option>
|
||||
<option value="3_6" {{if eq .Search.Category "3_6"}}selected{{end}}>Anime - Raw</option>
|
||||
<option value="2_" {{if eq .Search.Category "2_"}}selected{{end}}>Audio</option>
|
||||
<option value="2_3" {{if eq .Search.Category "2_3"}}selected{{end}}>Audio - Lossless</option>
|
||||
<option value="2_4" {{if eq .Search.Category "2_4"}}selected{{end}}>Audio - Lossy</option>
|
||||
<option value="4_" {{if eq .Search.Category "4_"}}selected{{end}}>Literature</option>
|
||||
<option value="4_7" {{if eq .Search.Category "4_7"}}selected{{end}}>Literature - English-translated</option>
|
||||
<option value="4_8" {{if eq .Search.Category "4_8"}}selected{{end}}>Literature - Raw</option>
|
||||
<option value="4_14" {{if eq .Search.Category "4_14"}}selected{{end}}>Literature - Non-English-translated</option>
|
||||
<option value="5_" {{if eq .Search.Category "5_"}}selected{{end}}>Live Action</option>
|
||||
<option value="5_9" {{if eq .Search.Category "5_9"}}selected{{end}}>Live Action - English-translated</option>
|
||||
<option value="5_10" {{if eq .Search.Category "5_10"}}selected{{end}}>Live Action - Idol/Promotional Video</option>
|
||||
<option value="5_18" {{if eq .Search.Category "5_18"}}selected{{end}}>Live Action - Non-English-translated</option>
|
||||
<option value="5_11" {{if eq .Search.Category "5_11"}}selected{{end}}>Live Action - Raw</option>
|
||||
<option value="6_" {{if eq .Search.Category "6_"}}selected{{end}}>Pictures</option>
|
||||
<option value="6_15" {{if eq .Search.Category "6_15"}}selected{{end}}>Pictures - Graphics</option>
|
||||
<option value="6_16" {{if eq .Search.Category "6_16"}}selected{{end}}>Pictures - Photos</option>
|
||||
<option value="1_" {{if eq .Search.Category "1_"}}selected{{end}}>Software</option>
|
||||
<option value="1_1" {{if eq .Search.Category "1_1"}}selected{{end}}>Software - Applications</option>
|
||||
<option value="1_2" {{if eq .Search.Category "1_2"}}selected{{end}}>Software - Games</option>
|
||||
</select>
|
||||
<select name="s" class="form-control input-sm">
|
||||
<option value="">Search all</option>
|
||||
<option value="2" {{if eq .Search.Status "2"}}selected{{end}}>Remakes</option>
|
||||
<option value="3" {{if eq .Search.Status "3"}}selected{{end}}>Trusted</option>
|
||||
<option value="4" {{if eq .Search.Status "4"}}selected{{end}}>A+</option>
|
||||
</select>
|
||||
<div class="input-group">
|
||||
<input name="q" class="form-control input-sm" placeholder="Search" type="text" value="{{.Search.Query}}">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-search" aria-hidden="true"></span> Search</button>
|
||||
</span>
|
||||
</div>
|
||||
{{block "search_common" .}}{{end}}
|
||||
{{block "search_button" .}}{{end}}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -90,70 +53,14 @@
|
|||
<div class="container" id="container">
|
||||
<div class="blockBody">
|
||||
<h3>Advanced Search</h3>
|
||||
<form class="navbar-form navbar-right" role="search" action="/search" method="get">
|
||||
<div class="form-group">
|
||||
|
||||
<select name="c" class="form-control input-sm" value>
|
||||
<option value="_">All categories</option>
|
||||
<option value="1_" {{if eq .Search.Category "1_"}}selected{{end}}>Software</option>
|
||||
<option value="1_1" {{if eq .Search.Category "1_1"}}selected{{end}}>Software - Applications</option>
|
||||
<option value="1_2" {{if eq .Search.Category "1_2"}}selected{{end}}>Software - Games</option>
|
||||
<option value="2_" {{if eq .Search.Category "2_"}}selected{{end}}>Audio</option>
|
||||
<option value="2_3" {{if eq .Search.Category "2_3"}}selected{{end}}>Audio - Lossless</option>
|
||||
<option value="2_4" {{if eq .Search.Category "2_4"}}selected{{end}}>Audio - Lossy</option>
|
||||
<option value="3_" {{if eq .Search.Category "3_"}}selected{{end}}>Anime</option>
|
||||
<option value="3_5" {{if eq .Search.Category "3_5"}}selected{{end}}>Anime - English-translated</option>
|
||||
<option value="3_6" {{if eq .Search.Category "3_6"}}selected{{end}}>Anime - Raw</option>
|
||||
<option value="4_" {{if eq .Search.Category "4_"}}selected{{end}}>Literature</option>
|
||||
<option value="4_7" {{if eq .Search.Category "4_7"}}selected{{end}}>Literature - English-translated</option>
|
||||
<option value="4_8" {{if eq .Search.Category "4_8"}}selected{{end}}>Literature - Raw</option>
|
||||
<option value="5_" {{if eq .Search.Category "5_"}}selected{{end}}>Live Action</option>
|
||||
<option value="5_9" {{if eq .Search.Category "5_9"}}selected{{end}}>Live Action - English-translated</option>
|
||||
<option value="5_10" {{if eq .Search.Category "5_10"}}selected{{end}}>Live Action - Idol/Promotional Video</option>
|
||||
<option value="5_11" {{if eq .Search.Category "5_11"}}selected{{end}}>Live Action - Raw</option>
|
||||
</select>
|
||||
<select name="s" class="form-control input-sm">
|
||||
<option value="">Search all</option>
|
||||
<option value="2" {{if eq .Search.Status "2"}}selected{{end}}>Remakes</option>
|
||||
<option value="3" {{if eq .Search.Status "3"}}selected{{end}}>Trusted</option>
|
||||
<option value="4" {{if eq .Search.Status "4"}}selected{{end}}>A+</option>
|
||||
</select>
|
||||
<select name="sort" class="form-control input-sm">
|
||||
<option value="torrent_id" {{if eq .Search.Sort "torrent_id"}}selected{{end}}>Id</option>
|
||||
<option value="torrent_name" {{if eq .Search.Sort "torrent_name"}}selected{{end}}>Name</option>
|
||||
<option value="date" {{if eq .Search.Sort "date"}}selected{{end}}>Date</option>
|
||||
<option value="downloads" {{if eq .Search.Sort "downloads"}}selected{{end}}>Downloads</option>
|
||||
</select>
|
||||
<select name="order" class="form-control input-sm">
|
||||
<option value="desc" {{if eq .Search.Order "desc"}}selected{{end}}>Descend</option>
|
||||
<option value="asc" {{if eq .Search.Order "asc"}}selected{{end}}>Ascend</option>
|
||||
</select>
|
||||
<select name="max" class="form-control input-sm" value>
|
||||
<option value="5" {{if eq .Navigation.MaxItemPerPage 5}}selected{{end}}>5</option>
|
||||
<option value="10" {{if eq .Navigation.MaxItemPerPage 10}}selected{{end}}>10</option>
|
||||
<option value="15" {{if eq .Navigation.MaxItemPerPage 15}}selected{{end}}>15</option>
|
||||
<option value="20" {{if eq .Navigation.MaxItemPerPage 20}}selected{{end}}>20</option>
|
||||
<option value="25" {{if eq .Navigation.MaxItemPerPage 25}}selected{{end}}>25</option>
|
||||
<option value="30" {{if eq .Navigation.MaxItemPerPage 30}}selected{{end}}>30</option>
|
||||
<option value="35" {{if eq .Navigation.MaxItemPerPage 35}}selected{{end}}>35</option>
|
||||
<option value="40" {{if eq .Navigation.MaxItemPerPage 40}}selected{{end}}>40</option>
|
||||
<option value="45" {{if eq .Navigation.MaxItemPerPage 45}}selected{{end}}>45</option>
|
||||
<option value="50" {{if eq .Navigation.MaxItemPerPage 50}}selected{{end}}>50</option>
|
||||
<option value="70" {{if eq .Navigation.MaxItemPerPage 70}}selected{{end}}>70</option>
|
||||
<option value="100" {{if eq .Navigation.MaxItemPerPage 100}}selected{{end}}>100</option>
|
||||
<option value="150" {{if eq .Navigation.MaxItemPerPage 150}}selected{{end}}>150</option>
|
||||
<option value="200" {{if eq .Navigation.MaxItemPerPage 200}}selected{{end}}>200</option>
|
||||
<option value="300" {{if eq .Navigation.MaxItemPerPage 300}}selected{{end}}>300</option>
|
||||
</select>
|
||||
<div class="input-group">
|
||||
<input name="q" class="form-control input-sm" placeholder="Search" type="text" value="{{.Search.Query}}">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-search" aria-hidden="true"></span> Search</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div style="clear:both"></div>
|
||||
<form class="navbar-form navbar-right" role="search" action="/search" method="get">
|
||||
<div class="form-group">
|
||||
{{block "search_common" .}}{{end}}
|
||||
{{block "search_advanced" .}}{{end}}
|
||||
{{block "search_button" .}}{{end}}
|
||||
</div>
|
||||
</form>
|
||||
<div style="clear:both"></div>
|
||||
</div>
|
||||
{{block "content" .}}Nothing Here.{{end}}
|
||||
</div>
|
||||
|
|
Référencer dans un nouveau ticket