mirror of
https://github.com/miniflux/v2.git
synced 2025-07-22 17:18:37 +00:00
Improve Context to be more idiomatic
This commit is contained in:
parent
02ff7b4bcf
commit
1bc43ec2bc
17 changed files with 107 additions and 106 deletions
|
@ -21,7 +21,7 @@ func (c *Controller) ShowCategories(ctx *core.Context, request *core.Request, re
|
|||
return
|
||||
}
|
||||
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
categories, err := c.store.GetCategoriesWithFeedCount(user.ID)
|
||||
if err != nil {
|
||||
response.HTML().ServerError(err)
|
||||
|
@ -37,7 +37,7 @@ func (c *Controller) ShowCategories(ctx *core.Context, request *core.Request, re
|
|||
|
||||
// ShowCategoryEntries shows all entries for the given category.
|
||||
func (c *Controller) ShowCategoryEntries(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
offset := request.QueryIntegerParam("offset", 0)
|
||||
|
||||
args, err := c.getCommonTemplateArgs(ctx)
|
||||
|
@ -75,7 +75,7 @@ func (c *Controller) ShowCategoryEntries(ctx *core.Context, request *core.Reques
|
|||
"category": category,
|
||||
"entries": entries,
|
||||
"total": count,
|
||||
"pagination": c.getPagination(ctx.GetRoute("categoryEntries", "categoryID", category.ID), count, offset),
|
||||
"pagination": c.getPagination(ctx.Route("categoryEntries", "categoryID", category.ID), count, offset),
|
||||
"menu": "categories",
|
||||
}))
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ func (c *Controller) CreateCategory(ctx *core.Context, request *core.Request, re
|
|||
|
||||
// SaveCategory validate and save the new category into the database.
|
||||
func (c *Controller) SaveCategory(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
args, err := c.getCommonTemplateArgs(ctx)
|
||||
if err != nil {
|
||||
response.HTML().ServerError(err)
|
||||
|
@ -133,12 +133,12 @@ func (c *Controller) SaveCategory(ctx *core.Context, request *core.Request, resp
|
|||
return
|
||||
}
|
||||
|
||||
response.Redirect(ctx.GetRoute("categories"))
|
||||
response.Redirect(ctx.Route("categories"))
|
||||
}
|
||||
|
||||
// EditCategory shows the form to modify a category.
|
||||
func (c *Controller) EditCategory(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
category, err := c.getCategoryFromURL(ctx, request, response)
|
||||
if err != nil {
|
||||
|
@ -157,7 +157,7 @@ func (c *Controller) EditCategory(ctx *core.Context, request *core.Request, resp
|
|||
|
||||
// UpdateCategory validate and update a category.
|
||||
func (c *Controller) UpdateCategory(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
category, err := c.getCategoryFromURL(ctx, request, response)
|
||||
if err != nil {
|
||||
|
@ -195,12 +195,12 @@ func (c *Controller) UpdateCategory(ctx *core.Context, request *core.Request, re
|
|||
return
|
||||
}
|
||||
|
||||
response.Redirect(ctx.GetRoute("categories"))
|
||||
response.Redirect(ctx.Route("categories"))
|
||||
}
|
||||
|
||||
// RemoveCategory delete a category from the database.
|
||||
func (c *Controller) RemoveCategory(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
category, err := c.getCategoryFromURL(ctx, request, response)
|
||||
if err != nil {
|
||||
|
@ -212,7 +212,7 @@ func (c *Controller) RemoveCategory(ctx *core.Context, request *core.Request, re
|
|||
return
|
||||
}
|
||||
|
||||
response.Redirect(ctx.GetRoute("categories"))
|
||||
response.Redirect(ctx.Route("categories"))
|
||||
}
|
||||
|
||||
func (c *Controller) getCategoryFromURL(ctx *core.Context, request *core.Request, response *core.Response) (*model.Category, error) {
|
||||
|
@ -222,7 +222,7 @@ func (c *Controller) getCategoryFromURL(ctx *core.Context, request *core.Request
|
|||
return nil, err
|
||||
}
|
||||
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
category, err := c.store.GetCategory(user.ID, categoryID)
|
||||
if err != nil {
|
||||
response.HTML().ServerError(err)
|
||||
|
|
|
@ -29,7 +29,7 @@ type Controller struct {
|
|||
}
|
||||
|
||||
func (c *Controller) getCommonTemplateArgs(ctx *core.Context) (tplParams, error) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
builder := c.store.GetEntryQueryBuilder(user.ID, user.Timezone)
|
||||
builder.WithStatus(model.EntryStatusUnread)
|
||||
|
||||
|
@ -42,7 +42,7 @@ func (c *Controller) getCommonTemplateArgs(ctx *core.Context) (tplParams, error)
|
|||
"menu": "",
|
||||
"user": user,
|
||||
"countUnread": countUnread,
|
||||
"csrf": ctx.GetCsrfToken(),
|
||||
"csrf": ctx.CsrfToken(),
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
// ShowFeedEntry shows a single feed entry in "feed" mode.
|
||||
func (c *Controller) ShowFeedEntry(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
sortingDirection := model.DefaultSortingDirection
|
||||
|
||||
entryID, err := request.IntegerParam("entryID")
|
||||
|
@ -80,12 +80,12 @@ func (c *Controller) ShowFeedEntry(ctx *core.Context, request *core.Request, res
|
|||
|
||||
nextEntryRoute := ""
|
||||
if nextEntry != nil {
|
||||
nextEntryRoute = ctx.GetRoute("feedEntry", "feedID", feedID, "entryID", nextEntry.ID)
|
||||
nextEntryRoute = ctx.Route("feedEntry", "feedID", feedID, "entryID", nextEntry.ID)
|
||||
}
|
||||
|
||||
prevEntryRoute := ""
|
||||
if prevEntry != nil {
|
||||
prevEntryRoute = ctx.GetRoute("feedEntry", "feedID", feedID, "entryID", prevEntry.ID)
|
||||
prevEntryRoute = ctx.Route("feedEntry", "feedID", feedID, "entryID", prevEntry.ID)
|
||||
}
|
||||
|
||||
if entry.Status == model.EntryStatusUnread {
|
||||
|
@ -108,7 +108,7 @@ func (c *Controller) ShowFeedEntry(ctx *core.Context, request *core.Request, res
|
|||
|
||||
// ShowCategoryEntry shows a single feed entry in "category" mode.
|
||||
func (c *Controller) ShowCategoryEntry(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
sortingDirection := model.DefaultSortingDirection
|
||||
|
||||
categoryID, err := request.IntegerParam("categoryID")
|
||||
|
@ -173,12 +173,12 @@ func (c *Controller) ShowCategoryEntry(ctx *core.Context, request *core.Request,
|
|||
|
||||
nextEntryRoute := ""
|
||||
if nextEntry != nil {
|
||||
nextEntryRoute = ctx.GetRoute("categoryEntry", "categoryID", categoryID, "entryID", nextEntry.ID)
|
||||
nextEntryRoute = ctx.Route("categoryEntry", "categoryID", categoryID, "entryID", nextEntry.ID)
|
||||
}
|
||||
|
||||
prevEntryRoute := ""
|
||||
if prevEntry != nil {
|
||||
prevEntryRoute = ctx.GetRoute("categoryEntry", "categoryID", categoryID, "entryID", prevEntry.ID)
|
||||
prevEntryRoute = ctx.Route("categoryEntry", "categoryID", categoryID, "entryID", prevEntry.ID)
|
||||
}
|
||||
|
||||
if entry.Status == model.EntryStatusUnread {
|
||||
|
@ -202,7 +202,7 @@ func (c *Controller) ShowCategoryEntry(ctx *core.Context, request *core.Request,
|
|||
|
||||
// ShowUnreadEntry shows a single feed entry in "unread" mode.
|
||||
func (c *Controller) ShowUnreadEntry(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
sortingDirection := model.DefaultSortingDirection
|
||||
|
||||
entryID, err := request.IntegerParam("entryID")
|
||||
|
@ -260,12 +260,12 @@ func (c *Controller) ShowUnreadEntry(ctx *core.Context, request *core.Request, r
|
|||
|
||||
nextEntryRoute := ""
|
||||
if nextEntry != nil {
|
||||
nextEntryRoute = ctx.GetRoute("unreadEntry", "entryID", nextEntry.ID)
|
||||
nextEntryRoute = ctx.Route("unreadEntry", "entryID", nextEntry.ID)
|
||||
}
|
||||
|
||||
prevEntryRoute := ""
|
||||
if prevEntry != nil {
|
||||
prevEntryRoute = ctx.GetRoute("unreadEntry", "entryID", prevEntry.ID)
|
||||
prevEntryRoute = ctx.Route("unreadEntry", "entryID", prevEntry.ID)
|
||||
}
|
||||
|
||||
if entry.Status == model.EntryStatusUnread {
|
||||
|
@ -289,7 +289,7 @@ func (c *Controller) ShowUnreadEntry(ctx *core.Context, request *core.Request, r
|
|||
|
||||
// ShowReadEntry shows a single feed entry in "history" mode.
|
||||
func (c *Controller) ShowReadEntry(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
sortingDirection := model.DefaultSortingDirection
|
||||
|
||||
entryID, err := request.IntegerParam("entryID")
|
||||
|
@ -347,12 +347,12 @@ func (c *Controller) ShowReadEntry(ctx *core.Context, request *core.Request, res
|
|||
|
||||
nextEntryRoute := ""
|
||||
if nextEntry != nil {
|
||||
nextEntryRoute = ctx.GetRoute("readEntry", "entryID", nextEntry.ID)
|
||||
nextEntryRoute = ctx.Route("readEntry", "entryID", nextEntry.ID)
|
||||
}
|
||||
|
||||
prevEntryRoute := ""
|
||||
if prevEntry != nil {
|
||||
prevEntryRoute = ctx.GetRoute("readEntry", "entryID", prevEntry.ID)
|
||||
prevEntryRoute = ctx.Route("readEntry", "entryID", prevEntry.ID)
|
||||
}
|
||||
|
||||
response.HTML().Render("entry", args.Merge(tplParams{
|
||||
|
@ -367,7 +367,7 @@ func (c *Controller) ShowReadEntry(ctx *core.Context, request *core.Request, res
|
|||
|
||||
// UpdateEntriesStatus handles Ajax request to update the status for a list of entries.
|
||||
func (c *Controller) UpdateEntriesStatus(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
entryIDs, status, err := payload.DecodeEntryStatusPayload(request.Body())
|
||||
if err != nil {
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
// ShowFeedsPage shows the page with all subscriptions.
|
||||
func (c *Controller) ShowFeedsPage(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
args, err := c.getCommonTemplateArgs(ctx)
|
||||
if err != nil {
|
||||
|
@ -38,7 +38,7 @@ func (c *Controller) ShowFeedsPage(ctx *core.Context, request *core.Request, res
|
|||
|
||||
// ShowFeedEntries shows all entries for the given feed.
|
||||
func (c *Controller) ShowFeedEntries(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
offset := request.QueryIntegerParam("offset", 0)
|
||||
|
||||
args, err := c.getCommonTemplateArgs(ctx)
|
||||
|
@ -76,14 +76,14 @@ func (c *Controller) ShowFeedEntries(ctx *core.Context, request *core.Request, r
|
|||
"feed": feed,
|
||||
"entries": entries,
|
||||
"total": count,
|
||||
"pagination": c.getPagination(ctx.GetRoute("feedEntries", "feedID", feed.ID), count, offset),
|
||||
"pagination": c.getPagination(ctx.Route("feedEntries", "feedID", feed.ID), count, offset),
|
||||
"menu": "feeds",
|
||||
}))
|
||||
}
|
||||
|
||||
// EditFeed shows the form to modify a subscription.
|
||||
func (c *Controller) EditFeed(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
feed, err := c.getFeedFromURL(request, response, user)
|
||||
if err != nil {
|
||||
|
@ -101,7 +101,7 @@ func (c *Controller) EditFeed(ctx *core.Context, request *core.Request, response
|
|||
|
||||
// UpdateFeed update a subscription and redirect to the feed entries page.
|
||||
func (c *Controller) UpdateFeed(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
feed, err := c.getFeedFromURL(request, response, user)
|
||||
if err != nil {
|
||||
|
@ -131,7 +131,7 @@ func (c *Controller) UpdateFeed(ctx *core.Context, request *core.Request, respon
|
|||
return
|
||||
}
|
||||
|
||||
response.Redirect(ctx.GetRoute("feedEntries", "feedID", feed.ID))
|
||||
response.Redirect(ctx.Route("feedEntries", "feedID", feed.ID))
|
||||
}
|
||||
|
||||
// RemoveFeed delete a subscription from the database and redirect to the list of feeds page.
|
||||
|
@ -142,13 +142,13 @@ func (c *Controller) RemoveFeed(ctx *core.Context, request *core.Request, respon
|
|||
return
|
||||
}
|
||||
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
if err := c.store.RemoveFeed(user.ID, feedID); err != nil {
|
||||
response.HTML().ServerError(err)
|
||||
return
|
||||
}
|
||||
|
||||
response.Redirect(ctx.GetRoute("feeds"))
|
||||
response.Redirect(ctx.Route("feeds"))
|
||||
}
|
||||
|
||||
// RefreshFeed refresh a subscription and redirect to the feed entries page.
|
||||
|
@ -159,12 +159,12 @@ func (c *Controller) RefreshFeed(ctx *core.Context, request *core.Request, respo
|
|||
return
|
||||
}
|
||||
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
if err := c.feedHandler.RefreshFeed(user.ID, feedID); err != nil {
|
||||
log.Println("[UI:RefreshFeed]", err)
|
||||
}
|
||||
|
||||
response.Redirect(ctx.GetRoute("feedEntries", "feedID", feedID))
|
||||
response.Redirect(ctx.Route("feedEntries", "feedID", feedID))
|
||||
}
|
||||
|
||||
func (c *Controller) getFeedFromURL(request *core.Request, response *core.Response, user *model.User) (*model.Feed, error) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
// ShowHistoryPage renders the page with all read entries.
|
||||
func (c *Controller) ShowHistoryPage(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
offset := request.QueryIntegerParam("offset", 0)
|
||||
|
||||
args, err := c.getCommonTemplateArgs(ctx)
|
||||
|
@ -42,14 +42,14 @@ func (c *Controller) ShowHistoryPage(ctx *core.Context, request *core.Request, r
|
|||
response.HTML().Render("history", args.Merge(tplParams{
|
||||
"entries": entries,
|
||||
"total": count,
|
||||
"pagination": c.getPagination(ctx.GetRoute("history"), count, offset),
|
||||
"pagination": c.getPagination(ctx.Route("history"), count, offset),
|
||||
"menu": "history",
|
||||
}))
|
||||
}
|
||||
|
||||
// FlushHistory changes all "read" items to "removed".
|
||||
func (c *Controller) FlushHistory(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
err := c.store.FlushHistory(user.ID)
|
||||
if err != nil {
|
||||
|
@ -57,5 +57,5 @@ func (c *Controller) FlushHistory(ctx *core.Context, request *core.Request, resp
|
|||
return
|
||||
}
|
||||
|
||||
response.Redirect(ctx.GetRoute("history"))
|
||||
response.Redirect(ctx.Route("history"))
|
||||
}
|
||||
|
|
|
@ -16,12 +16,12 @@ import (
|
|||
|
||||
func (c *Controller) ShowLoginPage(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
if ctx.IsAuthenticated() {
|
||||
response.Redirect(ctx.GetRoute("unread"))
|
||||
response.Redirect(ctx.Route("unread"))
|
||||
return
|
||||
}
|
||||
|
||||
response.HTML().Render("login", tplParams{
|
||||
"csrf": ctx.GetCsrfToken(),
|
||||
"csrf": ctx.CsrfToken(),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ func (c *Controller) CheckLogin(ctx *core.Context, request *core.Request, respon
|
|||
authForm := form.NewAuthForm(request.Request())
|
||||
tplParams := tplParams{
|
||||
"errorMessage": "Invalid username or password.",
|
||||
"csrf": ctx.GetCsrfToken(),
|
||||
"csrf": ctx.CsrfToken(),
|
||||
}
|
||||
|
||||
if err := authForm.Validate(); err != nil {
|
||||
|
@ -65,11 +65,11 @@ func (c *Controller) CheckLogin(ctx *core.Context, request *core.Request, respon
|
|||
}
|
||||
|
||||
response.SetCookie(cookie)
|
||||
response.Redirect(ctx.GetRoute("unread"))
|
||||
response.Redirect(ctx.Route("unread"))
|
||||
}
|
||||
|
||||
func (c *Controller) Logout(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
sessionCookie := request.Cookie("sessionID")
|
||||
if err := c.store.RemoveSessionByToken(user.ID, sessionCookie); err != nil {
|
||||
|
@ -87,5 +87,5 @@ func (c *Controller) Logout(ctx *core.Context, request *core.Request, response *
|
|||
}
|
||||
|
||||
response.SetCookie(cookie)
|
||||
response.Redirect(ctx.GetRoute("login"))
|
||||
response.Redirect(ctx.Route("login"))
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
func (c *Controller) Export(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
opml, err := c.opmlHandler.Export(user.ID)
|
||||
if err != nil {
|
||||
response.HTML().ServerError(err)
|
||||
|
@ -37,12 +37,12 @@ func (c *Controller) UploadOPML(ctx *core.Context, request *core.Request, respon
|
|||
file, fileHeader, err := request.File("file")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
response.Redirect(ctx.GetRoute("import"))
|
||||
response.Redirect(ctx.Route("import"))
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
log.Printf("[UI:UploadOPML] User #%d uploaded this file: %s (%d bytes)\n", user.ID, fileHeader.Filename, fileHeader.Size)
|
||||
|
||||
if impErr := c.opmlHandler.Import(user.ID, file); impErr != nil {
|
||||
|
@ -60,5 +60,5 @@ func (c *Controller) UploadOPML(ctx *core.Context, request *core.Request, respon
|
|||
return
|
||||
}
|
||||
|
||||
response.Redirect(ctx.GetRoute("feeds"))
|
||||
response.Redirect(ctx.Route("feeds"))
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
func (c *Controller) ShowSessions(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
args, err := c.getCommonTemplateArgs(ctx)
|
||||
if err != nil {
|
||||
response.HTML().ServerError(err)
|
||||
|
@ -32,7 +32,7 @@ func (c *Controller) ShowSessions(ctx *core.Context, request *core.Request, resp
|
|||
}
|
||||
|
||||
func (c *Controller) RemoveSession(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
sessionID, err := request.IntegerParam("sessionID")
|
||||
if err != nil {
|
||||
|
@ -45,5 +45,5 @@ func (c *Controller) RemoveSession(ctx *core.Context, request *core.Request, res
|
|||
log.Println("[UI:RemoveSession]", err)
|
||||
}
|
||||
|
||||
response.Redirect(ctx.GetRoute("sessions"))
|
||||
response.Redirect(ctx.Route("sessions"))
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
func (c *Controller) ShowSettings(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
args, err := c.getSettingsFormTemplateArgs(ctx, user, nil)
|
||||
if err != nil {
|
||||
|
@ -25,7 +25,7 @@ func (c *Controller) ShowSettings(ctx *core.Context, request *core.Request, resp
|
|||
}
|
||||
|
||||
func (c *Controller) UpdateSettings(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
settingsForm := form.NewSettingsForm(request.Request())
|
||||
args, err := c.getSettingsFormTemplateArgs(ctx, user, settingsForm)
|
||||
|
@ -60,7 +60,7 @@ func (c *Controller) UpdateSettings(ctx *core.Context, request *core.Request, re
|
|||
return
|
||||
}
|
||||
|
||||
response.Redirect(ctx.GetRoute("settings"))
|
||||
response.Redirect(ctx.Route("settings"))
|
||||
}
|
||||
|
||||
func (c *Controller) getSettingsFormTemplateArgs(ctx *core.Context, user *model.User, settingsForm *form.SettingsForm) (tplParams, error) {
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
func (c *Controller) AddSubscription(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
args, err := c.getSubscriptionFormTemplateArgs(ctx, user)
|
||||
if err != nil {
|
||||
|
@ -25,7 +25,7 @@ func (c *Controller) AddSubscription(ctx *core.Context, request *core.Request, r
|
|||
}
|
||||
|
||||
func (c *Controller) SubmitSubscription(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
args, err := c.getSubscriptionFormTemplateArgs(ctx, user)
|
||||
if err != nil {
|
||||
|
@ -71,7 +71,7 @@ func (c *Controller) SubmitSubscription(ctx *core.Context, request *core.Request
|
|||
return
|
||||
}
|
||||
|
||||
response.Redirect(ctx.GetRoute("feedEntries", "feedID", feed.ID))
|
||||
response.Redirect(ctx.Route("feedEntries", "feedID", feed.ID))
|
||||
case n > 1:
|
||||
response.HTML().Render("choose_subscription", args.Merge(tplParams{
|
||||
"categoryID": subscriptionForm.CategoryID,
|
||||
|
@ -81,7 +81,7 @@ func (c *Controller) SubmitSubscription(ctx *core.Context, request *core.Request
|
|||
}
|
||||
|
||||
func (c *Controller) ChooseSubscription(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
args, err := c.getSubscriptionFormTemplateArgs(ctx, user)
|
||||
if err != nil {
|
||||
|
@ -107,7 +107,7 @@ func (c *Controller) ChooseSubscription(ctx *core.Context, request *core.Request
|
|||
return
|
||||
}
|
||||
|
||||
response.Redirect(ctx.GetRoute("feedEntries", "feedID", feed.ID))
|
||||
response.Redirect(ctx.Route("feedEntries", "feedID", feed.ID))
|
||||
}
|
||||
|
||||
func (c *Controller) getSubscriptionFormTemplateArgs(ctx *core.Context, user *model.User) (tplParams, error) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
// ShowUnreadPage render the page with all unread entries.
|
||||
func (c *Controller) ShowUnreadPage(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
offset := request.QueryIntegerParam("offset", 0)
|
||||
|
||||
builder := c.store.GetEntryQueryBuilder(user.ID, user.Timezone)
|
||||
|
@ -37,8 +37,8 @@ func (c *Controller) ShowUnreadPage(ctx *core.Context, request *core.Request, re
|
|||
"user": user,
|
||||
"countUnread": countUnread,
|
||||
"entries": entries,
|
||||
"pagination": c.getPagination(ctx.GetRoute("unread"), countUnread, offset),
|
||||
"pagination": c.getPagination(ctx.Route("unread"), countUnread, offset),
|
||||
"menu": "unread",
|
||||
"csrf": ctx.GetCsrfToken(),
|
||||
"csrf": ctx.CsrfToken(),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
func (c *Controller) ShowUsers(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
if !user.IsAdmin {
|
||||
response.HTML().Forbidden()
|
||||
|
@ -39,7 +39,7 @@ func (c *Controller) ShowUsers(ctx *core.Context, request *core.Request, respons
|
|||
}
|
||||
|
||||
func (c *Controller) CreateUser(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
if !user.IsAdmin {
|
||||
response.HTML().Forbidden()
|
||||
|
@ -59,7 +59,7 @@ func (c *Controller) CreateUser(ctx *core.Context, request *core.Request, respon
|
|||
}
|
||||
|
||||
func (c *Controller) SaveUser(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
if !user.IsAdmin {
|
||||
response.HTML().Forbidden()
|
||||
|
@ -102,11 +102,11 @@ func (c *Controller) SaveUser(ctx *core.Context, request *core.Request, response
|
|||
return
|
||||
}
|
||||
|
||||
response.Redirect(ctx.GetRoute("users"))
|
||||
response.Redirect(ctx.Route("users"))
|
||||
}
|
||||
|
||||
func (c *Controller) EditUser(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
if !user.IsAdmin {
|
||||
response.HTML().Forbidden()
|
||||
|
@ -135,7 +135,7 @@ func (c *Controller) EditUser(ctx *core.Context, request *core.Request, response
|
|||
}
|
||||
|
||||
func (c *Controller) UpdateUser(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
|
||||
if !user.IsAdmin {
|
||||
response.HTML().Forbidden()
|
||||
|
@ -186,11 +186,11 @@ func (c *Controller) UpdateUser(ctx *core.Context, request *core.Request, respon
|
|||
return
|
||||
}
|
||||
|
||||
response.Redirect(ctx.GetRoute("users"))
|
||||
response.Redirect(ctx.Route("users"))
|
||||
}
|
||||
|
||||
func (c *Controller) RemoveUser(ctx *core.Context, request *core.Request, response *core.Response) {
|
||||
user := ctx.GetLoggedUser()
|
||||
user := ctx.LoggedUser()
|
||||
if !user.IsAdmin {
|
||||
response.HTML().Forbidden()
|
||||
return
|
||||
|
@ -206,7 +206,7 @@ func (c *Controller) RemoveUser(ctx *core.Context, request *core.Request, respon
|
|||
return
|
||||
}
|
||||
|
||||
response.Redirect(ctx.GetRoute("users"))
|
||||
response.Redirect(ctx.Route("users"))
|
||||
}
|
||||
|
||||
func (c *Controller) getUserFromURL(ctx *core.Context, request *core.Request, response *core.Response) (*model.User, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue