; Blog app defpage declarations
; Pages kept as Python: home, index, post-detail (cache_page / complex branching)

; --- New post/page editors ---

(defpage new-post
  :path "/new/"
  :auth :admin
  :layout :blog
  :content (editor-content))

(defpage new-page
  :path "/new-page/"
  :auth :admin
  :layout :blog
  :content (editor-page-content))

; --- Post admin pages (absolute paths under /<slug>/admin/) ---

(defpage post-admin
  :path "/<slug>/admin/"
  :auth :admin
  :layout (:post-admin :selected "admin")
  :content (post-admin-content slug))

(defpage post-data
  :path "/<slug>/admin/data/"
  :auth :admin
  :layout (:post-admin :selected "data")
  :content (post-data-content slug))

(defpage post-preview
  :path "/<slug>/admin/preview/"
  :auth :admin
  :layout (:post-admin :selected "preview")
  :content (post-preview-content slug))

(defpage post-entries
  :path "/<slug>/admin/entries/"
  :auth :admin
  :layout (:post-admin :selected "entries")
  :content (post-entries-content slug))

(defpage post-settings
  :path "/<slug>/admin/settings/"
  :auth :post_author
  :layout (:post-admin :selected "settings")
  :content (post-settings-content slug))

(defpage post-edit
  :path "/<slug>/admin/edit/"
  :auth :post_author
  :layout (:post-admin :selected "edit")
  :content (post-edit-content slug))

; --- Settings pages (absolute paths) ---

(defpage settings-home
  :path "/settings/"
  :auth :admin
  :layout :blog-settings
  :content (div :class "max-w-2xl mx-auto px-4 py-6"))

(defpage cache-page
  :path "/settings/cache/"
  :auth :admin
  :layout :blog-cache
  :data (service "blog-page" "cache-data")
  :content (~blog-cache-panel :clear-url clear-url :csrf csrf))

; --- Snippets ---

(defpage snippets-page
  :path "/settings/snippets/"
  :auth :login
  :layout :blog-snippets
  :data (service "blog-page" "snippets-data")
  :content (~blog-snippets-content
    :snippets snippets :is-admin is-admin :csrf csrf))

; --- Menu Items ---

(defpage menu-items-page
  :path "/settings/menu_items/"
  :auth :admin
  :layout :blog-menu-items
  :data (service "blog-page" "menu-items-data")
  :content (~blog-menu-items-content
    :menu-items menu-items :new-url new-url :csrf csrf))

; --- Tag Groups ---

(defpage tag-groups-page
  :path "/settings/tag-groups/"
  :auth :admin
  :layout :blog-tag-groups
  :data (service "blog-page" "tag-groups-data")
  :content (~blog-tag-groups-content
    :groups groups :unassigned-tags unassigned-tags
    :create-url create-url :csrf csrf))

(defpage tag-group-edit
  :path "/settings/tag-groups/<int:id>/"
  :auth :admin
  :layout :blog-tag-group-edit
  :data (service "blog-page" "tag-group-edit-data" :id id)
  :content (~blog-tag-group-edit-content
    :group group :all-tags all-tags
    :save-url save-url :delete-url delete-url :csrf csrf))
