Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/templateVariables.go
akuma06 9586f1e731 Rearranged Files
Configurations are separated in files in the folder config
Connection to database by a package to import when needed
Models will be in a model package for better maintenance
Services access to the models
Utils are tools or functions that can be used anywhere
main.go cleaned a bit and other files modifications are there for the above modifications
2017-05-05 14:20:51 +02:00

77 lignes
1,7 Kio
Go

package main
import (
"github.com/gorilla/mux"
"github.com/ewhal/nyaa/model"
"net/url"
)
/* Each Page should have an object to pass to their own template
* Therefore, we put them in a separate file for better maintenance
*
* MAIN Template Variables
*/
type FaqTemplateVariables struct {
Navigation Navigation
Search SearchForm
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
}
type ViewTemplateVariables struct {
Torrent model.TorrentsJson
Search SearchForm
Navigation Navigation
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
}
type HomeTemplateVariables struct {
ListTorrents []model.TorrentsJson
ListCategories []model.Categories
Search SearchForm
Navigation Navigation
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
}
/*
* Variables used by the upper ones
*/
type Navigation struct {
TotalItem int
MaxItemPerPage int
CurrentPage int
Route string
}
type SearchForm struct {
Query string
Status string
Category string
Sort string
Order string
}
// Some Default Values to ease things out
func NewSearchForm(params ...string) SearchForm {
searchForm := SearchForm{}
if (len(params) > 1) {
searchForm.Category = params[0]
} else {
searchForm.Category = "_"
}
if (len(params) > 2) {
searchForm.Sort = params[0]
} else {
searchForm.Sort = "torrent_id"
}
if (len(params) > 3) {
searchForm.Order = params[0]
} else {
searchForm.Order = "DESC"
}
return searchForm
}