Merge branch 'master' of https://github.com/ewhal/nyaa
BIN
img/favicon.png
Avant Largeur: | Hauteur: | Taille: 5,1 Kio Après Largeur: | Hauteur: | Taille: 4,6 Kio |
BIN
img/megumin.png
Avant Largeur: | Hauteur: | Taille: 19 Kio Après Largeur: | Hauteur: | Taille: 15 Kio |
BIN
img/renchon.png
Avant Largeur: | Hauteur: | Taille: 18 Kio Après Largeur: | Hauteur: | Taille: 16 Kio |
Avant Largeur: | Hauteur: | Taille: 3,6 Kio Après Largeur: | Hauteur: | Taille: 3,4 Kio |
Avant Largeur: | Hauteur: | Taille: 3,3 Kio Après Largeur: | Hauteur: | Taille: 3 Kio |
Avant Largeur: | Hauteur: | Taille: 3,6 Kio Après Largeur: | Hauteur: | Taille: 3,4 Kio |
Avant Largeur: | Hauteur: | Taille: 3,2 Kio Après Largeur: | Hauteur: | Taille: 2,9 Kio |
Avant Largeur: | Hauteur: | Taille: 3,1 Kio Après Largeur: | Hauteur: | Taille: 2,8 Kio |
Avant Largeur: | Hauteur: | Taille: 2,4 Kio Après Largeur: | Hauteur: | Taille: 2,3 Kio |
Avant Largeur: | Hauteur: | Taille: 4,3 Kio Après Largeur: | Hauteur: | Taille: 4,1 Kio |
Avant Largeur: | Hauteur: | Taille: 4,3 Kio Après Largeur: | Hauteur: | Taille: 4,1 Kio |
Avant Largeur: | Hauteur: | Taille: 3,1 Kio Après Largeur: | Hauteur: | Taille: 2,8 Kio |
Avant Largeur: | Hauteur: | Taille: 3,5 Kio Après Largeur: | Hauteur: | Taille: 3,3 Kio |
Avant Largeur: | Hauteur: | Taille: 2,8 Kio Après Largeur: | Hauteur: | Taille: 2,6 Kio |
Avant Largeur: | Hauteur: | Taille: 3,5 Kio Après Largeur: | Hauteur: | Taille: 3,2 Kio |
Avant Largeur: | Hauteur: | Taille: 3,1 Kio Après Largeur: | Hauteur: | Taille: 2,9 Kio |
Avant Largeur: | Hauteur: | Taille: 3,8 Kio Après Largeur: | Hauteur: | Taille: 3,7 Kio |
Avant Largeur: | Hauteur: | Taille: 2,6 Kio Après Largeur: | Hauteur: | Taille: 2,5 Kio |
Avant Largeur: | Hauteur: | Taille: 4,7 Kio Après Largeur: | Hauteur: | Taille: 4,5 Kio |
Avant Largeur: | Hauteur: | Taille: 3,4 Kio Après Largeur: | Hauteur: | Taille: 3,1 Kio |
|
@ -1,19 +1,24 @@
|
||||||
package router
|
package router
|
||||||
|
|
||||||
|
import (
|
||||||
import(
|
|
||||||
"net/http"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var faqTemplate = template.Must(template.New("FAQ").Funcs(FuncMap).ParseFiles("templates/index.html", "templates/FAQ.html"))
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// common
|
||||||
|
template.Must(faqTemplate.ParseGlob("templates/_*.html"))
|
||||||
|
}
|
||||||
|
|
||||||
func FaqHandler(w http.ResponseWriter, r *http.Request) {
|
func FaqHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
var templates = template.Must(template.New("FAQ").Funcs(FuncMap).ParseFiles("templates/index.html", "templates/FAQ.html"))
|
|
||||||
templates.ParseGlob("templates/_*.html") // common
|
|
||||||
searchForm := NewSearchForm()
|
searchForm := NewSearchForm()
|
||||||
searchForm.HideAdvancedSearch = true
|
searchForm.HideAdvancedSearch = true
|
||||||
err := templates.ExecuteTemplate(w, "index.html", FaqTemplateVariables{Navigation{}, searchForm, r.URL, mux.CurrentRoute(r)})
|
err := faqTemplate.ExecuteTemplate(w, "index.html", FaqTemplateVariables{Navigation{}, searchForm, 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,24 @@
|
||||||
package router
|
package router
|
||||||
|
|
||||||
import(
|
import (
|
||||||
"net/http"
|
|
||||||
"html/template"
|
|
||||||
"github.com/gorilla/mux"
|
|
||||||
"html"
|
"html"
|
||||||
|
"html/template"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/ewhal/nyaa/model"
|
"github.com/ewhal/nyaa/model"
|
||||||
"github.com/ewhal/nyaa/service/torrent"
|
"github.com/ewhal/nyaa/service/torrent"
|
||||||
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var homeTemplate = template.Must(template.New("home").Funcs(FuncMap).ParseFiles("templates/index.html", "templates/home.html"))
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
template.Must(homeTemplate.ParseGlob("templates/_*.html")) // common
|
||||||
|
}
|
||||||
|
|
||||||
func HomeHandler(w http.ResponseWriter, r *http.Request) {
|
func HomeHandler(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)
|
||||||
templates.ParseGlob("templates/_*.html") // common
|
|
||||||
vars := mux.Vars(r)
|
|
||||||
page := vars["page"]
|
page := vars["page"]
|
||||||
|
|
||||||
// db params url
|
// db params url
|
||||||
|
@ -39,7 +44,7 @@ var templates = template.Must(template.New("home").Funcs(FuncMap).ParseFiles("te
|
||||||
navigationTorrents := Navigation{nbTorrents, maxPerPage, pagenum, "search_page"}
|
navigationTorrents := Navigation{nbTorrents, maxPerPage, pagenum, "search_page"}
|
||||||
htv := HomeTemplateVariables{b, torrentService.GetAllCategories(false), NewSearchForm(), navigationTorrents, r.URL, mux.CurrentRoute(r)}
|
htv := HomeTemplateVariables{b, torrentService.GetAllCategories(false), NewSearchForm(), navigationTorrents, r.URL, mux.CurrentRoute(r)}
|
||||||
|
|
||||||
err := templates.ExecuteTemplate(w, "index.html", htv)
|
err := homeTemplate.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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,24 @@
|
||||||
package router
|
package router
|
||||||
|
|
||||||
import(
|
import (
|
||||||
"github.com/ewhal/nyaa/util/search"
|
|
||||||
"net/http"
|
|
||||||
"html/template"
|
|
||||||
"github.com/gorilla/mux"
|
|
||||||
"html"
|
"html"
|
||||||
|
"html/template"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/ewhal/nyaa/model"
|
"github.com/ewhal/nyaa/model"
|
||||||
"github.com/ewhal/nyaa/service/torrent"
|
"github.com/ewhal/nyaa/service/torrent"
|
||||||
|
"github.com/ewhal/nyaa/util/search"
|
||||||
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var searchTemplate = template.Must(template.New("home").Funcs(FuncMap).ParseFiles("templates/index.html", "templates/home.html"))
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
template.Must(searchTemplate.ParseGlob("templates/_*.html")) // common
|
||||||
|
}
|
||||||
|
|
||||||
func SearchHandler(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"))
|
|
||||||
templates.ParseGlob("templates/_*.html") // common
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
page := vars["page"]
|
page := vars["page"]
|
||||||
|
|
||||||
|
@ -22,10 +27,10 @@ func SearchHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if pagenum == 0 {
|
if pagenum == 0 {
|
||||||
pagenum = 1
|
pagenum = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
b := []model.TorrentsJson{}
|
b := []model.TorrentsJson{}
|
||||||
|
|
||||||
search_param, torrents, nbTorrents := search.SearchByQuery( r, pagenum )
|
search_param, torrents, nbTorrents := search.SearchByQuery(r, pagenum)
|
||||||
|
|
||||||
for i, _ := range torrents {
|
for i, _ := range torrents {
|
||||||
res := torrents[i].ToJson()
|
res := torrents[i].ToJson()
|
||||||
|
@ -39,12 +44,12 @@ func SearchHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
search_param.Category,
|
search_param.Category,
|
||||||
search_param.Sort,
|
search_param.Sort,
|
||||||
search_param.Order,
|
search_param.Order,
|
||||||
false,
|
false,
|
||||||
}
|
}
|
||||||
htv := HomeTemplateVariables{b, torrentService.GetAllCategories(false), searchForm, navigationTorrents, r.URL, mux.CurrentRoute(r)}
|
htv := HomeTemplateVariables{b, torrentService.GetAllCategories(false), searchForm, navigationTorrents, r.URL, mux.CurrentRoute(r)}
|
||||||
|
|
||||||
err := templates.ExecuteTemplate(w, "index.html", htv)
|
err := searchTemplate.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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
package router
|
package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gorilla/mux"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var uploadTemplate = template.Must(template.New("upload").Funcs(FuncMap).ParseFiles("templates/index.html", "templates/upload.html"))
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
template.Must(uploadTemplate.ParseGlob("templates/_*.html")) // common
|
||||||
|
}
|
||||||
|
|
||||||
func UploadHandler(w http.ResponseWriter, r *http.Request) {
|
func UploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
var templates = template.Must(template.New("upload").Funcs(FuncMap).ParseFiles("templates/index.html", "templates/upload.html"))
|
|
||||||
templates.ParseGlob("templates/_*.html") // common
|
|
||||||
var err error
|
var err error
|
||||||
var uploadForm UploadForm
|
var uploadForm UploadForm
|
||||||
if r.Method == "POST" {
|
if r.Method == "POST" {
|
||||||
|
@ -20,7 +25,7 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
} else if r.Method == "GET" {
|
} else if r.Method == "GET" {
|
||||||
htv := UploadTemplateVariables{uploadForm, NewSearchForm(), Navigation{}, r.URL, mux.CurrentRoute(r)}
|
htv := UploadTemplateVariables{uploadForm, NewSearchForm(), Navigation{}, r.URL, mux.CurrentRoute(r)}
|
||||||
err = templates.ExecuteTemplate(w, "index.html", htv)
|
err = uploadTemplate.ExecuteTemplate(w, "index.html", htv)
|
||||||
} else {
|
} else {
|
||||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
package router
|
package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ewhal/nyaa/service/torrent"
|
|
||||||
"github.com/gorilla/mux"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/ewhal/nyaa/service/torrent"
|
||||||
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var viewTemplate = template.Must(template.New("view").Funcs(FuncMap).ParseFiles("templates/index.html", "templates/view.html"))
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
template.Must(viewTemplate.ParseGlob("templates/_*.html")) // common
|
||||||
|
}
|
||||||
|
|
||||||
func ViewHandler(w http.ResponseWriter, r *http.Request) {
|
func ViewHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
var templates = template.Must(template.New("view").Funcs(FuncMap).ParseFiles("templates/index.html", "templates/view.html"))
|
|
||||||
templates.ParseGlob("templates/_*.html") // common
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
id := vars["id"]
|
id := vars["id"]
|
||||||
|
|
||||||
|
@ -18,7 +23,7 @@ func ViewHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
htv := ViewTemplateVariables{b, NewSearchForm(), Navigation{}, r.URL, mux.CurrentRoute(r)}
|
htv := ViewTemplateVariables{b, NewSearchForm(), Navigation{}, r.URL, mux.CurrentRoute(r)}
|
||||||
|
|
||||||
err = templates.ExecuteTemplate(w, "index.html", htv)
|
err = viewTemplate.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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,14 +34,15 @@ func BindValueForm(form interface{}, r *http.Request) {
|
||||||
for i := 0; i < formElem.NumField(); i++ {
|
for i := 0; i < formElem.NumField(); i++ {
|
||||||
typeField := formElem.Type().Field(i)
|
typeField := formElem.Type().Field(i)
|
||||||
tag := typeField.Tag
|
tag := typeField.Tag
|
||||||
switch typeField.Type.Name() :
|
switch typeField.Type.Name() {
|
||||||
case "string" :
|
case "string" :
|
||||||
formElem.Field(i).SetString(r.PostFormValue(tag.Get("form")))
|
formElem.Field(i).SetString(r.PostFormValue(tag.Get("form")))
|
||||||
case "int" :
|
case "int" :
|
||||||
nbr, _ := strconv.Atoi(r.PostFormValue(tag.Get("form")))
|
nbr, _ := strconv.Atoi(r.PostFormValue(tag.Get("form")))
|
||||||
formElem.Field(i).SetInt(nbr)
|
formElem.Field(i).SetInt(int64(nbr))
|
||||||
case "float" :
|
case "float" :
|
||||||
nbr, _ := strconv.Atoi(r.PostFormValue(tag.Get("form")))
|
nbr, _ := strconv.Atoi(r.PostFormValue(tag.Get("form")))
|
||||||
formElem.Field(i).SetFloat(float64(nbr))
|
formElem.Field(i).SetFloat(float64(nbr))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|