mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
refactor: unexport symbols
This commit is contained in:
parent
a4d51b5586
commit
566670cc06
36 changed files with 369 additions and 376 deletions
|
@ -10,14 +10,14 @@ import (
|
|||
"miniflux.app/v2/internal/locale"
|
||||
)
|
||||
|
||||
// AuthForm represents the authentication form.
|
||||
type AuthForm struct {
|
||||
// authForm represents the authentication form.
|
||||
type authForm struct {
|
||||
Username string
|
||||
Password string
|
||||
}
|
||||
|
||||
// Validate makes sure the form values are valid.
|
||||
func (a AuthForm) Validate() *locale.LocalizedError {
|
||||
func (a authForm) Validate() *locale.LocalizedError {
|
||||
if a.Username == "" || a.Password == "" {
|
||||
return locale.NewLocalizedError("error.fields_mandatory")
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ func (a AuthForm) Validate() *locale.LocalizedError {
|
|||
}
|
||||
|
||||
// NewAuthForm returns a new AuthForm.
|
||||
func NewAuthForm(r *http.Request) *AuthForm {
|
||||
return &AuthForm{
|
||||
func NewAuthForm(r *http.Request) *authForm {
|
||||
return &authForm{
|
||||
Username: strings.TrimSpace(r.FormValue("username")),
|
||||
Password: strings.TrimSpace(r.FormValue("password")),
|
||||
}
|
||||
|
|
|
@ -13,14 +13,14 @@ import (
|
|||
"miniflux.app/v2/internal/validator"
|
||||
)
|
||||
|
||||
// MarkReadBehavior list all possible behaviors for automatically marking an entry as read
|
||||
type MarkReadBehavior string
|
||||
// markReadBehavior list all possible behaviors for automatically marking an entry as read
|
||||
type markReadBehavior string
|
||||
|
||||
const (
|
||||
NoAutoMarkAsRead MarkReadBehavior = "no-auto"
|
||||
MarkAsReadOnView MarkReadBehavior = "on-view"
|
||||
MarkAsReadOnViewButWaitForPlayerCompletion MarkReadBehavior = "on-view-but-wait-for-player-completion"
|
||||
MarkAsReadOnlyOnPlayerCompletion MarkReadBehavior = "on-player-completion"
|
||||
NoAutoMarkAsRead markReadBehavior = "no-auto"
|
||||
MarkAsReadOnView markReadBehavior = "on-view"
|
||||
MarkAsReadOnViewButWaitForPlayerCompletion markReadBehavior = "on-view-but-wait-for-player-completion"
|
||||
MarkAsReadOnlyOnPlayerCompletion markReadBehavior = "on-player-completion"
|
||||
)
|
||||
|
||||
// SettingsForm represents the settings form.
|
||||
|
@ -48,7 +48,7 @@ type SettingsForm struct {
|
|||
CategoriesSortingOrder string
|
||||
MarkReadOnView bool
|
||||
// MarkReadBehavior is a string representation of the MarkReadOnView and MarkReadOnMediaPlayerCompletion fields together
|
||||
MarkReadBehavior MarkReadBehavior
|
||||
MarkReadBehavior markReadBehavior
|
||||
MediaPlaybackRate float64
|
||||
BlockFilterEntryRules string
|
||||
KeepFilterEntryRules string
|
||||
|
@ -58,7 +58,7 @@ type SettingsForm struct {
|
|||
|
||||
// MarkAsReadBehavior returns the MarkReadBehavior from the given MarkReadOnView and MarkReadOnMediaPlayerCompletion values.
|
||||
// Useful to convert the values from the User model to the form
|
||||
func MarkAsReadBehavior(markReadOnView, markReadOnMediaPlayerCompletion bool) MarkReadBehavior {
|
||||
func MarkAsReadBehavior(markReadOnView, markReadOnMediaPlayerCompletion bool) markReadBehavior {
|
||||
switch {
|
||||
case markReadOnView && !markReadOnMediaPlayerCompletion:
|
||||
return MarkAsReadOnView
|
||||
|
@ -73,9 +73,9 @@ func MarkAsReadBehavior(markReadOnView, markReadOnMediaPlayerCompletion bool) Ma
|
|||
}
|
||||
}
|
||||
|
||||
// ExtractMarkAsReadBehavior returns the MarkReadOnView and MarkReadOnMediaPlayerCompletion values from the given MarkReadBehavior.
|
||||
// extractMarkAsReadBehavior returns the MarkReadOnView and MarkReadOnMediaPlayerCompletion values from the given MarkReadBehavior.
|
||||
// Useful to extract the values from the form to the User model
|
||||
func ExtractMarkAsReadBehavior(behavior MarkReadBehavior) (markReadOnView, markReadOnMediaPlayerCompletion bool) {
|
||||
func extractMarkAsReadBehavior(behavior markReadBehavior) (markReadOnView, markReadOnMediaPlayerCompletion bool) {
|
||||
switch behavior {
|
||||
case MarkAsReadOnView:
|
||||
return true, false
|
||||
|
@ -119,7 +119,7 @@ func (s *SettingsForm) Merge(user *model.User) *model.User {
|
|||
user.AlwaysOpenExternalLinks = s.AlwaysOpenExternalLinks
|
||||
user.OpenExternalLinksInNewTab = s.OpenExternalLinksInNewTab
|
||||
|
||||
MarkReadOnView, MarkReadOnMediaPlayerCompletion := ExtractMarkAsReadBehavior(s.MarkReadBehavior)
|
||||
MarkReadOnView, MarkReadOnMediaPlayerCompletion := extractMarkAsReadBehavior(s.MarkReadBehavior)
|
||||
user.MarkReadOnView = MarkReadOnView
|
||||
user.MarkReadOnMediaPlayerCompletion = MarkReadOnMediaPlayerCompletion
|
||||
|
||||
|
@ -205,7 +205,7 @@ func NewSettingsForm(r *http.Request) *SettingsForm {
|
|||
DefaultHomePage: r.FormValue("default_home_page"),
|
||||
CategoriesSortingOrder: r.FormValue("categories_sorting_order"),
|
||||
MarkReadOnView: r.FormValue("mark_read_on_view") == "1",
|
||||
MarkReadBehavior: MarkReadBehavior(r.FormValue("mark_read_behavior")),
|
||||
MarkReadBehavior: markReadBehavior(r.FormValue("mark_read_behavior")),
|
||||
MediaPlaybackRate: mediaPlaybackRate,
|
||||
BlockFilterEntryRules: r.FormValue("block_filter_entry_rules"),
|
||||
KeepFilterEntryRules: r.FormValue("keep_filter_entry_rules"),
|
||||
|
|
|
@ -13,28 +13,28 @@ import (
|
|||
"miniflux.app/v2/internal/ui/static"
|
||||
)
|
||||
|
||||
// View wraps template argument building.
|
||||
type View struct {
|
||||
// view wraps template argument building.
|
||||
type view struct {
|
||||
tpl *template.Engine
|
||||
r *http.Request
|
||||
params map[string]any
|
||||
}
|
||||
|
||||
// Set adds a new template argument.
|
||||
func (v *View) Set(param string, value any) *View {
|
||||
func (v *view) Set(param string, value any) *view {
|
||||
v.params[param] = value
|
||||
return v
|
||||
}
|
||||
|
||||
// Render executes the template with arguments.
|
||||
func (v *View) Render(template string) []byte {
|
||||
func (v *view) Render(template string) []byte {
|
||||
return v.tpl.Render(template+".html", v.params)
|
||||
}
|
||||
|
||||
// New returns a new view with default parameters.
|
||||
func New(tpl *template.Engine, r *http.Request, sess *session.Session) *View {
|
||||
func New(tpl *template.Engine, r *http.Request, sess *session.Session) *view {
|
||||
theme := request.UserTheme(r)
|
||||
return &View{tpl, r, map[string]any{
|
||||
return &view{tpl, r, map[string]any{
|
||||
"menu": "",
|
||||
"csrf": request.CSRF(r),
|
||||
"flashMessage": sess.FlashMessage(request.FlashMessage(r)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue