mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
feat: add new settings option to allow external fonts
This commit is contained in:
parent
600dea6ce5
commit
e555e442fb
32 changed files with 257 additions and 56 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"miniflux.app/v2/internal/config"
|
||||
"miniflux.app/v2/internal/locale"
|
||||
"miniflux.app/v2/internal/model"
|
||||
"miniflux.app/v2/internal/validator"
|
||||
)
|
||||
|
||||
// MarkReadBehavior list all possible behaviors for automatically marking an entry as read
|
||||
|
@ -37,6 +38,7 @@ type SettingsForm struct {
|
|||
ShowReadingTime bool
|
||||
CustomCSS string
|
||||
CustomJS string
|
||||
ExternalFontHosts string
|
||||
EntrySwipe bool
|
||||
GestureNav string
|
||||
DisplayMode string
|
||||
|
@ -101,6 +103,7 @@ func (s *SettingsForm) Merge(user *model.User) *model.User {
|
|||
user.ShowReadingTime = s.ShowReadingTime
|
||||
user.Stylesheet = s.CustomCSS
|
||||
user.CustomJS = s.CustomJS
|
||||
user.ExternalFontHosts = s.ExternalFontHosts
|
||||
user.EntrySwipe = s.EntrySwipe
|
||||
user.GestureNav = s.GestureNav
|
||||
user.DisplayMode = s.DisplayMode
|
||||
|
@ -148,6 +151,12 @@ func (s *SettingsForm) Validate() *locale.LocalizedError {
|
|||
return locale.NewLocalizedError("error.settings_media_playback_rate_range")
|
||||
}
|
||||
|
||||
if s.ExternalFontHosts != "" {
|
||||
if !validator.IsValidDomainList(s.ExternalFontHosts) {
|
||||
return locale.NewLocalizedError("error.settings_invalid_domain_list")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -183,6 +192,7 @@ func NewSettingsForm(r *http.Request) *SettingsForm {
|
|||
ShowReadingTime: r.FormValue("show_reading_time") == "1",
|
||||
CustomCSS: r.FormValue("custom_css"),
|
||||
CustomJS: r.FormValue("custom_js"),
|
||||
ExternalFontHosts: r.FormValue("external_font_hosts"),
|
||||
EntrySwipe: r.FormValue("entry_swipe") == "1",
|
||||
GestureNav: r.FormValue("gesture_nav"),
|
||||
DisplayMode: r.FormValue("display_mode"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue