mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +00:00
Add the ability to use custom css
This commit is contained in:
parent
ae8e5c4dbc
commit
7accdc4416
19 changed files with 67 additions and 12 deletions
|
@ -21,6 +21,7 @@ type SettingsForm struct {
|
|||
Timezone string
|
||||
EntryDirection string
|
||||
KeyboardShortcuts bool
|
||||
CustomCSS string
|
||||
}
|
||||
|
||||
// Merge updates the fields of the given user.
|
||||
|
@ -31,6 +32,7 @@ func (s *SettingsForm) Merge(user *model.User) *model.User {
|
|||
user.Timezone = s.Timezone
|
||||
user.EntryDirection = s.EntryDirection
|
||||
user.KeyboardShortcuts = s.KeyboardShortcuts
|
||||
user.Extra["custom_css"] = s.CustomCSS
|
||||
|
||||
if s.Password != "" {
|
||||
user.Password = s.Password
|
||||
|
@ -74,5 +76,6 @@ func NewSettingsForm(r *http.Request) *SettingsForm {
|
|||
Timezone: r.FormValue("timezone"),
|
||||
EntryDirection: r.FormValue("entry_direction"),
|
||||
KeyboardShortcuts: r.FormValue("keyboard_shortcuts") == "1",
|
||||
CustomCSS: r.FormValue("custom_css"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ func (h *handler) showSettingsPage(w http.ResponseWriter, r *http.Request) {
|
|||
Timezone: user.Timezone,
|
||||
EntryDirection: user.EntryDirection,
|
||||
KeyboardShortcuts: user.KeyboardShortcuts,
|
||||
CustomCSS: user.Extra["custom_css"],
|
||||
}
|
||||
|
||||
timezones, err := h.store.Timezones()
|
||||
|
|
|
@ -16,6 +16,24 @@ import (
|
|||
|
||||
func (h *handler) showStylesheet(w http.ResponseWriter, r *http.Request) {
|
||||
filename := request.RouteStringParam(r, "name")
|
||||
if filename == "custom_css" {
|
||||
user, err := h.store.UserByID(request.UserID(r))
|
||||
if err != nil {
|
||||
html.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
b := response.New(w, r)
|
||||
if user == nil {
|
||||
b.WithHeader("Content-Type", "text/css; charset=utf-8")
|
||||
b.WithBody("")
|
||||
b.Write()
|
||||
return
|
||||
}
|
||||
b.WithHeader("Content-Type", "text/css; charset=utf-8")
|
||||
b.WithBody(user.Extra["custom_css"])
|
||||
b.Write()
|
||||
return
|
||||
}
|
||||
etag, found := static.StylesheetsChecksums[filename]
|
||||
if !found {
|
||||
html.NotFound(w, r)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue