Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Merge pull request #356 from ewhal/date-comment

New translation function and time depends on translation
Cette révision appartient à :
akuma06 2017-05-11 13:16:59 +02:00 révisé par GitHub
révision 376c2d8633
5 fichiers modifiés avec 12 ajouts et 4 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 string `json:"date"`
Date time.Time `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.Format(time.RFC3339)})
commentsJSON = append(commentsJSON, CommentJSON{Username: c.Username, UserID: -1, Content: template.HTML(c.Content), Date: c.Date.UTC()})
}
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.Format(time.RFC3339)})
commentsJSON = append(commentsJSON, CommentJSON{Username: c.User.Username, UserID: int(c.User.ID), Content: util.MarkdownToHTML(c.Content), Date: c.CreatedAt.UTC()})
}
uploader := ""
if t.Uploader != nil {

Voir le fichier

@ -62,6 +62,7 @@ var FuncMap = template.FuncMap{
return template.HTML(ret)
},
"T": i18n.IdentityTfunc,
"Ts": i18n.IdentityTfunc,
"getAvatar": func(hash string, size int) string {
return "https://www.gravatar.com/avatar/" + hash + "?s=" + strconv.Itoa(size)
},

Voir le fichier

@ -94,7 +94,7 @@
{{end}}
</div>
<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 }}
{{ .Date.Format ( Ts "date_format" ) }}
{{/* output: "2017-05-01 15:30"
Went with "Year-Month-Day" because it's the most unambiguous.
If you want it to be determined by where you're from, be my guest. */}}

Voir le fichier

@ -602,5 +602,9 @@
{
"id": "profile_edit_page",
"translation": "Edit %s's profile"
},
{
"id":"date_format",
"translation": "2006-01-02 15:04"
}
]

Voir le fichier

@ -56,6 +56,9 @@ func SetTranslation(tmpl *template.Template, language string, languages ...strin
"T": func(str string, args ...interface{}) template.HTML {
return template.HTML(fmt.Sprintf(T(str), args...))
},
"Ts": func(str string, args ...interface{}) string {
return fmt.Sprintf(T(str), args...)
},
})
return T
}