bottom margin for comment avatar & other small things (#1646)
* bottom margin for comment avatar * Resetting API key now redirects you back to edit page * move important faq things up in the faq * Add div as high as header instead of top margin for #content * Fix modtools showing behind ad * No margin-top for body * add functions that will be used in the future to file.go * Update create.go * fix css rule that didn't apply * Fix some JS of upload form that kept shitting out errors since i updated the upload form * Update upload.jet.html * fix duplicate id on a form * Fix very very slightly misaligned input * fix html error on filelist * Add FullDate variable to torrents * Create Go function that returns an user-friendly date when fed a go date * akuma must hate me for butchering the template_functions_test file * Make use of said function in view.jet.html * Forgot to vars.set the function * Remove useless title * Make use of function in listing * modify JS to fetch full date from title instead of innerText * Fix title date & two functions looping on non-existing objects * Show full dates in an AM/PM format like on live * Torrent dates on UTC+0 by default
Cette révision appartient à :
Parent
c72604cc22
révision
2044a3c98a
14 fichiers modifiés avec 145 ajouts et 53 suppressions
|
@ -235,5 +235,5 @@ func UserAPIKeyResetHandler(c *gin.Context) {
|
|||
} else {
|
||||
messages.AddInfoT("infos", "profile_updated")
|
||||
}
|
||||
UserProfileHandler(c)
|
||||
UserDetailsHandler(c)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/NyaaPantsu/nyaa/config"
|
||||
"github.com/zeebo/bencode"
|
||||
)
|
||||
|
@ -52,3 +54,29 @@ func (f *File) Filename() string {
|
|||
path := f.Path()
|
||||
return path[len(path)-1]
|
||||
}
|
||||
|
||||
// FilenameWithoutExtension : Returns the filename of the file without the extension
|
||||
func (f *File) FilenameWithoutExtension() string {
|
||||
path := f.Path()
|
||||
fileName := path[len(path)-1]
|
||||
index := strings.LastIndex(fileName, ".")
|
||||
|
||||
if index == -1 {
|
||||
return fileName
|
||||
}
|
||||
|
||||
return fileName[:index]
|
||||
}
|
||||
|
||||
// FilenameExtension : Returns the extension of a filename, or an empty string
|
||||
func (f *File) FilenameExtension() string {
|
||||
path := f.Path()
|
||||
fileName := path[len(path)-1]
|
||||
index := strings.LastIndex(fileName, ".")
|
||||
|
||||
if index == -1 {
|
||||
return ""
|
||||
}
|
||||
|
||||
return fileName[index:]
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ type TorrentJSON struct {
|
|||
Hidden bool `json:"-"`
|
||||
Hash string `json:"hash"`
|
||||
Date string `json:"date"`
|
||||
FullDate time.Time `json:"-"` //Used to convert the date to full OR short format depending on the situation
|
||||
Filesize int64 `json:"filesize"`
|
||||
Description template.HTML `json:"description"`
|
||||
Comments []CommentJSON `json:"comments"`
|
||||
|
@ -356,6 +357,7 @@ func (t *Torrent) ToJSON() TorrentJSON {
|
|||
Hidden: t.Hidden,
|
||||
Hash: t.Hash,
|
||||
Date: t.Date.Format(time.RFC3339),
|
||||
FullDate: t.Date,
|
||||
Filesize: t.Filesize,
|
||||
Description: sanitize.MarkdownToHTML(t.Description),
|
||||
Comments: commentsJSON,
|
||||
|
|
|
@ -26,7 +26,7 @@ func Create(user *models.User, uploadForm *torrentValidator.TorrentRequest) (*mo
|
|||
Description: uploadForm.Description,
|
||||
WebsiteLink: uploadForm.WebsiteLink,
|
||||
UploaderID: user.ID}
|
||||
torrent.EncodeLanguages() // Convert languages array in language string
|
||||
|
||||
torrent.ParseTrackers(uploadForm.Trackers)
|
||||
for _, tagForm := range uploadForm.Tags {
|
||||
tag := &models.Tag{
|
||||
|
@ -41,7 +41,31 @@ func Create(user *models.User, uploadForm *torrentValidator.TorrentRequest) (*mo
|
|||
torrent.Tags = append(torrent.Tags, *tag) // Finally we append it to the torrent
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if torrent.Category == 6 {
|
||||
torrent.Languages = []string{}
|
||||
//Pictures category, does not ever need a language
|
||||
}
|
||||
|
||||
if (torrent.Category == 3 && torrent.SubCategory == 5) || (torrent.Category == 4 && torrent.SubCategory == 7) || (torrent.Category == 5 && torrent.SubCategory == 9){
|
||||
//English Translated Anime, Live Action and Litterature
|
||||
//We only add english if there is another language already there
|
||||
//We don't want to add the english flag on every single torrent of these sub categories, not without any changes to redundant languages
|
||||
if len(torrent.Languages) != 0 {
|
||||
containsEnglish := false
|
||||
for _, lang := range torrent.Languages {
|
||||
if lang == "en" {
|
||||
containsEnglish = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !containsEnglish {
|
||||
torrent.Languages = append(torrent.Languages, "en")
|
||||
}
|
||||
}
|
||||
}
|
||||
torrent.EncodeLanguages() // Convert languages array in language string
|
||||
|
||||
err := models.ORM.Create(&torrent).Error
|
||||
log.Infof("Torrent ID %d created!\n", torrent.ID)
|
||||
if err != nil {
|
||||
|
|
|
@ -26,6 +26,7 @@ body {
|
|||
font-size: 14px;
|
||||
font-family: 'Noto Sans', Arial, sans-serif;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
img[class^="jl-"], img[class^="wb-"] {
|
||||
|
@ -77,9 +78,11 @@ img[class$="-w"] {
|
|||
width: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 60px;
|
||||
border-bottom: 1px solid;
|
||||
}
|
||||
.header, #header-height-offset {
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
#cookie-warning {
|
||||
z-index: 4;
|
||||
|
@ -340,10 +343,9 @@ select.form-input {
|
|||
|
||||
#content {
|
||||
position: relative;
|
||||
top: 54px;
|
||||
}
|
||||
#content.content-admin {
|
||||
top: 108px!important;
|
||||
top: 54px;
|
||||
}
|
||||
|
||||
.content {
|
||||
|
@ -567,7 +569,7 @@ th {
|
|||
font-size: 0px;
|
||||
}
|
||||
.tr-cs a::before {
|
||||
font-size: 14px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.tr-size {
|
||||
|
@ -901,7 +903,7 @@ html, body {
|
|||
width: 100%!important;
|
||||
}
|
||||
.upload-form-table .table-input-label {
|
||||
width: 25%;
|
||||
width: 25%!important;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1140,7 +1142,7 @@ html, body {
|
|||
}
|
||||
|
||||
.comment-box p:nth-child(2) {
|
||||
margin-top: 9px;
|
||||
margin-top: 9px;
|
||||
}
|
||||
|
||||
.comment-box img {
|
||||
|
@ -1148,6 +1150,7 @@ html, body {
|
|||
height: 50px;
|
||||
float: left;
|
||||
margin-right: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.comment-form {
|
||||
|
@ -2138,13 +2141,13 @@ table.multiple-upload {
|
|||
}
|
||||
|
||||
.user-edit-table td {
|
||||
padding: 3px 0;
|
||||
vertical-align: top;
|
||||
padding: 3px 0;
|
||||
vertical-align: top;
|
||||
}
|
||||
.user-edit-table td:nth-child(1){
|
||||
width: 150px;
|
||||
font-weight: bold;
|
||||
font-size: 14px!important;
|
||||
width: 150px;
|
||||
font-weight: bold;
|
||||
font-size: 14px!important;
|
||||
padding: 5px 0;
|
||||
}
|
||||
|
||||
|
@ -2158,7 +2161,7 @@ table.multiple-upload {
|
|||
}
|
||||
.user-search [type="text"] {
|
||||
vertical-align: top;
|
||||
width: calc(100% - 30px);
|
||||
width: calc(100% - 28px);
|
||||
}
|
||||
|
||||
.torrent-info-row .tr-se span, .torrent-info-row .tr-le span, .torrent-info-row .tr-dl span {
|
||||
|
@ -2172,7 +2175,7 @@ html[lang="ja-jp"] .form-refine span.spacing {
|
|||
vertical-align: middle;
|
||||
}
|
||||
html[lang="ja-jp"] .form-input.refine-category {
|
||||
vertical-align: top;
|
||||
vertical-align: top;
|
||||
}
|
||||
@media (max-width: 1100px) {
|
||||
html[lang="ja-jp"] .header .h-user>.nav-btn {
|
||||
|
|
|
@ -52,16 +52,14 @@ function parseAllDates() {
|
|||
}
|
||||
|
||||
var list = document.getElementsByClassName("date-short")
|
||||
for (var i in list) {
|
||||
for(var i = 0; i < list.length; i++) {
|
||||
var e = list[i]
|
||||
e.title = new Date(e.innerText).toLocaleString(lang)
|
||||
e.innerText = new Date(e.innerText).toLocaleString(lang, ymdOpt)
|
||||
e.innerText = new Date(e.title).toLocaleString(lang, ymdOpt)
|
||||
e.title = new Date(e.title).toLocaleString(lang)
|
||||
}
|
||||
|
||||
var list = document.getElementsByClassName("date-full")
|
||||
for (var i in list) {
|
||||
if(list.length == 0)
|
||||
break;
|
||||
for(var i = 0; i < list.length; i++) {
|
||||
var e = list[i]
|
||||
var dateDifference = dateDiff(new Date(e.innerText), new Date())
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
<nav id="header" class="header">
|
||||
{{block menu()}}{{end}}
|
||||
</nav>
|
||||
<div id="header-height-offset"></div>
|
||||
{{ AdType := kilo_rand(2) }}
|
||||
<div id="content" class="{{ block contclass()}}{{end}}">
|
||||
<div class="content container center">
|
||||
|
|
|
@ -11,16 +11,31 @@
|
|||
{{ yield ruleList(open=true) }}
|
||||
|
||||
|
||||
<h2 id="links">{{ T("links_replacement_mirror")}}</h2>
|
||||
<a href="{{Config.WebAddress.Nyaa}}">Nyaa - {{GetHostname(Config.WebAddress.Nyaa)}}</a><br />
|
||||
<a href="{{Config.WebAddress.Sukebei}}">Sukebei - {{GetHostname(Config.WebAddress.Sukebei)}}</a><br /><br />
|
||||
<a href="https://nyoo.moe/">Nyaa - https://nyoo.moe/ (Mirror)</a><br />
|
||||
<a href="https://sukebei.nyoo.moe/">Sukebei - https://sukebei.nyoo.moe/ (Mirror)</a><br /><br />
|
||||
<a href="https://nyaa.pt/">Nyaa - https://nyaa.pt/ (Mirror)</a><br />
|
||||
<a href="https://sukebei.nyaa.pt/">Sukebei - https://sukebei.nyaa.pt/ (Mirror)</a><br /><br />
|
||||
<a href="https://dpzz6tjaqbl3ttba.onion/">Nyaa - dpzz6tjaqbl3ttba.onion (Mirror)</a><br />
|
||||
<a href="https://34knbgrnvicofdgz.onion/">Sukebei - 34knbgrnvicofdgz.onion (Mirror)</a><br />
|
||||
<h2 id="links">{{ T("links_replacement_mirror")}}</h2>
|
||||
<a href="{{Config.WebAddress.Nyaa}}">Nyaa - {{GetHostname(Config.WebAddress.Nyaa)}}</a><br />
|
||||
<a href="{{Config.WebAddress.Sukebei}}">Sukebei - {{GetHostname(Config.WebAddress.Sukebei)}}</a><br /><br />
|
||||
<a href="https://nyoo.moe/">Nyaa - https://nyoo.moe/ (Mirror)</a><br />
|
||||
<a href="https://sukebei.nyoo.moe/">Sukebei - https://sukebei.nyoo.moe/ (Mirror)</a><br /><br />
|
||||
<a href="https://nyaa.pt/">Nyaa - https://nyaa.pt/ (Mirror)</a><br />
|
||||
<a href="https://sukebei.nyaa.pt/">Sukebei - https://sukebei.nyaa.pt/ (Mirror)</a><br /><br />
|
||||
<a href="https://dpzz6tjaqbl3ttba.onion/">Nyaa - dpzz6tjaqbl3ttba.onion (Mirror)</a><br />
|
||||
<a href="https://34knbgrnvicofdgz.onion/">Sukebei - 34knbgrnvicofdgz.onion (Mirror)</a><br />
|
||||
|
||||
<h2 id="torrent_colors">{{ T("torrent_colors")}}</h2>
|
||||
<p>{{ T("green")}}</p>
|
||||
<ul>
|
||||
<li>{{ T("trusted")}}</li>
|
||||
</ul>
|
||||
<p>{{ T("red")}}</p>
|
||||
<ul>
|
||||
<li>{{ T("reencodes")}}</li>
|
||||
<li>{{ T("remux")}}</li>
|
||||
<li>{{ T("reupload")}}</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="how_get_old_account">{{ T("how_do_i_link_my_old_account")}}</h2>
|
||||
<p>{{ T("answer_how_do_i_link_my_old_account")|raw}}</p>
|
||||
|
||||
<h2 id="server_status">{{ T("server_status_link")}}</h2>
|
||||
<a href="{{Config.WebAddress.Status}}">Status - {{GetHostname(Config.WebAddress.Status)}}</a><br />
|
||||
|
||||
|
@ -58,21 +73,7 @@
|
|||
|
||||
<h2 id="why_ads">{{ T("faq_ads")}}</h2>
|
||||
<p>{{ T("faq_ads_explanation")|raw}}</p>
|
||||
|
||||
<h2 id="how_get_old_account">{{ T("how_do_i_link_my_old_account")}}</h2>
|
||||
<p>{{ T("answer_how_do_i_link_my_old_account")|raw}}</p>
|
||||
|
||||
<h2 id="torrent_colors">{{ T("torrent_colors")}}</h2>
|
||||
<p>{{ T("green")}}</p>
|
||||
<ul>
|
||||
<li>{{ T("trusted")}}</li>
|
||||
</ul>
|
||||
<p>{{ T("red")}}</p>
|
||||
<ul>
|
||||
<li>{{ T("reencodes")}}</li>
|
||||
<li>{{ T("remux")}}</li>
|
||||
<li>{{ T("reupload")}}</li>
|
||||
</ul>
|
||||
<h2 id="trackers">{{ T("which_trackers_do_you_recommend")}}</h2>
|
||||
<p>{{ T("answer_which_trackers_do_you_recommend")}}</p>
|
||||
<pre>udp://tracker.uw0.xyz:6969
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
<td class="tr-le home-td hide-smol">{{.Leechers}}</td>
|
||||
<td class="tr-dl home-td hide-xs">{{.Completed}}</td>
|
||||
{{end}}
|
||||
<td class="tr-date home-td date-short hide-xs">{{.Date}}</td>
|
||||
<td class="tr-date home-td date-short hide-xs" title="{{.Date}}">{{formatDate(.FullDate, true)}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
|
|
|
@ -144,11 +144,16 @@
|
|||
<script type="text/javascript" src="/js/template.js?v={{ Config.Version}}{{ Config.Build }}"></script>
|
||||
<script type="text/javascript" src="/js/simplemde.min.js?v={{ Config.Version}}{{ Config.Build }}"></script>
|
||||
<script type="text/javascript">
|
||||
document.querySelector('#upload-button').addEventListener("click", (e) => {
|
||||
if(document.querySelector('.upload-form-table select[name="c"]').selectedIndex == 0)
|
||||
setTimeout(function(){ window.scrollBy(0, -70) }, 1);
|
||||
})
|
||||
|
||||
document.querySelector("input[name='magnet']").addEventListener("keyup", (e) => {
|
||||
var torrentInput = document.querySelector("input[name='torrent']")
|
||||
torrentInput.disabled = e.target.value != ""
|
||||
if (e.target.value == "") torrentInput.previousElementSibling.classList.remove("hidden")
|
||||
else torrentInput.previousElementSibling.classList.add("hidden")
|
||||
if (e.target.value == "") torrentInput.classList.remove("hidden")
|
||||
else torrentInput.classList.add("hidden")
|
||||
try{
|
||||
torrentInput.value = '';
|
||||
if (torrentInput.value) {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<br/>
|
||||
</td>
|
||||
<td class="torrent-info-td torrent-info-label">{{ T("date") }}:</td>
|
||||
<td class="torrent-info-td date-full">{{Torrent.Date}}</td>
|
||||
<td class="torrent-info-td date-full">{{formatDate(Torrent.FullDate, false)}}</td>
|
||||
</tr>
|
||||
<tr class="torrent-info-row">
|
||||
<td class="torrent-info-td torrent-info-label">{{ T("uploaded_by") }}:</td>
|
||||
|
@ -50,7 +50,7 @@
|
|||
<td class="torrent-info-td torrent-info-label">{{ T("size")}}:</td>
|
||||
<td class="torrent-view-td torrent-info-data">{{ fileSize(Torrent.Filesize, T) }}</td>
|
||||
<td class="torrent-info-td torrent-info-label">{{ T("last_scraped")}}</td>
|
||||
<td class="torrent-info-td scrape-date{{if !Torrent.LastScrape.IsZero && formatDateRFC(Torrent.LastScrape) != "0001-01-01T00:00:00Z"}} date-full">{{formatDateRFC(Torrent.LastScrape)}}{{else}}">{{ T("unknown")}}{{end}}</td>
|
||||
<td class="torrent-info-td scrape-date{{if !Torrent.LastScrape.IsZero && formatDateRFC(Torrent.LastScrape) != "0001-01-01T00:00:00Z"}} date-full">{{formatDate(Torrent.LastScrape, false)}}{{else}}">{{ T("unknown")}}{{end}}</td>
|
||||
</tr>
|
||||
{{ if len(Torrent.Languages) > 0 && Torrent.Languages[0] != "" }}
|
||||
<tr class="torrent-info-row">
|
||||
|
@ -161,8 +161,10 @@
|
|||
{* how do i concat lol *}
|
||||
<table class="table-filelist">
|
||||
<thead>
|
||||
<th style="width: 80%">{{ T("file_name")}}</th>
|
||||
<th>{{ T("size")}}</th>
|
||||
<tr>
|
||||
<th style="width: 80%">{{ T("file_name")}}</th>
|
||||
<th>{{ T("size")}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ yield make_treeview(treeviewData=makeTreeViewData(RootFolder, 0, "root")) }}
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
</a>
|
||||
</div>
|
||||
<div class="user-search">
|
||||
<form role="search" action="/user/{{UserProfile.ID}}/{{UserProfile.Username}}/search" id="header-form" method="get">'
|
||||
<form role="search" action="/user/{{UserProfile.ID}}/{{UserProfile.Username}}/search" method="get">'
|
||||
<input class="form-input" name="q" type="text" placeholder="{{T("search_from_user")}}">
|
||||
<button type="submit" class="form-input icon-search"></button>
|
||||
</form>
|
||||
|
|
|
@ -59,6 +59,7 @@ func templateFunctions(vars jet.VarMap) jet.VarMap {
|
|||
vars.Set("getDomainName", getDomainName)
|
||||
vars.Set("getThemeList", getThemeList)
|
||||
vars.Set("formatThemeName", formatThemeName)
|
||||
vars.Set("formatDate", formatDate)
|
||||
return vars
|
||||
}
|
||||
func getRawQuery(currentURL *url.URL) string {
|
||||
|
@ -439,3 +440,15 @@ func formatThemeName(name string, T publicSettings.TemplateTfunc) string {
|
|||
return name
|
||||
}
|
||||
|
||||
func formatDate(Date time.Time, short bool) string {
|
||||
Date = Date.UTC()
|
||||
if short {
|
||||
return fmt.Sprintf("%.3s %d, %d", Date.Month(), Date.Day(), Date.Year())
|
||||
}
|
||||
|
||||
if Date.Hour() >= 12 {
|
||||
return fmt.Sprintf("%d/%d/%d, %d:%.2d:%.2d PM UTC+0", Date.Month(), Date.Day(), Date.Year(), Date.Hour() - 12, Date.Minute(), Date.Second())
|
||||
} else {
|
||||
return fmt.Sprintf("%d/%d/%d, %d:%.2d:%.2d AM UTC+0", Date.Month(), Date.Day(), Date.Year(), Date.Hour(), Date.Minute(), Date.Second())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -765,6 +765,21 @@ func TestRand(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func testFormatDate(t *testing.T) {
|
||||
var tests = []struct {
|
||||
domainName string
|
||||
}{
|
||||
{
|
||||
domainName: "test",
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
value := formatDate(time.Now(), false)
|
||||
if value != test.domainName {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mockupTemplateT(t *testing.T) publicSettings.TemplateTfunc {
|
||||
conf := config.Get().I18n
|
||||
|
|
Référencer dans un nouveau ticket