Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Add RSS link on userprofile, "Search from this user" input, route changes, other changes (#1630)

* Styling for new "Search from user" input in profile

* new "Search from this user" input

* Add RSS link on user profile

* fix rss icon being misaligned

* start comment count at 1 instead of 0

* fix misalignement of category in refine in japanese

* Add new routes for user search

* Update torrents.jet.html

* add translation string

* Update en-us.all.json

* Update CHANGELOG.md

* remove margin-right of torrent button icon

* Add /username/XXX/Search route

* /username/XXX route doesn't redirect anymore
Cette révision appartient à :
kilo 2017-10-03 01:44:33 +02:00 révisé par GitHub
Parent 415db8ca06
révision 7273156007
8 fichiers modifiés avec 69 ajouts et 22 suppressions

Voir le fichier

@ -3,7 +3,6 @@ package userController
import ( import (
"strconv" "strconv"
"time" "time"
"fmt"
"net/http" "net/http"
@ -60,14 +59,36 @@ func UserProfileHandler(c *gin.Context) {
func UserGetFromName(c *gin.Context) { func UserGetFromName(c *gin.Context) {
username := c.Param("username") username := c.Param("username")
if(username != "") { Ts, _ := publicSettings.GetTfuncAndLanguageFromRequest(c)
user, _, _, err := users.FindByUsername(username) messages := msg.GetMessages(c)
if err == nil {
c.Redirect(http.StatusSeeOther, fmt.Sprintf("/user/%d/%s", uint32(user.ID), username)) userProfile, _, _, err := users.FindByUsername(username)
return if err == nil {
} currentUser := router.GetUser(c)
} follow := c.Request.URL.Query()["followed"]
c.Status(http.StatusNotFound) unfollow := c.Request.URL.Query()["unfollowed"]
deleteVar := c.Request.URL.Query()["delete"]
if (deleteVar != nil) && (currentUser.CurrentOrAdmin(userProfile.ID)) {
_, err := userProfile.Delete(currentUser)
if err == nil && currentUser.CurrentUserIdentical(userProfile.ID) {
cookies.Clear(c)
}
templates.Static(c, "site/static/delete_success.jet.html")
} else {
if follow != nil {
messages.AddInfof("infos", Ts("user_followed_msg"), userProfile.Username)
}
if unfollow != nil {
messages.AddInfof("infos", Ts("user_unfollowed_msg"), userProfile.Username)
}
userProfile.ParseSettings()
templates.UserProfile(c, userProfile)
}
} else {
c.Status(http.StatusNotFound)
}
} }
// UserDetailsHandler : Getting User Profile Details View // UserDetailsHandler : Getting User Profile Details View

Voir le fichier

@ -2,6 +2,7 @@ package userController
import "github.com/NyaaPantsu/nyaa/controllers/router" import "github.com/NyaaPantsu/nyaa/controllers/router"
import "github.com/NyaaPantsu/nyaa/controllers/feed" import "github.com/NyaaPantsu/nyaa/controllers/feed"
import "github.com/NyaaPantsu/nyaa/controllers/search"
func init() { func init() {
@ -31,9 +32,13 @@ func init() {
userRoutes.GET("/:id/:username/edit", UserDetailsHandler) userRoutes.GET("/:id/:username/edit", UserDetailsHandler)
userRoutes.POST("/:id/:username/edit", UserProfileFormHandler) userRoutes.POST("/:id/:username/edit", UserProfileFormHandler)
userRoutes.GET("/:id/:username/apireset", UserAPIKeyResetHandler) userRoutes.GET("/:id/:username/apireset", UserAPIKeyResetHandler)
userRoutes.GET("/:id/:username/search", searchController.SearchHandler)
userRoutes.GET("/:id/:username/search/:page", searchController.SearchHandler)
userRoutes.GET("/:id/:username/feed", feedController.RSSHandler) userRoutes.GET("/:id/:username/feed", feedController.RSSHandler)
userRoutes.GET("/:id/:username/feed/:page", feedController.RSSHandler) userRoutes.GET("/:id/:username/feed/:page", feedController.RSSHandler)
} }
router.Get().Any("/username/:username", UserGetFromName) router.Get().Any("/username/:username", UserGetFromName)
router.Get().Any("/username/:username/search", searchController.SearchHandler)
router.Get().Any("/username/:username/search:page", searchController.SearchHandler)
} }

Voir le fichier

@ -699,7 +699,6 @@ html, body {
.torrent-buttons a [class^="icon-"], .torrent-buttons a [class*=" icon-"], a.form-input.btn-green>div[class^="icon-"], a.form-input.btn-green>div[class*="icon-"] { .torrent-buttons a [class^="icon-"], .torrent-buttons a [class*=" icon-"], a.form-input.btn-green>div[class^="icon-"], a.form-input.btn-green>div[class*="icon-"] {
vertical-align: initial; vertical-align: initial;
margin-right: 5px;
} }
#mascotKeepHide { #mascotKeepHide {
@ -1051,7 +1050,9 @@ html, body {
display: block; display: block;
margin-bottom: 11px; margin-bottom: 11px;
} }
.profile-usermenu .icon-rss-squared {
vertical-align: top;
}
.profile-userbuttons { .profile-userbuttons {
display: inline-flex; display: inline-flex;
margin-bottom: 5px; margin-bottom: 5px;
@ -2144,11 +2145,24 @@ table.multiple-upload {
padding: 5px 0; padding: 5px 0;
} }
.user-search {
word-spacing: -7px;
display:block;
padding: 0 1rem;
}
.user-search [type="text"] {
vertical-align: top;
width: calc(100% - 30px);
}
/* Language specific CSS */ /* Language specific CSS */
html[lang="ja-jp"] .form-refine span.spacing { html[lang="ja-jp"] .form-refine span.spacing {
vertical-align: middle; vertical-align: middle;
} }
html[lang="ja-jp"] .form-input.refine-category {
vertical-align: top;
}
@media (max-width: 1100px) { @media (max-width: 1100px) {
html[lang="ja-jp"] .header .h-user>.nav-btn { html[lang="ja-jp"] .header .h-user>.nav-btn {
font-size: 75%; font-size: 75%;

Voir le fichier

@ -37,25 +37,22 @@
<div class="profile-usermenu"> <div class="profile-usermenu">
{{ if User.ID > 0 && (User.CurrentUserIdentical(UserProfile.ID) || User.CurrentOrAdmin(UserProfile.ID)) }} {{ if User.ID > 0 && (User.CurrentUserIdentical(UserProfile.ID) || User.CurrentOrAdmin(UserProfile.ID)) }}
<a class="form-input btn-green" href="/user/{{ UserProfile.ID }}/{{ UserProfile.Username }}"> <a class="form-input btn-green" href="/user/{{ UserProfile.ID }}/{{ UserProfile.Username }}">
<div class="icon-floppy"></div>{{ T("torrents")}}
</a>
<br/>
{{ else }} {{ else }}
<a class="form-input btn-green" href="/search?userID={{ UserProfile.ID }}"> <a class="form-input btn-green" href="/search?userID={{ UserProfile.ID }}">
{{end}}
<div class="icon-floppy"></div>{{ T("torrents")}} <div class="icon-floppy"></div>{{ T("torrents")}}
</a> </a>
<br/> <a class="form-input btn-orange" href="/feed?userID={{ UserProfile.ID }}">
{{ end }} <div class="icon-rss-squared"></div>RSS
</a>
{{if User.ID > 0 }} {{if User.ID > 0 }}
{{ if User.CurrentUserIdentical(UserProfile.ID) }} {{ if User.CurrentUserIdentical(UserProfile.ID) }}
<a class="form-input" href="/notifications">{{ T("my_notifications")}}</a> <a class="form-input" href="/notifications">{{ T("my_notifications")}}</a>
<br/>
{{end}} {{end}}
{{if UserProfile.ID > 0 && User.CurrentOrAdmin(UserProfile.ID) }} {{if UserProfile.ID > 0 && User.CurrentOrAdmin(UserProfile.ID) }}
<a class="form-input" href="/user/{{UserProfile.ID}}/{{UserProfile.Username}}/edit"> <a class="form-input" href="/user/{{UserProfile.ID}}/{{UserProfile.Username}}/edit">
{{ T("settings")}} {{ T("settings")}}
</a> </a>
<br/>
{{end}} {{end}}
{{end}} {{end}}
</div> </div>

Voir le fichier

@ -177,7 +177,7 @@
{{range index, element := Torrent.Comments}} {{range index, element := Torrent.Comments}}
<div class="torrent-info-box comment-box"> <div class="torrent-info-box comment-box">
<span class="comment-index"> <span class="comment-index">
<a href="#comment_{{index}}">{{index}}</a> <a href="#comment_{{index+1}}">{{index}}</a>
<small style="padding-left: 4px;" class="date-short">{{formatDateRFC(element.Date)}}</small> <small style="padding-left: 4px;" class="date-short">{{formatDateRFC(element.Date)}}</small>
</span> </span>
<p><img src="https://www.gravatar.com/avatar/{{ element.UserAvatar }}"/><a {{if element.UserID > 0}}href="/user/{{element.UserID}}/{{element.Username}}"{{end}} class="comment-user">{{element.Username}}</a></p> <p><img src="https://www.gravatar.com/avatar/{{ element.UserAvatar }}"/><a {{if element.UserID > 0}}href="/user/{{element.UserID}}/{{element.Username}}"{{end}} class="comment-user">{{element.Username}}</a></p>

Voir le fichier

@ -47,15 +47,19 @@
</tr> </tr>
{{end}} {{end}}
</table> </table>
<nav class="torrentNav" aria-label="Page navigation">
<div class="pagination"> <div class="pagination">
<a href="/search?userID={{ UserProfile.ID }}" aria-label="Next"> <a href="/search?userID={{ UserProfile.ID }}" aria-label="Next">
<span> <span style="display:block;border-right:1px solid;">
{{ T("see_more_torrents_from", UserProfile.Username) }} {{ T("see_more_torrents_from", UserProfile.Username) }}
</span> </span>
</a> </a>
</div> </div>
</nav> <div class="user-search">
<form role="search" action="/user/{{UserProfile.ID}}/{{UserProfile.Username}}/search" id="header-form" 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>
</div>
{{else}} {{else}}
<h2 style="text-align: center;">{{ T("no_torrents_uploaded") }}</h2> <h2 style="text-align: center;">{{ T("no_torrents_uploaded") }}</h2>
{{end}} {{end}}

Voir le fichier

@ -50,3 +50,5 @@
* + disabled * + disabled
* + reset_api_key * + reset_api_key
* + tag_error * + tag_error
## 2017/10/02
* + search_from_user

Voir le fichier

@ -2142,5 +2142,9 @@
{ {
"id": "tag_error", "id": "tag_error",
"translation": "Couldn't add a tag, please check your internet connection and that all fields are filled." "translation": "Couldn't add a tag, please check your internet connection and that all fields are filled."
},
{
"id": "search_from_user",
"translation": "Search from this user..."
} }
] ]