Added logged badge + new User variable in each template variables
Cette révision appartient à :
Parent
10b6794e04
révision
9bc75c86f3
|
@ -31,7 +31,7 @@ func GormInit(conf *config.Config) (*gorm.DB, error) {
|
||||||
if config.Environment == "DEVELOPMENT" {
|
if config.Environment == "DEVELOPMENT" {
|
||||||
db.LogMode(true)
|
db.LogMode(true)
|
||||||
// db.DropTable(&model.User{}, "UserFollower")
|
// db.DropTable(&model.User{}, "UserFollower")
|
||||||
db.AutoMigrate(&model.Torrents{}, &model.User{}, &model.Role{}, &model.Connection{}, &model.Language{})
|
db.AutoMigrate(&model.Torrents{}, &model.User{}, &model.Role{}, &model.Language{})
|
||||||
// db.AutoMigrate(&model.Article{}, &model.Location{}, &model.Comment{}, &model.File{})
|
// db.AutoMigrate(&model.Article{}, &model.Location{}, &model.Comment{}, &model.File{})
|
||||||
// db.Model(&model.User{}).AddIndex("idx_user_token", "token")
|
// db.Model(&model.User{}).AddIndex("idx_user_token", "token")
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ type User struct {
|
||||||
Likings []User `gorm:"foreignkey:userId;associationforeignkey:follower_id;many2many:users_followers;"`
|
Likings []User `gorm:"foreignkey:userId;associationforeignkey:follower_id;many2many:users_followers;"`
|
||||||
Liked []User `gorm:"foreignkey:follower_id;associationforeignkey:userId;many2many:users_followers;"`
|
Liked []User `gorm:"foreignkey:follower_id;associationforeignkey:userId;many2many:users_followers;"`
|
||||||
|
|
||||||
Connections []Connection
|
//Connections []Connection
|
||||||
|
|
||||||
Languages []Language `gorm:"many2many:user_languages;"` // Many To Many, user_languages is the join table
|
Languages []Language `gorm:"many2many:user_languages;"` // Many To Many, user_languages is the join table
|
||||||
Roles []Role `gorm:"many2many:users_roles;"` // Many To Many, users_roles
|
Roles []Role `gorm:"many2many:users_roles;"` // Many To Many, users_roles
|
||||||
|
@ -79,13 +79,13 @@ type PublicUser struct {
|
||||||
LastLoginIp omit `json:"lastLoginIp,omitempty",sql:"size:100"`
|
LastLoginIp omit `json:"lastLoginIp,omitempty",sql:"size:100"`
|
||||||
CurrentLoginIp omit `json:"currentLoginIp,omitempty",sql:"size:100"`
|
CurrentLoginIp omit `json:"currentLoginIp,omitempty",sql:"size:100"`
|
||||||
|
|
||||||
Connections omit `json:"connections,omitempty"`
|
//Connections omit `json:"connections,omitempty"`
|
||||||
Languages omit `json:"languages,omitempty"`
|
Languages omit `json:"languages,omitempty"`
|
||||||
Roles omit `json:"roles,omitempty"`
|
Roles omit `json:"roles,omitempty"`
|
||||||
Torrents omit `json:"articles,omitempty"` //should user torrents not be displayed?
|
Torrents omit `json:"articles,omitempty"` //should user torrents not be displayed?
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connection is a connection model for oauth.
|
/*// Connection is a connection model for oauth.
|
||||||
type Connection struct {
|
type Connection struct {
|
||||||
Id uint `json:"id"`
|
Id uint `json:"id"`
|
||||||
UserId uint `json:"userId"`
|
UserId uint `json:"userId"`
|
||||||
|
@ -95,3 +95,4 @@ type Connection struct {
|
||||||
ProfileUrl string `gorm:"column:profile_url", json:"profileUrl"`
|
ProfileUrl string `gorm:"column:profile_url", json:"profileUrl"`
|
||||||
ImageUrl string `gorm:"column:image_url", json:"imageUrl"`
|
ImageUrl string `gorm:"column:image_url", json:"imageUrl"`
|
||||||
}
|
}
|
||||||
|
*/
|
|
@ -20,19 +20,25 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/* modified copy of NyaaTorrent theme */
|
/* modified copy of NyaaTorrent theme */
|
||||||
#mainmenu {
|
#mainmenu, #mainmenu .dropdown-menu{
|
||||||
background: #263238;
|
background: #263238;
|
||||||
position: fixed;
|
|
||||||
color: white;
|
color: white;
|
||||||
|
}
|
||||||
|
#mainmenu {
|
||||||
|
position: fixed;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 4;
|
z-index: 4;
|
||||||
border: 0px solid white;
|
border: 0px solid white;
|
||||||
}
|
}
|
||||||
|
|
||||||
#mainmenu a {
|
#mainmenu a {
|
||||||
|
background: none;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#mainmenu .divider {
|
||||||
|
background: black;
|
||||||
|
}
|
||||||
|
|
||||||
#container {
|
#container {
|
||||||
padding-top: 1.25em;
|
padding-top: 1.25em;
|
||||||
background: white;
|
background: white;
|
||||||
|
@ -182,3 +188,7 @@ div.container div.blockBody:nth-of-type(2) table tr:first-of-type th:last-of-typ
|
||||||
.navbar {
|
.navbar {
|
||||||
border-radius: 0px;
|
border-radius: 0px;
|
||||||
}
|
}
|
||||||
|
.navbar-nav>li>a.profile-image {
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
|
@ -9,7 +9,7 @@ import (
|
||||||
func FaqHandler(w http.ResponseWriter, r *http.Request) {
|
func FaqHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
searchForm := NewSearchForm()
|
searchForm := NewSearchForm()
|
||||||
searchForm.HideAdvancedSearch = true
|
searchForm.HideAdvancedSearch = true
|
||||||
err := faqTemplate.ExecuteTemplate(w, "index.html", FaqTemplateVariables{Navigation{}, searchForm, r.URL, mux.CurrentRoute(r)})
|
err := faqTemplate.ExecuteTemplate(w, "index.html", FaqTemplateVariables{Navigation{}, searchForm, GetUser(r), r.URL, mux.CurrentRoute(r)})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ func HomeHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
navigationTorrents := Navigation{nbTorrents, maxPerPage, pagenum, "search_page"}
|
navigationTorrents := Navigation{nbTorrents, maxPerPage, pagenum, "search_page"}
|
||||||
htv := HomeTemplateVariables{b, NewSearchForm(), navigationTorrents, r.URL, mux.CurrentRoute(r)}
|
htv := HomeTemplateVariables{b, NewSearchForm(), navigationTorrents, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
||||||
|
|
||||||
err := homeTemplate.ExecuteTemplate(w, "index.html", htv)
|
err := homeTemplate.ExecuteTemplate(w, "index.html", htv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -19,7 +19,7 @@ func NotFoundHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
searchForm := NewSearchForm()
|
searchForm := NewSearchForm()
|
||||||
searchForm.HideAdvancedSearch = true
|
searchForm.HideAdvancedSearch = true
|
||||||
err := notFoundTemplate.ExecuteTemplate(w, "index.html", NotFoundTemplateVariables{Navigation{}, searchForm, r.URL, mux.CurrentRoute(r)})
|
err := notFoundTemplate.ExecuteTemplate(w, "index.html", NotFoundTemplateVariables{Navigation{}, searchForm, GetUser(r), r.URL, mux.CurrentRoute(r)})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ func init() {
|
||||||
Router.HandleFunc("/verify/email/{token}", UserVerifyEmailHandler).Name("user_verify").Methods("GET")
|
Router.HandleFunc("/verify/email/{token}", UserVerifyEmailHandler).Name("user_verify").Methods("GET")
|
||||||
Router.HandleFunc("/user/register", UserRegisterPostHandler).Name("user_register_post").Methods("POST")
|
Router.HandleFunc("/user/register", UserRegisterPostHandler).Name("user_register_post").Methods("POST")
|
||||||
Router.HandleFunc("/user/login", UserLoginPostHandler).Name("user_login_post").Methods("POST")
|
Router.HandleFunc("/user/login", UserLoginPostHandler).Name("user_login_post").Methods("POST")
|
||||||
|
Router.HandleFunc("/user/{id}", UserProfileHandler).Name("user_profile")
|
||||||
Router.PathPrefix("/captcha").Methods("GET").HandlerFunc(captcha.ServeFiles)
|
Router.PathPrefix("/captcha").Methods("GET").HandlerFunc(captcha.ServeFiles)
|
||||||
|
|
||||||
Router.NotFoundHandler = http.HandlerFunc(NotFoundHandler)
|
Router.NotFoundHandler = http.HandlerFunc(NotFoundHandler)
|
||||||
|
|
|
@ -37,7 +37,7 @@ func SearchHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
search_param.Order,
|
search_param.Order,
|
||||||
false,
|
false,
|
||||||
}
|
}
|
||||||
htv := HomeTemplateVariables{b, searchForm, navigationTorrents, r.URL, mux.CurrentRoute(r)}
|
htv := HomeTemplateVariables{b, searchForm, navigationTorrents, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
||||||
|
|
||||||
err := searchTemplate.ExecuteTemplate(w, "index.html", htv)
|
err := searchTemplate.ExecuteTemplate(w, "index.html", htv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -2,9 +2,11 @@ package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/ewhal/nyaa/model"
|
"github.com/ewhal/nyaa/model"
|
||||||
userForms "github.com/ewhal/nyaa/service/user/form"
|
userForms "github.com/ewhal/nyaa/service/user/form"
|
||||||
|
"github.com/ewhal/nyaa/service/user"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,6 +19,7 @@ import (
|
||||||
type FaqTemplateVariables struct {
|
type FaqTemplateVariables struct {
|
||||||
Navigation Navigation
|
Navigation Navigation
|
||||||
Search SearchForm
|
Search SearchForm
|
||||||
|
User model.User
|
||||||
URL *url.URL // For parsing Url in templates
|
URL *url.URL // For parsing Url in templates
|
||||||
Route *mux.Route // For getting current route in templates
|
Route *mux.Route // For getting current route in templates
|
||||||
}
|
}
|
||||||
|
@ -24,6 +27,7 @@ type FaqTemplateVariables struct {
|
||||||
type NotFoundTemplateVariables struct {
|
type NotFoundTemplateVariables struct {
|
||||||
Navigation Navigation
|
Navigation Navigation
|
||||||
Search SearchForm
|
Search SearchForm
|
||||||
|
User model.User
|
||||||
URL *url.URL // For parsing Url in templates
|
URL *url.URL // For parsing Url in templates
|
||||||
Route *mux.Route // For getting current route in templates
|
Route *mux.Route // For getting current route in templates
|
||||||
}
|
}
|
||||||
|
@ -32,6 +36,7 @@ type ViewTemplateVariables struct {
|
||||||
Torrent model.TorrentsJson
|
Torrent model.TorrentsJson
|
||||||
Search SearchForm
|
Search SearchForm
|
||||||
Navigation Navigation
|
Navigation Navigation
|
||||||
|
User model.User
|
||||||
URL *url.URL // For parsing Url in templates
|
URL *url.URL // For parsing Url in templates
|
||||||
Route *mux.Route // For getting current route in templates
|
Route *mux.Route // For getting current route in templates
|
||||||
}
|
}
|
||||||
|
@ -41,6 +46,7 @@ type UserRegisterTemplateVariables struct {
|
||||||
FormErrors map[string][]string
|
FormErrors map[string][]string
|
||||||
Search SearchForm
|
Search SearchForm
|
||||||
Navigation Navigation
|
Navigation Navigation
|
||||||
|
User model.User
|
||||||
URL *url.URL // For parsing Url in templates
|
URL *url.URL // For parsing Url in templates
|
||||||
Route *mux.Route // For getting current route in templates
|
Route *mux.Route // For getting current route in templates
|
||||||
}
|
}
|
||||||
|
@ -49,6 +55,7 @@ type UserVerifyTemplateVariables struct {
|
||||||
FormErrors map[string][]string
|
FormErrors map[string][]string
|
||||||
Search SearchForm
|
Search SearchForm
|
||||||
Navigation Navigation
|
Navigation Navigation
|
||||||
|
User model.User
|
||||||
URL *url.URL // For parsing Url in templates
|
URL *url.URL // For parsing Url in templates
|
||||||
Route *mux.Route // For getting current route in templates
|
Route *mux.Route // For getting current route in templates
|
||||||
}
|
}
|
||||||
|
@ -58,6 +65,7 @@ type UserLoginFormVariables struct {
|
||||||
FormErrors map[string][]string
|
FormErrors map[string][]string
|
||||||
Search SearchForm
|
Search SearchForm
|
||||||
Navigation Navigation
|
Navigation Navigation
|
||||||
|
User model.User
|
||||||
URL *url.URL // For parsing Url in templates
|
URL *url.URL // For parsing Url in templates
|
||||||
Route *mux.Route // For getting current route in templates
|
Route *mux.Route // For getting current route in templates
|
||||||
}
|
}
|
||||||
|
@ -66,6 +74,7 @@ type HomeTemplateVariables struct {
|
||||||
ListTorrents []model.TorrentsJson
|
ListTorrents []model.TorrentsJson
|
||||||
Search SearchForm
|
Search SearchForm
|
||||||
Navigation Navigation
|
Navigation Navigation
|
||||||
|
User model.User
|
||||||
URL *url.URL // For parsing Url in templates
|
URL *url.URL // For parsing Url in templates
|
||||||
Route *mux.Route // For getting current route in templates
|
Route *mux.Route // For getting current route in templates
|
||||||
}
|
}
|
||||||
|
@ -74,6 +83,7 @@ type UploadTemplateVariables struct {
|
||||||
Upload UploadForm
|
Upload UploadForm
|
||||||
Search SearchForm
|
Search SearchForm
|
||||||
Navigation Navigation
|
Navigation Navigation
|
||||||
|
User model.User
|
||||||
URL *url.URL
|
URL *url.URL
|
||||||
Route *mux.Route
|
Route *mux.Route
|
||||||
}
|
}
|
||||||
|
@ -123,3 +133,8 @@ func NewSearchForm(params ...string) (searchForm SearchForm) {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUser(r *http.Request) model.User {
|
||||||
|
user, _ , _ := userService.RetrieveCurrentUser(r)
|
||||||
|
return user
|
||||||
|
}
|
|
@ -55,7 +55,7 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
} else if r.Method == "GET" {
|
} else if r.Method == "GET" {
|
||||||
uploadForm.CaptchaID = captcha.GetID()
|
uploadForm.CaptchaID = captcha.GetID()
|
||||||
htv := UploadTemplateVariables{uploadForm, NewSearchForm(), Navigation{}, r.URL, mux.CurrentRoute(r)}
|
htv := UploadTemplateVariables{uploadForm, NewSearchForm(), Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
||||||
err = uploadTemplate.ExecuteTemplate(w, "index.html", htv)
|
err = uploadTemplate.ExecuteTemplate(w, "index.html", htv)
|
||||||
} else {
|
} else {
|
||||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||||
|
|
|
@ -22,7 +22,7 @@ func UserRegisterFormHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
modelHelper.BindValueForm(&b, r)
|
modelHelper.BindValueForm(&b, r)
|
||||||
b.CaptchaID = captcha.GetID()
|
b.CaptchaID = captcha.GetID()
|
||||||
languages.SetTranslationFromRequest(viewRegisterTemplate, r, "en-us")
|
languages.SetTranslationFromRequest(viewRegisterTemplate, r, "en-us")
|
||||||
htv := UserRegisterTemplateVariables{b, form.NewErrors(), NewSearchForm(), Navigation{}, r.URL, mux.CurrentRoute(r)}
|
htv := UserRegisterTemplateVariables{b, form.NewErrors(), NewSearchForm(), Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
||||||
err := viewRegisterTemplate.ExecuteTemplate(w, "index.html", htv)
|
err := viewRegisterTemplate.ExecuteTemplate(w, "index.html", htv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
@ -38,7 +38,7 @@ func UserLoginFormHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
modelHelper.BindValueForm(&b, r)
|
modelHelper.BindValueForm(&b, r)
|
||||||
|
|
||||||
languages.SetTranslationFromRequest(viewLoginTemplate, r, "en-us")
|
languages.SetTranslationFromRequest(viewLoginTemplate, r, "en-us")
|
||||||
htv := UserLoginFormVariables{b, form.NewErrors(), NewSearchForm(), Navigation{}, r.URL, mux.CurrentRoute(r)}
|
htv := UserLoginFormVariables{b, form.NewErrors(), NewSearchForm(), Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
||||||
|
|
||||||
err := viewLoginTemplate.ExecuteTemplate(w, "index.html", htv)
|
err := viewLoginTemplate.ExecuteTemplate(w, "index.html", htv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -78,7 +78,7 @@ func UserRegisterPostHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if (len(err) == 0) {
|
if (len(err) == 0) {
|
||||||
b := form.RegistrationForm{}
|
b := form.RegistrationForm{}
|
||||||
languages.SetTranslationFromRequest(viewRegisterSuccessTemplate, r, "en-us")
|
languages.SetTranslationFromRequest(viewRegisterSuccessTemplate, r, "en-us")
|
||||||
htv := UserRegisterTemplateVariables{b, err, NewSearchForm(), Navigation{}, r.URL, mux.CurrentRoute(r)}
|
htv := UserRegisterTemplateVariables{b, err, NewSearchForm(), Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
||||||
errorTmpl := viewRegisterSuccessTemplate.ExecuteTemplate(w, "index.html", htv)
|
errorTmpl := viewRegisterSuccessTemplate.ExecuteTemplate(w, "index.html", htv)
|
||||||
if errorTmpl != nil {
|
if errorTmpl != nil {
|
||||||
http.Error(w, errorTmpl.Error(), http.StatusInternalServerError)
|
http.Error(w, errorTmpl.Error(), http.StatusInternalServerError)
|
||||||
|
@ -90,7 +90,7 @@ func UserRegisterPostHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if (len(err) > 0) {
|
if (len(err) > 0) {
|
||||||
b.CaptchaID = captcha.GetID()
|
b.CaptchaID = captcha.GetID()
|
||||||
languages.SetTranslationFromRequest(viewRegisterTemplate, r, "en-us")
|
languages.SetTranslationFromRequest(viewRegisterTemplate, r, "en-us")
|
||||||
htv := UserRegisterTemplateVariables{b, err, NewSearchForm(), Navigation{}, r.URL, mux.CurrentRoute(r)}
|
htv := UserRegisterTemplateVariables{b, err, NewSearchForm(), Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
||||||
errorTmpl := viewRegisterTemplate.ExecuteTemplate(w, "index.html", htv)
|
errorTmpl := viewRegisterTemplate.ExecuteTemplate(w, "index.html", htv)
|
||||||
if errorTmpl != nil {
|
if errorTmpl != nil {
|
||||||
http.Error(w, errorTmpl.Error(), http.StatusInternalServerError)
|
http.Error(w, errorTmpl.Error(), http.StatusInternalServerError)
|
||||||
|
@ -107,7 +107,7 @@ func UserVerifyEmailHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
err["errors"] = append(err["errors"], errEmail.Error())
|
err["errors"] = append(err["errors"], errEmail.Error())
|
||||||
}
|
}
|
||||||
languages.SetTranslationFromRequest(viewVerifySuccessTemplate, r, "en-us")
|
languages.SetTranslationFromRequest(viewVerifySuccessTemplate, r, "en-us")
|
||||||
htv := UserVerifyTemplateVariables{err, NewSearchForm(), Navigation{}, r.URL, mux.CurrentRoute(r)}
|
htv := UserVerifyTemplateVariables{err, NewSearchForm(), Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
||||||
errorTmpl := viewVerifySuccessTemplate.ExecuteTemplate(w, "index.html", htv)
|
errorTmpl := viewVerifySuccessTemplate.ExecuteTemplate(w, "index.html", htv)
|
||||||
if errorTmpl != nil {
|
if errorTmpl != nil {
|
||||||
http.Error(w, errorTmpl.Error(), http.StatusInternalServerError)
|
http.Error(w, errorTmpl.Error(), http.StatusInternalServerError)
|
||||||
|
@ -125,7 +125,7 @@ func UserLoginPostHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if (errorUser != nil) {
|
if (errorUser != nil) {
|
||||||
err["errors"] = append(err["errors"], errorUser.Error())
|
err["errors"] = append(err["errors"], errorUser.Error())
|
||||||
languages.SetTranslationFromRequest(viewLoginTemplate, r, "en-us")
|
languages.SetTranslationFromRequest(viewLoginTemplate, r, "en-us")
|
||||||
htv := UserLoginFormVariables{b, err, NewSearchForm(), Navigation{}, r.URL, mux.CurrentRoute(r)}
|
htv := UserLoginFormVariables{b, err, NewSearchForm(), Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
||||||
errorTmpl := viewLoginTemplate.ExecuteTemplate(w, "index.html", htv)
|
errorTmpl := viewLoginTemplate.ExecuteTemplate(w, "index.html", htv)
|
||||||
if errorTmpl != nil {
|
if errorTmpl != nil {
|
||||||
http.Error(w, errorTmpl.Error(), http.StatusInternalServerError)
|
http.Error(w, errorTmpl.Error(), http.StatusInternalServerError)
|
||||||
|
|
|
@ -19,7 +19,7 @@ func ViewHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
b := torrent.ToJson()
|
b := torrent.ToJson()
|
||||||
|
|
||||||
htv := ViewTemplateVariables{b, NewSearchForm(), Navigation{}, r.URL, mux.CurrentRoute(r)}
|
htv := ViewTemplateVariables{b, NewSearchForm(), Navigation{}, GetUser(r), r.URL, mux.CurrentRoute(r)}
|
||||||
|
|
||||||
err = viewTemplate.ExecuteTemplate(w, "index.html", htv)
|
err = viewTemplate.ExecuteTemplate(w, "index.html", htv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
20
templates/_badgemenu.html
Fichier normal
20
templates/_badgemenu.html
Fichier normal
|
@ -0,0 +1,20 @@
|
||||||
|
{{define "badge_user"}}
|
||||||
|
{{with .User}}
|
||||||
|
<ul class="nav navbar-nav navbar-right">
|
||||||
|
<li class="dropdown">
|
||||||
|
{{if gt .Id 0}}
|
||||||
|
<a href="{{ genRoute "user_profile" "id" (print .Id) }}" class="dropdown-toggle" data-toggle="dropdown">
|
||||||
|
<img src="https://www.gravatar.com/avatar/{{ .Md5 }}?s=50" class="profile-image img-circle"> {{ .Username }} <b class="caret"></b></a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a href="{{ genRoute "user_profile" "id" (print .Id) }}"><i class="fa fa-cog"></i> Profile</a></li>
|
||||||
|
<li class="divider"></li>
|
||||||
|
<li><a href="#soon"><i class="fa fa-sign-out"></i> Sign-out</a></li>
|
||||||
|
</ul>
|
||||||
|
{{ else }}
|
||||||
|
<li><a href="{{ genRoute "user_login" }}"><i class="fa fa-sign-out"></i> Sign in</a></li>
|
||||||
|
<li><a href="{{ genRoute "user_register" }}"><i class="fa fa-cog"></i> Sign Up</a></li>
|
||||||
|
{{end}}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
|
@ -55,6 +55,7 @@
|
||||||
{{block "search_button" .}}{{end}}
|
{{block "search_button" .}}{{end}}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
{{block "badge_user" .}}{{end}}
|
||||||
<div class="nightswitch">
|
<div class="nightswitch">
|
||||||
<a href="javascript:toggleNightMode();" ><img id="nighticon" src="/img/moon.png"></a>
|
<a href="javascript:toggleNightMode();" ><img id="nighticon" src="/img/moon.png"></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
Référencer dans un nouveau ticket