mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Implement breadcrumbs
This commit is contained in:
parent
16c0813d13
commit
73bf88b666
2 changed files with 34 additions and 7 deletions
|
|
@ -11,8 +11,9 @@
|
|||
["/album/:id" ::album-view]]))
|
||||
|
||||
; use this in views to construct a url
|
||||
(defn url-for [k params]
|
||||
(str "#" (r/resolve router k params)))
|
||||
(defn url-for
|
||||
([k] (url-for k {}))
|
||||
([k params] (str "#" (r/resolve router k params))))
|
||||
|
||||
; which routes need valid login credentials?
|
||||
(def protected-routes #{::main ::artist-view ::album-view})
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
(:require [re-frame.core :refer [dispatch subscribe]]
|
||||
[reagent.core :as r]
|
||||
[airsonic-ui.config :as config]
|
||||
[airsonic-ui.routes :as routes]
|
||||
[airsonic-ui.routes :as routes :refer [url-for]]
|
||||
[airsonic-ui.events :as events]
|
||||
[airsonic-ui.subs :as subs]))
|
||||
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
(let [artist-id (:artistId song)]
|
||||
[:div
|
||||
[:a
|
||||
(when artist-id {:href (routes/url-for ::routes/artist-view {:id artist-id})})
|
||||
(when artist-id {:href (url-for ::routes/artist-view {:id artist-id})})
|
||||
(:artist song)]
|
||||
" - "
|
||||
[:a
|
||||
|
|
@ -66,15 +66,14 @@
|
|||
(let [{:keys [artist artistId name coverArt year id]} album]
|
||||
[:div
|
||||
;; link to artist page
|
||||
[:a {:href (routes/url-for ::routes/artist-view {:id artistId})} artist]
|
||||
[:a {:href (url-for ::routes/artist-view {:id artistId})} artist]
|
||||
" - "
|
||||
;; link to album
|
||||
[:a {:href (routes/url-for ::routes/album-view {:id id})} name] (when year (str " (" year ")"))]))
|
||||
[:a {:href (url-for ::routes/album-view {:id id})} name] (when year (str " (" year ")"))]))
|
||||
|
||||
(defn artist-detail [content]
|
||||
[:div
|
||||
[:h2 (:name content)]
|
||||
[:p (:albumCount content) " items"]
|
||||
[:ul (for [[idx album] (map-indexed vector (:album content))]
|
||||
[:li {:key idx} [album-item album]])]])
|
||||
|
||||
|
|
@ -86,6 +85,32 @@
|
|||
[:ul (for [[idx album] (map-indexed vector (:album content))]
|
||||
[:li {:key idx} [album-item album]])]])
|
||||
|
||||
;; top navigation
|
||||
|
||||
(defn content-type
|
||||
"Helper to see what kind of server response"
|
||||
[content]
|
||||
(cond
|
||||
(and (vector? (:album content)) (:id content)) :artist
|
||||
(vector? (:song content)) :album
|
||||
:else :unknown-content))
|
||||
|
||||
(defmulti breadcrumbs content-type)
|
||||
|
||||
(defmethod breadcrumbs :default [content]
|
||||
[:div [:span "Start"]])
|
||||
|
||||
(defmethod breadcrumbs :artist [content]
|
||||
[:div
|
||||
[:span [:a {:href (url-for ::routes/main)} "Start"]]
|
||||
[:span " · " (:name content)]])
|
||||
|
||||
(defmethod breadcrumbs :album [content]
|
||||
[:div
|
||||
[:span [:a {:href (url-for ::routes/main)} "Start"]]
|
||||
[:span " · " [:a {:href (url-for ::routes/artist-view {:id (:artistId content)})} (:artist content)]]
|
||||
[:span " · " (:name content)]])
|
||||
|
||||
;; currently playing / coming next / audio controls...
|
||||
|
||||
(defn current-song-info [{:keys [item status]}]
|
||||
|
|
@ -116,6 +141,7 @@
|
|||
content @(subscribe [::subs/current-content])]
|
||||
[:div
|
||||
[:span (str "Currently logged in as " (:u login))]
|
||||
[breadcrumbs content]
|
||||
(case route
|
||||
::routes/main [most-recent content]
|
||||
::routes/artist-view [artist-detail content]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue