Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Merge branch 'master' into patch-3

Cette révision appartient à :
akuma06 2017-05-11 12:37:24 +02:00 révisé par GitHub
révision 0fb5c2eb3a
8 fichiers modifiés avec 74 ajouts et 50 suppressions

Voir le fichier

@ -85,7 +85,7 @@ type CommentJSON struct {
Username string `json:"username"`
UserID int `json:"user_id"`
Content template.HTML `json:"content"`
Date time.Time `json:"date"`
Date string `json:"date"`
}
type TorrentJSON struct {
@ -117,10 +117,10 @@ func (t *Torrent) ToJSON() TorrentJSON {
magnet := util.InfoHashToMagnet(strings.TrimSpace(t.Hash), t.Name, config.Trackers...)
commentsJSON := make([]CommentJSON, 0, len(t.OldComments)+len(t.Comments))
for _, c := range t.OldComments {
commentsJSON = append(commentsJSON, CommentJSON{Username: c.Username, UserID: -1, Content: template.HTML(c.Content), Date: c.Date})
commentsJSON = append(commentsJSON, CommentJSON{Username: c.Username, UserID: -1, Content: template.HTML(c.Content), Date: c.Date.Format(time.RFC3339)})
}
for _, c := range t.Comments {
commentsJSON = append(commentsJSON, CommentJSON{Username: c.User.Username, UserID: int(c.User.ID), Content: util.MarkdownToHTML(c.Content), Date: c.CreatedAt})
commentsJSON = append(commentsJSON, CommentJSON{Username: c.User.Username, UserID: int(c.User.ID), Content: util.MarkdownToHTML(c.Content), Date: c.CreatedAt.Format(time.RFC3339)})
}
uploader := ""
if t.Uploader != nil {
@ -130,7 +130,8 @@ func (t *Torrent) ToJSON() TorrentJSON {
if t.ID <= config.LastOldTorrentID && len(config.TorrentCacheLink) > 0 {
torrentlink = fmt.Sprintf(config.TorrentCacheLink, t.Hash)
} else if t.ID > config.LastOldTorrentID && len(config.TorrentStorageLink) > 0 {
torrentlink = fmt.Sprintf(config.TorrentStorageLink, t.Hash) // TODO: Fix as part of configuration changes
// TODO: Fix as part of configuration changes (fix what?)
torrentlink = fmt.Sprintf(config.TorrentStorageLink, t.Hash)
}
res := TorrentJSON{
ID: strconv.FormatUint(uint64(t.ID), 10),

Voir le fichier

@ -377,4 +377,9 @@ footer {
position: relative;
top: -0.5rem;
float: right;
}
}
.comment-date {
font-size: smaller;
width: auto; /* Undo bootstrap's fixed width */
}

Voir le fichier

@ -157,6 +157,11 @@ func UserProfileFormHandler(w http.ResponseWriter, r *http.Request) {
modelHelper.BindValueForm(&b, r)
if !userPermission.HasAdmin(currentUser) {
b.Username = currentUser.Username
b.Status = currentUser.Status
} else {
if b.Status == 2 {
err["errors"] = append(err["errors"], "Elevating status to moderator is prohibited")
}
}
err = modelHelper.ValidateForm(&b, err)
if len(err) == 0 {

Voir le fichier

@ -16,24 +16,6 @@ var cookieHandler = securecookie.New(
securecookie.GenerateRandomKey(64),
securecookie.GenerateRandomKey(32))
// TODO: Figure out what this is about before I delete it
// // UserName get username from a cookie.
// func UserName(c *gin.Context) (string, error) {
// var userName string
// request := c.Request
// cookie, err := request.Cookie("session")
// if err != nil {
// return userName, err
// }
// cookieValue := make(map[string]string)
// err = cookieHandler.Decode("session", cookie.Value, &cookieValue)
// if err != nil {
// return userName, err
// }
// userName = cookieValue["name"]
// return userName, nil
// }
func Token(r *http.Request) (string, error) {
var token string
cookie, err := r.Cookie("session")
@ -90,17 +72,20 @@ func SetCookieHandler(w http.ResponseWriter, email string, pass string) (int, er
if isValidEmail {
log.Debug("User entered valid email.")
if db.ORM.Where("email = ?", email).First(&user).RecordNotFound() {
return http.StatusNotFound, errors.New("user not found")
return http.StatusNotFound, errors.New("User not found")
}
} else {
log.Debug("User entered username.")
if db.ORM.Where("username = ?", email).First(&user).RecordNotFound() {
return http.StatusNotFound, errors.New("user not found")
return http.StatusNotFound, errors.New("User not found")
}
}
err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(pass))
if err != nil {
return http.StatusUnauthorized, errors.New("password incorrect")
return http.StatusUnauthorized, errors.New("Password incorrect")
}
if user.Status == -1 {
return http.StatusUnauthorized, errors.New("Account banned")
}
status, err := SetCookie(w, user.Token)
if err != nil {

Voir le fichier

@ -34,7 +34,7 @@
{{end}}
</div>
</div>
{{ if not (HasAdmin .)}}
{{ if not (HasAdmin $.User)}}
<div class="form-group">
<label class="col-md-3 control-label">{{ T "current_password"}}:</label>
<div class="col-md-8">
@ -63,7 +63,7 @@
{{end}}
</div>
</div>
{{ if HasAdmin .}}
{{ if HasAdmin $.User}}
<h3>{{ T "moderation"}}</h3>
<div class="form-group">
<label class="col-md-3 control-label">{{ T "username"}}:</label>
@ -82,7 +82,7 @@
<option value="-1" {{ if eq .Status -1 }}selected{{end}}>{{ T "banned"}}</option>
<option value="0" {{ if eq .Status 0 }}selected{{end}}>{{ T "member"}} ({{ T "default" }})</option>
<option value="1" {{ if eq .Status 1 }}selected{{end}}>{{ T "trusted_member"}} </option>
<option value="2" {{ if eq .Status 2 }}selected{{end}}>{{ T "moderator"}} </option>
<!-- <option value="2" {{ if eq .Status 2 }}selected{{end}}>{{ T "moderator"}} </option> -->
</select>
</div>
{{ range (index $.FormErrors "status")}}

Voir le fichier

@ -93,7 +93,7 @@
<a href="{{$.URL.Parse (printf "/user/%d/-" .UserID ) }}">{{.Username}}</a>
{{end}}
</div>
<div class="col-md-2">
<div class="col-md-1 date-short comment-date">
{{printf "%d-%02d-%02d %02d:%02d" .Date.Year .Date.Month .Date.Day .Date.Hour .Date.Minute }}
{{/* output: "2017-05-01 15:30"
Went with "Year-Month-Day" because it's the most unambiguous.

Voir le fichier

@ -578,5 +578,29 @@
{
"id": "mark_as_remake",
"translation": "Segnala come remake"
}
},
{
"id": "email_changed",
"translation": "Email cambiata con successo! Dovrai, tuttavia, per confermare cliccare il link mandato a: %s"
},
{
"id": "torrent_status",
"translation": "Torrent status"
},
{
"id": "torrent_status_hidden",
"translation": "Nascosto"
},
{
"id": "torrent_status_normal",
"translation": "Normale"
},
{
"id": "torrent_status_remake",
"translation": "Remake"
},
{
"id": "profile_edit_page",
"translation": "Modifica il profilo di %s"
}
]

Voir le fichier

@ -49,7 +49,7 @@
},
{
"id":"i_agree",
"translation": "동의합니다"
"translation": "동의"
},
{
"id":"terms_conditions_confirm",
@ -65,11 +65,11 @@
},
{
"id":"terms_conditions",
"translation": "약관"
"translation": "이용약관"
},
{
"id":"terms_conditions_full",
"translation": "블라블라"
"translation": "ㅅㅂ"
},
{
"id":"remember_me",
@ -115,6 +115,10 @@
"id":"follow",
"translation": "팔로우"
},
{
"id":"unfollow",
"translation": "언팔로우"
},
{
"id":"profile_page",
"translation": "%s 프로필 페이지"
@ -165,7 +169,7 @@
},
{
"id": "fap",
"translation": ""
"translation": "자위"
},
{
"id": "advanced_search",
@ -201,11 +205,11 @@
},
{
"id": "sign_up",
"translation": "가입"
"translation": "회원가입"
},
{
"id": "no_results_found",
"translation": "결과 없음"
"translation": "검색결과가 없습니다"
},
{
"id": "notice_keep_seeding",
@ -221,7 +225,7 @@
},
{
"id": "what_happened",
"translation": "무슨 일이 있었던거야?"
"translation": "무슨 일입니까?"
},
{
"id": "nyaa_se_went_offline",
@ -341,23 +345,23 @@
},
{
"id": "anime",
"translation": "Anime"
"translation": "애니"
},
{
"id": "anime_amv",
"translation": "Anime - 애니메이션 뮤직 비디오"
"translation": "애니 - 애니메이션 뮤직 비디오"
},
{
"id": "anime_english_translated",
"translation": "Anime - 영문 번역"
"translation": "애니 - 영문 번역"
},
{
"id": "anime_non_english_translated",
"translation": "Anime - 비-영문 번역"
"translation": "애니 - 비-영문 번역"
},
{
"id": "anime_raw",
"translation": "Anime - Raw"
"translation": "애니 - Raw"
},
{
"id": "audio",
@ -409,27 +413,27 @@
},
{
"id": "pictures",
"translation": "Pictures"
"translation": "사진"
},
{
"id": "pictures_graphics",
"translation": "Pictures - 그래픽"
"translation": "사진 - 그래픽"
},
{
"id": "pictures_photos",
"translation": "Pictures - 사진"
"translation": "사진 - 사진"
},
{
"id": "software",
"translation": "Software"
"translation": "소프트웨어"
},
{
"id": "software_applications",
"translation": "Software - 응용프로그램"
"translation": "소프트웨어 - 응용프로그램"
},
{
"id": "software_games",
"translation": "Software - 게임"
"translation": "소프트웨어 - 게임"
},
{
"id": "torrent_description",
@ -453,7 +457,7 @@
},
{
"id": "id",
"translation": "ID"
"translation": "아이디"
},
{
"id": "downloads",