urlencode stuff
This commit is contained in:
parent
7433479dc8
commit
964cfe55ed
3 changed files with 13 additions and 6 deletions
|
@ -26,3 +26,4 @@ executable blog
|
|||
build-depends: base
|
||||
, hakyll
|
||||
, directory
|
||||
, HTTP
|
||||
|
|
16
src/Main.hs
16
src/Main.hs
|
@ -5,6 +5,7 @@ import Hakyll
|
|||
import Data.Monoid ((<>), mconcat)
|
||||
import Data.List (sort, delete, intercalate)
|
||||
import System.Directory
|
||||
import Network.HTTP.Base (urlEncode)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
main :: IO ()
|
||||
|
@ -65,12 +66,15 @@ main = do
|
|||
paginateRules pages $ \num _ -> do
|
||||
route $ setExtension "html"
|
||||
compile $ do
|
||||
let ident = paginateMakeId pages $ num
|
||||
ident <- getUnderlying
|
||||
tagList <- getTags ident
|
||||
let tagString = intercalate "," tagList
|
||||
meta <- getMetadata ident
|
||||
title <- getMetadataField' ident "title"
|
||||
let url = toFilePath ident
|
||||
compiled <- getResourceBody >>= renderPandoc
|
||||
let pageCtx = paginateContext pages num
|
||||
let ctx = (postCtx tags) <> pageCtx <> flattrCtx tagString
|
||||
let ctx = (postCtx tags) <> pageCtx <> flattrCtx tagString (urlEncode title) (urlEncode $ "htps://nek0.eu" ++ url)
|
||||
full <- loadAndApplyTemplate "templates/post.html" ctx compiled
|
||||
_ <- saveSnapshot "content" compiled
|
||||
loadAndApplyTemplate "templates/default.html" baseCtx full
|
||||
|
@ -142,9 +146,11 @@ feedCtx = mconcat
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
flattrCtx :: String -> Context String
|
||||
flattrCtx str = mconcat
|
||||
[ constField "rawtags" str
|
||||
flattrCtx :: String -> String -> String -> Context String
|
||||
flattrCtx tag tit url = mconcat
|
||||
[ constField "rawtags" tag
|
||||
, constField "enctitle" tit
|
||||
, constField "encurl" url
|
||||
]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
$body$
|
||||
|
||||
<a class="flattr" target="_blank" href="https://flattr.com/submit/auto?user_id=nek0&url=https://nek0.eu$url$&title=$title$&tags=$rawtags$" alt="flattr this!">flattr this!</a>
|
||||
<a class="flattr" target="_blank" href="https://flattr.com/submit/auto?user_id=nek0&url=$encurl$&title=$enctitle$&tags=$rawtags$" alt="flattr this!">flattr this!</a>
|
||||
|
||||
<div class="pagination">
|
||||
$if(previousPageNum)$
|
||||
|
|
Loading…
Reference in a new issue