mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Use route + content for breadcrumbs, add missing ones (closes #24)
This commit is contained in:
parent
b0dd2bd10d
commit
2509a66961
2 changed files with 18 additions and 21 deletions
|
|
@ -102,15 +102,15 @@
|
||||||
(defn media-content
|
(defn media-content
|
||||||
"Provides the complete UI to browse the media library, interact with search
|
"Provides the complete UI to browse the media library, interact with search
|
||||||
results etc"
|
results etc"
|
||||||
[route-id params query]
|
[[route-id :as route]]
|
||||||
(let [;; TODO: Move this to a layer 3 subscription ↓
|
(let [;; TODO: Move this to a layer 3 subscription ↓
|
||||||
route-events @(subscribe [:routes/events-for-current-route])
|
route-events @(subscribe [:routes/events-for-current-route])
|
||||||
content @(subscribe [:api/route-data route-events])]
|
content @(subscribe [:api/route-data route-events])]
|
||||||
[:div
|
[:div
|
||||||
[:section.section
|
[:section.section
|
||||||
[breadcrumbs content]
|
[breadcrumbs route content]
|
||||||
(case route-id
|
(case route-id
|
||||||
::routes/library [library/main [route-id params query] content]
|
::routes/library [library/main route content]
|
||||||
::routes/artist.detail [artist/detail content]
|
::routes/artist.detail [artist/detail content]
|
||||||
::routes/album.detail [collection/detail content]
|
::routes/album.detail [collection/detail content]
|
||||||
::routes/search [search/results content]
|
::routes/search [search/results content]
|
||||||
|
|
@ -127,7 +127,7 @@
|
||||||
[]
|
[]
|
||||||
(let [notifications @(subscribe [::subs/notifications])
|
(let [notifications @(subscribe [::subs/notifications])
|
||||||
is-booting? @(subscribe [::subs/is-booting?])
|
is-booting? @(subscribe [::subs/is-booting?])
|
||||||
[route-id params query] @(subscribe [:routes/current-route])]
|
[route-id :as route] @(subscribe [:routes/current-route])]
|
||||||
[(add-classes :div route-id)
|
[(add-classes :div route-id)
|
||||||
[notification-list notifications]
|
[notification-list notifications]
|
||||||
(if is-booting?
|
(if is-booting?
|
||||||
|
|
@ -136,4 +136,4 @@
|
||||||
[navbar-top]
|
[navbar-top]
|
||||||
(case route-id
|
(case route-id
|
||||||
::routes/login [login-form]
|
::routes/login [login-form]
|
||||||
[media-content route-id params query])])]))
|
[media-content route])])]))
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,6 @@
|
||||||
;; hierarchy no matter how you came to the url. They should allow easy
|
;; hierarchy no matter how you came to the url. They should allow easy
|
||||||
;; navigation upwards that hierarchy (e.g. album -> artist)
|
;; navigation upwards that hierarchy (e.g. album -> artist)
|
||||||
|
|
||||||
(defn page-type
|
|
||||||
"Helper to see what kind of view we're currently dealing with"
|
|
||||||
[content]
|
|
||||||
(case (set (keys content))
|
|
||||||
#{:artist :artist-info} :artist
|
|
||||||
#{:album} :album
|
|
||||||
#{:search} :search
|
|
||||||
#{:podcasts} :podcast
|
|
||||||
:other-content))
|
|
||||||
|
|
||||||
(defn- bulma-breadcrumbs [& items]
|
(defn- bulma-breadcrumbs [& items]
|
||||||
[:div.container>nav.breadcrumb {:aria-label "breadcrumbs"}
|
[:div.container>nav.breadcrumb {:aria-label "breadcrumbs"}
|
||||||
[:ul
|
[:ul
|
||||||
|
|
@ -22,25 +12,32 @@
|
||||||
[:li {:key idx} [:a {:href href} label]])
|
[:li {:key idx} [:a {:href href} label]])
|
||||||
[:li.is-active>a (last items)]]])
|
[:li.is-active>a (last items)]]])
|
||||||
|
|
||||||
(defmulti breadcrumbs page-type)
|
(defmulti breadcrumbs
|
||||||
|
(fn dispatch-on [[route-id] content] route-id))
|
||||||
|
|
||||||
(defmethod breadcrumbs :default [content]
|
(defmethod breadcrumbs :default [_ _]
|
||||||
[bulma-breadcrumbs "Start"])
|
[bulma-breadcrumbs "Start"])
|
||||||
|
|
||||||
(def start [(url-for ::routes/library) "Start"])
|
(def start [(url-for ::routes/library) "Start"])
|
||||||
|
|
||||||
(defmethod breadcrumbs :artist [{:keys [artist]}]
|
(defmethod breadcrumbs ::routes/artist.detail [_ {:keys [artist]}]
|
||||||
[bulma-breadcrumbs start
|
[bulma-breadcrumbs start
|
||||||
(:name artist)])
|
(:name artist)])
|
||||||
|
|
||||||
(defmethod breadcrumbs :album [{:keys [album]}]
|
(defmethod breadcrumbs ::routes/album.detail [_ {:keys [album]}]
|
||||||
[bulma-breadcrumbs start
|
[bulma-breadcrumbs start
|
||||||
[(url-for ::routes/artist.detail {:id (:artistId album)}) (:artist album)]
|
[(url-for ::routes/artist.detail {:id (:artistId album)}) (:artist album)]
|
||||||
(:name album)])
|
(:name album)])
|
||||||
|
|
||||||
(defmethod breadcrumbs :search [_]
|
(defmethod breadcrumbs ::routes/search [_ _]
|
||||||
[bulma-breadcrumbs start "Search"])
|
[bulma-breadcrumbs start "Search"])
|
||||||
|
|
||||||
(defmethod breadcrumbs :podcast [{:keys [channel]}]
|
(defmethod breadcrumbs ::routes/podcast.overview [_ _]
|
||||||
;; TODO: Detail view
|
;; TODO: Detail view
|
||||||
[bulma-breadcrumbs start "Podcasts"])
|
[bulma-breadcrumbs start "Podcasts"])
|
||||||
|
|
||||||
|
(defmethod breadcrumbs ::routes/current-queue [_ _]
|
||||||
|
[bulma-breadcrumbs start "Current Queue"])
|
||||||
|
|
||||||
|
(defmethod breadcrumbs ::routes/about [_ _]
|
||||||
|
[bulma-breadcrumbs start "About"])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue