aboutsummaryrefslogtreecommitdiffstats
path: root/internal/web/handlers_design.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/web/handlers_design.go')
-rw-r--r--internal/web/handlers_design.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/internal/web/handlers_design.go b/internal/web/handlers_design.go
index 3da7ee3..1e18001 100644
--- a/internal/web/handlers_design.go
+++ b/internal/web/handlers_design.go
@@ -36,7 +36,7 @@ func (s *Server) handleDesign(w http.ResponseWriter, r *http.Request) {
}
theme := ThemeFromForm(ParseTheme(blog.ThemeJSON), r.Form)
// Optional direct uploads from the design form.
- for field, dst := range map[string]*string{"bg_image_file": &theme.BgImage, "header_image_file": &theme.HeaderImage, "favicon_file": &theme.Favicon} {
+ for field, dst := range map[string]*string{"bg_image_file": &theme.BgImage, "header_image_file": &theme.HeaderImage, "logo_file": &theme.Logo, "favicon_file": &theme.Favicon} {
img, err := s.readUpload(r, field)
if err != nil {
images, _ := s.st.ListImages(r.Context(), blog.ID)
@@ -71,14 +71,19 @@ func (s *Server) handleDesignPreset(w http.ResponseWriter, r *http.Request) {
redirectOK(w, r, "/b/"+blog.Subdomain+"/design", "Applied the "+p.Name+" scheme. Refresh your blog to see it.")
}
-// handleDesignReset restores the defaults; images stay in the library.
+// handleDesignReset restores the defaults, layout modules included; images
+// stay in the library and the menu is left alone.
func (s *Server) handleDesignReset(w http.ResponseWriter, r *http.Request) {
blog := currentBlog(r)
if err := s.st.UpdateBlogTheme(r.Context(), blog.ID, DefaultTheme().JSON()); err != nil {
s.serverError(w, err)
return
}
- redirectOK(w, r, "/b/"+blog.Subdomain+"/design", "Design reset to the defaults.")
+ if err := s.st.ResetModules(r.Context(), blog.ID); err != nil {
+ s.serverError(w, err)
+ return
+ }
+ redirectOK(w, r, "/b/"+blog.Subdomain+"/design", "Design and layout reset to the defaults.")
}
// readUpload stores the file from a multipart field, returning nil if the field is empty.
@@ -218,6 +223,9 @@ func (s *Server) handleImageDelete(w http.ResponseWriter, r *http.Request) {
if theme.Favicon == id.String() {
theme.Favicon, changed = "", true
}
+ if theme.Logo == id.String() {
+ theme.Logo, changed = "", true
+ }
if changed {
if err := s.st.UpdateBlogTheme(r.Context(), blog.ID, theme.JSON()); err != nil {
s.serverError(w, err)