Merge pull request #14 from ayame-git/master
status search and typo fixes
Cette révision appartient à :
révision
8d1aca9c4a
3 fichiers modifiés avec 16 ajouts et 7 suppressions
|
@ -60,6 +60,12 @@
|
|||
<option value="5_10" {{if eq .Category "5_10"}}selected{{end}}>Live Action - Idol/Promotional Video</option>
|
||||
<option value="5_11" {{if eq .Category "5_11"}}selected{{end}}>Live Action - Raw</option>
|
||||
</select>
|
||||
<select name="s" class="form-control">
|
||||
<option value="">Search all</option>
|
||||
<option value="2" {{if eq .Status "2"}}selected{{end}}>Remakes</option>
|
||||
<option value="3" {{if eq .Status "3"}}selected{{end}}>Trusted</option>
|
||||
<option value="4" {{if eq .Status "4"}}selected{{end}}>A+</option>
|
||||
</select>
|
||||
<input name="q" class="form-control" placeholder="Search" type="text">
|
||||
<select name="max" class="form-control" value>
|
||||
<option value="">No Items per Page</option>
|
||||
|
|
8
main.go
8
main.go
|
@ -96,6 +96,7 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
|
|||
pagenum, _ := strconv.Atoi(html.EscapeString(page))
|
||||
searchQuery := r.URL.Query().Get("q")
|
||||
cat := r.URL.Query().Get("c")
|
||||
stat := r.URL.Query().Get("s")
|
||||
catsSplit := strings.Split(cat, "_")
|
||||
// need this to prevent out of index panics
|
||||
var searchCatId, searchSubCatId string
|
||||
|
@ -109,7 +110,8 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
b := []TorrentsJson{}
|
||||
|
||||
torrents := getTorrents(createWhereParams("torrent_name LIKE ? AND category_id LIKE ? AND sub_category_id LIKE ?", "%"+searchQuery+"%", searchCatId+"%", searchSubCatId+"%"), maxPerPage, maxPerPage*(pagenum-1))
|
||||
torrents := getTorrents(createWhereParams("torrent_name LIKE ? AND status_id LIKE ? AND category_id LIKE ? AND sub_category_id LIKE ?",
|
||||
"%"+searchQuery+"%", stat+"%", searchCatId+"%", searchSubCatId+"%"), maxPerPage, maxPerPage*(pagenum-1))
|
||||
|
||||
for i, _ := range torrents {
|
||||
nbTorrents++
|
||||
|
@ -119,7 +121,7 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
}
|
||||
|
||||
htv := HomeTemplateVariables{b, getAllCategories(false), searchQuery, cat, maxPerPage, nbTorrents}
|
||||
htv := HomeTemplateVariables{b, getAllCategories(false), searchQuery, stat, cat, maxPerPage, nbTorrents}
|
||||
|
||||
err := templates.ExecuteTemplate(w, "index.html", htv)
|
||||
if err != nil {
|
||||
|
@ -159,7 +161,7 @@ func rootHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
}
|
||||
|
||||
htv := HomeTemplateVariables{b, getAllCategories(false), "", "_", maxPerPage, nbTorrents}
|
||||
htv := HomeTemplateVariables{b, getAllCategories(false), "", "", "_", maxPerPage, nbTorrents}
|
||||
|
||||
err := templates.ExecuteTemplate(w, "index.html", htv)
|
||||
if err != nil {
|
||||
|
|
|
@ -25,10 +25,10 @@ type Sub_Categories struct {
|
|||
|
||||
type Torrents struct {
|
||||
gorm.Model
|
||||
Id int `gorm:"column:torrent_id"`
|
||||
Name string `gorm:"column:torrent_name"`
|
||||
Category_id int `gorm:"column:category_id"`
|
||||
Sub_category_id int
|
||||
Id int `gorm:"column:torrent_id"`
|
||||
Name string `gorm:"column:torrent_name"`
|
||||
Category_id int `gorm:"column:category_id"`
|
||||
Sub_category_id int `gorm:"column:sub_category_id"`
|
||||
Status int `gorm:"column:status_id"`
|
||||
Hash string `gorm:"column:torrent_hash"`
|
||||
Categories Categories `gorm:"ForeignKey:category_id;AssociationForeignKey:category_id"`
|
||||
|
@ -67,6 +67,7 @@ type HomeTemplateVariables struct {
|
|||
ListTorrents []TorrentsJson
|
||||
ListCategories []Categories
|
||||
Query string
|
||||
Status string
|
||||
Category string
|
||||
QueryRecordCount int
|
||||
TotalRecordCount int
|
||||
|
|
Référencer dans un nouveau ticket