From 4a6f987bf7f9d73e9dd33d225fd2d73e9bf69a88 Mon Sep 17 00:00:00 2001 From: grm Date: Wed, 16 Sep 2026 19:10:13 +0300 Subject: Merge the Layout and Design tabs into one form with a single Save The look and the layout of a blog were split over two tabs that cross-linked each other, and the Layout tab saved every toggle, move and add straight away through a dozen tiny forms. Now one Design tab holds it all, organised by part of the blog (colours & fonts, header, menu, content, side columns, footer, logo & icon) behind a sticky side index, and one Save stores the theme, every module and the menu atomically (BlogStore.SaveDesign). Module settings are edited inline; Discard changes throws the edits away; a validation error shows the form again exactly as it was sent. The image pickers no longer render the whole library four times over: a select of the newest images, and a script-driven panel that fetches the library page by page (GET /files as JSON) with lazy thumbnails. New options: posts per page, site title size, footer alignment. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A --- internal/store/menu.go | 42 ------------------------------------------ 1 file changed, 42 deletions(-) (limited to 'internal/store/menu.go') diff --git a/internal/store/menu.go b/internal/store/menu.go index cedb7ad..e2314af 100644 --- a/internal/store/menu.go +++ b/internal/store/menu.go @@ -76,45 +76,3 @@ func (bs *BlogStore) SetPageInMenu(ctx context.Context, pageID int64, on bool) e _, err := bs.db.Exec(ctx, `DELETE FROM menu_items WHERE page_id=$1`, pageID) return err } - -// AddMenuLink appends a custom link to the menu. -func (bs *BlogStore) AddMenuLink(ctx context.Context, label, url string) error { - _, err := bs.db.Exec(ctx, `INSERT INTO menu_items (label, url, sort_order) - VALUES ($1,$2,(SELECT coalesce(max(sort_order),-1)+1 FROM menu_items))`, label, url) - return err -} - -func (bs *BlogStore) DeleteMenuItem(ctx context.Context, id int64) error { - _, err := bs.db.Exec(ctx, `DELETE FROM menu_items WHERE id=$1`, id) - return err -} - -// MoveMenuItem swaps sort_order with the neighbouring entry (dir = -1 up, +1 down). -func (bs *BlogStore) MoveMenuItem(ctx context.Context, id int64, dir int) error { - items, err := bs.ListMenu(ctx) - if err != nil { - return err - } - idx := -1 - for i := range items { - if items[i].ID == id { - idx = i - } - } - j := idx + dir - if idx < 0 || j < 0 || j >= len(items) { - return nil - } - items[idx], items[j] = items[j], items[idx] - tx, err := bs.db.Begin(ctx) - if err != nil { - return err - } - defer tx.Rollback(ctx) - for i, m := range items { // renumber everything; keeps orders dense - if _, err := tx.Exec(ctx, `UPDATE menu_items SET sort_order=$2 WHERE id=$1`, m.ID, i); err != nil { - return err - } - } - return tx.Commit(ctx) -} -- cgit v1.2.3