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/router/templateVariables.go

204 lignes
5,1 Kio
Go
Brut Vue normale Historique

package router
import (
"net/http"
"net/url"
2017-05-06 23:16:21 +02:00
2017-05-10 11:03:49 +02:00
"github.com/ewhal/nyaa/common"
"github.com/ewhal/nyaa/model"
"github.com/ewhal/nyaa/service/user"
userForms "github.com/ewhal/nyaa/service/user/form"
2017-05-06 10:36:37 +02:00
"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
*
* MAIN Template Variables
*/
type FaqTemplateVariables struct {
2017-05-07 01:20:13 +02:00
Navigation Navigation
Search SearchForm
User *model.User
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
}
2017-05-07 08:59:45 +02:00
type NotFoundTemplateVariables struct {
Navigation Navigation
Search SearchForm
User *model.User
2017-05-07 08:59:45 +02:00
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
}
type ViewTemplateVariables struct {
Torrent model.TorrentJSON
CaptchaID string
2017-05-07 01:20:13 +02:00
Search SearchForm
Navigation Navigation
User *model.User
2017-05-06 10:36:37 +02:00
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
}
type UserRegisterTemplateVariables struct {
2017-05-07 01:20:13 +02:00
RegistrationForm userForms.RegistrationForm
FormErrors map[string][]string
2017-05-07 01:20:13 +02:00
Search SearchForm
Navigation Navigation
User *model.User
2017-05-07 01:20:13 +02:00
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
}
2017-05-09 17:47:06 +02:00
type UserProfileEditVariables struct {
UserProfile *model.User
UserForm userForms.UserForm
FormErrors map[string][]string
FormInfos map[string][]string
2017-05-10 21:45:39 +02:00
Languages map[string]string
Search SearchForm
Navigation Navigation
User *model.User
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
2017-05-09 17:47:06 +02:00
}
type UserVerifyTemplateVariables struct {
FormErrors map[string][]string
Search SearchForm
Navigation Navigation
User *model.User
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
}
type UserLoginFormVariables struct {
LoginForm userForms.LoginForm
FormErrors map[string][]string
Search SearchForm
Navigation Navigation
User *model.User
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
}
type UserProfileVariables struct {
UserProfile *model.User
2017-05-10 11:03:49 +02:00
FormInfos map[string][]string
Search SearchForm
Navigation Navigation
User *model.User
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
}
type HomeTemplateVariables struct {
ListTorrents []model.TorrentJSON
2017-05-07 01:20:13 +02:00
Search SearchForm
Navigation Navigation
User *model.User
2017-05-07 01:20:13 +02:00
URL *url.URL // For parsing Url in templates
Route *mux.Route // For getting current route in templates
}
2017-05-06 10:36:37 +02:00
type UploadTemplateVariables struct {
Upload UploadForm
2017-05-07 01:20:13 +02:00
Search SearchForm
Navigation Navigation
User *model.User
2017-05-06 10:36:37 +02:00
URL *url.URL
Route *mux.Route
}
2017-05-07 01:20:13 +02:00
2017-05-13 00:17:34 +02:00
type ChangeLanguageVariables struct {
Search SearchForm
Navigation Navigation
Language string
Languages map[string]string
User *model.User
URL *url.URL
Route *mux.Route
}
/* MODERATION Variables */
type PanelIndexVbs struct {
2017-05-10 20:42:20 +02:00
Torrents []model.Torrent
TorrentReports []model.TorrentReportJson
2017-05-10 20:42:20 +02:00
Users []model.User
Comments []model.Comment
Search SearchForm
User *model.User
URL *url.URL // For parsing Url in templates
}
type PanelTorrentListVbs struct {
2017-05-10 20:42:20 +02:00
Torrents []model.Torrent
Search SearchForm
2017-05-10 15:08:38 +02:00
Navigation Navigation
User *model.User
2017-05-10 20:42:20 +02:00
URL *url.URL // For parsing Url in templates
}
type PanelUserListVbs struct {
2017-05-10 20:42:20 +02:00
Users []model.User
Search SearchForm
2017-05-10 15:08:38 +02:00
Navigation Navigation
User *model.User
2017-05-10 20:42:20 +02:00
URL *url.URL // For parsing Url in templates
}
type PanelCommentListVbs struct {
2017-05-10 20:42:20 +02:00
Comments []model.Comment
Search SearchForm
2017-05-10 15:08:38 +02:00
Navigation Navigation
User *model.User
2017-05-10 20:42:20 +02:00
URL *url.URL // For parsing Url in templates
}
type PanelTorrentEdVbs struct {
Upload UploadForm
2017-05-10 20:42:20 +02:00
Search SearchForm
User *model.User
FormErrors map[string][]string
2017-05-11 00:08:13 +02:00
FormInfos map[string][]string
2017-05-11 00:02:36 +02:00
URL *url.URL // For parsing Url in templates
}
2017-05-10 20:42:20 +02:00
type PanelTorrentReportListVbs struct {
2017-05-10 21:09:37 +02:00
TorrentReports []model.TorrentReportJson
Search SearchForm
Navigation Navigation
User *model.User
URL *url.URL // For parsing Url in templates
}
2017-05-07 01:20:13 +02:00
/*
* Variables used by the upper ones
*/
type Navigation struct {
TotalItem int
MaxItemPerPage int
CurrentPage int
Route string
}
type SearchForm struct {
2017-05-10 11:03:49 +02:00
common.SearchParam
2017-05-07 01:20:13 +02:00
Category string
HideAdvancedSearch bool
}
// Some Default Values to ease things out
func NewSearchForm() SearchForm {
return SearchForm{
Category: "_",
2017-05-07 01:20:13 +02:00
}
}
func GetUser(r *http.Request) *model.User {
user, _, _ := userService.RetrieveCurrentUser(r)
return &user
}