Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0

Merge branch 'dev' into filelist-fetching

Cette révision appartient à :
kilo 2017-11-09 14:10:18 +01:00 révisé par GitHub
révision 4bd364eb91
Signature inconnue de Forgejo
ID de la clé GPG: 4AEE18F83AFDEB23
13 fichiers modifiés avec 62 ajouts et 35 suppressions

Voir le fichier

@ -170,7 +170,7 @@ users:
default_notifications_settings: {"new_torrent": true, "new_torrent_email": false, "new_comment": true, "new_comment_email": false, "new_responses": false, "new_responses_email": false, "new_follower": false, "new_follower_email": false, "followed": false, "followed_email": false}
navigation:
torrents_per_page: 50
max_torrents_per_page: 300
max_torrents_per_page: 500
log:
# AccessLogFilePath : Path to logs access
access_log_filepath: log/access

Voir le fichier

@ -13,7 +13,7 @@ import (
// IndexModPanel : Controller for showing index page of Mod Panel
func IndexModPanel(c *gin.Context) {
offset := 10
torrents, _, _ := torrents.FindAll(offset, 0)
torrents, _, _ := torrents.FindAllOrderBy("torrent_id DESC", offset, 0)
users, _ := users.FindUsersForAdmin(offset, 0)
comments, _ := comments.FindAll(offset, 0, "", "")
torrentReports, _, _ := reports.GetAll(offset, 0)

Voir le fichier

@ -31,7 +31,7 @@ func SeePublicSettingsHandler(c *gin.Context) {
// ChangePublicSettingsHandler : Controller for changing the current language and theme
func ChangePublicSettingsHandler(c *gin.Context) {
theme := c.PostForm("theme")
lang := c.PostForm("language")
lang := c.PostForm("lang")
mascot := c.PostForm("mascot")
mascotURL := c.PostForm("mascot_url")
altColors := c.PostForm("altColors")

Voir le fichier

@ -95,7 +95,7 @@ func FindOldUploadsByUsername(username string) ([]uint, error) {
// FindByID retrieves a user by ID.
func FindByID(id uint) (*models.User, int, error) {
var user = &models.User{}
if models.ORM.Preload("Notifications", func(db *gorm.DB) *gorm.DB { return db.Order("id DESC") }).Last(user, id).RecordNotFound() {
if models.ORM.Preload("Notifications", func(db *gorm.DB) *gorm.DB { return db.Order("date DESC") }).Last(user, id).RecordNotFound() {
return user, http.StatusNotFound, errors.New("user_not_found")
}
var liked, likings []models.User
@ -117,7 +117,7 @@ func FindRawByID(id uint) (*models.User, int, error) {
func SessionByID(id uint) (*models.User, int, error) {
var user = &models.User{}
if models.ORM.Preload("Notifications", func(db *gorm.DB) *gorm.DB { return db.Order("id DESC") }).Where("user_id = ?", id).First(user).RecordNotFound() { // We only load unread notifications
if models.ORM.Preload("Notifications", func(db *gorm.DB) *gorm.DB { return db.Order("date DESC") }).Where("user_id = ?", id).First(user).RecordNotFound() { // We only load unread notifications
return user, http.StatusBadRequest, errors.New("user_not_found")
}
return user, http.StatusOK, nil
@ -126,7 +126,7 @@ func SessionByID(id uint) (*models.User, int, error) {
// FindForAdmin retrieves a user for an administrator, preloads torrents.
func FindForAdmin(id uint) (*models.User, int, error) {
var user = &models.User{}
if models.ORM.Preload("Notifications", func(db *gorm.DB) *gorm.DB { return db.Order("id DESC") }).Preload("Torrents").Last(user, id).RecordNotFound() {
if models.ORM.Preload("Notifications", func(db *gorm.DB) *gorm.DB { return db.Order("date DESC") }).Preload("Torrents").Last(user, id).RecordNotFound() {
return user, http.StatusNotFound, errors.New("user_not_found")
}
var liked, likings []models.User

Voir le fichier

@ -265,10 +265,10 @@ select.form-input {
.website-nav .pagination span {
min-width: auto;
}
.website-nav #page-prev{
.website-nav .page-prev{
float: left;
}
.website-nav #page-next{
.website-nav .page-next{
float: right;
}
@ -348,7 +348,7 @@ span.comment-user:hover {
margin: 1px 0;
}
#solution {
.solution {
margin-top: -3px;
}

Voir le fichier

@ -116,9 +116,7 @@ function resetCookies() {
if(domain == hostName) {
//only execute if cookie are supposed to be shared between nyaa & sukebei, aka on host name without subdomain
var cookieValue = getCookieValue(cookieName)
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;"
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;domain=" + window.location.host
document.cookie = cookieName + "=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;"
deleteCookie(cookieName)
if(cookieName != "session")
document.cookie = cookieName + "=" + cookieValue + ";path=/;expires=" + farFutureString + ";domain=" + domain
else document.cookie = cookieName + "=" + cookieValue + ";path=/;expires=" + farFutureString
@ -127,12 +125,12 @@ function resetCookies() {
}
continue
}
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;"
document.cookie = cookieName + "=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;"
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;domain=" + window.location.host
deleteCookie(cookieName)
}
//Set new version in cookie
deleteCookie("commit")
deleteCookie("version")
document.cookie = "commit=" + commitVersion + ";path=/;expires=" + farFutureString + ";domain=" + domain
document.cookie = "version=" + websiteVersion + ";path=/;expires=" + farFutureString + ";domain=" + domain
@ -306,4 +304,24 @@ function getCookieValue(cookieName) {
return endPos == -1 ? document.cookie.substring(startPos) : document.cookie.substring(startPos, endPos + startPos)
}
function deleteCookie(cookieName) {
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;"
document.cookie = cookieName + "=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;"
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;domain=" + window.location.host
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;domain=" + domain
//Also need to delete from current hostname without subdomain, which is what this accomplish
var hostName = window.location.host
var lastDotIndex = hostName.lastIndexOf(".")
var secondLast = -1
for(var index = 0; index < lastDotIndex; index++) {
if(hostName[index] == '.')
secondLast = index
}
hostName = hostName.substr(secondLast == -1 ? 0 : secondLast)
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;domain=" + hostName
}
// @license-end

Voir le fichier

@ -11,7 +11,7 @@
{{ T("captcha_audio") }}
</a>
</audio>
<input class="form-input up-input form-control" type="text" name="solution" id="solution" style="display:block;" placeholder="{{ T("captcha")}}" autocomplete="off" required />
<input class="form-input up-input form-control" type="text" name="solution" class="solution" style="display:block;" placeholder="{{ T("captcha")}}" autocomplete="off" required />
</div>
{{end}}
{{end}}

Voir le fichier

@ -5,7 +5,7 @@
<tr>
{{ range _, cat := GetCategories(true, false) }}
<td>{{if Search.Category == cat.ID ||(len(Search.Category) > 2 && Search.Category[:2] == cat.ID)}}<b>{{ T(cat.Name) }}</b>{{else}}<a href="{{genSearchWithCategory(URL, cat.ID, Search.SearchURL)}}">{{ T(cat.Name) }}</a>{{end}}</td>
{{ if _ % 3 == 2}}
{{ if _ % 3 == 2 && _ + 1 != len(GetCategories(true, false)) }}
</tr>
<tr>
{{end}}

Voir le fichier

@ -34,7 +34,7 @@
<option value="3" {{if Search.Status == 3}}selected{{end}}>{{ T("trusted")}}</option>
<option value="4" {{if Search.Status == 4}}selected{{end}}>A+</option>
</select>
{{ T("limit_torrent_count")}}: <input type="number" name="limit" value="{{ Navigation.MaxItemPerPage }}" class="form-input spacing" min="1" max="300"/>
{{ T("limit_torrent_count")}}: <input type="number" name="limit" value="{{ Navigation.MaxItemPerPage }}" class="form-input spacing" min="1" max="500"/>
{{ T("from_user") }}: <input type="text" name="user" placeholder="Username/#ID" value="{{ Search.User == "" ? (Search.UserID == 0 ? "" : ("#" + Search.UserID)) : Search.User }}" class="form-input refine-user"/>
</span>
<span class="form-refine">

Voir le fichier

@ -4,7 +4,7 @@
{{ folderId := treeviewData.IdentifierChain+"_"+index }}
<tr class="tr-filelist tr-folder">
<td style="padding-left: {{ treeviewData.NestLevel * 2.5 }}%;"><label for="contents_{{folderId}}">{{folder.FolderName}}</label></td>
<td>{{ fileSize(folder.TotalSize(), T, false) }}</td>
<td>{{ fileSize(folder.TotalSize(), T, true) }}</td>
</tr>
<tr>
<td colspan="2">

Voir le fichier

@ -218,7 +218,7 @@
{{previousComment := ""}}
{{previousUser := 0}}
{{range index, element := Torrent.Comments}}
{{if previousComment != element.Content || previousUser != element.UserID}}
{{if previousComment != element.Content || previousUser != element.UserID || element.UserID == 0}}
<div class="torrent-info-box comment-box">
<span class="comment-index">
<a href="#comment_{{idx}}">{{idx}}</a>

Voir le fichier

@ -8,7 +8,7 @@
<div id="settings-container">
<span class="form-group">
<h3>{{ T("language")}}</h3>
<select id="language" name="language" class="form-input">
<select id="language" name="lang" class="form-input">
{{ range translatedName := Form.Languages }}
<option value="{{ translatedName[2] }}" {{ if Form.Current == translatedName[2] }}selected{{end}}>{{ translatedName[0] }}</option>
{{ end }}
@ -67,21 +67,30 @@
{{ block footer_js()}}
<!-- JS Function for selecting multiple checkboxes -->
<script type="text/javascript">
var SaveButton = document.querySelector('button[type="submit"')
var SaveButton = document.querySelector('form[method="POST"] button[type="submit"]')
//Golang settings.go controller set cookies for the domain variable in config, if we are currently on a mirror this will mean that the cookie will not be set for the right website
if(UserID == 0 && Mirror)
//Doing this, we avoid having to do a query (which is unneeded for logged-in users) and can make sure that the cookies are set for the right domain name
if(UserID == 0)
SaveButton.addEventListener("click", function(e) {
var OptionSelected = document.getElementById("theme-selector").selectedIndex
document.cookie = "theme=" + document.querySelector("#theme-selector :nth-child(" + OptionSelected + ")").value + ";path=/;expires=" + farFutureString + ";domain=" + domain
//Set theme cookie
OptionSelected = document.getElementById("language").selectedIndex
document.cookie = "lang=" + document.querySelector("#language :nth-child(" + OptionSelected + ")").value + ";path=/;expires=" + farFutureString + ";domain=" + domain
//Set language cookie
//Will have to do the rest
var formInputs = document.querySelectorAll("form[method='POST'] input"),
formSelect = document.querySelectorAll("form[method='POST'] select")
for(var i = 0; i < formInputs.length; i++) {
var setting = formInputs[i]
if(setting.name == "csrf_token") continue
deleteCookie(setting.name)
document.cookie = setting.name + "=" + setting.value + ";path=/;expires=" + farFutureString + ";domain=" + domain
}
for(var i = 0; i < formSelect.length; i++) {
var setting = formSelect[i],
selectValues = setting.querySelectorAll("option")
deleteCookie(setting.name)
document.cookie = setting.name + "=" + selectValues[setting.selectedIndex].value + ";path=/;expires=" + farFutureString + ";domain=" + domain
}
window.location.replace("/")
e.preventDefault()
})

Voir le fichier

@ -149,7 +149,7 @@ func genNav(nav Navigation, currentURL *url.URL, pagesSelectable int) template.H
display = ""
href = " href=\"" + "/" + nav.Route + "/1" + "?" + currentURL.RawQuery + "\""
}
ret = ret + "<a id=\"page-prev\"" + display + href + " aria-label=\"Previous\"><span aria-hidden=\"true\">&laquo;</span></a>"
ret = ret + "<a class=\"page-prev\"" + display + href + " aria-label=\"Previous\"><span aria-hidden=\"true\">&laquo;</span></a>"
startValue := 1
if nav.CurrentPage > pagesSelectable/2 {
@ -178,7 +178,7 @@ func genNav(nav Navigation, currentURL *url.URL, pagesSelectable int) template.H
display = ""
href = " href=\"" + "/" + nav.Route + "/" + strconv.Itoa(int(maxPages)) + "?" + currentURL.RawQuery + "\""
}
ret = ret + "<a id=\"page-next\"" + display + href +" aria-label=\"Next\"><span aria-hidden=\"true\">&raquo;</span></a>"
ret = ret + "<a class=\"page-next\"" + display + href +" aria-label=\"Next\"><span aria-hidden=\"true\">&raquo;</span></a>"
itemsThisPageStart := nav.MaxItemPerPage*(nav.CurrentPage-1) + 1
itemsThisPageEnd := nav.MaxItemPerPage * nav.CurrentPage