diff options
author | Vincent Ambo <vincent@kivra.com> | 2015-11-21T16·24+0100 |
---|---|---|
committer | Vincent Ambo <vincent@kivra.com> | 2015-11-21T16·24+0100 |
commit | 9f33d98db59d6c5c1997ce55eb7be219089bd8b0 (patch) | |
tree | 71bb15243f42779f80f576dacdf2f54f59848bff /src | |
parent | cfea17dc0d69de8e5e2e27433a068d36efa2d1b1 (diff) |
[blog] Implement new and simpler design
Diffstat (limited to 'src')
-rw-r--r-- | src/Blog.hs | 152 | ||||
-rw-r--r-- | src/Locales.hs | 8 | ||||
-rw-r--r-- | src/Server.hs | 3 |
3 files changed, 63 insertions, 100 deletions
diff --git a/src/Blog.hs b/src/Blog.hs index 7d985c400897..97c7fa9bc961 100644 --- a/src/Blog.hs +++ b/src/Blog.hs @@ -28,61 +28,39 @@ show' = pack . show markdownCutoff :: UTCTime markdownCutoff = fromJust $ parseTimeM False defaultTimeLocale "%s" "1367149834" - --- blog CSS (admin is still static) -stylesheetSource = $(luciusFile "res/blog.lucius") -blogStyle = renderCssUrl undefined stylesheetSource - -- blog HTML blogTemplate :: BlogLang -> Text -> Html -> Html blogTemplate lang t_append body = [shamlet| $doctype 5 <head> - <title>#{blogTitle lang t_append} - <link rel="stylesheet" type="text/css" href="/static/bootstrap.css" media="all"> - <link rel="stylesheet" type="text/css" href="/static/blogv40.css" media="all"> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="stylesheet" type="text/css" href="/static/blog.css" media="all"> <link rel="alternate" type="application/rss+xml" title="RSS-Feed" href=#{rssUrl}> - <meta http-equiv="content-type" content="text/html;charset=UTF-8"> + <title>#{blogTitle lang t_append} <body> - <div #wrap> - <div .header> - <div .container > - <div .row> - <div .span12 .blogtitle> - <a class="btitle" href="/">#{blogTitle lang empty} - <div .row> - <br> - <div .span6> - <span .contacts #cosx>^{contactInfo} - <div .container> - ^{body} - <footer .footer> - ^{showFooter $ pack version} + <header> + <h1> + <a href="/" .unstyled-link>#{blogTitle lang empty} + <hr> + ^{body} + ^{showFooter} |] where rssUrl = T.concat ["/", show' lang, "/rss.xml"] - contactInfo = [shamlet| -#{contactText lang} -<a class="link" href=#{mailTo}>Mail -#{orText lang} -<a class="link" href=#{twitter} target="_blank">Twitter -|] -showFooter :: Text -> Html -showFooter v = [shamlet| -<div .container> - <div .row> - <div .span12 .righttext style="text-align: right;margin-right:-200px"> - Proudly made with # - <a class="link" href="http://haskell.org">Haskell - , # - <a class="link" href="https://hackage.haskell.org/package/acid-state">Acid-State - \ and without PHP, Java, Perl, MySQL and Python. - <p> - <a class="link" href=#{repoURL}>#{append "Version " v} - <div .row .text-center> - <div .span12> - <span style="font-size:13px;font-family:Helvetica;">ಠ_ಠ +showFooter :: Html +showFooter = [shamlet| +<footer> + <p .footer>Served without any dynamic languages. + <p .footer> + <a href=#{repoURL} .uncoloured-link>Version #{version} + | + <a href=#{twitter} .uncoloured-link>Twitter + | + <a href=#{mailTo} .uncoloured-link>Mail + <p .lod> + ಠ_ಠ |] isEntryMarkdown :: Entry -> Bool @@ -91,77 +69,63 @@ isEntryMarkdown e = edate e > markdownCutoff renderEntryMarkdown :: Text -> Html renderEntryMarkdown = markdown def {msXssProtect = False} . fromStrict -renderEntries :: Bool -> [Entry] -> Text -> Maybe Html -> Html -renderEntries showAll entries topText footerLinks = [shamlet| -<div .row> - <div .span12> - <p> - <span class="innerTitle"> - <b>#{topText} -$forall entry <- elist - <div .row> - <div .span2> - <a href=#{linkElems entry}> - <b>#{title entry} - <br> - <i>#{pack $ formatTime defaultTimeLocale "%Y-%m-%d" $ edate entry} - <div .span10 .entry> - $if (isEntryMarkdown entry) - ^{renderEntryMarkdown $ append " " $ btext entry} - $else - ^{preEscapedToHtml $ append " " $ btext entry} - $if ((/=) (mtext entry) empty) - <p> - <a .readmore href=#{linkElems entry}>#{readMore $ lang entry} - $else - <br> -$maybe links <- footerLinks +renderEntries :: Bool -> [Entry] -> Maybe Html -> Html +renderEntries showAll entries pageLinks = [shamlet| +$forall entry <- toDisplay + <article> + <h2> + <a href=#{linkElems entry} .unstyled-link> + #{title entry} + <aside .date> + #{pack $ formatTime defaultTimeLocale "%Y-%m-%d" $ edate entry} + $if (isEntryMarkdown entry) + ^{renderEntryMarkdown $ btext entry} + $else + ^{preEscapedToHtml $ btext entry} + $if ((/=) (mtext entry) empty) + <a .uncoloured-link href=#{linkElems entry}> + #{readMore $ lang entry} + <hr> +$maybe links <- pageLinks ^{links} |] where - elist = if' showAll entries (take 6 entries) + toDisplay = if' showAll entries (take 6 entries) linkElems Entry{..} = concat $ intersperse' "/" [show lang, show entryId] showLinks :: Maybe Int -> BlogLang -> Html showLinks (Just i) lang = [shamlet| $if ((>) i 1) - <div .row .text-center> - <div .span12> - <a href=#{nLink $ succ i}>#{backText lang} - \ -- # - <a href=#{nLink $ pred i}>#{nextText lang} + <div .navigation> + <a href=#{nLink $ succ i} .uncoloured-link>#{backText lang} + | + <a href=#{nLink $ pred i} .uncoloured-link>#{nextText lang} $elseif ((<=) i 1) ^{showLinks Nothing lang} |] where nLink page = T.concat ["/", show' lang, "/?page=", show' page] showLinks Nothing lang = [shamlet| -<div .row .text-center> - <div .span12> - <a href=#{nLink}>#{backText lang} +<div .navigation> + <a href=#{nLink} .uncoloured-link>#{backText lang} |] where nLink = T.concat ["/", show' lang, "/?page=2"] renderEntry :: Entry -> Html renderEntry e@Entry{..} = [shamlet| -<div .row .pusher> - <div .span9> - <span .boldify>#{title} - <div .span3> - <span .righttext><i>#{woText}</i> -<div .row .innerContainer> - <div .span10> - <article> - $if (isEntryMarkdown e) - ^{renderEntryMarkdown btext} - <p>^{renderEntryMarkdown $ mtext} - $else - ^{preEscapedToHtml $ btext} - <p>^{preEscapedToHtml $ mtext} +<article> + <h2> + #{title} + <aside .date> + #{pack $ formatTime defaultTimeLocale "%Y-%m-%d" edate} + $if (isEntryMarkdown e) + ^{renderEntryMarkdown btext} + <p>^{renderEntryMarkdown $ mtext} + $else + ^{preEscapedToHtml $ btext} +<hr> |] - where - woText = flip T.append author $ T.pack $ formatTime defaultTimeLocale (eTimeFormat lang) edate {- Administration pages -} diff --git a/src/Locales.hs b/src/Locales.hs index 0ee5f0e535f0..00b2b871d19e 100644 --- a/src/Locales.hs +++ b/src/Locales.hs @@ -20,8 +20,8 @@ if' True x _ = x if' False _ y = y blogTitle :: BlogLang -> Text -> Text -blogTitle DE s = T.concat ["Tazjins Blog", s] -blogTitle EN s = T.concat ["Tazjin's Blog", s] +blogTitle DE s = T.concat ["Tazjins blog", s] +blogTitle EN s = T.concat ["Tazjin's blog", s] showLangText :: BlogLang -> Text showLangText EN = "en" @@ -77,8 +77,8 @@ nextText DE = "Später" nextText EN = "Later" readMore :: BlogLang -> Text -readMore DE = "Weiterlesen" -readMore EN = "Read more" +readMore DE = "[Weiterlesen]" +readMore EN = "[Read more]" eTimeFormat :: BlogLang -> String eTimeFormat DE = "Geschrieben am %Y-%m-%d von " diff --git a/src/Server.hs b/src/Server.hs index 30cf422a83c5..6996583f5ddb 100644 --- a/src/Server.hs +++ b/src/Server.hs @@ -40,7 +40,6 @@ tazBlog acid resDir = do adminHandler acid -- this checks auth , method GET >> (ok $ toResponse adminLogin) , method POST >> processLogin acid ] - , dirs "static/blogv40.css" $ serveBlogStyle , dir "static" $ staticHandler resDir , blogHandler acid EN , notFound $ toResponse $ showError NotFound DE @@ -96,7 +95,7 @@ showIndex acid lang = do entries <- query' acid (LatestEntries lang) (page :: Maybe Int) <- optional $ lookRead "page" ok $ toResponse $ blogTemplate lang "" $ - renderEntries False (eDrop page entries) (topText lang) (Just $ showLinks page lang) + renderEntries False (eDrop page entries) (Just $ showLinks page lang) where eDrop :: Maybe Int -> [a] -> [a] eDrop (Just i) = drop ((i-1) * 6) |