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
|
build-depends: base
|
||||||
, hakyll
|
, hakyll
|
||||||
, directory
|
, directory
|
||||||
|
, HTTP
|
||||||
|
|
16
src/Main.hs
16
src/Main.hs
|
@ -5,6 +5,7 @@ import Hakyll
|
||||||
import Data.Monoid ((<>), mconcat)
|
import Data.Monoid ((<>), mconcat)
|
||||||
import Data.List (sort, delete, intercalate)
|
import Data.List (sort, delete, intercalate)
|
||||||
import System.Directory
|
import System.Directory
|
||||||
|
import Network.HTTP.Base (urlEncode)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
|
@ -65,12 +66,15 @@ main = do
|
||||||
paginateRules pages $ \num _ -> do
|
paginateRules pages $ \num _ -> do
|
||||||
route $ setExtension "html"
|
route $ setExtension "html"
|
||||||
compile $ do
|
compile $ do
|
||||||
let ident = paginateMakeId pages $ num
|
ident <- getUnderlying
|
||||||
tagList <- getTags ident
|
tagList <- getTags ident
|
||||||
let tagString = intercalate "," tagList
|
let tagString = intercalate "," tagList
|
||||||
|
meta <- getMetadata ident
|
||||||
|
title <- getMetadataField' ident "title"
|
||||||
|
let url = toFilePath ident
|
||||||
compiled <- getResourceBody >>= renderPandoc
|
compiled <- getResourceBody >>= renderPandoc
|
||||||
let pageCtx = paginateContext pages num
|
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
|
full <- loadAndApplyTemplate "templates/post.html" ctx compiled
|
||||||
_ <- saveSnapshot "content" compiled
|
_ <- saveSnapshot "content" compiled
|
||||||
loadAndApplyTemplate "templates/default.html" baseCtx full
|
loadAndApplyTemplate "templates/default.html" baseCtx full
|
||||||
|
@ -142,9 +146,11 @@ feedCtx = mconcat
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
flattrCtx :: String -> Context String
|
flattrCtx :: String -> String -> String -> Context String
|
||||||
flattrCtx str = mconcat
|
flattrCtx tag tit url = mconcat
|
||||||
[ constField "rawtags" str
|
[ constField "rawtags" tag
|
||||||
|
, constField "enctitle" tit
|
||||||
|
, constField "encurl" url
|
||||||
]
|
]
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
$body$
|
$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">
|
<div class="pagination">
|
||||||
$if(previousPageNum)$
|
$if(previousPageNum)$
|
||||||
|
|
Loading…
Reference in a new issue