Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Added login page + multilanguage support

Cette révision appartient à :
akuma06 2017-05-07 04:02:57 +02:00
Parent cd3dae3d5e
révision 81e8a9bc40
5 fichiers modifiés avec 72 ajouts et 1 suppressions

Voir le fichier

@ -30,4 +30,5 @@ func init() {
Router.HandleFunc("/view/{id}", ViewHandler).Name("view_torrent")
Router.HandleFunc("/upload", UploadHandler).Name("upload")
Router.HandleFunc("/user/register", UserRegisterFormHandler).Name("user_register")
Router.HandleFunc("/user/login", UserLoginFormHandler).Name("user_login")
}

Voir le fichier

@ -37,6 +37,14 @@ type UserRegisterTemplateVariables struct {
Route *mux.Route // For getting current route in templates
}
type UserLoginFormVariables struct {
LoginForm userForms.LoginForm
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
Search SearchForm

Voir le fichier

@ -11,11 +11,13 @@ import (
)
var viewRegisterTemplate = template.Must(template.New("userRegister").Funcs(FuncMap).ParseFiles("templates/index.html", "templates/user/register.html"))
var viewLoginTemplate = template.Must(template.New("userLogin").Funcs(FuncMap).ParseFiles("templates/index.html", "templates/user/login.html"))
//var viewTemplate = template.Must(template.New("view").Funcs(FuncMap).ParseFiles("templates/index.html", "templates/view.html"))
//var viewTemplate = template.Must(template.New("view").Funcs(FuncMap).ParseFiles("templates/index.html", "templates/view.html"))
func init() {
template.Must(viewRegisterTemplate.ParseGlob("templates/_*.html"))
template.Must(viewLoginTemplate.ParseGlob("templates/_*.html"))
}
// Getting View User Registration
@ -33,7 +35,14 @@ func UserRegisterFormHandler(w http.ResponseWriter, r *http.Request) {
// Getting View User Login
func UserLoginFormHandler(w http.ResponseWriter, r *http.Request) {
b := form.LoginForm{}
modelHelper.BindValueForm(&b, r)
languages.SetTranslation("en-us", viewLoginTemplate)
htv := UserLoginFormVariables{b, NewSearchForm(), Navigation{}, r.URL, mux.CurrentRoute(r)}
err := viewLoginTemplate.ExecuteTemplate(w, "index.html", htv)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
// Getting User Profile

Voir le fichier

@ -66,5 +66,21 @@
{
"id":"terms_conditions_full",
"translation": "Some Shit."
},
{
"id":"remember_me",
"translation": "Remember me"
},
{
"id":"forgot_password",
"translation": "Forgot Password?"
},
{
"id":"sign_in_box_title",
"translation": "Please Sign In"
},
{
"id":"sign_in_title",
"translation": "Sign In"
}
]

37
templates/user/login.html Fichier normal
Voir le fichier

@ -0,0 +1,37 @@
{{define "title"}}{{ T "sign_in_title" }}{{end}}
{{define "contclass"}}cont-view{{end}}
{{define "content"}}
<div class="blockBody">
<div class="row" style="margin-top:20px">
<div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3">
<form role="form">
<fieldset>
<h2>{{T "sign_in_box_title"}}</h2>
<hr class="colorgraph">
<div class="form-group">
<input type="email" name="email" id="email" class="form-control input-lg" placeholder="{{ T "email_address"}}">
</div>
<div class="form-group">
<input type="password" name="password" id="password" class="form-control input-lg" placeholder="{{ T "password"}}">
</div>
<span class="button-checkbox">
<button type="button" class="btn hidden" data-color="info">{{ T "remember_me"}}</button>
<input type="checkbox" name="remember_me" id="remember_me" checked="checked">
<a href="" class="btn btn-link pull-right">{{ T "forgot_password"}}</a>
</span>
<hr class="colorgraph">
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<input type="submit" class="btn btn-lg btn-success btn-block" value="{{ T "signin"}}">
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<a href="" class="btn btn-lg btn-primary btn-block">{{ T "register"}}</a>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
{{end}}
{{define "js_footer"}}<script type="text/javascript" charset="utf-8" src="{{.URL.Parse "/js/registerPage.js"}}"></script>{{end}}