func RequireAdmin(h wombat.Handler) wombat.Handler { return func(ctx wombat.Context) { if ctx.User.IsAnonymous() { ctx.Redirect(config.SigninURL) } else if !ctx.User.IsAdmin() { if v := views.Get(fmt.Sprintf("%s%s", wombat.ERR_TMPL, "401.html")); v != nil { v.Execute(ctx.Context, data.New(ctx)) } else { ctx.HttpError(http.StatusUnauthorized) } } else { h(ctx) } } }
func (h Handler) Data(ctx wombat.Context, article interface{}, titlePath string) interface{} { if titlePath == "" { return &ArticlesData{data.New(ctx), article, h.MediaURL} } return &ArticleData{data.New(ctx), article, h.MediaURL + titlePath} }