Link to user page from comment section
Cette révision appartient à :
Parent
c07d771559
révision
9c562018e5
2 fichiers modifiés avec 7 ajouts et 2 suppressions
|
@ -78,6 +78,7 @@ type ApiResultJSON struct {
|
|||
|
||||
type CommentJSON struct {
|
||||
Username string `json:"username"`
|
||||
UserID int `json:"user_id"`
|
||||
Content template.HTML `json:"content"`
|
||||
Date time.Time `json:"date"`
|
||||
}
|
||||
|
@ -107,10 +108,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, 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})
|
||||
}
|
||||
for _, c := range t.Comments {
|
||||
commentsJSON = append(commentsJSON, CommentJSON{Username: c.User.Username, 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})
|
||||
}
|
||||
uploader := ""
|
||||
if t.Uploader != nil {
|
||||
|
|
|
@ -68,7 +68,11 @@
|
|||
{{ range $index, $element := .Comments }}
|
||||
<div class="row comment-row" id="comment_{{$index}}">
|
||||
<div class="col-md-4">
|
||||
{{if eq .UserID -1}}
|
||||
<a href="#comment_{{$index}}">{{$index}}</a> {{.Username}}
|
||||
{{else}}
|
||||
<a href="#comment_{{$index}}">{{$index}}</a> <a href="{{$.URL.Parse (printf "/user/%d/-" .UserID) }}">{{.Username}}</a>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
{{.Content}}
|
||||
|
|
Référencer dans un nouveau ticket