import Text.XHtml
import Music.Diatonic.Note
import Music.Diatonic.Scale
import Music.Diatonic.Key
import Music.Diatonic.Chord
import List (intersperse)
import DD.Html
head' =
header <<
thetitle << "Diatonic Dashboard" +++
thelink ! [rel "stylesheet", thetype "text/css", href "dd.css"] << noHtml
notes' =
table ! [theclass "center", cellspacing 2, cellpadding 4] <<
tr <<
cells
where cells = concatHtml . intersperse sep . map cell $ noteList
sep = td << ("|" +++ br +++ "|")
cell ns = td << (concatHtml . intersperse br . map justHtml $ ns)
noteList = [[Nothing, Just C, Nothing], [Just . sharp $ C, Nothing, Just . flat $ D], [Nothing, Just D, Nothing]
,[Just . sharp $ D, Nothing, Just . flat $ E], [Nothing, Just E, Nothing], [Nothing, Just F, Nothing]
,[Just . sharp $ F, Nothing, Just . flat $ G], [Nothing, Just G, Nothing], [Just . sharp $ G, Nothing, Just . flat $ A]
,[Nothing, Just A, Nothing], [Just . sharp $ A, Nothing, Just . flat $ B], [Nothing, Just B, Just. flat $ C]
]
justHtml Nothing = spaceHtml
justHtml (Just n) = linkNote n
keys' =
table ! [theclass "center", cellspacing 2, cellpadding 4] <<
tr <<
cells
where cells = concatHtml . intersperse sep . map cell $ kl
sep = td << ("|" +++ br +++ "|" +++ br +++ "|")
cell ks = td << (concatHtml . intersperse br $ ks)
kl = map (\(k1, k2) -> [linkKey k1, linkKey k2, keyDesc k1]) keyList
keyList = map (\k -> (k, relative k)) majorKeys
keyDesc k =
if null ss
then toHtml "(-)"
else displayMusicHTML . snd . break (== ' ') $ ss
where ss = show . signature $ k
chords' =
table ! [theclass "center", cellspacing 2, cellpadding 4] <<
tr <<
cells
where cells = concatHtml . intersperse sep . map cell $ chordList
sep = td << ("|" +++ (concatHtml . replicate (length noteList - 1) $ (br +++ "|")))
cell cs = td << (concatHtml . intersperse br $ cs)
chordList = map (\c -> [ linkChord . c $ n | n <- noteList ]) chordTypes
noteList = [C, sharp C, flat D, D, sharp D, flat E, E, F,
sharp F, flat G, G, sharp G, flat A, A, sharp A, flat B, B, flat C]
chordTypes = [majorChord, minorChord, diminishedChord, dominant7thChord, major7thChord, minor7thChord, minor7thFlat5thChord]
main = putStrLn . renderHtml $
head'
+++ body ! [theclass "center"]
<< h2 << "Diatonic Dashboard"
+++ h3 << "Notes"
+++ notes'
+++ h3 << "Keys"
+++ keys'
+++ h3 << "Chords"
+++ chords'