move to shake
This commit is contained in:
parent
84bdac8e87
commit
a7df9b3959
11 changed files with 70 additions and 47 deletions
38
Shakefile.hs
Normal file
38
Shakefile.hs
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import Development.Shake
|
||||||
|
import Development.Shake.Command
|
||||||
|
import Development.Shake.FilePath
|
||||||
|
import Development.Shake.Util
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = do
|
||||||
|
let shOpts = shakeOptions { shakeVerbosity = Chatty, shakeLintInside = ["\\"] }
|
||||||
|
shakeArgsForward shOpts buildRules
|
||||||
|
|
||||||
|
buildRules :: Action ()
|
||||||
|
buildRules = do
|
||||||
|
allPosts <- buildPosts
|
||||||
|
buildIndex allPosts
|
||||||
|
buildFeed allPosts
|
||||||
|
copyStaticFiles
|
||||||
|
|
||||||
|
-- | Find and build all posts
|
||||||
|
buildPosts :: Action [Post]
|
||||||
|
buildPosts = do
|
||||||
|
pPaths <- getDirectoryFiles "." ["site/posts//*.md"]
|
||||||
|
forP pPaths buildPost
|
||||||
|
|
||||||
|
-- | Load a post, process metadata, write it to output, then return the post object
|
||||||
|
-- Detects changes to either post content or template
|
||||||
|
buildPost :: FilePath -> Action Post
|
||||||
|
buildPost srcPath = cacheAction ("build" :: T.Text, srcPath) $ do
|
||||||
|
liftIO . putStrLn $ "Rebuilding post: " <> srcPath
|
||||||
|
postContent <- readFile' srcPath
|
||||||
|
-- load post content and metadata as JSON blob
|
||||||
|
postData <- markdownToHTML . T.pack $ postContent
|
||||||
|
let postUrl = T.pack . dropDirectory1 $ srcPath -<.> "html"
|
||||||
|
withPostUrl = _Object . at "url" ?~ String postUrl
|
||||||
|
-- Add additional metadata we've been able to compute
|
||||||
|
let fullPostData = withSiteMeta . withPostUrl $ postData
|
||||||
|
template <- compileTemplate' "site/templates/post.html"
|
||||||
|
writeFile' (outputFolder </> T.unpack postUrl) . T.unpack $ substitute template fullPostData
|
||||||
|
convert fullPostData
|
3
build.sh
Executable file
3
build.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
mkdir -p _shake
|
||||||
|
ghc --make Shakefile.hs -rtsopts -threaded -with-rtsopts=-I0 -outputdir=_shake -o _shake/build && _shake/build "$@"
|
|
@ -1,8 +1,3 @@
|
||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env bash
|
||||||
#!nix-shell -i bash
|
|
||||||
#!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"
|
|
||||||
#!nix-shell -p minify
|
|
||||||
|
|
||||||
# nix-shell -p nodePackages.clean-css
|
|
||||||
|
|
||||||
minify "$1" > "$2"
|
minify "$1" > "$2"
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env zsh
|
||||||
#!nix-shell -i zsh
|
|
||||||
#!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"
|
|
||||||
|
|
||||||
cd "$(git rev-parse --show-toplevel)" || exit 1
|
cd "$(git rev-parse --show-toplevel)" || exit 1
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env zsh
|
||||||
#!nix-shell -i zsh
|
|
||||||
#!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"
|
|
||||||
|
|
||||||
cd "$(git rev-parse --show-toplevel)" || exit 1
|
cd "$(git rev-parse --show-toplevel)" || exit 1
|
||||||
# Directory
|
# Directory
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env zsh
|
||||||
#!nix-shell -i zsh
|
|
||||||
#!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"
|
|
||||||
|
|
||||||
cd "$(git rev-parse --show-toplevel)" || exit 1
|
cd "$(git rev-parse --show-toplevel)" || exit 1
|
||||||
webdir="_optim"
|
webdir="_optim"
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env zsh
|
||||||
#!nix-shell -i zsh
|
|
||||||
#!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"
|
|
||||||
|
|
||||||
cd "$(git rev-parse --show-toplevel)" || exit 1
|
cd "$(git rev-parse --show-toplevel)" || exit 1
|
||||||
webdir="_optim"
|
webdir="_optim"
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
# { pkgs ? import <nixpkgs> {} }:
|
|
||||||
{ pkgs ? import (fetchTarball https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz) {} }:
|
|
||||||
pkgs.mkShell {
|
|
||||||
buildInputs = [ pkgs.coreutils
|
|
||||||
pkgs.html-xml-utils
|
|
||||||
pkgs.zsh
|
|
||||||
pkgs.perl
|
|
||||||
pkgs.perlPackages.URI
|
|
||||||
pkgs.minify
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -1,6 +1,4 @@
|
||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env zsh
|
||||||
#!nix-shell -i zsh
|
|
||||||
#!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"
|
|
||||||
|
|
||||||
cd "$(git rev-parse --show-toplevel)" || exit 1
|
cd "$(git rev-parse --show-toplevel)" || exit 1
|
||||||
webdir="_optim"
|
webdir="_optim"
|
||||||
|
|
|
@ -284,7 +284,7 @@
|
||||||
" %s" ;; source
|
" %s" ;; source
|
||||||
" -sampling-factor 4:2:0"
|
" -sampling-factor 4:2:0"
|
||||||
" -strip"
|
" -strip"
|
||||||
" -resize 200x200\\>"
|
" -resize 300x300\\>"
|
||||||
" -interlace Plane"
|
" -interlace Plane"
|
||||||
" -quality 85"
|
" -quality 85"
|
||||||
" -define filter:blur=0.75"
|
" -define filter:blur=0.75"
|
||||||
|
|
30
shell.nix
30
shell.nix
|
@ -1,15 +1,23 @@
|
||||||
# { pkgs ? import <nixpkgs> {} }:
|
{ pkgs ? import (fetchTarball https://github.com/NixOS/nixpkgs/archive/20.03.tar.gz) {} }:
|
||||||
{ pkgs ? import (fetchTarball https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz) {} }:
|
let
|
||||||
let my_aspell = pkgs.aspellWithDicts(p: with p; [en fr]);
|
haskellDeps = ps : with ps; [
|
||||||
|
shake
|
||||||
|
];
|
||||||
|
pkgs1909 = import (fetchTarball https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz) {};
|
||||||
|
ghc = pkgs.haskellPackages.ghcWithPackages haskellDeps;
|
||||||
in
|
in
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
buildInputs = [ pkgs.coreutils
|
buildInputs = with pkgs;
|
||||||
pkgs.html-xml-utils
|
[cacert
|
||||||
pkgs.zsh
|
coreutils
|
||||||
pkgs.perl
|
html-xml-utils
|
||||||
pkgs.perlPackages.URI
|
zsh
|
||||||
pkgs.minify
|
perl
|
||||||
pkgs.haskellPackages.sws
|
perlPackages.URI
|
||||||
pkgs.cacert
|
minify
|
||||||
|
niv
|
||||||
|
ghc
|
||||||
|
pkgs1909.haskellPackages.sws
|
||||||
|
haskellPackages.shake
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue