module Lykah.Theme2
(theme
,sect
,subSect
,floatingImage
,loremMore
) where
import Control.Monad.Identity
import qualified Data.Map.Strict as M
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import Data.Traversable hiding (sequence)
import Lykah.Structure
import Lykah.EHtml
import Lykah.BuildingBlocks
import qualified Lykah.Style as S
import Text.BlazeT
import qualified Text.BlazeT as B
import Text.BlazeT.Html5 hiding (head,link,menu)
import qualified Text.BlazeT.Html5 as H
import Text.BlazeT.Html5.Attributes hiding (id)
import qualified Text.BlazeT.Html5.Attributes as A
theme :: Theme
theme = Theme ([myCss,retina,js,fonts]) t1page bentry menuItem
myCss = Pathed "css/style.css" "myCss" Nothing Nothing
$ mconcat [Copy "assets/css/googlefonts.css"
,Write $ T.fromStrict S.myCss
,Copy "assets/css/glyphicons.css"
]
fonts = Pathed "fonts" "fonts" Nothing Nothing $ CopyDir "assets/fonts"
js = Pathed "main.js" "js" Nothing Nothing $ mconcat
[Copy "assets/js.js"
]
retina = Pathed "retina.js" "retina" Nothing Nothing $ Copy "assets/retina.min.js"
t1page :: SHtml a
-> SHtml a
t1page body = do
Page t _ _ <- askPage
docTypeHtml $ do
H.head $ do
autoBase
meta ! charset "UTF-8"
meta ! name "viewport" ! content "width=device-width,initial-scale=1.0"
--,maximum-scale=1.0"
path' myCss >>= stylesheet'
javascript "//code.jquery.com/jquery-1.11.1.min.js"
path' js >>= javascript'
googleAnalytics =<< readWebsite googleAnalyticsId
reference fonts
tit <- readPage pTitle
H.title $ string "Dr. Johannes Gerer - " >> tit
H.body $ do
let mh = H.div $ H.div $ do
a ! class_ "name" $ do
H.span ! class_ "long" $ do
text "D"
H.span ! class_ "letterSpace" $ "r."
" Johannes Gerer"
H.span ! class_ "short" $ "J. Gerer"
menu
clear
menuExtra "fixedExtra"
H.div ! A.id "content" $ do
H.div ! class_ "menu" $ do
mh ! class_ "visible"
mh ! class_ "hidden"
clear
H.div ! A.id "contentBody" $ do
body
footer $ sequence_
["Site proudly generated by "
,link "http://johannesgerer.com/Lykah" "Lykah"
,"."]
path' retina >>= javascript'
menuExtra :: AttributeValue -> SHtml a
menuExtra f = do
H.div ! class_ (f <> " title") $ H.span mempty
menuItem :: Int
-> Bool
-> PathedPage ()
-> SHtml a
menuItem ix active p@Pathed{aName=(Just n)} = do
path <- path' p
when active $ do
H.span ! class_ "preload glyphicon glyphicon-menu-down" $ ""
H.div ! class_ ("collapsedExtra hamburger") $ do
H.span ! class_ "glyphicon glyphicon-menu-down" $ ""
(! class_' (toValue $ intercalate " " $
[g active, aId p, "menuItem" <> show ix ])) $
a ! href' path ! dataAttribute "text" (toValue n) $ do
lazyText n
when active $ menuExtra "collapsedExtra"
where g True = "active"
g False = "inactive"
menuItem ix a p = error $ "menuItem not supported for unnamed pages:\n"
++ show (ix, a, p)
bentry :: Bool
-> SHtml Post
bentry single = do
Page t body (Post dat) <- askPage
let d = string $ formatTime defaultTimeLocale "%x %R %Z" (dat ::ZonedTime)
H.div ! class_' (postClass "entry" ::String) $ do
H.div ! class_ "title" $ do
postTitle t
H.div ! class_ "date" $ d
clear
H.div ! class_ "body" $ body
clear
where
(postClass,postTitle) = if single then ((++" single"),id)
else (id, \n -> do
p <- join $ readPathed path'
H.a ! A.href (toValue p) $ n)
sect :: Monad m => Markup2 -> MarkupT m () -> MarkupT m () -> MarkupT m ()
sect h t b = H.div ! class_ "section" $ do
h ! class_ "title" $ t
H.div ! class_ "body" $ b
subSect :: Monad m => Markup2 -> MarkupT m () -> MarkupT m () -> MarkupT m ()
subSect h title body = do
h ! class_ "title" $ title
body
floatingImage :: IDO a
=> Int
-> Bool
-> String
-> Maybe a
-> a
-> Maybe (EHtml b ())
-> EHtml b ()
floatingImage s withLink classes downscaled pId body =
H.div ! class_' (intercalate " "
["imgP"
,sc s
,cl body
,classes
]) $ do
path <- path' pId
let a = if withLink then flip namedLinkB' pId
else id
path2 <- maybe (return path) path' downscaled
a $ img ! src' path2 ! dataAttribute "rjs" (toValue path)
fromMaybe mempty body
where sc 1 = "small"
sc 2 = "normal"
sc 0 = "tiny"
cl Nothing = ""
cl _ = "clearfix"