Do not use shared variable to translate templates
This commit is contained in:
parent
6b360d08c1
commit
ddd3af4b85
21 changed files with 104 additions and 101 deletions
|
@ -14,7 +14,6 @@ import (
|
||||||
"github.com/miniflux/miniflux/locale"
|
"github.com/miniflux/miniflux/locale"
|
||||||
"github.com/miniflux/miniflux/middleware"
|
"github.com/miniflux/miniflux/middleware"
|
||||||
"github.com/miniflux/miniflux/reader/feed"
|
"github.com/miniflux/miniflux/reader/feed"
|
||||||
"github.com/miniflux/miniflux/reader/opml"
|
|
||||||
"github.com/miniflux/miniflux/scheduler"
|
"github.com/miniflux/miniflux/scheduler"
|
||||||
"github.com/miniflux/miniflux/storage"
|
"github.com/miniflux/miniflux/storage"
|
||||||
"github.com/miniflux/miniflux/template"
|
"github.com/miniflux/miniflux/template"
|
||||||
|
@ -29,7 +28,7 @@ func routes(cfg *config.Config, store *storage.Storage, feedHandler *feed.Handle
|
||||||
|
|
||||||
apiController := api.NewController(store, feedHandler)
|
apiController := api.NewController(store, feedHandler)
|
||||||
feverController := fever.NewController(store)
|
feverController := fever.NewController(store)
|
||||||
uiController := ui.NewController(cfg, store, pool, feedHandler, opml.NewHandler(store))
|
uiController := ui.NewController(cfg, store, pool, feedHandler)
|
||||||
|
|
||||||
apiHandler := handler.NewHandler(cfg, store, router, templateEngine, translator)
|
apiHandler := handler.NewHandler(cfg, store, router, templateEngine, translator)
|
||||||
feverHandler := handler.NewHandler(cfg, store, router, templateEngine, translator)
|
feverHandler := handler.NewHandler(cfg, store, router, templateEngine, translator)
|
||||||
|
|
|
@ -85,7 +85,11 @@ func (c *Context) UserLanguage() string {
|
||||||
return user.Language
|
return user.Language
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.getContextStringValue(middleware.UserLanguageContextKey)
|
language := c.getContextStringValue(middleware.UserLanguageContextKey)
|
||||||
|
if language == "" {
|
||||||
|
language = "en_US"
|
||||||
|
}
|
||||||
|
return language
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translate translates a message in the current language.
|
// Translate translates a message in the current language.
|
||||||
|
|
|
@ -41,13 +41,6 @@ func (h *Handler) Use(f ControllerFunc) http.Handler {
|
||||||
ctx := NewContext(r, h.store, h.router, h.translator)
|
ctx := NewContext(r, h.store, h.router, h.translator)
|
||||||
request := NewRequest(r)
|
request := NewRequest(r)
|
||||||
response := NewResponse(h.cfg, w, r, h.template)
|
response := NewResponse(h.cfg, w, r, h.template)
|
||||||
language := ctx.UserLanguage()
|
|
||||||
|
|
||||||
if language != "" {
|
|
||||||
h.template.SetLanguage(language)
|
|
||||||
} else {
|
|
||||||
h.template.SetLanguage("en_US")
|
|
||||||
}
|
|
||||||
|
|
||||||
f(ctx, request, response)
|
f(ctx, request, response)
|
||||||
})
|
})
|
||||||
|
|
|
@ -19,9 +19,9 @@ type HTMLResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render execute a template and send to the client the generated HTML.
|
// Render execute a template and send to the client the generated HTML.
|
||||||
func (h *HTMLResponse) Render(template string, args map[string]interface{}) {
|
func (h *HTMLResponse) Render(template, language string, args map[string]interface{}) {
|
||||||
h.writer.Header().Set("Content-Type", "text/html; charset=utf-8")
|
h.writer.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
h.template.Execute(h.writer, template, args)
|
h.template.Render(h.writer, template, language, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerError sends a 500 error to the browser.
|
// ServerError sends a 500 error to the browser.
|
||||||
|
|
|
@ -8,8 +8,10 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/miniflux/miniflux/config"
|
"github.com/miniflux/miniflux/config"
|
||||||
|
"github.com/miniflux/miniflux/errors"
|
||||||
"github.com/miniflux/miniflux/locale"
|
"github.com/miniflux/miniflux/locale"
|
||||||
"github.com/miniflux/miniflux/logger"
|
"github.com/miniflux/miniflux/logger"
|
||||||
|
|
||||||
|
@ -35,18 +37,37 @@ func (e *Engine) parseAll() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLanguage change the language for template processing.
|
// Render process a template and write the ouput.
|
||||||
func (e *Engine) SetLanguage(language string) {
|
func (e *Engine) Render(w io.Writer, name, language string, data interface{}) {
|
||||||
e.funcMap.Language = e.translator.GetLanguage(language)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute process a template.
|
|
||||||
func (e *Engine) Execute(w io.Writer, name string, data interface{}) {
|
|
||||||
tpl, ok := e.templates[name]
|
tpl, ok := e.templates[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
logger.Fatal("[Template] The template %s does not exists", name)
|
logger.Fatal("[Template] The template %s does not exists", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lang := e.translator.GetLanguage(language)
|
||||||
|
tpl.Funcs(template.FuncMap{
|
||||||
|
"elapsed": func(timezone string, t time.Time) string {
|
||||||
|
return elapsedTime(lang, timezone, t)
|
||||||
|
},
|
||||||
|
"t": func(key interface{}, args ...interface{}) string {
|
||||||
|
switch key.(type) {
|
||||||
|
case string:
|
||||||
|
return lang.Get(key.(string), args...)
|
||||||
|
case errors.LocalizedError:
|
||||||
|
return key.(errors.LocalizedError).Localize(lang)
|
||||||
|
case *errors.LocalizedError:
|
||||||
|
return key.(*errors.LocalizedError).Localize(lang)
|
||||||
|
case error:
|
||||||
|
return key.(error).Error()
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"plural": func(key string, n int, args ...interface{}) string {
|
||||||
|
return lang.Plural(key, n, args...)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
err := tpl.ExecuteTemplate(&b, "base", data)
|
err := tpl.ExecuteTemplate(&b, "base", data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -61,7 +82,7 @@ func NewEngine(cfg *config.Config, router *mux.Router, translator *locale.Transl
|
||||||
tpl := &Engine{
|
tpl := &Engine{
|
||||||
templates: make(map[string]*template.Template),
|
templates: make(map[string]*template.Template),
|
||||||
translator: translator,
|
translator: translator,
|
||||||
funcMap: newFuncMap(cfg, router, translator.GetLanguage("en_US")),
|
funcMap: newFuncMap(cfg, router),
|
||||||
}
|
}
|
||||||
|
|
||||||
tpl.parseAll()
|
tpl.parseAll()
|
||||||
|
|
|
@ -12,17 +12,14 @@ import (
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/miniflux/miniflux/config"
|
"github.com/miniflux/miniflux/config"
|
||||||
"github.com/miniflux/miniflux/errors"
|
|
||||||
"github.com/miniflux/miniflux/filter"
|
"github.com/miniflux/miniflux/filter"
|
||||||
"github.com/miniflux/miniflux/http/route"
|
"github.com/miniflux/miniflux/http/route"
|
||||||
"github.com/miniflux/miniflux/locale"
|
|
||||||
"github.com/miniflux/miniflux/url"
|
"github.com/miniflux/miniflux/url"
|
||||||
)
|
)
|
||||||
|
|
||||||
type funcMap struct {
|
type funcMap struct {
|
||||||
cfg *config.Config
|
cfg *config.Config
|
||||||
router *mux.Router
|
router *mux.Router
|
||||||
Language *locale.Language
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *funcMap) Map() template.FuncMap {
|
func (f *funcMap) Map() template.FuncMap {
|
||||||
|
@ -77,30 +74,21 @@ func (f *funcMap) Map() template.FuncMap {
|
||||||
"isodate": func(ts time.Time) string {
|
"isodate": func(ts time.Time) string {
|
||||||
return ts.Format("2006-01-02 15:04:05")
|
return ts.Format("2006-01-02 15:04:05")
|
||||||
},
|
},
|
||||||
|
"dict": dict,
|
||||||
|
|
||||||
|
// These functions are overrided at runtime after the parsing.
|
||||||
"elapsed": func(timezone string, t time.Time) string {
|
"elapsed": func(timezone string, t time.Time) string {
|
||||||
return elapsedTime(f.Language, timezone, t)
|
return ""
|
||||||
},
|
},
|
||||||
"t": func(key interface{}, args ...interface{}) string {
|
"t": func(key interface{}, args ...interface{}) string {
|
||||||
switch key.(type) {
|
return ""
|
||||||
case string:
|
|
||||||
return f.Language.Get(key.(string), args...)
|
|
||||||
case errors.LocalizedError:
|
|
||||||
return key.(errors.LocalizedError).Localize(f.Language)
|
|
||||||
case *errors.LocalizedError:
|
|
||||||
return key.(*errors.LocalizedError).Localize(f.Language)
|
|
||||||
case error:
|
|
||||||
return key.(error).Error()
|
|
||||||
default:
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"plural": func(key string, n int, args ...interface{}) string {
|
"plural": func(key string, n int, args ...interface{}) string {
|
||||||
return f.Language.Plural(key, n, args...)
|
return ""
|
||||||
},
|
},
|
||||||
"dict": dict,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newFuncMap(cfg *config.Config, router *mux.Router, language *locale.Language) *funcMap {
|
func newFuncMap(cfg *config.Config, router *mux.Router) *funcMap {
|
||||||
return &funcMap{cfg, router, language}
|
return &funcMap{cfg, router}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ func (c *Controller) AboutPage(ctx *handler.Context, request *handler.Request, r
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("about", args.Merge(tplParams{
|
response.HTML().Render("about", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"version": version.Version,
|
"version": version.Version,
|
||||||
"build_date": version.BuildDate,
|
"build_date": version.BuildDate,
|
||||||
"menu": "settings",
|
"menu": "settings",
|
||||||
|
|
|
@ -28,7 +28,7 @@ func (c *Controller) ShowCategories(ctx *handler.Context, request *handler.Reque
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("categories", args.Merge(tplParams{
|
response.HTML().Render("categories", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"categories": categories,
|
"categories": categories,
|
||||||
"total": len(categories),
|
"total": len(categories),
|
||||||
"menu": "categories",
|
"menu": "categories",
|
||||||
|
@ -71,7 +71,7 @@ func (c *Controller) ShowCategoryEntries(ctx *handler.Context, request *handler.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("category_entries", args.Merge(tplParams{
|
response.HTML().Render("category_entries", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"category": category,
|
"category": category,
|
||||||
"entries": entries,
|
"entries": entries,
|
||||||
"total": count,
|
"total": count,
|
||||||
|
@ -88,7 +88,7 @@ func (c *Controller) CreateCategory(ctx *handler.Context, request *handler.Reque
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("create_category", args.Merge(tplParams{
|
response.HTML().Render("create_category", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"menu": "categories",
|
"menu": "categories",
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ func (c *Controller) SaveCategory(ctx *handler.Context, request *handler.Request
|
||||||
|
|
||||||
categoryForm := form.NewCategoryForm(request.Request())
|
categoryForm := form.NewCategoryForm(request.Request())
|
||||||
if err := categoryForm.Validate(); err != nil {
|
if err := categoryForm.Validate(); err != nil {
|
||||||
response.HTML().Render("create_category", args.Merge(tplParams{
|
response.HTML().Render("create_category", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"errorMessage": err.Error(),
|
"errorMessage": err.Error(),
|
||||||
}))
|
}))
|
||||||
return
|
return
|
||||||
|
@ -117,7 +117,7 @@ func (c *Controller) SaveCategory(ctx *handler.Context, request *handler.Request
|
||||||
}
|
}
|
||||||
|
|
||||||
if duplicateCategory != nil {
|
if duplicateCategory != nil {
|
||||||
response.HTML().Render("create_category", args.Merge(tplParams{
|
response.HTML().Render("create_category", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"errorMessage": "This category already exists.",
|
"errorMessage": "This category already exists.",
|
||||||
}))
|
}))
|
||||||
return
|
return
|
||||||
|
@ -127,7 +127,7 @@ func (c *Controller) SaveCategory(ctx *handler.Context, request *handler.Request
|
||||||
err = c.store.CreateCategory(&category)
|
err = c.store.CreateCategory(&category)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Info("[Controller:CreateCategory] %v", err)
|
logger.Info("[Controller:CreateCategory] %v", err)
|
||||||
response.HTML().Render("create_category", args.Merge(tplParams{
|
response.HTML().Render("create_category", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"errorMessage": "Unable to create this category.",
|
"errorMessage": "Unable to create this category.",
|
||||||
}))
|
}))
|
||||||
return
|
return
|
||||||
|
@ -152,7 +152,7 @@ func (c *Controller) EditCategory(ctx *handler.Context, request *handler.Request
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("edit_category", args)
|
response.HTML().Render("edit_category", ctx.UserLanguage(), args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateCategory validate and update a category.
|
// UpdateCategory validate and update a category.
|
||||||
|
@ -173,14 +173,14 @@ func (c *Controller) UpdateCategory(ctx *handler.Context, request *handler.Reque
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := categoryForm.Validate(); err != nil {
|
if err := categoryForm.Validate(); err != nil {
|
||||||
response.HTML().Render("edit_category", args.Merge(tplParams{
|
response.HTML().Render("edit_category", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"errorMessage": err.Error(),
|
"errorMessage": err.Error(),
|
||||||
}))
|
}))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.store.AnotherCategoryExists(user.ID, category.ID, categoryForm.Title) {
|
if c.store.AnotherCategoryExists(user.ID, category.ID, categoryForm.Title) {
|
||||||
response.HTML().Render("edit_category", args.Merge(tplParams{
|
response.HTML().Render("edit_category", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"errorMessage": "This category already exists.",
|
"errorMessage": "This category already exists.",
|
||||||
}))
|
}))
|
||||||
return
|
return
|
||||||
|
@ -189,7 +189,7 @@ func (c *Controller) UpdateCategory(ctx *handler.Context, request *handler.Reque
|
||||||
err = c.store.UpdateCategory(categoryForm.Merge(category))
|
err = c.store.UpdateCategory(categoryForm.Merge(category))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("[Controller:UpdateCategory] %v", err)
|
logger.Error("[Controller:UpdateCategory] %v", err)
|
||||||
response.HTML().Render("edit_category", args.Merge(tplParams{
|
response.HTML().Render("edit_category", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"errorMessage": "Unable to update this category.",
|
"errorMessage": "Unable to update this category.",
|
||||||
}))
|
}))
|
||||||
return
|
return
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"github.com/miniflux/miniflux/http/handler"
|
"github.com/miniflux/miniflux/http/handler"
|
||||||
"github.com/miniflux/miniflux/model"
|
"github.com/miniflux/miniflux/model"
|
||||||
"github.com/miniflux/miniflux/reader/feed"
|
"github.com/miniflux/miniflux/reader/feed"
|
||||||
"github.com/miniflux/miniflux/reader/opml"
|
|
||||||
"github.com/miniflux/miniflux/scheduler"
|
"github.com/miniflux/miniflux/scheduler"
|
||||||
"github.com/miniflux/miniflux/storage"
|
"github.com/miniflux/miniflux/storage"
|
||||||
)
|
)
|
||||||
|
@ -30,7 +29,6 @@ type Controller struct {
|
||||||
store *storage.Storage
|
store *storage.Storage
|
||||||
pool *scheduler.WorkerPool
|
pool *scheduler.WorkerPool
|
||||||
feedHandler *feed.Handler
|
feedHandler *feed.Handler
|
||||||
opmlHandler *opml.Handler
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) getCommonTemplateArgs(ctx *handler.Context) (tplParams, error) {
|
func (c *Controller) getCommonTemplateArgs(ctx *handler.Context) (tplParams, error) {
|
||||||
|
@ -55,12 +53,11 @@ func (c *Controller) getCommonTemplateArgs(ctx *handler.Context) (tplParams, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewController returns a new Controller.
|
// NewController returns a new Controller.
|
||||||
func NewController(cfg *config.Config, store *storage.Storage, pool *scheduler.WorkerPool, feedHandler *feed.Handler, opmlHandler *opml.Handler) *Controller {
|
func NewController(cfg *config.Config, store *storage.Storage, pool *scheduler.WorkerPool, feedHandler *feed.Handler) *Controller {
|
||||||
return &Controller{
|
return &Controller{
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
store: store,
|
store: store,
|
||||||
pool: pool,
|
pool: pool,
|
||||||
feedHandler: feedHandler,
|
feedHandler: feedHandler,
|
||||||
opmlHandler: opmlHandler,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
ui/entry.go
10
ui/entry.go
|
@ -155,7 +155,7 @@ func (c *Controller) ShowFeedEntry(ctx *handler.Context, request *handler.Reques
|
||||||
prevEntryRoute = ctx.Route("feedEntry", "feedID", feedID, "entryID", prevEntry.ID)
|
prevEntryRoute = ctx.Route("feedEntry", "feedID", feedID, "entryID", prevEntry.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("entry", args.Merge(tplParams{
|
response.HTML().Render("entry", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"entry": entry,
|
"entry": entry,
|
||||||
"prevEntry": prevEntry,
|
"prevEntry": prevEntry,
|
||||||
"nextEntry": nextEntry,
|
"nextEntry": nextEntry,
|
||||||
|
@ -231,7 +231,7 @@ func (c *Controller) ShowCategoryEntry(ctx *handler.Context, request *handler.Re
|
||||||
prevEntryRoute = ctx.Route("categoryEntry", "categoryID", categoryID, "entryID", prevEntry.ID)
|
prevEntryRoute = ctx.Route("categoryEntry", "categoryID", categoryID, "entryID", prevEntry.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("entry", args.Merge(tplParams{
|
response.HTML().Render("entry", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"entry": entry,
|
"entry": entry,
|
||||||
"prevEntry": prevEntry,
|
"prevEntry": prevEntry,
|
||||||
"nextEntry": nextEntry,
|
"nextEntry": nextEntry,
|
||||||
|
@ -302,7 +302,7 @@ func (c *Controller) ShowUnreadEntry(ctx *handler.Context, request *handler.Requ
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("entry", args.Merge(tplParams{
|
response.HTML().Render("entry", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"entry": entry,
|
"entry": entry,
|
||||||
"prevEntry": prevEntry,
|
"prevEntry": prevEntry,
|
||||||
"nextEntry": nextEntry,
|
"nextEntry": nextEntry,
|
||||||
|
@ -362,7 +362,7 @@ func (c *Controller) ShowReadEntry(ctx *handler.Context, request *handler.Reques
|
||||||
prevEntryRoute = ctx.Route("readEntry", "entryID", prevEntry.ID)
|
prevEntryRoute = ctx.Route("readEntry", "entryID", prevEntry.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("entry", args.Merge(tplParams{
|
response.HTML().Render("entry", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"entry": entry,
|
"entry": entry,
|
||||||
"prevEntry": prevEntry,
|
"prevEntry": prevEntry,
|
||||||
"nextEntry": nextEntry,
|
"nextEntry": nextEntry,
|
||||||
|
@ -431,7 +431,7 @@ func (c *Controller) ShowStarredEntry(ctx *handler.Context, request *handler.Req
|
||||||
prevEntryRoute = ctx.Route("starredEntry", "entryID", prevEntry.ID)
|
prevEntryRoute = ctx.Route("starredEntry", "entryID", prevEntry.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("entry", args.Merge(tplParams{
|
response.HTML().Render("entry", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"entry": entry,
|
"entry": entry,
|
||||||
"prevEntry": prevEntry,
|
"prevEntry": prevEntry,
|
||||||
"nextEntry": nextEntry,
|
"nextEntry": nextEntry,
|
||||||
|
|
10
ui/feed.go
10
ui/feed.go
|
@ -45,7 +45,7 @@ func (c *Controller) ShowFeedsPage(ctx *handler.Context, request *handler.Reques
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("feeds", args.Merge(tplParams{
|
response.HTML().Render("feeds", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"feeds": feeds,
|
"feeds": feeds,
|
||||||
"total": len(feeds),
|
"total": len(feeds),
|
||||||
"menu": "feeds",
|
"menu": "feeds",
|
||||||
|
@ -88,7 +88,7 @@ func (c *Controller) ShowFeedEntries(ctx *handler.Context, request *handler.Requ
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("feed_entries", args.Merge(tplParams{
|
response.HTML().Render("feed_entries", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"feed": feed,
|
"feed": feed,
|
||||||
"entries": entries,
|
"entries": entries,
|
||||||
"total": count,
|
"total": count,
|
||||||
|
@ -112,7 +112,7 @@ func (c *Controller) EditFeed(ctx *handler.Context, request *handler.Request, re
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("edit_feed", args)
|
response.HTML().Render("edit_feed", ctx.UserLanguage(), args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateFeed update a subscription and redirect to the feed entries page.
|
// UpdateFeed update a subscription and redirect to the feed entries page.
|
||||||
|
@ -132,7 +132,7 @@ func (c *Controller) UpdateFeed(ctx *handler.Context, request *handler.Request,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := feedForm.ValidateModification(); err != nil {
|
if err := feedForm.ValidateModification(); err != nil {
|
||||||
response.HTML().Render("edit_feed", args.Merge(tplParams{
|
response.HTML().Render("edit_feed", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"errorMessage": err.Error(),
|
"errorMessage": err.Error(),
|
||||||
}))
|
}))
|
||||||
return
|
return
|
||||||
|
@ -141,7 +141,7 @@ func (c *Controller) UpdateFeed(ctx *handler.Context, request *handler.Request,
|
||||||
err = c.store.UpdateFeed(feedForm.Merge(feed))
|
err = c.store.UpdateFeed(feedForm.Merge(feed))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("[Controller:EditFeed] %v", err)
|
logger.Error("[Controller:EditFeed] %v", err)
|
||||||
response.HTML().Render("edit_feed", args.Merge(tplParams{
|
response.HTML().Render("edit_feed", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"errorMessage": "Unable to update this feed.",
|
"errorMessage": "Unable to update this feed.",
|
||||||
}))
|
}))
|
||||||
return
|
return
|
||||||
|
|
|
@ -39,7 +39,7 @@ func (c *Controller) ShowHistoryPage(ctx *handler.Context, request *handler.Requ
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("history", args.Merge(tplParams{
|
response.HTML().Render("history", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"entries": entries,
|
"entries": entries,
|
||||||
"total": count,
|
"total": count,
|
||||||
"pagination": c.getPagination(ctx.Route("history"), count, offset),
|
"pagination": c.getPagination(ctx.Route("history"), count, offset),
|
||||||
|
|
|
@ -27,7 +27,7 @@ func (c *Controller) ShowIntegrations(ctx *handler.Context, request *handler.Req
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("integrations", args.Merge(tplParams{
|
response.HTML().Render("integrations", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"menu": "settings",
|
"menu": "settings",
|
||||||
"form": form.IntegrationForm{
|
"form": form.IntegrationForm{
|
||||||
PinboardEnabled: integration.PinboardEnabled,
|
PinboardEnabled: integration.PinboardEnabled,
|
||||||
|
|
|
@ -20,7 +20,7 @@ func (c *Controller) ShowLoginPage(ctx *handler.Context, request *handler.Reques
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("login", tplParams{
|
response.HTML().Render("login", ctx.UserLanguage(), tplParams{
|
||||||
"csrf": ctx.CSRF(),
|
"csrf": ctx.CSRF(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -36,13 +36,13 @@ func (c *Controller) CheckLogin(ctx *handler.Context, request *handler.Request,
|
||||||
|
|
||||||
if err := authForm.Validate(); err != nil {
|
if err := authForm.Validate(); err != nil {
|
||||||
logger.Error("[Controller:CheckLogin] %v", err)
|
logger.Error("[Controller:CheckLogin] %v", err)
|
||||||
response.HTML().Render("login", tplParams)
|
response.HTML().Render("login", ctx.UserLanguage(), tplParams)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.store.CheckPassword(authForm.Username, authForm.Password); err != nil {
|
if err := c.store.CheckPassword(authForm.Username, authForm.Password); err != nil {
|
||||||
logger.Error("[Controller:CheckLogin] %v", err)
|
logger.Error("[Controller:CheckLogin] %v", err)
|
||||||
response.HTML().Render("login", tplParams)
|
response.HTML().Render("login", ctx.UserLanguage(), tplParams)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,13 @@ package ui
|
||||||
import (
|
import (
|
||||||
"github.com/miniflux/miniflux/http/handler"
|
"github.com/miniflux/miniflux/http/handler"
|
||||||
"github.com/miniflux/miniflux/logger"
|
"github.com/miniflux/miniflux/logger"
|
||||||
|
"github.com/miniflux/miniflux/reader/opml"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Export generates the OPML file.
|
// Export generates the OPML file.
|
||||||
func (c *Controller) Export(ctx *handler.Context, request *handler.Request, response *handler.Response) {
|
func (c *Controller) Export(ctx *handler.Context, request *handler.Request, response *handler.Response) {
|
||||||
user := ctx.LoggedUser()
|
user := ctx.LoggedUser()
|
||||||
opml, err := c.opmlHandler.Export(user.ID)
|
opml, err := opml.NewHandler(c.store).Export(user.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
response.HTML().ServerError(err)
|
response.HTML().ServerError(err)
|
||||||
return
|
return
|
||||||
|
@ -29,7 +30,7 @@ func (c *Controller) Import(ctx *handler.Context, request *handler.Request, resp
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("import", args.Merge(tplParams{
|
response.HTML().Render("import", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"menu": "feeds",
|
"menu": "feeds",
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -52,14 +53,14 @@ func (c *Controller) UploadOPML(ctx *handler.Context, request *handler.Request,
|
||||||
fileHeader.Size,
|
fileHeader.Size,
|
||||||
)
|
)
|
||||||
|
|
||||||
if impErr := c.opmlHandler.Import(user.ID, file); impErr != nil {
|
if impErr := opml.NewHandler(c.store).Import(user.ID, file); impErr != nil {
|
||||||
args, err := c.getCommonTemplateArgs(ctx)
|
args, err := c.getCommonTemplateArgs(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
response.HTML().ServerError(err)
|
response.HTML().ServerError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("import", args.Merge(tplParams{
|
response.HTML().Render("import", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"errorMessage": impErr,
|
"errorMessage": impErr,
|
||||||
"menu": "feeds",
|
"menu": "feeds",
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -25,7 +25,7 @@ func (c *Controller) ShowSessions(ctx *handler.Context, request *handler.Request
|
||||||
}
|
}
|
||||||
|
|
||||||
sessions.UseTimezone(user.Timezone)
|
sessions.UseTimezone(user.Timezone)
|
||||||
response.HTML().Render("sessions", args.Merge(tplParams{
|
response.HTML().Render("sessions", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"sessions": sessions,
|
"sessions": sessions,
|
||||||
"currentSessionToken": ctx.UserSessionToken(),
|
"currentSessionToken": ctx.UserSessionToken(),
|
||||||
"menu": "settings",
|
"menu": "settings",
|
||||||
|
|
|
@ -22,7 +22,7 @@ func (c *Controller) ShowSettings(ctx *handler.Context, request *handler.Request
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("settings", args)
|
response.HTML().Render("settings", ctx.UserLanguage(), args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateSettings update the settings.
|
// UpdateSettings update the settings.
|
||||||
|
@ -37,7 +37,7 @@ func (c *Controller) UpdateSettings(ctx *handler.Context, request *handler.Reque
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := settingsForm.Validate(); err != nil {
|
if err := settingsForm.Validate(); err != nil {
|
||||||
response.HTML().Render("settings", args.Merge(tplParams{
|
response.HTML().Render("settings", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"form": settingsForm,
|
"form": settingsForm,
|
||||||
"errorMessage": err.Error(),
|
"errorMessage": err.Error(),
|
||||||
}))
|
}))
|
||||||
|
@ -45,7 +45,7 @@ func (c *Controller) UpdateSettings(ctx *handler.Context, request *handler.Reque
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.store.AnotherUserExists(user.ID, settingsForm.Username) {
|
if c.store.AnotherUserExists(user.ID, settingsForm.Username) {
|
||||||
response.HTML().Render("settings", args.Merge(tplParams{
|
response.HTML().Render("settings", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"form": settingsForm,
|
"form": settingsForm,
|
||||||
"errorMessage": "This user already exists.",
|
"errorMessage": "This user already exists.",
|
||||||
}))
|
}))
|
||||||
|
@ -55,7 +55,7 @@ func (c *Controller) UpdateSettings(ctx *handler.Context, request *handler.Reque
|
||||||
err = c.store.UpdateUser(settingsForm.Merge(user))
|
err = c.store.UpdateUser(settingsForm.Merge(user))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("[Controller:UpdateSettings] %v", err)
|
logger.Error("[Controller:UpdateSettings] %v", err)
|
||||||
response.HTML().Render("settings", args.Merge(tplParams{
|
response.HTML().Render("settings", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"form": settingsForm,
|
"form": settingsForm,
|
||||||
"errorMessage": "Unable to update this user.",
|
"errorMessage": "Unable to update this user.",
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (c *Controller) ShowStarredPage(ctx *handler.Context, request *handler.Requ
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("starred", args.Merge(tplParams{
|
response.HTML().Render("starred", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"entries": entries,
|
"entries": entries,
|
||||||
"total": count,
|
"total": count,
|
||||||
"pagination": c.getPagination(ctx.Route("starred"), count, offset),
|
"pagination": c.getPagination(ctx.Route("starred"), count, offset),
|
||||||
|
|
|
@ -22,7 +22,7 @@ func (c *Controller) Bookmarklet(ctx *handler.Context, request *handler.Request,
|
||||||
}
|
}
|
||||||
|
|
||||||
bookmarkletURL := request.QueryStringParam("uri", "")
|
bookmarkletURL := request.QueryStringParam("uri", "")
|
||||||
response.HTML().Render("add_subscription", args.Merge(tplParams{
|
response.HTML().Render("add_subscription", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"form": &form.SubscriptionForm{URL: bookmarkletURL},
|
"form": &form.SubscriptionForm{URL: bookmarkletURL},
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func (c *Controller) AddSubscription(ctx *handler.Context, request *handler.Requ
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("add_subscription", args)
|
response.HTML().Render("add_subscription", ctx.UserLanguage(), args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubmitSubscription try to find a feed from the URL provided by the user.
|
// SubmitSubscription try to find a feed from the URL provided by the user.
|
||||||
|
@ -52,7 +52,7 @@ func (c *Controller) SubmitSubscription(ctx *handler.Context, request *handler.R
|
||||||
|
|
||||||
subscriptionForm := form.NewSubscriptionForm(request.Request())
|
subscriptionForm := form.NewSubscriptionForm(request.Request())
|
||||||
if err := subscriptionForm.Validate(); err != nil {
|
if err := subscriptionForm.Validate(); err != nil {
|
||||||
response.HTML().Render("add_subscription", args.Merge(tplParams{
|
response.HTML().Render("add_subscription", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"form": subscriptionForm,
|
"form": subscriptionForm,
|
||||||
"errorMessage": err.Error(),
|
"errorMessage": err.Error(),
|
||||||
}))
|
}))
|
||||||
|
@ -62,7 +62,7 @@ func (c *Controller) SubmitSubscription(ctx *handler.Context, request *handler.R
|
||||||
subscriptions, err := subscription.FindSubscriptions(subscriptionForm.URL)
|
subscriptions, err := subscription.FindSubscriptions(subscriptionForm.URL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("[Controller:SubmitSubscription] %v", err)
|
logger.Error("[Controller:SubmitSubscription] %v", err)
|
||||||
response.HTML().Render("add_subscription", args.Merge(tplParams{
|
response.HTML().Render("add_subscription", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"form": subscriptionForm,
|
"form": subscriptionForm,
|
||||||
"errorMessage": err,
|
"errorMessage": err,
|
||||||
}))
|
}))
|
||||||
|
@ -74,14 +74,14 @@ func (c *Controller) SubmitSubscription(ctx *handler.Context, request *handler.R
|
||||||
n := len(subscriptions)
|
n := len(subscriptions)
|
||||||
switch {
|
switch {
|
||||||
case n == 0:
|
case n == 0:
|
||||||
response.HTML().Render("add_subscription", args.Merge(tplParams{
|
response.HTML().Render("add_subscription", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"form": subscriptionForm,
|
"form": subscriptionForm,
|
||||||
"errorMessage": "Unable to find any subscription.",
|
"errorMessage": "Unable to find any subscription.",
|
||||||
}))
|
}))
|
||||||
case n == 1:
|
case n == 1:
|
||||||
feed, err := c.feedHandler.CreateFeed(user.ID, subscriptionForm.CategoryID, subscriptions[0].URL, subscriptionForm.Crawler)
|
feed, err := c.feedHandler.CreateFeed(user.ID, subscriptionForm.CategoryID, subscriptions[0].URL, subscriptionForm.Crawler)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
response.HTML().Render("add_subscription", args.Merge(tplParams{
|
response.HTML().Render("add_subscription", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"form": subscriptionForm,
|
"form": subscriptionForm,
|
||||||
"errorMessage": err,
|
"errorMessage": err,
|
||||||
}))
|
}))
|
||||||
|
@ -90,7 +90,7 @@ func (c *Controller) SubmitSubscription(ctx *handler.Context, request *handler.R
|
||||||
|
|
||||||
response.Redirect(ctx.Route("feedEntries", "feedID", feed.ID))
|
response.Redirect(ctx.Route("feedEntries", "feedID", feed.ID))
|
||||||
case n > 1:
|
case n > 1:
|
||||||
response.HTML().Render("choose_subscription", args.Merge(tplParams{
|
response.HTML().Render("choose_subscription", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"categoryID": subscriptionForm.CategoryID,
|
"categoryID": subscriptionForm.CategoryID,
|
||||||
"subscriptions": subscriptions,
|
"subscriptions": subscriptions,
|
||||||
}))
|
}))
|
||||||
|
@ -109,7 +109,7 @@ func (c *Controller) ChooseSubscription(ctx *handler.Context, request *handler.R
|
||||||
|
|
||||||
subscriptionForm := form.NewSubscriptionForm(request.Request())
|
subscriptionForm := form.NewSubscriptionForm(request.Request())
|
||||||
if err := subscriptionForm.Validate(); err != nil {
|
if err := subscriptionForm.Validate(); err != nil {
|
||||||
response.HTML().Render("add_subscription", args.Merge(tplParams{
|
response.HTML().Render("add_subscription", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"form": subscriptionForm,
|
"form": subscriptionForm,
|
||||||
"errorMessage": err.Error(),
|
"errorMessage": err.Error(),
|
||||||
}))
|
}))
|
||||||
|
@ -118,7 +118,7 @@ func (c *Controller) ChooseSubscription(ctx *handler.Context, request *handler.R
|
||||||
|
|
||||||
feed, err := c.feedHandler.CreateFeed(user.ID, subscriptionForm.CategoryID, subscriptionForm.URL, subscriptionForm.Crawler)
|
feed, err := c.feedHandler.CreateFeed(user.ID, subscriptionForm.CategoryID, subscriptionForm.URL, subscriptionForm.Crawler)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
response.HTML().Render("add_subscription", args.Merge(tplParams{
|
response.HTML().Render("add_subscription", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"form": subscriptionForm,
|
"form": subscriptionForm,
|
||||||
"errorMessage": err,
|
"errorMessage": err,
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -39,7 +39,7 @@ func (c *Controller) ShowUnreadPage(ctx *handler.Context, request *handler.Reque
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("unread", tplParams{
|
response.HTML().Render("unread", ctx.UserLanguage(), tplParams{
|
||||||
"user": user,
|
"user": user,
|
||||||
"countUnread": countUnread,
|
"countUnread": countUnread,
|
||||||
"entries": entries,
|
"entries": entries,
|
||||||
|
|
18
ui/user.go
18
ui/user.go
|
@ -35,7 +35,7 @@ func (c *Controller) ShowUsers(ctx *handler.Context, request *handler.Request, r
|
||||||
}
|
}
|
||||||
|
|
||||||
users.UseTimezone(user.Timezone)
|
users.UseTimezone(user.Timezone)
|
||||||
response.HTML().Render("users", args.Merge(tplParams{
|
response.HTML().Render("users", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"users": users,
|
"users": users,
|
||||||
"menu": "settings",
|
"menu": "settings",
|
||||||
}))
|
}))
|
||||||
|
@ -56,7 +56,7 @@ func (c *Controller) CreateUser(ctx *handler.Context, request *handler.Request,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("create_user", args.Merge(tplParams{
|
response.HTML().Render("create_user", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"menu": "settings",
|
"menu": "settings",
|
||||||
"form": &form.UserForm{},
|
"form": &form.UserForm{},
|
||||||
}))
|
}))
|
||||||
|
@ -79,7 +79,7 @@ func (c *Controller) SaveUser(ctx *handler.Context, request *handler.Request, re
|
||||||
|
|
||||||
userForm := form.NewUserForm(request.Request())
|
userForm := form.NewUserForm(request.Request())
|
||||||
if err := userForm.ValidateCreation(); err != nil {
|
if err := userForm.ValidateCreation(); err != nil {
|
||||||
response.HTML().Render("create_user", args.Merge(tplParams{
|
response.HTML().Render("create_user", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"menu": "settings",
|
"menu": "settings",
|
||||||
"form": userForm,
|
"form": userForm,
|
||||||
"errorMessage": err.Error(),
|
"errorMessage": err.Error(),
|
||||||
|
@ -88,7 +88,7 @@ func (c *Controller) SaveUser(ctx *handler.Context, request *handler.Request, re
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.store.UserExists(userForm.Username) {
|
if c.store.UserExists(userForm.Username) {
|
||||||
response.HTML().Render("create_user", args.Merge(tplParams{
|
response.HTML().Render("create_user", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"menu": "settings",
|
"menu": "settings",
|
||||||
"form": userForm,
|
"form": userForm,
|
||||||
"errorMessage": "This user already exists.",
|
"errorMessage": "This user already exists.",
|
||||||
|
@ -99,7 +99,7 @@ func (c *Controller) SaveUser(ctx *handler.Context, request *handler.Request, re
|
||||||
newUser := userForm.ToUser()
|
newUser := userForm.ToUser()
|
||||||
if err := c.store.CreateUser(newUser); err != nil {
|
if err := c.store.CreateUser(newUser); err != nil {
|
||||||
logger.Error("[Controller:SaveUser] %v", err)
|
logger.Error("[Controller:SaveUser] %v", err)
|
||||||
response.HTML().Render("edit_user", args.Merge(tplParams{
|
response.HTML().Render("edit_user", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"menu": "settings",
|
"menu": "settings",
|
||||||
"form": userForm,
|
"form": userForm,
|
||||||
"errorMessage": "Unable to create this user.",
|
"errorMessage": "Unable to create this user.",
|
||||||
|
@ -130,7 +130,7 @@ func (c *Controller) EditUser(ctx *handler.Context, request *handler.Request, re
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.HTML().Render("edit_user", args.Merge(tplParams{
|
response.HTML().Render("edit_user", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"menu": "settings",
|
"menu": "settings",
|
||||||
"selected_user": selectedUser,
|
"selected_user": selectedUser,
|
||||||
"form": &form.UserForm{
|
"form": &form.UserForm{
|
||||||
|
@ -162,7 +162,7 @@ func (c *Controller) UpdateUser(ctx *handler.Context, request *handler.Request,
|
||||||
|
|
||||||
userForm := form.NewUserForm(request.Request())
|
userForm := form.NewUserForm(request.Request())
|
||||||
if err := userForm.ValidateModification(); err != nil {
|
if err := userForm.ValidateModification(); err != nil {
|
||||||
response.HTML().Render("edit_user", args.Merge(tplParams{
|
response.HTML().Render("edit_user", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"menu": "settings",
|
"menu": "settings",
|
||||||
"selected_user": selectedUser,
|
"selected_user": selectedUser,
|
||||||
"form": userForm,
|
"form": userForm,
|
||||||
|
@ -172,7 +172,7 @@ func (c *Controller) UpdateUser(ctx *handler.Context, request *handler.Request,
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.store.AnotherUserExists(selectedUser.ID, userForm.Username) {
|
if c.store.AnotherUserExists(selectedUser.ID, userForm.Username) {
|
||||||
response.HTML().Render("edit_user", args.Merge(tplParams{
|
response.HTML().Render("edit_user", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"menu": "settings",
|
"menu": "settings",
|
||||||
"selected_user": selectedUser,
|
"selected_user": selectedUser,
|
||||||
"form": userForm,
|
"form": userForm,
|
||||||
|
@ -184,7 +184,7 @@ func (c *Controller) UpdateUser(ctx *handler.Context, request *handler.Request,
|
||||||
userForm.Merge(selectedUser)
|
userForm.Merge(selectedUser)
|
||||||
if err := c.store.UpdateUser(selectedUser); err != nil {
|
if err := c.store.UpdateUser(selectedUser); err != nil {
|
||||||
logger.Error("[Controller:UpdateUser] %v", err)
|
logger.Error("[Controller:UpdateUser] %v", err)
|
||||||
response.HTML().Render("edit_user", args.Merge(tplParams{
|
response.HTML().Render("edit_user", ctx.UserLanguage(), args.Merge(tplParams{
|
||||||
"menu": "settings",
|
"menu": "settings",
|
||||||
"selected_user": selectedUser,
|
"selected_user": selectedUser,
|
||||||
"form": userForm,
|
"form": userForm,
|
||||||
|
|
Loading…
Reference in a new issue