{% import "fmt" %} {% import "time" %} {% import "strconv" %} {% import "github.com/bakape/meguca/auth" %} {% import "github.com/bakape/meguca/config" %} {% import "github.com/bakape/meguca/lang" %} {% import "github.com/bakape/meguca/common" %} {% import "github.com/bakape/mnemonics" %} // Header of a standalone HTML page {% func htmlHeader() %}{% stripspace %} {% endstripspace %}{% endfunc %} // End of a standalone HTML page {% func htmlEnd() %}{% stripspace %} {% endstripspace %}{% endfunc %} BanPage renders a ban page for a banned user {% func BanPage(rec auth.BanRecord) %}{% stripspace %} {%= htmlHeader() %} {% code ln := lang.Get().Templates["banPage"] %} {% if len(ln) < 3 %} {% code panic(fmt.Errorf("invalid ban format strings: %v", ln)) %} {% endif %} {% if rec.By == "system" && rec.Reason == "brum brum" %} {% endif %}
{%s= fmt.Sprintf(ln[0], bold(rec.Board), bold(rec.By)) %}

{%s rec.Reason %}

{% code exp := rec.Expires.Round(time.Second) %} {% code date := exp.Format(time.UnixDate) %} {% code till := exp.Sub(time.Now().Round(time.Second)).String() %} {%s= fmt.Sprintf(ln[1], bold(date), bold(till)) %}

{%s= fmt.Sprintf(ln[2], bold(rec.IP)) %}
{%= htmlEnd() %} {% endstripspace %}{% endfunc %} Renders a list of bans for a specific page with optional unbanning API links {% func BanList(bans []auth.BanRecord, board string, canUnban bool) %}{% stripspace %} {%= htmlHeader() %} {%= tableStyle() %} {% code ln := lang.Get() %}
{% code headers := []string{ "reason", "by", "post", "posterID", "expires", "type", } %} {% if canUnban %} {% code headers = append(headers, "unban") %} {% endif %} {%= tableHeaders(headers...) %} {% code salt := config.Get().Salt %} {% for _, b := range bans %} {% code buf := make([]byte, 0, len(salt)+len(b.IP)) %} {% code buf = append(buf, salt...) %} {% code buf = append(buf, b.IP...) %} {% if canUnban %} {% endif %} {% endfor %}
{%s b.Reason %} {%s b.By %} {%= staticPostLink(b.ForPost) %}{%s mnemonic.FantasyName(buf) %} {%s b.Expires.Format(time.UnixDate) %} {%s ln.UI[b.Type] %}
{% if canUnban %} {%= submit(false) %} {% endif %}
{%= htmlEnd() %} {% endstripspace %}{% endfunc %} Common style for plain html tables {% func tableStyle() %}{% stripspace %} {% endstripspace %}{% endfunc %} Post link, that will redirect to the post from any page {% func staticPostLink(id uint64) %}{% stripspace %} {%= postLink(common.Link{id, id, "all"}, true, true) %} {% endstripspace %}{% endfunc %} Renders a moderation log page {% func ModLog(log []auth.ModLogEntry) %}{% stripspace %} {%= htmlHeader() %} {% code ln := lang.Get() %} {%= tableStyle() %} {%= tableHeaders("type", "by", "post", "time", "data", "duration") %} {% for _, l := range log %} {% endfor %}
{% switch l.Type %} {% case common.BanPost %} {%s ln.UI["ban"] %} {% case common.ShadowBinPost %} {%s ln.UI["shadowBin"] %} {% case common.UnbanPost %} {%s ln.UI["unban"] %} {% case common.DeletePost %} {%s ln.UI["deletePost"] %} {% case common.DeleteImage %} {%s ln.UI["deleteImage"] %} {% case common.SpoilerImage %} {%s ln.UI["spoilerImage"] %} {% case common.LockThread %} {%s ln.Common.UI["lockThread"] %} {% case common.DeleteBoard %} {%s ln.Common.UI["deleteBoard"] %} {% case common.MeidoVision %} {%s ln.Common.UI["meidoVisionPost"] %} {% case common.PurgePost %} {%s ln.UI["purgePost"] %} {% case common.RedirectIP %} {%s ln.UI["redirectIP"] %} {% case common.RedirectThread %} {%s ln.UI["redirectThread"] %} {% endswitch %} {%s l.By %} {% if l.ID != 0 %} {%= staticPostLink(l.ID) %} {% endif %} {%s l.Created.Format(time.UnixDate) %} {%s l.Data %} {% if l.Length != 0 %} {%s (time.Second * time.Duration(l.Length)).String() %} {% endif %}
{%= htmlEnd() %} {% endstripspace %}{% endfunc %}