mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +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"),
|
||||
|
|
|
@ -34,6 +34,7 @@ func (h *handler) showSettingsPage(w http.ResponseWriter, r *http.Request) {
|
|||
ShowReadingTime: user.ShowReadingTime,
|
||||
CustomCSS: user.Stylesheet,
|
||||
CustomJS: user.CustomJS,
|
||||
ExternalFontHosts: user.ExternalFontHosts,
|
||||
EntrySwipe: user.EntrySwipe,
|
||||
GestureNav: user.GestureNav,
|
||||
DisplayMode: user.DisplayMode,
|
||||
|
|
|
@ -85,6 +85,7 @@ func (h *handler) updateSettings(w http.ResponseWriter, r *http.Request) {
|
|||
MediaPlaybackRate: model.OptionalNumber(settingsForm.MediaPlaybackRate),
|
||||
BlockFilterEntryRules: model.OptionalString(settingsForm.BlockFilterEntryRules),
|
||||
KeepFilterEntryRules: model.OptionalString(settingsForm.KeepFilterEntryRules),
|
||||
ExternalFontHosts: model.OptionalString(settingsForm.ExternalFontHosts),
|
||||
}
|
||||
|
||||
if validationErr := validator.ValidateUserModification(h.store, loggedUser.ID, userModificationRequest); validationErr != nil {
|
||||
|
|
|
@ -427,7 +427,6 @@ input[type="number"] {
|
|||
line-height: 20px;
|
||||
width: 250px;
|
||||
font-size: 99%;
|
||||
margin-bottom: 10px;
|
||||
margin-top: 5px;
|
||||
appearance: none;
|
||||
}
|
||||
|
@ -448,7 +447,8 @@ input[type="number"]:focus {
|
|||
}
|
||||
|
||||
input[type="checkbox"] {
|
||||
margin-bottom: 15px;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue