From cd8d4fc8a62a67ad36b6d1d788f487fd1ed6548c Mon Sep 17 00:00:00 2001 From: Eduardo Trujillo <ed@chromabits.com> Date: Thu, 3 Dec 2015 05:28:44 -0500 Subject: [PATCH] Refinements post-release --- index.html | 1 + site.hs | 26 +++++++++++++++++++++++++- templates/default.html | 13 +++++++++++++ templates/disqus.html | 31 ++++++++++--------------------- templates/projects.html | 2 +- 5 files changed, 50 insertions(+), 23 deletions(-) diff --git a/index.html b/index.html index a285c86..1d8947b 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,5 @@ --- +title: Blog --- $posts$ diff --git a/site.hs b/site.hs index 80b1745..b2f0938 100644 --- a/site.hs +++ b/site.hs @@ -1,11 +1,12 @@ -------------------------------------------------------------------------------- {-# LANGUAGE OverloadedStrings #-} +import Control.Applicative import Control.Monad (liftM) import Control.Monad.IO.Class import qualified Data.Map as M import Data.Maybe (fromMaybe) import Data.Monoid (mappend) -import Data.List (intersperse) +import Data.List (intersperse, isSuffixOf) import Data.List.Split (splitOn) import Hakyll import Text.Highlighting.Kate.Styles (haddock) @@ -73,12 +74,14 @@ main = hakyllWith hakyllConf $ do compile $ pandocHtml5Compiler >>= loadAndApplyTemplate "templates/default.html" siteCtx >>= relativizeUrls + >>= deIndexUrls create ["about.html"] $ do route $ indexify `composeRoutes` setExtension "html" compile $ pandocHtml5Compiler >>= loadAndApplyTemplate "templates/default.html" siteCtx >>= relativizeUrls + >>= deIndexUrls matchMetadata "posts/*" (M.member "legacy") $ version "legacy" $ do route $ legacyRoute `composeRoutes` setExtension "html" @@ -94,6 +97,7 @@ main = hakyllWith hakyllConf $ do >>= loadAndApplyTemplate "templates/full-post.html" ctx >>= loadAndApplyTemplate "templates/default.html" ctx >>= relativizeUrls + >>= deIndexUrls match "posts/*" $ do route $ directorizeDate `composeRoutes` setExtension "html" @@ -110,6 +114,7 @@ main = hakyllWith hakyllConf $ do >>= loadAndApplyTemplate "templates/full-post.html" ctx >>= loadAndApplyTemplate "templates/default.html" ctx >>= relativizeUrls + >>= deIndexUrls match "drafts/*" $ do route $ setExtension "html" @@ -121,6 +126,7 @@ main = hakyllWith hakyllConf $ do >>= loadAndApplyTemplate "templates/full-post.html" ctx >>= loadAndApplyTemplate "templates/default.html" ctx >>= relativizeUrls + >>= deIndexUrls match "projects/*" $ do route $ indexify `composeRoutes` setExtension "html" @@ -136,6 +142,7 @@ main = hakyllWith hakyllConf $ do saveSnapshot "content" full >>= loadAndApplyTemplate "templates/default.html" siteCtx >>= relativizeUrls + >>= deIndexUrls create ["archive.html"] $ do route indexify @@ -151,6 +158,7 @@ main = hakyllWith hakyllConf $ do >>= loadAndApplyTemplate "templates/archive.html" archiveCtx >>= loadAndApplyTemplate "templates/default.html" archiveCtx >>= relativizeUrls + >>= deIndexUrls create ["projects.html"] $ do route indexify @@ -166,6 +174,7 @@ main = hakyllWith hakyllConf $ do >>= loadAndApplyTemplate "templates/projects.html" archiveCtx >>= loadAndApplyTemplate "templates/default.html" archiveCtx >>= relativizeUrls + >>= deIndexUrls pag <- buildPaginateWith grouper ("posts/*" .&&. hasNoVersion) makeId @@ -185,6 +194,7 @@ main = hakyllWith hakyllConf $ do >>= applyTemplate body (ctx `mappend` bodyField "posts") >>= loadAndApplyTemplate "templates/default.html" ctx >>= relativizeUrls + >>= deIndexUrls paginateRules pag $ \pageNum pattern -> do route idRoute @@ -205,12 +215,14 @@ main = hakyllWith hakyllConf $ do >>= loadAndApplyTemplate "templates/default.html" (ctx `mappend` bodyField "posts") >>= relativizeUrls + >>= deIndexUrls match "templates/*" $ compile templateCompiler -------------------------------------------------------------------------------- siteCtx :: Context String siteCtx = + deIndexedUrlField "url" `mappend` constField "root" (siteRoot siteConf) `mappend` constField "gaId" (siteGaId siteConf) `mappend` defaultContext @@ -251,6 +263,18 @@ grouper ids = (liftM (paginateEvery 3) . sortRecentFirst) ids makeId :: PageNumber -> Identifier makeId pageNum = fromFilePath $ "page/" ++ show pageNum ++ "/index.html" +stripIndex :: String -> String +stripIndex url = if "index.html" `isSuffixOf` url + && elem (head url) ("/." :: String) + then take (length url - 10) url else url + +deIndexUrls :: Item String -> Compiler (Item String) +deIndexUrls item = return $ fmap (withUrls stripIndex) item + +deIndexedUrlField :: String -> Context a +deIndexedUrlField key = field key + $ fmap (stripIndex . maybe empty toUrl) . getRoute . itemIdentifier + dropMore :: Item String -> Item String dropMore = fmap (unlines . takeWhile (/= "<!--more-->") . lines) diff --git a/templates/default.html b/templates/default.html index 2008c25..92ec666 100644 --- a/templates/default.html +++ b/templates/default.html @@ -13,8 +13,21 @@ <script src="https://use.typekit.net/voy2fek.js"></script> <script>try{Typekit.load({ async: true });}catch(e){}</script> + + <meta property="fb:admins" content="etcinit"/> </head> <body> + <div id="fb-root"></div> + <script> + (function(d, s, id) { + var js, fjs = d.getElementsByTagName(s)[0]; + if (d.getElementById(id)) return; + js = d.createElement(s); js.id = id; + js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5&appId=332765426823646"; + fjs.parentNode.insertBefore(js, fjs); + }(document, 'script', 'facebook-jssdk')); + </script> + <div id="header" class="row align-middle"> <div class="columns medium-6"> <a href="/" id="logo"><div></div></a> diff --git a/templates/disqus.html b/templates/disqus.html index 793007c..5b16240 100644 --- a/templates/disqus.html +++ b/templates/disqus.html @@ -1,22 +1,11 @@ -<div id="disqus_thread"></div> -<script> -var disqus_config = function () { - this.page.url = '$url$'; - this.page.identifier = '$uuid$'; -}; +<div class="fb-like" + data-href="https://chromabits.com$url$" + data-layout="standard" data-action="like" data-show-faces="true" + data-share="true"> +</div> -(function() { -var d = document, s = d.createElement('script'); - -s.src = '//openwalls.disqus.com/embed.js'; - -s.setAttribute('data-timestamp', +new Date()); -(d.head || d.body).appendChild(s); -})(); -</script> -<noscript> - Please enable JavaScript to view the - <a href="https://disqus.com/?ref_noscript" rel="nofollow"> - comments powered by Disqus. - </a> -</noscript> +<div class="fb-comments" + data-href="https://chromabits.com$url$" + data-width="100%" + data-numposts="5"> +</div> diff --git a/templates/projects.html b/templates/projects.html index c6938d2..022c741 100644 --- a/templates/projects.html +++ b/templates/projects.html @@ -22,7 +22,7 @@ </p> <div class="button-group"> - <a class="button" href="//phabricator.chromabits.com"> + <a class="button" href="http://phabricator.chromabits.com"> <i class="fa fa-cog"></i> Phabricator </a> -- GitLab