Big Update !
Design copied from NyaaTorrents Reorganised some sql queries Added dynamic navigation within torrents Added nesting templates support Added more variables/functions imported in the templates Separated templates functions and variables in other files for more clarity
|
@ -7,3 +7,51 @@
|
|||
.aplus {
|
||||
background-color: #60b0f0;
|
||||
}
|
||||
|
||||
|
||||
/* Copy of NyaaTorrent theme */
|
||||
nav#mainmenu {
|
||||
background: url(/img/topbar.png) repeat-x black;
|
||||
position: fixed;
|
||||
color:white;
|
||||
width: 100%;
|
||||
z-index:2;
|
||||
}
|
||||
nav#mainmenu a {
|
||||
color: white;
|
||||
}
|
||||
div#container {
|
||||
padding-top: 7rem;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #FBFBFB;
|
||||
color: #111111;
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.blockBody {
|
||||
border-radius: 5px;
|
||||
border: 2px solid black;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.torrentNav {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Links, Text */
|
||||
a {
|
||||
color: #106655;
|
||||
text-decoration : none;
|
||||
}
|
||||
|
||||
.torrentName {
|
||||
font-weight: bold;
|
||||
overflow: hidden;
|
||||
padding-bottom: 3px;
|
||||
padding-top: 3px;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
|
BIN
img/topbar.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 228 o |
BIN
img/torrents/1.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 3,6 Kio |
BIN
img/torrents/10.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 3,3 Kio |
BIN
img/torrents/11.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 3,6 Kio |
BIN
img/torrents/12.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 3,1 Kio |
BIN
img/torrents/13.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 3,2 Kio |
BIN
img/torrents/14.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 2,4 Kio |
BIN
img/torrents/15.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 3,1 Kio |
BIN
img/torrents/16.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 4,3 Kio |
BIN
img/torrents/17.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 4,3 Kio |
BIN
img/torrents/2.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 3,5 Kio |
BIN
img/torrents/3.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 2,8 Kio |
BIN
img/torrents/4.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 3,5 Kio |
BIN
img/torrents/5.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 3,1 Kio |
BIN
img/torrents/6.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 3,8 Kio |
BIN
img/torrents/7.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 2,6 Kio |
BIN
img/torrents/8.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 4,7 Kio |
BIN
img/torrents/9.png
Fichier normal
Après Largeur: | Hauteur: | Taille: 3,4 Kio |
51
main.go
|
@ -15,7 +15,8 @@ import (
|
|||
)
|
||||
|
||||
var db *gorm.DB
|
||||
var templates = template.Must(template.ParseFiles("index.html", "FAQ.html"))
|
||||
var router *mux.Router
|
||||
|
||||
var debugLogger *log.Logger
|
||||
var trackers = "&tr=udp://zer0day.to:1337/announce&tr=udp://tracker.leechers-paradise.org:6969&tr=udp://explodie.org:6969&tr=udp://tracker.opentrackr.org:1337&tr=udp://tracker.coppersurfer.tk:6969"
|
||||
|
||||
|
@ -46,13 +47,12 @@ func apiHandler(w http.ResponseWriter, r *http.Request) {
|
|||
maxPerPage := 50
|
||||
nbTorrents := 0
|
||||
|
||||
torrents := getAllTorrents(maxPerPage, maxPerPage*(pagenum-1))
|
||||
torrents, nbTorrents := getAllTorrents(maxPerPage, maxPerPage*(pagenum-1))
|
||||
for i, _ := range torrents {
|
||||
nbTorrents++
|
||||
res := torrents[i].toJson()
|
||||
|
||||
b.Torrents = append(b.Torrents, res)
|
||||
}
|
||||
|
||||
b.QueryRecordCount = maxPerPage
|
||||
b.TotalRecordCount = nbTorrents
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -86,6 +86,7 @@ func singleapiHandler(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"))
|
||||
vars := mux.Vars(r)
|
||||
page := vars["page"]
|
||||
|
||||
|
@ -95,6 +96,7 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
|
|||
maxPerPage = 50 // default Value maxPerPage
|
||||
}
|
||||
pagenum, _ := strconv.Atoi(html.EscapeString(page))
|
||||
if (pagenum == 0) { pagenum = 1 }
|
||||
searchQuery := r.URL.Query().Get("q")
|
||||
cat := r.URL.Query().Get("c")
|
||||
stat := r.URL.Query().Get("s")
|
||||
|
@ -111,18 +113,16 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
b := []TorrentsJson{}
|
||||
|
||||
torrents := getTorrents(createWhereParams("torrent_name LIKE ? AND status_id LIKE ? AND category_id LIKE ? AND sub_category_id LIKE ?",
|
||||
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))
|
||||
|
||||
for i, _ := range torrents {
|
||||
nbTorrents++
|
||||
res := torrents[i].toJson()
|
||||
|
||||
b = append(b, res)
|
||||
|
||||
}
|
||||
|
||||
htv := HomeTemplateVariables{b, getAllCategories(false), searchQuery, stat, cat, maxPerPage, nbTorrents}
|
||||
navigationTorrents := Navigation{nbTorrents, maxPerPage, pagenum, "search_page"}
|
||||
htv := HomeTemplateVariables{b, getAllCategories(false), searchQuery, stat, cat, navigationTorrents, r.URL, mux.CurrentRoute(r)}
|
||||
|
||||
err := templates.ExecuteTemplate(w, "index.html", htv)
|
||||
if err != nil {
|
||||
|
@ -134,13 +134,15 @@ func safe(s string) template.URL {
|
|||
}
|
||||
|
||||
func faqHandler(w http.ResponseWriter, r *http.Request) {
|
||||
err := templates.ExecuteTemplate(w, "FAQ.html", "")
|
||||
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{}})
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
func rootHandler(w http.ResponseWriter, r *http.Request) {
|
||||
var templates = template.Must(template.New("home").Funcs(funcMap).ParseFiles("templates/index.html", "templates/home.html"))
|
||||
vars := mux.Vars(r)
|
||||
page := vars["page"]
|
||||
|
||||
|
@ -152,17 +154,18 @@ func rootHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
nbTorrents := 0
|
||||
pagenum, _ := strconv.Atoi(html.EscapeString(page))
|
||||
if (pagenum == 0) { pagenum = 1 }
|
||||
|
||||
b := []TorrentsJson{}
|
||||
torrents := getAllTorrents(maxPerPage, maxPerPage*(pagenum-1))
|
||||
torrents, nbTorrents := getAllTorrents(maxPerPage, maxPerPage*(pagenum-1))
|
||||
|
||||
for i, _ := range torrents {
|
||||
nbTorrents++
|
||||
res := torrents[i].toJson()
|
||||
|
||||
b = append(b, res)
|
||||
|
||||
}
|
||||
|
||||
htv := HomeTemplateVariables{b, getAllCategories(false), "", "", "_", maxPerPage, nbTorrents}
|
||||
navigationTorrents := Navigation{nbTorrents, maxPerPage, pagenum, "search_page"}
|
||||
htv := HomeTemplateVariables{b, getAllCategories(false), "", "", "_", navigationTorrents, r.URL, mux.CurrentRoute(r)}
|
||||
|
||||
err := templates.ExecuteTemplate(w, "index.html", htv)
|
||||
if err != nil {
|
||||
|
@ -174,21 +177,23 @@ func rootHandler(w http.ResponseWriter, r *http.Request) {
|
|||
func main() {
|
||||
|
||||
db = getDBHandle()
|
||||
router := mux.NewRouter()
|
||||
router = mux.NewRouter()
|
||||
|
||||
cssHandler := http.FileServer(http.Dir("./css/"))
|
||||
jsHandler := http.FileServer(http.Dir("./js/"))
|
||||
imgHandler := http.FileServer(http.Dir("./img/"))
|
||||
http.Handle("/css/", http.StripPrefix("/css/", cssHandler))
|
||||
http.Handle("/js/", http.StripPrefix("/js/", jsHandler))
|
||||
http.Handle("/img/", http.StripPrefix("/img/", imgHandler))
|
||||
|
||||
// Routes,
|
||||
router.HandleFunc("/", rootHandler)
|
||||
router.HandleFunc("/page/{page}", rootHandler)
|
||||
router.HandleFunc("/search", searchHandler)
|
||||
router.HandleFunc("/search/{page}", searchHandler)
|
||||
router.HandleFunc("/api/{page}", apiHandler).Methods("GET")
|
||||
router.HandleFunc("/api/torrent/{id}", singleapiHandler).Methods("GET")
|
||||
router.HandleFunc("/faq", faqHandler)
|
||||
router.HandleFunc("/", rootHandler).Name("home")
|
||||
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("/faq", faqHandler).Name("faq")
|
||||
|
||||
http.Handle("/", router)
|
||||
|
||||
|
|
87
models.go
|
@ -10,15 +10,15 @@ import (
|
|||
)
|
||||
|
||||
type Categories struct {
|
||||
Category_id int
|
||||
Category_name string
|
||||
Id int `gorm:"column:category_id"`
|
||||
Name string `gorm:"column:category_name"`
|
||||
Torrents []Torrents `gorm:"ForeignKey:category_id;AssociationForeignKey:category_id"`
|
||||
Sub_Categories []Sub_Categories `gorm:"ForeignKey:category_id;AssociationForeignKey:parent_id"`
|
||||
Sub_Categories []Sub_Categories `gorm:"ForeignKey:parent_id;AssociationForeignKey:category_id"`
|
||||
}
|
||||
|
||||
type Sub_Categories struct {
|
||||
Sub_category_id int `gorm:"column:sub_category_id"`
|
||||
Sub_category_name string `gorm:"column:Sub_category_name"`
|
||||
Id int `gorm:"column:sub_category_id"`
|
||||
Name string `gorm:"column:Sub_category_name"`
|
||||
Parent_id int `gorm:"column:parent_id"`
|
||||
Torrents []Torrents `gorm:"ForeignKey:sub_category_id;AssociationForeignKey:sub_category_id"`
|
||||
}
|
||||
|
@ -42,17 +42,25 @@ JSON Models Oject
|
|||
*/
|
||||
|
||||
type CategoryJson struct {
|
||||
Category string `json: "category"`
|
||||
Id string `json: "id"`
|
||||
Name string `json: "category"`
|
||||
Torrents []TorrentsJson `json: "torrents"`
|
||||
QueryRecordCount int `json: "queryRecordCount"`
|
||||
TotalRecordCount int `json: "totalRecordCount"`
|
||||
}
|
||||
|
||||
type SubCategoryJson struct {
|
||||
Id string `json: "id"`
|
||||
Name string `json: "category"`
|
||||
}
|
||||
|
||||
type TorrentsJson struct {
|
||||
Id string `json: "id"` // Is there a need to put the ID?
|
||||
Name string `json: "name"`
|
||||
Status int `json: "status"`
|
||||
Hash string `json: "hash"`
|
||||
Sub_Category SubCategoryJson `json: "sub_category"`
|
||||
Category CategoryJson `json: "category"`
|
||||
Magnet template.URL `json: "magnet"`
|
||||
}
|
||||
|
||||
|
@ -61,17 +69,6 @@ type WhereParams struct {
|
|||
params []interface{}
|
||||
}
|
||||
|
||||
/* Each Page should have an object to pass to their own template */
|
||||
|
||||
type HomeTemplateVariables struct {
|
||||
ListTorrents []TorrentsJson
|
||||
ListCategories []Categories
|
||||
Query string
|
||||
Status string
|
||||
Category string
|
||||
QueryRecordCount int
|
||||
TotalRecordCount int
|
||||
}
|
||||
|
||||
/* Function to interact with Models
|
||||
*
|
||||
|
@ -89,13 +86,15 @@ func getTorrentById(id string) (Torrents, error) {
|
|||
return torrent, nil
|
||||
}
|
||||
|
||||
func getTorrentsOrderBy(parameters *WhereParams, orderBy string, limit int, offset int) []Torrents {
|
||||
func getTorrentsOrderBy(parameters *WhereParams, orderBy string, limit int, offset int) ([]Torrents, int) {
|
||||
var torrents []Torrents
|
||||
var dbQuery *gorm.DB
|
||||
|
||||
var count int
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -104,35 +103,35 @@ func getTorrentsOrderBy(parameters *WhereParams, orderBy string, limit int, offs
|
|||
dbQuery = dbQuery.Limit(limit).Offset(offset)
|
||||
}
|
||||
dbQuery.Order(orderBy).Preload("Categories").Preload("Sub_Categories").Find(&torrents)
|
||||
return torrents
|
||||
return torrents, count
|
||||
}
|
||||
|
||||
/* Functions to simplify the get parameters of the main function
|
||||
*
|
||||
* Get Torrents with where parameters and limits, order by default
|
||||
*/
|
||||
func getTorrents(parameters WhereParams, limit int, offset int) []Torrents {
|
||||
func getTorrents(parameters WhereParams, limit int, offset int) ([]Torrents, int) {
|
||||
return getTorrentsOrderBy(¶meters, "", limit, offset)
|
||||
}
|
||||
|
||||
/* Get Torrents with where parameters but no limit and order by default (get all the torrents corresponding in the db)
|
||||
*/
|
||||
func getTorrentsDB(parameters WhereParams) []Torrents {
|
||||
func getTorrentsDB(parameters WhereParams) ([]Torrents, int) {
|
||||
return getTorrentsOrderBy(¶meters, "", 0, 0)
|
||||
}
|
||||
|
||||
/* Function to get all torrents
|
||||
*/
|
||||
|
||||
func getAllTorrentsOrderBy(orderBy string, limit int, offset int) [] Torrents {
|
||||
func getAllTorrentsOrderBy(orderBy string, limit int, offset int) ([]Torrents, int) {
|
||||
return getTorrentsOrderBy(nil, orderBy, limit, offset)
|
||||
}
|
||||
|
||||
func getAllTorrents(limit int, offset int) []Torrents {
|
||||
func getAllTorrents(limit int, offset int) ([]Torrents, int) {
|
||||
return getTorrentsOrderBy(nil, "", limit, offset)
|
||||
}
|
||||
|
||||
func getAllTorrentsDB() []Torrents {
|
||||
func getAllTorrentsDB() ([]Torrents, int) {
|
||||
return getTorrentsOrderBy(nil, "", 0, 0)
|
||||
}
|
||||
|
||||
|
@ -148,17 +147,6 @@ func getAllCategories(populatedWithTorrents bool) []Categories {
|
|||
return categories
|
||||
}
|
||||
|
||||
func (t *Torrents) toJson() TorrentsJson {
|
||||
magnet := "magnet:?xt=urn:btih:" + strings.TrimSpace(t.Hash) + "&dn=" + t.Name + trackers
|
||||
res := TorrentsJson{
|
||||
Id: strconv.Itoa(t.Id),
|
||||
Name: html.UnescapeString(t.Name),
|
||||
Status: t.Status,
|
||||
Hash: t.Hash,
|
||||
Magnet: safe(magnet)}
|
||||
return res
|
||||
}
|
||||
|
||||
func createWhereParams(conditions string, params ...string) WhereParams {
|
||||
whereParams := WhereParams{}
|
||||
whereParams.conditions = conditions
|
||||
|
@ -169,4 +157,31 @@ func createWhereParams(conditions string, params ...string) WhereParams {
|
|||
return whereParams
|
||||
}
|
||||
|
||||
/* Model Conversion to Json */
|
||||
|
||||
func (t *Torrents) toJson() TorrentsJson {
|
||||
magnet := "magnet:?xt=urn:btih:" + strings.TrimSpace(t.Hash) + "&dn=" + t.Name + trackers
|
||||
res := TorrentsJson{
|
||||
Id: strconv.Itoa(t.Id),
|
||||
Name: html.UnescapeString(t.Name),
|
||||
Status: t.Status,
|
||||
Hash: t.Hash,
|
||||
Sub_Category: t.Sub_Categories.toJson(),
|
||||
Category: t.Categories.toJson(),
|
||||
Magnet: safe(magnet)}
|
||||
return res
|
||||
}
|
||||
|
||||
func (c *Sub_Categories) toJson() SubCategoryJson {
|
||||
return SubCategoryJson{
|
||||
Id: strconv.Itoa(c.Id),
|
||||
Name: html.UnescapeString(c.Name)}
|
||||
}
|
||||
|
||||
func (c *Categories) toJson() CategoryJson {
|
||||
return CategoryJson{
|
||||
Id: strconv.Itoa(c.Id),
|
||||
Name: html.UnescapeString(c.Name)}
|
||||
}
|
||||
|
||||
/* Complete the functions when necessary... */
|
50
templateFunctions.go
Fichier normal
|
@ -0,0 +1,50 @@
|
|||
package main
|
||||
|
||||
import(
|
||||
"math"
|
||||
"html/template"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"log"
|
||||
)
|
||||
|
||||
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)
|
||||
|
||||
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\">«</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\">»</span></a></li>"
|
||||
}
|
||||
return template.HTML(ret)
|
||||
},
|
||||
}
|
37
templateVariables.go
Fichier normal
|
@ -0,0 +1,37 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
/* 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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
type Navigation struct {
|
||||
TotalItem int
|
||||
MaxItemPerPage int
|
||||
CurrentPage int
|
||||
Route string
|
||||
}
|
|
@ -1,49 +1,6 @@
|
|||
<!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>Pantsu Nyaa - FAQ</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="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">Pantsu Nyaa</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>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
<div class="container">
|
||||
{{define "title"}}FAQ{{end}}
|
||||
{{define "content"}}
|
||||
<div class="blockBody">
|
||||
<h1>NOTICE: KEEP SEEDING YOU RETARD</h1>
|
||||
|
||||
<h1>Official Nyaapocalypse FAQ</h1>
|
||||
|
@ -87,8 +44,5 @@
|
|||
<p>If you have website development expertise, you can join the #nyaapantsu IRC channel on irc.rizon.net. If you have any current databases, <b>UPLOAD THEM</b>.</p>
|
||||
|
||||
<h1>nyaa.pantsu.cat and sukebei.pantsu.cat do not host any files.</h1>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</div>
|
||||
{{end}}
|
33
templates/home.html
Fichier normal
|
@ -0,0 +1,33 @@
|
|||
{{define "title"}}Home{{end}}
|
||||
{{define "content"}}
|
||||
<div class="blockBody">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Name</th>
|
||||
<th>Hash</th>
|
||||
<th>Links</th>
|
||||
</tr>
|
||||
{{ 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><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>{{.Hash}}</td>
|
||||
|
||||
<td><a href="{{.Magnet}}" target="_blank" title="Magnet link"><span class="glyphicon glyphicon-magnet" aria-hidden="true"></span></a>
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
{{end}}
|
||||
|
||||
</table>
|
||||
<nav class="torrentNav" aria-label="Page navigation">
|
||||
<ul class="pagination">
|
||||
{{ genNav .Navigation .URL 10 }}
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
{{end}}
|
|
@ -5,7 +5,7 @@
|
|||
<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>
|
||||
<title>Nyaa Pantsu - {{block "title" .}}Error 404{{end}}</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">
|
||||
|
||||
|
@ -19,10 +19,10 @@
|
|||
<![endif]-->
|
||||
|
||||
<!-- Website CSS -->
|
||||
<link rel="stylesheet" href="https://nyaa.pantsu.cat/css/style.css">
|
||||
<link rel="stylesheet" href="{{.URL.Parse "/css/style.css"}}">
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-default">
|
||||
<nav class="navbar navbar-default" id ="mainmenu">
|
||||
<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">
|
||||
|
@ -31,16 +31,18 @@
|
|||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="https://nyaa.pantsu.cat">Nyaa Pantsu</a>
|
||||
<a class="navbar-brand" href="{{.URL.Parse "/"}}">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>
|
||||
<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">
|
||||
|
||||
<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>
|
||||
|
@ -66,75 +68,38 @@
|
|||
<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>
|
||||
<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="{{.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>
|
||||
<button type="submit" class="btn btn-default">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Name</th>
|
||||
<th>Hash</th>
|
||||
<th>Links</th>
|
||||
</tr>
|
||||
{{ 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>{{.Name}}</td>
|
||||
<td>{{.Hash}}</td>
|
||||
|
||||
<td><a href="{{.Magnet}}" target="_blank" title="Magnet link" ><span class="glyphicon glyphicon-magnet" aria-hidden="true"></span></a>
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
{{end}}
|
||||
|
||||
</table>
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination">
|
||||
<li>
|
||||
<a id="page-prev" href="/page/" aria-label="Previous">
|
||||
<span aria-hidden="true">«</span>
|
||||
</a>
|
||||
</li>
|
||||
<li><a id="page-0" href="/page/"></a></li>
|
||||
<li><a id="page-1" href="/page/"></a></li>
|
||||
<li><a id="page-2" href="/page/"></a></li>
|
||||
<li><a id="page-3" href="/page/"></a></li>
|
||||
<li><a id="page-4" href="/page/"></a></li>
|
||||
<li>
|
||||
<a id="page-next" href="/page/" aria-label="Next">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="container" id="container">
|
||||
{{block "content" .}}Nothing Here.{{end}}
|
||||
</div>
|
||||
|
||||
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
|
||||
|
@ -144,6 +109,6 @@
|
|||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Main Javascript File -->
|
||||
<script type="text/javascript" charset="utf-8" src="//nyaa.pantsu.cat/js/main.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="{{.URL.Parse "/js/main.js"}}"></script>
|
||||
</body>
|
||||
</html>
|