Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Cette révision appartient à :
kipukun 2017-05-05 01:05:26 -04:00
révision 1867174167
10 fichiers modifiés avec 212 ajouts et 240 suppressions

1
.gitignore externe
Voir le fichier

@ -5,3 +5,4 @@ nyaa
nyaa.exe
nyaa-master.exe
*.zip
*.swp

Voir le fichier

@ -21,7 +21,7 @@ nav#mainmenu a {
color: white;
}
div#container {
padding-top: 7rem;
padding-top: 10rem;
}
body {

41
main.go
Voir le fichier

@ -40,13 +40,17 @@ func checkErr(err error) {
}
func unZlib(description []byte) string {
b := bytes.NewReader(description)
z, err := zlib.NewReader(b)
checkErr(err)
defer z.Close()
p, err := ioutil.ReadAll(z)
checkErr(err)
return string(p)
if len(description) > 0 {
b := bytes.NewReader(description)
log.Println(b)
z, err := zlib.NewReader(b)
checkErr(err)
defer z.Close()
p, err := ioutil.ReadAll(z)
checkErr(err)
return string(p)
}
return ""
}
func apiHandler(w http.ResponseWriter, r *http.Request) {
@ -137,8 +141,9 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
b := []TorrentsJson{}
torrents, nbTorrents := 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))
parameters := createWhereParams("torrent_name LIKE ? AND status_id LIKE ? AND category_id LIKE ? AND sub_category_id LIKE ?",
"%"+searchQuery+"%", stat+"%", searchCatId+"%", searchSubCatId+"%")
torrents, nbTorrents := getTorrentsOrderBy(&parameters, order_by, maxPerPage, maxPerPage*(pagenum-1))
for i, _ := range torrents {
res := torrents[i].toJson()
@ -146,7 +151,7 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
}
navigationTorrents := Navigation{nbTorrents, maxPerPage, pagenum, "search_page"}
htv := HomeTemplateVariables{b, getAllCategories(false), searchQuery, stat, cat, navigationTorrents, r.URL, mux.CurrentRoute(r)}
htv := HomeTemplateVariables{b, getAllCategories(false), searchQuery, stat, cat, sort, order, navigationTorrents, r.URL, mux.CurrentRoute(r)}
err := templates.ExecuteTemplate(w, "index.html", htv)
if err != nil {
@ -159,7 +164,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"))
err := templates.ExecuteTemplate(w, "index.html", FaqTemplateVariables{r.URL, mux.CurrentRoute(r), "", "", "", Navigation{}})
err := templates.ExecuteTemplate(w, "index.html", FaqTemplateVariables{r.URL, mux.CurrentRoute(r), "", "", "_", "torrent_id", "desc", Navigation{}})
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
@ -212,7 +217,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"))
vars := mux.Vars(r)
id := vars["id"]
b := []TorrentsJson{}
@ -221,9 +226,9 @@ func viewHandler(w http.ResponseWriter, r *http.Request) {
res := torrent.toJson()
b = append(b, res)
htv := HomeTemplateVariables{b, getAllCategories(false), "", "", "_", "", "", 1, 1}
htv := HomeTemplateVariables{b, getAllCategories(false), "", "", "_", "", "", Navigation{}, r.URL, mux.CurrentRoute(r)}
err = templates.ExecuteTemplate(w, "view.html", htv)
err = templates.ExecuteTemplate(w, "index.html", htv)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
@ -255,7 +260,7 @@ func rootHandler(w http.ResponseWriter, r *http.Request) {
}
navigationTorrents := Navigation{nbTorrents, maxPerPage, pagenum, "search_page"}
htv := HomeTemplateVariables{b, getAllCategories(false), "", "", "_", navigationTorrents, r.URL, mux.CurrentRoute(r)}
htv := HomeTemplateVariables{b, getAllCategories(false), "", "", "_", "torrent_id", "desc", navigationTorrents, r.URL, mux.CurrentRoute(r)}
err := templates.ExecuteTemplate(w, "index.html", htv)
if err != nil {
@ -281,9 +286,11 @@ func main() {
router.HandleFunc("/page/{page:[0-9]+}", rootHandler).Name("home_page")
router.HandleFunc("/search", searchHandler).Name("search")
router.HandleFunc("/search/{page}", searchHandler).Name("search_page")
router.HandleFunc("/api/{page:[0-9]+}", apiHandler).Methods("GET")
router.HandleFunc("/api/torrent/{id:[0-9]+}", singleapiHandler).Methods("GET")
router.HandleFunc("/api/{page}", apiHandler).Methods("GET")
router.HandleFunc("/api/view/{id}", apiViewHandler).Methods("GET")
router.HandleFunc("/faq", faqHandler).Name("faq")
router.HandleFunc("/feed.xml", rssHandler)
router.HandleFunc("/view/{id}", viewHandler).Name("view_torrent")
http.Handle("/", router)

Voir le fichier

@ -42,7 +42,7 @@ type Torrents struct {
Name string `gorm:"column:torrent_name"`
Category_id int `gorm:"column:category_id"`
Sub_category_id int `gorm:"column:sub_category_id"`
Status_id int `gorm:"column:status_id"`
Status int `gorm:"column:status_id"`
Hash string `gorm:"column:torrent_hash"`
Date int `gorm:"column:date"`
Downloads int `gorm:"column:downloads"`
@ -131,13 +131,14 @@ func getTorrentsOrderBy(parameters *WhereParams, orderBy string, limit int, offs
var torrents []Torrents
var dbQuery *gorm.DB
var count int
conditions := "torrent_hash is not null" //filter out broken entries
var params []interface{}
if parameters != nil { // if there is where parameters
db.Model(&torrents).Where(parameters.conditions, parameters.params...).Count(&count)
dbQuery = db.Model(&torrents).Where(parameters.conditions, parameters.params...)
} else {
db.Model(&torrents).Count(&count)
dbQuery = db.Model(&torrents)
conditions += " AND " + parameters.conditions
params = parameters.params
}
db.Model(&torrents).Where(conditions, params...).Count(&count)
dbQuery = db.Model(&torrents).Where(conditions, params...)
if orderBy == "" {
orderBy = "torrent_id DESC"
@ -147,6 +148,7 @@ func getTorrentsOrderBy(parameters *WhereParams, orderBy string, limit int, offs
}
dbQuery.Order(orderBy).Preload("Categories").Preload("Sub_Categories").Find(&torrents)
return torrents, count
}
/* Functions to simplify the get parameters of the main function
@ -167,6 +169,7 @@ func getTorrentsDB(parameters WhereParams) ([]Torrents, int) {
*/
func getAllTorrentsOrderBy(orderBy string, limit int, offset int) ([]Torrents, int) {
return getTorrentsOrderBy(nil, orderBy, limit, offset)
}
@ -215,6 +218,7 @@ func (t *Torrents) toJson() TorrentsJson {
Sub_Category: t.Sub_Categories.toJson(),
Category: t.Categories.toJson(),
Magnet: safe(magnet)}
return res
}

Voir le fichier

@ -1,50 +1,54 @@
package main
import(
"math"
"html/template"
"net/url"
"strconv"
"log"
import (
"html/template"
"log"
"math"
"net/url"
"strconv"
)
var funcMap = template.FuncMap{
"min": math.Min,
"genRoute": func (name string, params ...string) string {
url, err := router.Get(name).URL(params...)
if (err == nil) {
return url.String()
}
return "error"
},
"genNav" : func (nav Navigation, currentUrl *url.URL, pagesSelectable int) template.HTML {
maxPages := math.Ceil(float64(nav.TotalItem)/float64(nav.MaxItemPerPage))
route := router.Get(nav.Route)
"min": math.Min,
"genRoute": func(name string, params ...string) string {
url, err := router.Get(name).URL(params...)
if err == nil {
return url.String()
}
return "error"
},
"genNav": func(nav Navigation, currentUrl *url.URL, pagesSelectable int) template.HTML {
maxPages := math.Ceil(float64(nav.TotalItem) / float64(nav.MaxItemPerPage))
route := router.Get(nav.Route)
var ret = ""
if nav.CurrentPage-1 > 0 {
url, _ := route.URL("page", "1")
ret = ret + "<li><a id=\"page-prev\" href=\""+ url.String() + "?" + currentUrl.RawQuery +"\" aria-label=\"Previous\"><span aria-hidden=\"true\">&laquo;</span></a></li>"
}
startValue := 1
if (nav.CurrentPage > pagesSelectable) {
startValue = (int(math.Min((float64(nav.CurrentPage) + math.Floor(float64(pagesSelectable)/2)), maxPages))-pagesSelectable+1)
}
endValue := (startValue+pagesSelectable-1)
if (endValue > int(maxPages)) { endValue = int(maxPages) }
log.Println(nav.TotalItem)
for i := startValue; i <= endValue; i++ {
pageNum := strconv.Itoa(i)
url,_ := route.URL("page", pageNum)
ret = ret + "<li"
if (i == nav.CurrentPage) { ret = ret + " class=\"active\"" }
var ret = ""
if nav.CurrentPage-1 > 0 {
url, _ := route.URL("page", "1")
ret = ret + "<li><a id=\"page-prev\" href=\"" + url.String() + "?" + currentUrl.RawQuery + "\" aria-label=\"Previous\"><span aria-hidden=\"true\">&laquo;</span></a></li>"
}
startValue := 1
if nav.CurrentPage > pagesSelectable {
startValue = (int(math.Min((float64(nav.CurrentPage)+math.Floor(float64(pagesSelectable)/2)), maxPages)) - pagesSelectable + 1)
}
endValue := (startValue + pagesSelectable - 1)
if endValue > int(maxPages) {
endValue = int(maxPages)
}
log.Println(nav.TotalItem)
for i := startValue; i <= endValue; i++ {
pageNum := strconv.Itoa(i)
url, _ := route.URL("page", pageNum)
ret = ret + "<li"
if i == nav.CurrentPage {
ret = ret + " class=\"active\""
}
ret = ret + "><a href=\""+ url.String() + "?" + currentUrl.RawQuery +"\">"+strconv.Itoa(i)+"</a></li>"
}
if nav.CurrentPage < int(maxPages) {
url, _ := route.URL("page", strconv.Itoa(nav.CurrentPage+1))
ret = ret + "<li><a id=\"page-next\" href=\""+ url.String() + "?" + currentUrl.RawQuery +"\" aria-label=\"Next\"><span aria-hidden=\"true\">&raquo;</span></a></li>"
}
return template.HTML(ret)
},
}
ret = ret + "><a href=\"" + url.String() + "?" + currentUrl.RawQuery + "\">" + strconv.Itoa(i) + "</a></li>"
}
if nav.CurrentPage < int(maxPages) {
url, _ := route.URL("page", strconv.Itoa(nav.CurrentPage+1))
ret = ret + "<li><a id=\"page-next\" href=\"" + url.String() + "?" + currentUrl.RawQuery + "\" aria-label=\"Next\"><span aria-hidden=\"true\">&raquo;</span></a></li>"
}
return template.HTML(ret)
},
}

Voir le fichier

@ -1,37 +1,41 @@
package main
import (
"net/url"
"github.com/gorilla/mux"
"net/url"
)
/* Each Page should have an object to pass to their own template
/* Each Page should have an object to pass to their own template
* Therefore, we put them in a separate file for better maintenance
*/
*/
type FaqTemplateVariables struct {
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
Query string
Status string
Category string
Navigation Navigation
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
Query string
Status string
Category string
Sort string
Order string
Navigation Navigation
}
type HomeTemplateVariables struct {
ListTorrents []TorrentsJson
ListCategories []Categories
Query string
Status string
Category string
Navigation Navigation
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
ListTorrents []TorrentsJson
ListCategories []Categories
Query string
Status string
Category string
Sort string
Order string
Navigation Navigation
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
}
type Navigation struct {
TotalItem int
MaxItemPerPage int
CurrentPage int
Route string
TotalItem int
MaxItemPerPage int
CurrentPage int
Route string
}

Voir le fichier

@ -6,6 +6,8 @@
<th>Id</th>
<th>Name</th>
<th>Hash</th>
<th>Date</th>
<th>Size</th>
<th>Links</th>
</tr>
{{ range .ListTorrents}}
@ -13,10 +15,13 @@
{{if eq .Status 3}}class="trusted"{{end}}
{{if eq .Status 4}}class="aplus"{{end}}>
<td><a href="{{$.URL.Parse (printf "/search?c=%s_%s" .Category.Id .Sub_Category.Id) }}"><img src="{{$.URL.Parse (printf "/img/torrents/%s.png" .Sub_Category.Id) }}"></td>
<td class="torrentName"><a href="{{$.URL.Parse (printf "/torrent/%s/%s" .Id .Name) }}">{{.Name}}</a></td>
<td class="torrentName"><a href="{{genRoute "view_torrent" "id" .Id }}">{{.Name}}</a></td>
<td>{{.Hash}}</td>
<td>{{.Date}}</td>
<td>{{.Filesize}}</td>
<td><a href="{{.Magnet}}" target="_blank" title="Magnet link"><span class="glyphicon glyphicon-magnet" aria-hidden="true"></span></a>
<a href="https://itorrents.org/torrent/{{.Hash}}.torrent" title="Torrent file"><span class="glyphicon glyphicon-floppy-save" aria-hidden="true"></span></a>
</td>

Voir le fichier

@ -35,10 +35,9 @@
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="https://sukebei.pantsu.cat">Sukebei Pantsu</a></li>
<li><a href="https://sukebei.pantsu.cat">Fap</a></li>
<li><a href="{{.URL.Parse "/faq"}}">Faq</a></li>
<li><a href="irc://irc.rizon.net/nyaapantsu">IRC</a></li>
</ul>
<form class="navbar-form navbar-right" role="search" action="/search" method="get">
<div class="form-group">
@ -68,9 +67,60 @@
<option value="3" {{if eq .Status "3"}}selected{{end}}>Trusted</option>
<option value="4" {{if eq .Status "4"}}selected{{end}}>A+</option>
</select>
======
<div class="input-group">
<input name="q" class="form-control input-sm" placeholder="Search" type="text" value="{{.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>
</div>
</nav>
<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 .Category "1_"}}selected{{end}}>Software</option>
<option value="1_1" {{if eq .Category "1_1"}}selected{{end}}>Software - Applications</option>
<option value="1_2" {{if eq .Category "1_2"}}selected{{end}}>Software - Games</option>
<option value="2_" {{if eq .Category "2_"}}selected{{end}}>Audio</option>
<option value="2_3" {{if eq .Category "2_3"}}selected{{end}}>Audio - Lossless</option>
<option value="2_4" {{if eq .Category "2_4"}}selected{{end}}>Audio - Lossy</option>
<option value="3_" {{if eq .Category "3_"}}selected{{end}}>Anime</option>
<option value="3_5" {{if eq .Category "3_5"}}selected{{end}}>Anime - English-translated</option>
<option value="3_6" {{if eq .Category "3_6"}}selected{{end}}>Anime - Raw</option>
<option value="4_" {{if eq .Category "4_"}}selected{{end}}>Literature</option>
<option value="4_7" {{if eq .Category "4_7"}}selected{{end}}>Literature - English-translated</option>
<option value="4_8" {{if eq .Category "4_8"}}selected{{end}}>Literature - Raw</option>
<option value="5_" {{if eq .Category "5_"}}selected{{end}}>Live Action</option>
<option value="5_9" {{if eq .Category "5_9"}}selected{{end}}>Live Action - English-translated</option>
<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 input-sm">
<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>
<select name="sort" class="form-control input-sm">
<option value="torrent_id" {{if eq .Sort "torrent_id"}}selected{{end}}>Id</option>
<option value="torrent_name" {{if eq .Sort "torrent_name"}}selected{{end}}>Name</option>
<option value="date" {{if eq .Sort "date"}}selected{{end}}>Date</option>
<option value="downloads" {{if eq .Sort "downloads"}}selected{{end}}>Downloads</option>
</select>
<select name="order" class="form-control input-sm">
<option value="desc" {{if eq .Order "desc"}}selected{{end}}>Descend</option>
<option value="asc" {{if eq .Order "asc"}}selected{{end}}>Ascend</option>
</select>
<select name="max" class="form-control input-sm" value>
<option value="">No Items per Page</option>
<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>
@ -95,10 +145,8 @@
</div>
</div>
</form>
</div>
</div>
</nav>
<div class="container" id="container">
<div style="clear:both"></div>
</div>
{{block "content" .}}Nothing Here.{{end}}
</div>

42
templates/view.html Fichier normal
Voir le fichier

@ -0,0 +1,42 @@
{{define "content"}}
<div class="blockBody">
<table class="table">
{{ range .ListTorrents}}
<tr {{if eq .Status 2}}class="remake"{{end}}
{{if eq .Status 3}}class="trusted"{{end}}
{{if eq .Status 4}}class="aplus"{{end}}>
<td>Id</td>
<td>{{.Id}}</td>
</tr>
<tr>
<td>Name</td>
<td>{{.Name}}</td>
</tr>
<tr>
<td>Hash</td>
<td>{{.Hash}}</td>
</tr>
<tr>
<td>Date</td>
<td>{{.Date}}</td>
</tr>
<tr>
<td>FileSize</td>
<td>{{.Filesize}}</td>
</tr>
tr
<tr>
<td>Links</td>
<td><a href="{{.Magnet}}" title="Magnet link" ><span class="glyphicon glyphicon-magnet" aria-hidden="true"></span></a>
<a href="https://itorrents.org/torrent/{{.Hash}}.torrent" title="Torrent file"><span class="glyphicon glyphicon-floppy-save" aria-hidden="true"></span></a>
</td>
</tr>
<tr>
<td>Description</td>
<td>{{.Description}}</td>
</tr>
{{end}}
</table>
</div>
{{end}}

143
view.html
Voir le fichier

@ -1,143 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Nyaa Pantsu</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Bootstrap -->
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Website CSS -->
<link rel="stylesheet" href="https://nyaa.pantsu.cat/css/style.css">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="https://nyaa.pantsu.cat">Nyaa Pantsu</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="https://sukebei.pantsu.cat">Sukebei Pantsu</a></li>
<li><a href="https://nyaa.pantsu.cat/faq">Faq</a></li>
</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="1_" {{if eq .Category "1_"}}selected{{end}}>Software</option>
<option value="1_1" {{if eq .Category "1_1"}}selected{{end}}>Software - Applications</option>
<option value="1_2" {{if eq .Category "1_2"}}selected{{end}}>Software - Games</option>
<option value="2_" {{if eq .Category "2_"}}selected{{end}}>Audio</option>
<option value="2_3" {{if eq .Category "2_3"}}selected{{end}}>Audio - Lossless</option>
<option value="2_4" {{if eq .Category "2_4"}}selected{{end}}>Audio - Lossy</option>
<option value="3_" {{if eq .Category "3_"}}selected{{end}}>Anime</option>
<option value="3_5" {{if eq .Category "3_5"}}selected{{end}}>Anime - English-translated</option>
<option value="3_6" {{if eq .Category "3_6"}}selected{{end}}>Anime - Raw</option>
<option value="4_" {{if eq .Category "4_"}}selected{{end}}>Literature</option>
<option value="4_7" {{if eq .Category "4_7"}}selected{{end}}>Literature - English-translated</option>
<option value="4_8" {{if eq .Category "4_8"}}selected{{end}}>Literature - Raw</option>
<option value="5_" {{if eq .Category "5_"}}selected{{end}}>Live Action</option>
<option value="5_9" {{if eq .Category "5_9"}}selected{{end}}>Live Action - English-translated</option>
<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 input-sm">
<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 input-sm" placeholder="Search" type="text" value={{.Query}}>
<select name="max" class="form-control input-sm" value>
<option value="">No Items per Page</option>
<option value="5" {{if eq .QueryRecordCount 5}}selected{{end}}>5</option>
<option value="10" {{if eq .QueryRecordCount 10}}selected{{end}}>10</option>
<option value="15" {{if eq .QueryRecordCount 15}}selected{{end}}>15</option>
<option value="20" {{if eq .QueryRecordCount 20}}selected{{end}}>20</option>
<option value="25" {{if eq .QueryRecordCount 25}}selected{{end}}>25</option>
<option value="30" {{if eq .QueryRecordCount 30}}selected{{end}}>30</option>
<option value="35" {{if eq .QueryRecordCount 35}}selected{{end}}>35</option>
<option value="40" {{if eq .QueryRecordCount 40}}selected{{end}}>40</option>
<option value="45" {{if eq .QueryRecordCount 45}}selected{{end}}>45</option>
<option value="50" {{if eq .QueryRecordCount 50}}selected{{end}}>50</option>
<option value="70" {{if eq .QueryRecordCount 70}}selected{{end}}>70</option>
<option value="100" {{if eq .QueryRecordCount 100}}selected{{end}}>100</option>
<option value="150" {{if eq .QueryRecordCount 150}}selected{{end}}>150</option>
<option value="200" {{if eq .QueryRecordCount 200}}selected{{end}}>200</option>
<option value="300" {{if eq .QueryRecordCount 300}}selected{{end}}>300</option>
</select>
</div>
<button type="submit" class="btn btn-default">Search</button>
</form>
</div>
</div>
</nav>
<div class="container">
<table class="table">
{{ range .ListTorrents}}
<tr {{if eq .Status 2}}class="remake"{{end}}
{{if eq .Status 3}}class="trusted"{{end}}
{{if eq .Status 4}}class="aplus"{{end}}>
<td>Id</td>
<td>{{.Id}}</td>
</tr>
<tr>
<td>Name</td>
<td>{{.Name}}</td>
</tr>
<tr>
<td>Hash</td>
<td>{{.Hash}}</td>
</tr>
<tr>
<td>Date</td>
<td>{{.Date}}</td>
</tr>
<tr>
<td>FileSize</td>
<td>{{.Filesize}}</td>
</tr>
tr
<tr>
<td>Links</td>
<td><a href="{{.Magnet}}" title="Magnet link" ><span class="glyphicon glyphicon-magnet" aria-hidden="true"></span></a>
<a href="https://itorrents.org/torrent/{{.Hash}}.torrent" title="Torrent file"><span class="glyphicon glyphicon-floppy-save" aria-hidden="true"></span></a>
</td>
</tr>
<tr>
<td>Description</td>
<td>{{.Description}}</td>
</tr>
{{end}}
</table>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>
</html>