Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/models/activity.go
akuma06 713ab02450 Added configor as a new library (#1126)
* Added configor as a new library

Now config is a singleton. You only need to do config.Get() instead of doing config.Conf.

* Forgot godep save 🐤

* Fix accidental removal of }
2017-07-10 22:11:05 +10:00

38 lignes
891 o
Go

package models
import (
"html/template"
"strings"
"github.com/NyaaPantsu/nyaa/config"
)
// Activity model
type Activity struct {
ID uint
Content string
Identifier string
Filter string
UserID uint
User *User
}
// NewActivity : Create a new activity log
func NewActivity(identifier string, filter string, c ...string) Activity {
return Activity{Identifier: identifier, Content: strings.Join(c, ","), Filter: filter}
}
// TableName : Return the name of activity table
func (a *Activity) TableName() string {
return config.Get().Models.ActivityTableName
}
// ToLocale : Convert list of parameters to message in local language
func (a *Activity) ToLocale(T func(string, ...interface{}) template.HTML) template.HTML {
c := strings.Split(a.Content, ",")
d := make([]interface{}, len(c)-1)
for i, s := range c[1:] {
d[i] = s
}
return T(c[0], d...)
}