im bad at nix
This commit is contained in:
parent
2694edafe9
commit
059d1b6934
@ -15,3 +15,7 @@
|
|||||||
## 0.1.2.0 -- 2018-08-23
|
## 0.1.2.0 -- 2018-08-23
|
||||||
|
|
||||||
* oh fuark i forgot to change the version. added robots.txt, favicons
|
* oh fuark i forgot to change the version. added robots.txt, favicons
|
||||||
|
|
||||||
|
## 0.1.2.1 -- 2018-08-25
|
||||||
|
|
||||||
|
* cleaned up and commented. you happy now?
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
{ mkDerivation, base, filepath, hakyll, hakyll-favicon, imagemagick
|
{ mkDerivation, base, binary, filepath, hakyll, hakyll-favicon, imagemagick
|
||||||
, stdenv
|
, stdenv
|
||||||
}:
|
}:
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
pname = "rf";
|
pname = "rf";
|
||||||
version = "0.1.2.0";
|
version = "0.1.2.1";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
isLibrary = false;
|
isLibrary = false;
|
||||||
isExecutable = true;
|
isExecutable = true;
|
||||||
executableHaskellDepends = [ base filepath hakyll hakyll-favicon ];
|
executableHaskellDepends = [ base binary filepath hakyll hakyll-favicon ];
|
||||||
executableSystemDepends = [ imagemagick ];
|
librarySystemDepends = [ imagemagick ];
|
||||||
homepage = "regularflolloping.com";
|
homepage = "regularflolloping.com";
|
||||||
description = "tA's blog";
|
description = "tA's blog";
|
||||||
license = stdenv.lib.licenses.bsd3;
|
license = stdenv.lib.licenses.bsd3;
|
||||||
|
4
rf.cabal
4
rf.cabal
@ -2,7 +2,7 @@
|
|||||||
-- see http://haskell.org/cabal/users-guide/
|
-- see http://haskell.org/cabal/users-guide/
|
||||||
|
|
||||||
name: rf
|
name: rf
|
||||||
version: 0.1.2.0
|
version: 0.1.2.1
|
||||||
synopsis: tA's blog
|
synopsis: tA's blog
|
||||||
-- description:
|
-- description:
|
||||||
homepage: regularflolloping.com
|
homepage: regularflolloping.com
|
||||||
@ -25,5 +25,5 @@ executable site
|
|||||||
, filepath
|
, filepath
|
||||||
, hakyll-favicon
|
, hakyll-favicon
|
||||||
-- hs-source-dirs:
|
-- hs-source-dirs:
|
||||||
extra-libraries: imagemagick
|
-- extra-libraries: imagemagick
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
83
site.hs
83
site.hs
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import Data.Monoid ((<>))
|
import Data.Monoid ((<>))
|
||||||
import Data.List (sortBy,isSuffixOf)
|
import Data.List (sortBy,isSuffixOf)
|
||||||
|
import Data.Typeable
|
||||||
import GHC.IO.Encoding
|
import GHC.IO.Encoding
|
||||||
import Hakyll
|
import Hakyll
|
||||||
import Hakyll.Favicon (faviconsRules, faviconsField)
|
import Hakyll.Favicon (faviconsRules, faviconsField)
|
||||||
@ -9,22 +10,25 @@ import System.FilePath.Posix (takeBaseName,takeDirectory,(</>))
|
|||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
|
|
||||||
|
-- Set the encoding so w3c doesnt complain
|
||||||
setLocaleEncoding utf8
|
setLocaleEncoding utf8
|
||||||
hakyll $ do
|
hakyll $ do
|
||||||
|
|
||||||
|
-- Generate the favicons
|
||||||
faviconsRules "icons/favicon.svg"
|
faviconsRules "icons/favicon.svg"
|
||||||
|
|
||||||
match (fromList ["humans.txt", "robots.txt"]) $ do
|
-- Straight copying of files
|
||||||
|
match (fromList ["humans.txt", "robots.txt", "fonts/*"]) $ do
|
||||||
route idRoute
|
route idRoute
|
||||||
compile copyFileCompiler
|
compile copyFileCompiler
|
||||||
|
|
||||||
|
-- CSS needs to be compiled and minified
|
||||||
match "css/*" $ do
|
match "css/*" $ do
|
||||||
route idRoute
|
route idRoute
|
||||||
compile compressCssCompiler
|
compile compressCssCompiler
|
||||||
|
|
||||||
match "fonts/*" $ do
|
-- Load pages that need to be formatted
|
||||||
route idRoute
|
|
||||||
compile copyFileCompiler
|
|
||||||
|
|
||||||
match (fromList ["about.md", "contact.md"]) $ do
|
match (fromList ["about.md", "contact.md"]) $ do
|
||||||
route $ cleanRoute
|
route $ cleanRoute
|
||||||
compile $ pandocCompiler
|
compile $ pandocCompiler
|
||||||
@ -32,6 +36,19 @@ main = do
|
|||||||
>>= relativizeUrls
|
>>= relativizeUrls
|
||||||
>>= cleanIndexUrls
|
>>= cleanIndexUrls
|
||||||
|
|
||||||
|
-- Render Atom + Rss feeds
|
||||||
|
create ["atom.xml"] $ do
|
||||||
|
route idRoute
|
||||||
|
(compileFeed renderAtom)
|
||||||
|
|
||||||
|
create ["rss.xml"] $ do
|
||||||
|
route idRoute
|
||||||
|
(compileFeed renderRss)
|
||||||
|
|
||||||
|
-- Compile the templates
|
||||||
|
match "templates/*" $ compile templateBodyCompiler
|
||||||
|
|
||||||
|
-- Compile the archive page and post list
|
||||||
match "archive.md" $ do
|
match "archive.md" $ do
|
||||||
route $ cleanRoute
|
route $ cleanRoute
|
||||||
compile $ pandocCompiler
|
compile $ pandocCompiler
|
||||||
@ -50,6 +67,7 @@ main = do
|
|||||||
>>= relativizeUrls
|
>>= relativizeUrls
|
||||||
>>= cleanIndexUrls
|
>>= cleanIndexUrls
|
||||||
|
|
||||||
|
-- Compile posts + save snapshots for the web feeds
|
||||||
match "posts/*" $ do
|
match "posts/*" $ do
|
||||||
route $ cleanRoute
|
route $ cleanRoute
|
||||||
compile $ pandocCompiler
|
compile $ pandocCompiler
|
||||||
@ -60,6 +78,7 @@ main = do
|
|||||||
>>= cleanIndexUrls
|
>>= cleanIndexUrls
|
||||||
>>= cleanIndexHtmls
|
>>= cleanIndexHtmls
|
||||||
|
|
||||||
|
-- Compile and load posts
|
||||||
match "index.html" $ do
|
match "index.html" $ do
|
||||||
route idRoute
|
route idRoute
|
||||||
compile $ do
|
compile $ do
|
||||||
@ -73,34 +92,43 @@ main = do
|
|||||||
>>= cleanIndexUrls
|
>>= cleanIndexUrls
|
||||||
>>= cleanIndexHtmls
|
>>= cleanIndexHtmls
|
||||||
|
|
||||||
match "templates/*" $ compile templateBodyCompiler
|
-- Agnememnon the Fuck-Upperer - Conquerer of Small Type Declarations
|
||||||
|
compileFeed ::
|
||||||
|
(FeedConfiguration
|
||||||
|
-> Context String
|
||||||
|
-> [Item String]
|
||||||
|
-> Compiler (Item String)
|
||||||
|
) -> Rules ()
|
||||||
|
-- For those left alive, this abstracts out creating
|
||||||
|
-- Atom and RSS feeds
|
||||||
|
compileFeed f = compile $ do
|
||||||
|
let feedCtx = postCtx <>
|
||||||
|
bodyField "description"
|
||||||
|
posts <- fmap (take 10) . recentFirst
|
||||||
|
=<< loadAllSnapshots "posts/*" "content"
|
||||||
|
f feedConfig feedCtx posts
|
||||||
|
|
||||||
create ["atom.xml"] $ do
|
-- The configuration for our Atom/RSS feeds
|
||||||
route idRoute
|
feedConfig :: FeedConfiguration
|
||||||
compile $ do
|
feedConfig = FeedConfiguration {
|
||||||
let feedCtx = postCtx <>
|
feedTitle = "Regular Flolloping"
|
||||||
bodyField "description"
|
, feedDescription = "tA's Blog"
|
||||||
posts <- fmap (take 10) . recentFirst
|
, feedAuthorName = "Shaun Kerr"
|
||||||
=<< loadAllSnapshots "posts/*" "content"
|
, feedAuthorEmail = "s@p7.co.nz"
|
||||||
renderAtom feedConfig feedCtx posts
|
, feedRoot = "https://regularflolloping.com"
|
||||||
|
}
|
||||||
create ["rss.xml"] $ do
|
|
||||||
route idRoute
|
|
||||||
compile $ do
|
|
||||||
let feedCtx = postCtx <>
|
|
||||||
bodyField "description"
|
|
||||||
posts <- fmap (take 10) . recentFirst
|
|
||||||
=<< loadAllSnapshots "posts/*" "content"
|
|
||||||
renderRss feedConfig feedCtx posts
|
|
||||||
|
|
||||||
|
-- Our default context for pages
|
||||||
ctx :: Context String
|
ctx :: Context String
|
||||||
ctx = defaultContext <>
|
ctx = defaultContext <>
|
||||||
faviconsField
|
faviconsField
|
||||||
|
|
||||||
|
-- Default context for posts
|
||||||
postCtx :: Context String
|
postCtx :: Context String
|
||||||
postCtx =
|
postCtx =
|
||||||
(dateField "date" "%B %e, %Y") <> ctx
|
(dateField "date" "%B %e, %Y") <> ctx
|
||||||
|
|
||||||
|
-- Functions to convert pages to /name/index.html
|
||||||
cleanRoute :: Routes
|
cleanRoute :: Routes
|
||||||
cleanRoute = customRoute createIndexRoute
|
cleanRoute = customRoute createIndexRoute
|
||||||
where
|
where
|
||||||
@ -122,12 +150,3 @@ cleanIndex url
|
|||||||
| idx `isSuffixOf` url = take (length url - length idx) url
|
| idx `isSuffixOf` url = take (length url - length idx) url
|
||||||
| otherwise = url
|
| otherwise = url
|
||||||
where idx = "index.html"
|
where idx = "index.html"
|
||||||
|
|
||||||
feedConfig :: FeedConfiguration
|
|
||||||
feedConfig = FeedConfiguration {
|
|
||||||
feedTitle = "Regular Flolloping"
|
|
||||||
, feedDescription = "tA's Blog"
|
|
||||||
, feedAuthorName = "Shaun Kerr"
|
|
||||||
, feedAuthorEmail = "s@p7.co.nz"
|
|
||||||
, feedRoot = "https://regularflolloping.com"
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user