Remove https for dlsite, fix few html errors, small css improvements (#1551)
* Remove https for dlsite * Update listing.jet.html * Update torrent_item.jet.html * Update torrent_item_upload.jet.html * Update torrents.jet.html * remove role attribute * remove role attribute * login & register page styling * website-nav stylisation for main.css * remove now useless css rules * up to date main.css * OwO * Update main.css * Last stylisation changes for classic's nav * margin-left * add categories * add TestgenSearchWithCategory to template_test * add genSearchWithCategory function * forgot to close the function call * Update template_functions_test.go * Update template_functions.go * Update template_functions.go * attempt at fixing template_functions * Update template_functions.go
Cette révision appartient à :
Parent
615ff10dc8
révision
1b0211cfb9
12 fichiers modifiés avec 114 ajouts et 28 suppressions
|
@ -24,9 +24,13 @@ body {
|
|||
font-size: 0.9em;
|
||||
width: 90px;
|
||||
}
|
||||
.refine-container-2 span.spacing {
|
||||
width: 69px;
|
||||
}
|
||||
|
||||
#sort-list-order {
|
||||
width: auto;
|
||||
width: auto;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
a {
|
||||
|
@ -194,11 +198,19 @@ select.form-input {
|
|||
display: none;
|
||||
}
|
||||
.website-nav {
|
||||
padding-bottom: 2px!important;
|
||||
padding-bottom: 4px!important;
|
||||
padding-top: 4px!important;
|
||||
}
|
||||
.website-nav .pagination {
|
||||
padding: .5rem;
|
||||
font-size: 1em;
|
||||
}
|
||||
.website-nav .pagination a {
|
||||
display: inline!important;
|
||||
}
|
||||
.website-nav .pagination span {
|
||||
min-width: auto;
|
||||
}
|
||||
.website-nav #page-prev{
|
||||
float: left;
|
||||
}
|
||||
|
@ -210,6 +222,20 @@ select.form-input {
|
|||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.user-form input[type="text"],.user-form input[type="email"],.user-form input[type="password"] {
|
||||
width: 173px;
|
||||
|
||||
}
|
||||
.user-form input.form-control {
|
||||
width: 100%;
|
||||
}
|
||||
.user-form h2 {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.user-form .input-label {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.results.box {
|
||||
padding: 1px!important;
|
||||
border-top: none;
|
||||
|
|
|
@ -614,6 +614,27 @@ th {
|
|||
border-radius: 0 3px 3px 0;
|
||||
border-right-width: 1px !important
|
||||
}
|
||||
.website-nav .pagination {
|
||||
font-size: .8em;
|
||||
padding: .5rem 0;
|
||||
|
||||
}
|
||||
.website-nav .pagination span {
|
||||
min-width: 31px;
|
||||
}
|
||||
.website-nav .pagination p {
|
||||
display: none;
|
||||
}
|
||||
.website-nav table {
|
||||
width: auto;
|
||||
}
|
||||
.website-nav #nav-category-list {
|
||||
width: 70%;
|
||||
margin-bottom: 13px;
|
||||
}
|
||||
.website-nav .pagination a {
|
||||
display: inline!important;
|
||||
}
|
||||
|
||||
textarea {
|
||||
max-width: 100%;
|
||||
|
|
|
@ -1,4 +1,19 @@
|
|||
<div class="box refine website-nav{{if URL.String() != "/" && !kilo_strcmp(URL.String(), "/search", 7, 1) }} refine-not-search{{end}}">
|
||||
<table id="nav-category-list">
|
||||
<tbody>
|
||||
<tr><td>{{if Search.Category == ""}}<b>{{ T("all_categories")}}</b>{{else}}<a href="{{genSearchWithCategory(URL, "_")}}">{{ T("all_categories")}}</a>{{end}}</td></tr>
|
||||
<tr>
|
||||
{{ range _, cat := GetCategories(true, false) }}
|
||||
<td>{{if Search.Category == cat.ID }}<b>{{ T(cat.Name) }}</b>{{else}}<a href="{{genSearchWithCategory(URL, cat.ID)}}">{{ T(cat.Name) }}</a>{{end}}</td>
|
||||
{{ if _ % 3 == 2}}
|
||||
</tr><tr>
|
||||
{{end}}
|
||||
{{if _ + 1 == len(GetCategories(true, false)) }}
|
||||
</tr>{{end}}
|
||||
{{ end }}
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table id="sort-list-order">
|
||||
<tbody>
|
||||
<tr>
|
||||
|
|
|
@ -47,8 +47,7 @@ Templates.Add("torrents.item", function(torrent) {
|
|||
<td class="tr-cat home-td">
|
||||
<div class="` + catClass +`">
|
||||
<a href="{{ URL.Parse("/search?c=") }}` + torrent.category + `_` + torrent.sub_category + `" class="category">
|
||||
` + languages + `
|
||||
</a>
|
||||
</a> ` + languages + `
|
||||
</div></td>
|
||||
<td class="tr-name home-td"` + colspan + `><a href="/view/` + torrent.id + `">` + Templates.EncodeEntities(torrent.name) + `</a></td>
|
||||
`+ commentTd +`
|
||||
|
|
|
@ -38,8 +38,7 @@ Templates.Add("torrents.item", function(torrent) {
|
|||
<td class="tr-cat home-td">
|
||||
<div class="` + catClass +`">
|
||||
<a class="category">
|
||||
` + languages + `
|
||||
</a>
|
||||
</a> ` + languages + `
|
||||
</div></td>
|
||||
<td class="tr-name home-td"` + colspan + `><a>` + Templates.EncodeEntities(torrent.name) + `</a></td>
|
||||
`+ commentTd +`
|
||||
|
|
|
@ -61,12 +61,12 @@
|
|||
<td class="tr-cat home-td">
|
||||
<div class="nyaa-cat {{ if Sukebei() }}sukebei-cat-{{ .Category }}{{else}}nyaa-cat-{{end}}{{ .SubCategory}}">
|
||||
<a href="{{ URL.Parse("/search?c="+.Category+"_"+ .SubCategory) }}" title="{{ T(CategoryName(.Category, .SubCategory)) }}" class="category">
|
||||
</a>
|
||||
{{if .Languages[0] != "" }}
|
||||
<a href="{{ URL.Parse("/search?c="+.Category+"_"+ .SubCategory +"&lang=") }}{{ range key, language := .Languages }}{{ language }}{{ if len(.Languages) > 1 && (key+1) < len(.Languages) }},{{ end }}{{ end }}">
|
||||
<img src="/img/blank.gif" alt="{{ range key, language := .Languages }}{{ LanguageNameFromCode(language, T) }}{{ if len(.Languages) > 1 && (key+1) < len(.Languages) }},{{ end }}{{ end }}" class="flag flag-{{ (len(.Languages) == 1) ? FlagCode(.Languages[0]) : "multiple" }}" title="{{ range key, language := .Languages }}{{ LanguageNameFromCode(language, T) }}{{ if len(.Languages) > 1 && (key+1) < len(.Languages) }},{{ end }}{{ end }}"/>
|
||||
</a>
|
||||
{{end}}
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
<td class="tr-name home-td" {{ if len(.Comments) == 0 }}colspan="2"{{ end }}>
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
{{end}}
|
||||
{{ if Torrent.Dlsite > 0 }}
|
||||
<span class="tag accepted">
|
||||
<span class="tag-text votable"><a href="https://www.dlsite.com/home/work/=/product_id/{{ Torrent.Dlsite }}.html">{{ T("tagtype_dlsite") }}: {{ Torrent.Dlsite }}</a></span>
|
||||
<span class="tag-text votable"><a href="http://www.dlsite.com/home/work/=/product_id/{{ Torrent.Dlsite }}.html">{{ T("tagtype_dlsite") }}: {{ Torrent.Dlsite }}</a></span>
|
||||
<a href="/search?dlsite={{ Torrent.Dlsite }}" title="{{ T("filter") }}"><i class="icon-search"></i></a>
|
||||
</span>
|
||||
{{end}}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
{{block content_body()}}
|
||||
<div class="box">
|
||||
<div class="user-form">
|
||||
<form role="form" method="POST">
|
||||
<form method="POST">
|
||||
{{ yield csrf_field()}}
|
||||
<h2>{{ T("sign_in_box_title")}}</h2>
|
||||
<input type="text" name="username" id="username" class="form-input up-input" autofocus placeholder="{{ T("email_address_or_username")}}"/>
|
||||
|
@ -22,6 +22,6 @@
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<br />
|
||||
<br/>
|
||||
<br/>
|
||||
{{end}}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
{{block content_body()}}
|
||||
<div class="box">
|
||||
<div class="user-form">
|
||||
<form role="form" method="POST">
|
||||
<form method="POST">
|
||||
{{ yield csrf_field() }}
|
||||
<h2>{{ T("signup_box_title") }}</h2>
|
||||
<input type="text" name="username" id="display_name" class="form-input up-input" placeholder="{{ T("username") }}" value="{{ Form.Username }}" autofocus/>
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
<td class="tr-cat user-td">
|
||||
<div class="nyaa-cat {{ if Sukebei() }}sukebei-cat-{{ torrent.Category }}{{else}}nyaa-cat-{{end}}{{ torrent.SubCategory}}">
|
||||
<a href="{{URL.Parse ("/search?c="+ torrent.Category + "_" +torrent.SubCategory) }}" title="{{T(CategoryName(torrent.Category, torrent.SubCategory))}}" class="category">
|
||||
</a>
|
||||
{{ if torrent.Languages[0] != "" }}
|
||||
<a href="{{ URL.Parse("/search?c="+torrent.Category+"_"+ torrent.SubCategory +"&lang=") }}{{ range key, language := torrent.Languages }}{{ language }}{{ if len(torrent.Languages) > 1 && (key+1) < len(torrent.Languages) }},{{ end }}{{ end }}">
|
||||
<img src="/img/blank.gif" alt="{{ LanguageNameFromCode(torrent.Languages[0], T) }}" class="flag flag-{{ (len(torrent.Languages) == 1) ? FlagCode(torrent.Languages[0]) : "multiple" }}" title=" {{ range key, language := torrent.Languages }}{{ LanguageNameFromCode(language, T) }}{{ if len(torrent.Languages) > 1 && (key+1) < len(torrent.Languages) }},{{ end }}{{ end }}"/>
|
||||
</a>
|
||||
{{end}}
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
<td class="tr-name user-td">
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
func templateFunctions(vars jet.VarMap) jet.VarMap {
|
||||
vars.Set("getRawQuery", getRawQuery)
|
||||
vars.Set("genSearchWithOrdering", genSearchWithOrdering)
|
||||
vars.Set("genSearchWithCategory", genSearchWithCategory)
|
||||
vars.Set("genSortArrows", genSortArrows)
|
||||
vars.Set("genNav", genNav)
|
||||
vars.Set("Sukebei", config.IsSukebei)
|
||||
|
@ -84,7 +85,23 @@ func genSearchWithOrdering(currentURL *url.URL, sortBy string) string {
|
|||
return u.String()
|
||||
}
|
||||
|
||||
func genSearchWithCategory(currentURL *url.URL, category string) string {
|
||||
values := currentURL.Query()
|
||||
cat := "_" //Default
|
||||
|
||||
if _, ok := values["c"]; ok {
|
||||
cat = values["c"][0]
|
||||
}
|
||||
|
||||
cat = category
|
||||
|
||||
values.Set("c", cat)
|
||||
|
||||
u, _ := url.Parse("/search")
|
||||
u.RawQuery = values.Encode()
|
||||
|
||||
return u.String()
|
||||
}
|
||||
|
||||
func genSortArrows(currentURL *url.URL, sortBy string) template.HTML {
|
||||
values := currentURL.Query()
|
||||
|
@ -119,14 +136,10 @@ func genNav(nav Navigation, currentURL *url.URL, pagesSelectable int) template.H
|
|||
if nav.TotalItem > 0 {
|
||||
maxPages := math.Ceil(float64(nav.TotalItem) / float64(nav.MaxItemPerPage))
|
||||
|
||||
href := ""
|
||||
display := " style=\"display:none;\""
|
||||
if nav.CurrentPage-1 > 0 {
|
||||
display = ""
|
||||
href = " href=\"" + "/" + nav.Route + "/1" + "?" + currentURL.RawQuery + "\""
|
||||
url := "/" + nav.Route + "/1"
|
||||
ret = ret + "<a id=\"page-prev\" href=\"" + url + "?" + currentURL.RawQuery + "\" aria-label=\"Previous\"><li><span aria-hidden=\"true\">«</span></li></a>"
|
||||
}
|
||||
ret = ret + "<a id=\"page-prev\"" + display + href + " aria-label=\"Previous\"><span aria-hidden=\"true\">«</span></a>"
|
||||
|
||||
startValue := 1
|
||||
if nav.CurrentPage > pagesSelectable/2 {
|
||||
startValue = (int(math.Min((float64(nav.CurrentPage)+math.Floor(float64(pagesSelectable)/2)), maxPages)) - pagesSelectable + 1)
|
||||
|
@ -141,21 +154,16 @@ func genNav(nav Navigation, currentURL *url.URL, pagesSelectable int) template.H
|
|||
for i := startValue; i <= endValue; i++ {
|
||||
pageNum := strconv.Itoa(i)
|
||||
url := "/" + nav.Route + "/" + pageNum
|
||||
ret = ret + "<a aria-label=\"Page " + strconv.Itoa(i) + "\" href=\"" + url + "?" + currentURL.RawQuery + "\">" + "<span"
|
||||
ret = ret + "<a aria-label=\"Page " + strconv.Itoa(i) + "\" href=\"" + url + "?" + currentURL.RawQuery + "\">" + "<li"
|
||||
if i == nav.CurrentPage {
|
||||
ret = ret + " class=\"active\""
|
||||
}
|
||||
ret = ret + ">" + strconv.Itoa(i) + "</span></a>"
|
||||
ret = ret + ">" + strconv.Itoa(i) + "</li></a>"
|
||||
}
|
||||
|
||||
href = ""
|
||||
display = " style=\"display:none;\""
|
||||
if nav.CurrentPage < int(maxPages) {
|
||||
display = ""
|
||||
href = " href=\"" + "/" + nav.Route + "/" + strconv.Itoa(nav.CurrentPage+1) + "?" + currentURL.RawQuery + "\""
|
||||
url := "/" + nav.Route + "/" + strconv.Itoa(nav.CurrentPage+1)
|
||||
ret = ret + "<a id=\"page-next\" href=\"" + url + "?" + currentURL.RawQuery + "\" aria-label=\"Next\"><li><span aria-hidden=\"true\">»</span></li></a>"
|
||||
}
|
||||
ret = ret + "<a id=\"page-next\"" + display + href +" aria-label=\"Next\"><span aria-hidden=\"true\">»</span></a>"
|
||||
|
||||
itemsThisPageStart := nav.MaxItemPerPage*(nav.CurrentPage-1) + 1
|
||||
itemsThisPageEnd := nav.MaxItemPerPage * nav.CurrentPage
|
||||
if nav.TotalItem < itemsThisPageEnd {
|
||||
|
|
|
@ -108,6 +108,24 @@ func TestGenSearchWithOrdering(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestgenSearchWithCategory(t *testing.T) {
|
||||
var tests = []map[string]string{
|
||||
{
|
||||
"test": "",
|
||||
"mode": "1_",
|
||||
"expected": "/search?c=1_",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
url, _ := url.Parse(test["test"])
|
||||
value := genSearchWithCategory(url, test["mode"])
|
||||
if value != test["expected"] {
|
||||
t.Errorf("Unexpected value from the function genSearchWithCategory, got '%s', wanted '%s' for '%s' and '%s'", value, test["expected"], test["test"], test["mode"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlagCode(t *testing.T) {
|
||||
var tests = []map[string]string{
|
||||
{
|
||||
|
|
Référencer dans un nouveau ticket