Browse Source

move to shake

shake
parent
commit
a7df9b3959
Signed by: yogsototh GPG Key ID: 7B19A4C650D59646
  1. 38
      Shakefile.hs
  2. 3
      build.sh
  3. 7
      engine/compresscss.sh
  4. 4
      engine/dup-for-themes.sh
  5. 4
      engine/mkrss.sh
  6. 4
      engine/optim-classes.sh
  7. 4
      engine/optim-html.sh
  8. 11
      engine/shell.nix
  9. 4
      engine/update-file-size.sh
  10. 2
      project.el
  11. 36
      shell.nix

38
Shakefile.hs

@ -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

@ -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 "$@"

7
engine/compresscss.sh

@ -1,8 +1,3 @@
#!/usr/bin/env nix-shell
#!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
#!/usr/bin/env bash
minify "$1" > "$2"

4
engine/dup-for-themes.sh

@ -1,6 +1,4 @@
#!/usr/bin/env nix-shell
#!nix-shell -i zsh
#!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"
#!/usr/bin/env zsh
cd "$(git rev-parse --show-toplevel)" || exit 1

4
engine/mkrss.sh

@ -1,6 +1,4 @@
#!/usr/bin/env nix-shell
#!nix-shell -i zsh
#!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"
#!/usr/bin/env zsh
cd "$(git rev-parse --show-toplevel)" || exit 1
# Directory

4
engine/optim-classes.sh

@ -1,6 +1,4 @@
#!/usr/bin/env nix-shell
#!nix-shell -i zsh
#!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"
#!/usr/bin/env zsh
cd "$(git rev-parse --show-toplevel)" || exit 1
webdir="_optim"

4
engine/optim-html.sh

@ -1,6 +1,4 @@
#!/usr/bin/env nix-shell
#!nix-shell -i zsh
#!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"
#!/usr/bin/env zsh
cd "$(git rev-parse --show-toplevel)" || exit 1
webdir="_optim"

11
engine/shell.nix

@ -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
];
}

4
engine/update-file-size.sh

@ -1,6 +1,4 @@
#!/usr/bin/env nix-shell
#!nix-shell -i zsh
#!nix-shell -I nixpkgs="https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"
#!/usr/bin/env zsh
cd "$(git rev-parse --show-toplevel)" || exit 1
webdir="_optim"

2
project.el

@ -284,7 +284,7 @@
" %s" ;; source
" -sampling-factor 4:2:0"
" -strip"
" -resize 200x200\\>"
" -resize 300x300\\>"
" -interlace Plane"
" -quality 85"
" -define filter:blur=0.75"

36
shell.nix

@ -1,15 +1,23 @@
# { pkgs ? import <nixpkgs> {} }:
{ pkgs ? import (fetchTarball https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz) {} }:
let my_aspell = pkgs.aspellWithDicts(p: with p; [en fr]);
in
pkgs.mkShell {
buildInputs = [ pkgs.coreutils
pkgs.html-xml-utils
pkgs.zsh
pkgs.perl
pkgs.perlPackages.URI
pkgs.minify
pkgs.haskellPackages.sws
pkgs.cacert
];
{ pkgs ? import (fetchTarball https://github.com/NixOS/nixpkgs/archive/20.03.tar.gz) {} }:
let
haskellDeps = ps : with ps; [
shake
];
pkgs1909 = import (fetchTarball https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz) {};
ghc = pkgs.haskellPackages.ghcWithPackages haskellDeps;
in
pkgs.mkShell {
buildInputs = with pkgs;
[cacert
coreutils
html-xml-utils
zsh
perl
perlPackages.URI
minify
niv
ghc
pkgs1909.haskellPackages.sws
haskellPackages.shake
];
}

Loading…
Cancel
Save