-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml.clj
More file actions
94 lines (85 loc) · 2.53 KB
/
html.clj
File metadata and controls
94 lines (85 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
(ns michmusic.html
(:use compojure)
(:require [compojure.encodings :as encodings]))
(defn- include-css-media [style media]
[:link {:type "text/css" :href style :rel "stylesheet" :media media}])
(defn- html-doc
[& body]
(html
(doctype :html4)
[:html
[:head
[:title "Mich House Music"]
(include-css-media "/static/external/screen.css" "screen, projection")
(include-css-media "/static/external/print.css" "print")
"<!--[if lt IE 8]>"
(include-css-media "/static/external/ie.css" "screen, projection")
"<![endif]-->"
(include-css "/static/style.css")
(include-js "/static/external/jquery-1.3.2.min.js"
"/static/external/sm2/soundmanager2.js"
"/static/navigation.js")]
[:body
[:div#navigation
(unordered-list [(link-to "/" "Browse")
(link-to "/upload/" "Upload")])]
[:table#player
[:tr
[:td#player-control {:rowspan 2}
[:img {:alt "play" :src "/static/icons/pause.png"}]]
[:td#player-song]]
[:tr
[:td#player-artist]]]
[:div.container
[:div#content
body]]]]))
(defn- artist-option
[a]
[a (str "/artist/" (encodings/urlencode a))])
(defn browse-html
[artists]
(html-doc
[:div#artists {:class "span-7"}
[:h2 "Artists"]
[:select#current-artist {:class "center" :size 25}
(select-options
(map artist-option artists))]]
[:div#main {:class "span-15 prepend-1 append-1 last"}
[:p "hi"]]))
(defn album-display
"The HTML for a single album and its songs."
[[[artist album year] songs]]
[[:h3.album-header
[:span.year year]
album " "
(link-to (str "/file/" artist " - " album ".zip")
"download album")]
[:ul
(for [s songs]
[:li
(:track s) " "
[:span.play-button "play"] " "
(link-to (str "/file/" (:sha s) "/" artist "_" (:title s) ".mp3")
(:title s))])]])
(defn artist-html
[artist summary img-src songs-by-album]
(html
[:h2#artist artist]
[:div {:class "span-8"}
[:p summary]]
[:div {:class "span-7 last"}
[:img.center {:src img-src :alt artist}]]
[:div {:class "span-15 prepend-top last"}
(mapcat album-display songs-by-album)]))
(defn upload-get-html
[]
(html-doc
[:h2 "Upload File"]
(form-to {:enctype "multipart/form-data"} [:post "/upload/"]
(file-upload :file)
(submit-button "Go"))))
(defn upload-post-html
[filename sha-str]
(html-doc
[:p "Filename: " filename]
[:p "SHA1: " sha-str]))