1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00

Make sure golint pass on the code base

This commit is contained in:
Frédéric Guillot 2017-11-27 21:30:04 -08:00
parent 8781648af9
commit bb8e61c7c5
59 changed files with 322 additions and 171 deletions

View file

@ -9,6 +9,7 @@ import (
"github.com/miniflux/miniflux2/version"
)
// AboutPage shows the about page.
func (c *Controller) AboutPage(ctx *core.Context, request *core.Request, response *core.Response) {
args, err := c.getCommonTemplateArgs(ctx)
if err != nil {

View file

@ -22,7 +22,7 @@ func (c *Controller) ShowCategories(ctx *core.Context, request *core.Request, re
}
user := ctx.LoggedUser()
categories, err := c.store.GetCategoriesWithFeedCount(user.ID)
categories, err := c.store.CategoriesWithFeedCount(user.ID)
if err != nil {
response.HTML().ServerError(err)
return
@ -57,7 +57,7 @@ func (c *Controller) ShowCategoryEntries(ctx *core.Context, request *core.Reques
builder.WithDirection(model.DefaultSortingDirection)
builder.WithoutStatus(model.EntryStatusRemoved)
builder.WithOffset(offset)
builder.WithLimit(NbItemsPerPage)
builder.WithLimit(nbItemsPerPage)
entries, err := builder.GetEntries()
if err != nil {
@ -110,7 +110,7 @@ func (c *Controller) SaveCategory(ctx *core.Context, request *core.Request, resp
return
}
duplicateCategory, err := c.store.GetCategoryByTitle(user.ID, categoryForm.Title)
duplicateCategory, err := c.store.CategoryByTitle(user.ID, categoryForm.Title)
if err != nil {
response.HTML().ServerError(err)
return
@ -223,7 +223,7 @@ func (c *Controller) getCategoryFromURL(ctx *core.Context, request *core.Request
}
user := ctx.LoggedUser()
category, err := c.store.GetCategory(user.ID, categoryID)
category, err := c.store.Category(user.ID, categoryID)
if err != nil {
response.HTML().ServerError(err)
return nil, err

View file

@ -39,7 +39,7 @@ func (c *Controller) ShowFeedsPage(ctx *core.Context, request *core.Request, res
return
}
feeds, err := c.store.GetFeeds(user.ID)
feeds, err := c.store.Feeds(user.ID)
if err != nil {
response.HTML().ServerError(err)
return
@ -74,7 +74,7 @@ func (c *Controller) ShowFeedEntries(ctx *core.Context, request *core.Request, r
builder.WithOrder(model.DefaultSortingOrder)
builder.WithDirection(model.DefaultSortingDirection)
builder.WithOffset(offset)
builder.WithLimit(NbItemsPerPage)
builder.WithLimit(nbItemsPerPage)
entries, err := builder.GetEntries()
if err != nil {
@ -190,7 +190,7 @@ func (c *Controller) getFeedFromURL(request *core.Request, response *core.Respon
return nil, err
}
feed, err := c.store.GetFeedById(user.ID, feedID)
feed, err := c.store.FeedByID(user.ID, feedID)
if err != nil {
response.HTML().ServerError(err)
return nil, err
@ -210,7 +210,7 @@ func (c *Controller) getFeedFormTemplateArgs(ctx *core.Context, user *model.User
return nil, err
}
categories, err := c.store.GetCategories(user.ID)
categories, err := c.store.Categories(user.ID)
if err != nil {
return nil, err
}

View file

@ -25,7 +25,7 @@ func (c *Controller) ShowHistoryPage(ctx *core.Context, request *core.Request, r
builder.WithOrder(model.DefaultSortingOrder)
builder.WithDirection(model.DefaultSortingDirection)
builder.WithOffset(offset)
builder.WithLimit(NbItemsPerPage)
builder.WithLimit(nbItemsPerPage)
entries, err := builder.GetEntries()
if err != nil {

View file

@ -5,10 +5,12 @@
package controller
import (
"github.com/miniflux/miniflux2/server/core"
"time"
"github.com/miniflux/miniflux2/server/core"
)
// ShowIcon shows the feed icon.
func (c *Controller) ShowIcon(ctx *core.Context, request *core.Request, response *core.Response) {
iconID, err := request.IntegerParam("iconID")
if err != nil {
@ -16,7 +18,7 @@ func (c *Controller) ShowIcon(ctx *core.Context, request *core.Request, response
return
}
icon, err := c.store.GetIconByID(iconID)
icon, err := c.store.IconByID(iconID)
if err != nil {
response.HTML().ServerError(err)
return

View file

@ -82,7 +82,7 @@ func (c *Controller) OAuth2Callback(ctx *core.Context, request *core.Request, re
return
}
user, err := c.store.GetUserByExtraField(profile.Key, profile.ID)
user, err := c.store.UserByExtraField(profile.Key, profile.ID)
if err != nil {
response.HTML().ServerError(err)
return

View file

@ -10,6 +10,7 @@ import (
"github.com/miniflux/miniflux2/server/core"
)
// Export generates the OPML file.
func (c *Controller) Export(ctx *core.Context, request *core.Request, response *core.Response) {
user := ctx.LoggedUser()
opml, err := c.opmlHandler.Export(user.ID)
@ -21,6 +22,7 @@ func (c *Controller) Export(ctx *core.Context, request *core.Request, response *
response.XML().Download("feeds.opml", opml)
}
// Import shows the import form.
func (c *Controller) Import(ctx *core.Context, request *core.Request, response *core.Response) {
args, err := c.getCommonTemplateArgs(ctx)
if err != nil {
@ -33,6 +35,7 @@ func (c *Controller) Import(ctx *core.Context, request *core.Request, response *
}))
}
// UploadOPML handles OPML file importation.
func (c *Controller) UploadOPML(ctx *core.Context, request *core.Request, response *core.Response) {
file, fileHeader, err := request.File("file")
if err != nil {

View file

@ -5,10 +5,10 @@
package controller
const (
NbItemsPerPage = 100
nbItemsPerPage = 100
)
type Pagination struct {
type pagination struct {
Route string
Total int
Offset int
@ -19,25 +19,25 @@ type Pagination struct {
PrevOffset int
}
func (c *Controller) getPagination(route string, total, offset int) Pagination {
func (c *Controller) getPagination(route string, total, offset int) pagination {
nextOffset := 0
prevOffset := 0
showNext := (total - offset) > NbItemsPerPage
showNext := (total - offset) > nbItemsPerPage
showPrev := offset > 0
if showNext {
nextOffset = offset + NbItemsPerPage
nextOffset = offset + nbItemsPerPage
}
if showPrev {
prevOffset = offset - NbItemsPerPage
prevOffset = offset - nbItemsPerPage
}
return Pagination{
return pagination{
Route: route,
Total: total,
Offset: offset,
ItemsPerPage: NbItemsPerPage,
ItemsPerPage: nbItemsPerPage,
ShowNext: showNext,
NextOffset: nextOffset,
ShowPrev: showPrev,

View file

@ -5,10 +5,12 @@
package controller
import (
"github.com/miniflux/miniflux2/server/core"
"log"
"github.com/miniflux/miniflux2/server/core"
)
// ShowSessions shows the list of active sessions.
func (c *Controller) ShowSessions(ctx *core.Context, request *core.Request, response *core.Response) {
user := ctx.LoggedUser()
args, err := c.getCommonTemplateArgs(ctx)
@ -17,7 +19,7 @@ func (c *Controller) ShowSessions(ctx *core.Context, request *core.Request, resp
return
}
sessions, err := c.store.GetSessions(user.ID)
sessions, err := c.store.Sessions(user.ID)
if err != nil {
response.HTML().ServerError(err)
return
@ -31,6 +33,7 @@ func (c *Controller) ShowSessions(ctx *core.Context, request *core.Request, resp
}))
}
// RemoveSession remove a session.
func (c *Controller) RemoveSession(ctx *core.Context, request *core.Request, response *core.Response) {
user := ctx.LoggedUser()

View file

@ -5,13 +5,15 @@
package controller
import (
"log"
"github.com/miniflux/miniflux2/locale"
"github.com/miniflux/miniflux2/model"
"github.com/miniflux/miniflux2/server/core"
"github.com/miniflux/miniflux2/server/ui/form"
"log"
)
// ShowSettings shows the settings page.
func (c *Controller) ShowSettings(ctx *core.Context, request *core.Request, response *core.Response) {
user := ctx.LoggedUser()
@ -24,6 +26,7 @@ func (c *Controller) ShowSettings(ctx *core.Context, request *core.Request, resp
response.HTML().Render("settings", args)
}
// UpdateSettings update the settings.
func (c *Controller) UpdateSettings(ctx *core.Context, request *core.Request, response *core.Response) {
user := ctx.LoggedUser()
@ -81,9 +84,9 @@ func (c *Controller) getSettingsFormTemplateArgs(ctx *core.Context, user *model.
}
args["menu"] = "settings"
args["themes"] = model.GetThemes()
args["languages"] = locale.GetAvailableLanguages()
args["timezones"], err = c.store.GetTimezones()
args["themes"] = model.Themes()
args["languages"] = locale.AvailableLanguages()
args["timezones"], err = c.store.Timezones()
if err != nil {
return args, err
}

View file

@ -6,12 +6,14 @@ package controller
import (
"encoding/base64"
"github.com/miniflux/miniflux2/server/core"
"github.com/miniflux/miniflux2/server/static"
"log"
"time"
"github.com/miniflux/miniflux2/server/core"
"github.com/miniflux/miniflux2/server/static"
)
// Stylesheet renders the CSS.
func (c *Controller) Stylesheet(ctx *core.Context, request *core.Request, response *core.Response) {
stylesheet := request.StringParam("name", "white")
body := static.Stylesheets["common"]
@ -25,10 +27,12 @@ func (c *Controller) Stylesheet(ctx *core.Context, request *core.Request, respon
response.Cache("text/css", etag, []byte(body), 48*time.Hour)
}
// Javascript renders application client side code.
func (c *Controller) Javascript(ctx *core.Context, request *core.Request, response *core.Response) {
response.Cache("text/javascript", static.JavascriptChecksums["app"], []byte(static.Javascript["app"]), 48*time.Hour)
}
// Favicon renders the application favicon.
func (c *Controller) Favicon(ctx *core.Context, request *core.Request, response *core.Response) {
blob, err := base64.StdEncoding.DecodeString(static.Binaries["favicon.ico"])
if err != nil {

View file

@ -135,7 +135,7 @@ func (c *Controller) getSubscriptionFormTemplateArgs(ctx *core.Context, user *mo
return nil, err
}
categories, err := c.store.GetCategories(user.ID)
categories, err := c.store.Categories(user.ID)
if err != nil {
return nil, err
}

View file

@ -19,7 +19,7 @@ func (c *Controller) ShowUnreadPage(ctx *core.Context, request *core.Request, re
builder.WithOrder(model.DefaultSortingOrder)
builder.WithDirection(model.DefaultSortingDirection)
builder.WithOffset(offset)
builder.WithLimit(NbItemsPerPage)
builder.WithLimit(nbItemsPerPage)
entries, err := builder.GetEntries()
if err != nil {

View file

@ -6,12 +6,14 @@ package controller
import (
"errors"
"log"
"github.com/miniflux/miniflux2/model"
"github.com/miniflux/miniflux2/server/core"
"github.com/miniflux/miniflux2/server/ui/form"
"log"
)
// ShowUsers shows the list of users.
func (c *Controller) ShowUsers(ctx *core.Context, request *core.Request, response *core.Response) {
user := ctx.LoggedUser()
@ -26,7 +28,7 @@ func (c *Controller) ShowUsers(ctx *core.Context, request *core.Request, respons
return
}
users, err := c.store.GetUsers()
users, err := c.store.Users()
if err != nil {
response.HTML().ServerError(err)
return
@ -38,6 +40,7 @@ func (c *Controller) ShowUsers(ctx *core.Context, request *core.Request, respons
}))
}
// CreateUser shows the user creation form.
func (c *Controller) CreateUser(ctx *core.Context, request *core.Request, response *core.Response) {
user := ctx.LoggedUser()
@ -58,6 +61,7 @@ func (c *Controller) CreateUser(ctx *core.Context, request *core.Request, respon
}))
}
// SaveUser validate and save the new user into the database.
func (c *Controller) SaveUser(ctx *core.Context, request *core.Request, response *core.Response) {
user := ctx.LoggedUser()
@ -105,6 +109,7 @@ func (c *Controller) SaveUser(ctx *core.Context, request *core.Request, response
response.Redirect(ctx.Route("users"))
}
// EditUser shows the form to edit a user.
func (c *Controller) EditUser(ctx *core.Context, request *core.Request, response *core.Response) {
user := ctx.LoggedUser()
@ -134,6 +139,7 @@ func (c *Controller) EditUser(ctx *core.Context, request *core.Request, response
}))
}
// UpdateUser validate and update a user.
func (c *Controller) UpdateUser(ctx *core.Context, request *core.Request, response *core.Response) {
user := ctx.LoggedUser()
@ -189,6 +195,7 @@ func (c *Controller) UpdateUser(ctx *core.Context, request *core.Request, respon
response.Redirect(ctx.Route("users"))
}
// RemoveUser deletes a user from the database.
func (c *Controller) RemoveUser(ctx *core.Context, request *core.Request, response *core.Response) {
user := ctx.LoggedUser()
if !user.IsAdmin {
@ -216,7 +223,7 @@ func (c *Controller) getUserFromURL(ctx *core.Context, request *core.Request, re
return nil, err
}
user, err := c.store.GetUserById(userID)
user, err := c.store.UserByID(userID)
if err != nil {
response.HTML().ServerError(err)
return nil, err