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]]))
|
["/album/:id" ::album-view]]))
|
||||||
|
|
||||||
; use this in views to construct a url
|
; use this in views to construct a url
|
||||||
(defn url-for [k params]
|
(defn url-for
|
||||||
(str "#" (r/resolve router k params)))
|
([k] (url-for k {}))
|
||||||
|
([k params] (str "#" (r/resolve router k params))))
|
||||||
|
|
||||||
; which routes need valid login credentials?
|
; which routes need valid login credentials?
|
||||||
(def protected-routes #{::main ::artist-view ::album-view})
|
(def protected-routes #{::main ::artist-view ::album-view})
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
(:require [re-frame.core :refer [dispatch subscribe]]
|
(:require [re-frame.core :refer [dispatch subscribe]]
|
||||||
[reagent.core :as r]
|
[reagent.core :as r]
|
||||||
[airsonic-ui.config :as config]
|
[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.events :as events]
|
||||||
[airsonic-ui.subs :as subs]))
|
[airsonic-ui.subs :as subs]))
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
(let [artist-id (:artistId song)]
|
(let [artist-id (:artistId song)]
|
||||||
[:div
|
[:div
|
||||||
[:a
|
[: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)]
|
(:artist song)]
|
||||||
" - "
|
" - "
|
||||||
[:a
|
[:a
|
||||||
|
|
@ -66,15 +66,14 @@
|
||||||
(let [{:keys [artist artistId name coverArt year id]} album]
|
(let [{:keys [artist artistId name coverArt year id]} album]
|
||||||
[:div
|
[:div
|
||||||
;; link to artist page
|
;; 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
|
;; 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]
|
(defn artist-detail [content]
|
||||||
[:div
|
[:div
|
||||||
[:h2 (:name content)]
|
[:h2 (:name content)]
|
||||||
[:p (:albumCount content) " items"]
|
|
||||||
[:ul (for [[idx album] (map-indexed vector (:album content))]
|
[:ul (for [[idx album] (map-indexed vector (:album content))]
|
||||||
[:li {:key idx} [album-item album]])]])
|
[:li {:key idx} [album-item album]])]])
|
||||||
|
|
||||||
|
|
@ -86,6 +85,32 @@
|
||||||
[:ul (for [[idx album] (map-indexed vector (:album content))]
|
[:ul (for [[idx album] (map-indexed vector (:album content))]
|
||||||
[:li {:key idx} [album-item album]])]])
|
[: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...
|
;; currently playing / coming next / audio controls...
|
||||||
|
|
||||||
(defn current-song-info [{:keys [item status]}]
|
(defn current-song-info [{:keys [item status]}]
|
||||||
|
|
@ -116,6 +141,7 @@
|
||||||
content @(subscribe [::subs/current-content])]
|
content @(subscribe [::subs/current-content])]
|
||||||
[:div
|
[:div
|
||||||
[:span (str "Currently logged in as " (:u login))]
|
[:span (str "Currently logged in as " (:u login))]
|
||||||
|
[breadcrumbs content]
|
||||||
(case route
|
(case route
|
||||||
::routes/main [most-recent content]
|
::routes/main [most-recent content]
|
||||||
::routes/artist-view [artist-detail content]
|
::routes/artist-view [artist-detail content]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue