From 3afebc0c8e80d1493e1605863176e9bfdf89784a Mon Sep 17 00:00:00 2001 From: "Laurent P. René de Cotret" Date: Tue, 30 Jun 2020 08:57:47 -0400 Subject: Continuous integration on Windows and Linux --- .github/workflows/main.yml | 53 ++++++++++++++++++++++++++++++++++++-------- hakyll.cabal | 2 +- lib/Hakyll/Core/Util/File.hs | 30 ++++++++++++++++++++++++- 3 files changed, 74 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9253d60..4e2b7c3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,20 +1,55 @@ +# This Github Actions workflow is modified from +# https://kodimensional.dev/github-actions name: 'CI' -on: ['push'] + +# Trigger the workflow on push or pull request, but only for the master branch +on: [push, pull_request] + jobs: build: + strategy: matrix: os: [ubuntu-latest, windows-latest] + + env: + ARGS: --no-terminal --fast name: ${{ matrix.os }} - runs-on: $${{ matrix.os }} + runs-on: ${{ matrix.os }} steps: - - uses: 'actions/checkout@v1' - - uses: 'mstksg/setup-stack@v1' - - uses: 'actions/cache@v1' + - uses: actions/checkout@v2 + if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' + + # https://github.com/actions/setup-haskell + - uses: actions/setup-haskell@v1.1 + name: Setup Haskell Stack with: - path: '~/.stack' - key: "${{ runner.os }}-v3-stack-${{ hashFiles('stack.yaml.lock') }}" - restore-keys: '${{ runner.os }}-v3-stack' - - run: 'stack build --test' + stack-version: "latest" + enable-stack: true + stack-no-global: true + + # https://github.com/actions/cache + - uses: actions/cache@v2 + name: Cache ~/.stack + with: + path: ~/.stack + key: ${{ runner.os }}-${{ hashFiles('stack.yaml') }} + + # There are strange problems with CI on Windows, where builds with GHC 8.8.* + # always fail. Therefore, we distinguish between builds on Ubuntu and Windows + # and use an older compiler on Windows. + # See here for bug reports: + # https://gitlab.haskell.org/ghc/ghc/issues/17599 + # https://gitlab.haskell.org/ghc/ghc/issues/17926 + + - name: Test (Ubuntu) + run: | + stack test $ARGS --stack-yaml stack.yaml + if: ${{ runner.os == 'Linux' }} + + - name: Test (Windows) + run: | + stack test $ARGS --stack-yaml stack.yaml --compiler ghc-8.6.5 + if: ${{ runner.os == 'Windows' }} diff --git a/hakyll.cabal b/hakyll.cabal index 4be61bc..6607ebf 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -173,7 +173,7 @@ Library cryptonite >= 0.25 && < 0.27, data-default >= 0.4 && < 0.8, deepseq >= 1.3 && < 1.5, - directory >= 1.0 && < 1.4, + directory >= 1.2.7.0 && < 1.4, file-embed >= 0.0.10.1 && < 0.0.12, filepath >= 1.0 && < 1.5, lrucache >= 1.1.1 && < 1.3, diff --git a/lib/Hakyll/Core/Util/File.hs b/lib/Hakyll/Core/Util/File.hs index 9db6b11..02b8ece 100644 --- a/lib/Hakyll/Core/Util/File.hs +++ b/lib/Hakyll/Core/Util/File.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE CPP #-} -------------------------------------------------------------------------------- -- | A module containing various file utility functions module Hakyll.Core.Util.File @@ -8,10 +10,12 @@ module Hakyll.Core.Util.File -------------------------------------------------------------------------------- +import Control.Concurrent (threadDelay) +import Control.Exception (SomeException, catch) import Control.Monad (filterM, forM, when) import System.Directory (createDirectoryIfMissing, doesDirectoryExist, getDirectoryContents, - removeDirectoryRecursive) + removeDirectoryRecursive, removePathForcibly) import System.FilePath (takeDirectory, ()) @@ -51,6 +55,30 @@ getRecursiveContents ignore top = go "" -------------------------------------------------------------------------------- removeDirectory :: FilePath -> IO () +#ifndef mingw32_HOST_OS removeDirectory fp = do e <- doesDirectoryExist fp when e $ removeDirectoryRecursive fp +#else +-- Deleting files on Windows is unreliable. If a file/directory is open by a program (e.g. antivirus), +-- then removing related directories *quickly* may fail with strange messages. +-- See here for discussions: +-- https://github.com/haskell/directory/issues/96 +-- https://github.com/haskell/win32/pull/129 +-- +-- The hacky solution is to retry deleting directories a few times, +-- with a delay, on Windows only. +removeDirectory = retryWithDelay 10 . removePathForcibly +#endif + + +-------------------------------------------------------------------------------- +-- | Retry an operation at most /n/ times (/n/ must be positive). +-- If the operation fails the /n/th time it will throw that final exception. +-- A delay of 100ms is introduced between every retry. +retryWithDelay :: Int -> IO a -> IO a +retryWithDelay i x + | i <= 0 = error "Hakyll.Core.Util.File.retry: retry count must be 1 or more" + | i == 1 = x + | otherwise = catch x $ \(_::SomeException) -> threadDelay 100 >> retryWithDelay (i-1) x + -- cgit v1.2.3 From b9a616820599f8c6f129fd464700b41e619ede09 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Tue, 30 Jun 2020 14:55:36 +0200 Subject: Bump tasty upper bound to 1.4 --- hakyll.cabal | 2 +- stack.yaml | 4 +--- stack.yaml.lock | 16 +--------------- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/hakyll.cabal b/hakyll.cabal index 6607ebf..570aa2a 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -266,7 +266,7 @@ Test-suite hakyll-tests Build-Depends: hakyll, QuickCheck >= 2.8 && < 2.14, - tasty >= 0.11 && < 1.3, + tasty >= 0.11 && < 1.4, tasty-hunit >= 0.9 && < 0.11, tasty-quickcheck >= 0.8 && < 0.11, -- Copy pasted from hakyll dependencies: diff --git a/stack.yaml b/stack.yaml index fff5623..c3958dd 100644 --- a/stack.yaml +++ b/stack.yaml @@ -22,6 +22,4 @@ build: haddock-hyperlink-source: true haddock-deps: false -extra-deps: -- 'lrucache-1.2.0.1' -- 'warp-3.3.9' +extra-deps: [] diff --git a/stack.yaml.lock b/stack.yaml.lock index 2d4b776..ebcdead 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -3,21 +3,7 @@ # For more information, please see the documentation at: # https://docs.haskellstack.org/en/stable/lock_files -packages: -- completed: - hackage: lrucache-1.2.0.1@sha256:18fc3d7052012c7ab3cd395160f34b53c5e1ec5379cc45185baf35b90ffadc2e,1254 - pantry-tree: - size: 619 - sha256: 61b2a39a11873f2d8a577e1f6b5e848d2f465ea7f6837ce15436796d3a20eda0 - original: - hackage: lrucache-1.2.0.1 -- completed: - hackage: warp-3.3.9@sha256:fc09116f4298811129b3a405f8487459ea7a052132f7474c3cd598cdc7d3d77b,10797 - pantry-tree: - size: 3898 - sha256: 54ca89c1bebb00b20a54aca8838e2e32ff68775d84b50a3139438b49646b431f - original: - hackage: warp-3.3.9 +packages: [] snapshots: - completed: size: 491387 -- cgit v1.2.3 From f22e5ed05513f13280c8238673109ff71dc431f3 Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Tue, 30 Jun 2020 20:59:37 +0800 Subject: Bump cryptonite upper bound to 0.28 --- hakyll.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hakyll.cabal b/hakyll.cabal index 570aa2a..317ca47 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -170,7 +170,7 @@ Library blaze-markup >= 0.5.1 && < 0.9, bytestring >= 0.9 && < 0.11, containers >= 0.3 && < 0.7, - cryptonite >= 0.25 && < 0.27, + cryptonite >= 0.25 && < 0.28, data-default >= 0.4 && < 0.8, deepseq >= 1.3 && < 1.5, directory >= 1.2.7.0 && < 1.4, -- cgit v1.2.3 From 7873e570afb3b51b2382e158bfd45e7ba6889981 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Tue, 30 Jun 2020 15:02:41 +0200 Subject: Bump version to 4.13.4.0 --- CHANGELOG.md | 6 ++++++ hakyll.cabal | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a11bab2..e9b29f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ title: Releases # Releases +## Hakyll 4.13.4.0 (2020-06-20) + +- Miscellaneous Windows-specific fixes and CI (by Laurent P. René de Cotret) +- Bump upper bound for `cryptonite` to 0.28 +- Bump upper bound for `tasty` to 1.4 + ## Hakyll 4.13.3.0 (2020-04-12) - Fix compilation issue related to `MonadFail` on Windows (by Martín Emanuel) diff --git a/hakyll.cabal b/hakyll.cabal index 317ca47..c80c392 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -1,5 +1,5 @@ Name: hakyll -Version: 4.13.3.0 +Version: 4.13.4.0 Synopsis: A static website compiler library Description: -- cgit v1.2.3 From eead94fde4278ccf78728eec1d5a99c99d40c32b Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sun, 30 Aug 2020 14:12:34 +0200 Subject: Add xvw.github.io to examples --- web/examples.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/examples.markdown b/web/examples.markdown index 3657ea0..770eecb 100644 --- a/web/examples.markdown +++ b/web/examples.markdown @@ -192,6 +192,8 @@ directly with the default Hakyll site. [source](https://github.com/rpearce/robertwpearce.com) - , [source](https://github.com/thjread/thjread-blog) +- , + [source](https://github.com/xvw/planet) ## Hakyll 3.X -- cgit v1.2.3 From f24c5873ed5bb091f0ce5ebdf4df7ab160e87c75 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Wed, 30 Sep 2020 14:04:33 +0200 Subject: Bump template-haskell and pandoc versions * Bumped bound for pandoc and add Binary-instances for new constructors that were added to pandoc-types * Support most recent template-haskell release * Set lower bound of pandoc to version 2.10 * Update CI configuration * Bump QuickCheck upper bound to 2.15 Co-authored-by: OC4 --- .github/workflows/main.yml | 104 +++++++++++++++++++++++++++------------- hakyll.cabal | 8 ++-- lib/Hakyll/Web/Pandoc/Binary.hs | 10 ++++ stack.yaml | 11 ++++- stack.yaml.lock | 59 +++++++++++++++++++++-- 5 files changed, 147 insertions(+), 45 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4e2b7c3..bfb65f2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,55 +1,91 @@ -# This Github Actions workflow is modified from -# https://kodimensional.dev/github-actions -name: 'CI' +name: CI # Trigger the workflow on push or pull request, but only for the master branch -on: [push, pull_request] +on: + pull_request: + push: + branches: [master] jobs: - build: + cabal: + name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + cabal: ["3.2"] + ghc: + - "8.6.5" + - "8.8.3" + - "8.10.1" + exclude: + - os: macOS-latest + ghc: 8.8.3 + - os: macOS-latest + ghc: 8.6.5 + - os: windows-latest + ghc: 8.8.3 + - os: windows-latest + ghc: 8.6.5 + + steps: + - uses: actions/checkout@v2 + if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' + + - uses: actions/setup-haskell@v1.1.1 + id: setup-haskell-cabal + name: Setup Haskell + with: + ghc-version: ${{ matrix.ghc }} + cabal-version: ${{ matrix.cabal }} + + - name: Freeze + run: | + cabal freeze + + - uses: actions/cache@v1 + name: Cache ~/.cabal/store + with: + path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }} + key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }} + + - name: Build + run: | + cabal configure --enable-tests --enable-benchmarks --test-show-details=direct + cabal build all + - name: Test + run: | + cabal test all + + stack: + name: stack / ghc ${{ matrix.ghc }} + runs-on: ubuntu-latest strategy: matrix: - os: [ubuntu-latest, windows-latest] + stack: ["2.3.1"] + ghc: ["8.8.3"] - env: - ARGS: --no-terminal --fast - - name: ${{ matrix.os }} - runs-on: ${{ matrix.os }} - steps: - uses: actions/checkout@v2 if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' - # https://github.com/actions/setup-haskell - uses: actions/setup-haskell@v1.1 name: Setup Haskell Stack with: - stack-version: "latest" - enable-stack: true - stack-no-global: true - - # https://github.com/actions/cache - - uses: actions/cache@v2 + ghc-version: ${{ matrix.ghc }} + stack-version: ${{ matrix.stack }} + + - uses: actions/cache@v1 name: Cache ~/.stack with: path: ~/.stack - key: ${{ runner.os }}-${{ hashFiles('stack.yaml') }} - - # There are strange problems with CI on Windows, where builds with GHC 8.8.* - # always fail. Therefore, we distinguish between builds on Ubuntu and Windows - # and use an older compiler on Windows. - # See here for bug reports: - # https://gitlab.haskell.org/ghc/ghc/issues/17599 - # https://gitlab.haskell.org/ghc/ghc/issues/17926 - - - name: Test (Ubuntu) + key: ${{ runner.os }}-${{ matrix.ghc }}-stack + + - name: Build run: | - stack test $ARGS --stack-yaml stack.yaml - if: ${{ runner.os == 'Linux' }} + stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks - - name: Test (Windows) + - name: Test run: | - stack test $ARGS --stack-yaml stack.yaml --compiler ghc-8.6.5 - if: ${{ runner.os == 'Windows' }} + stack test --system-ghc diff --git a/hakyll.cabal b/hakyll.cabal index c80c392..e7af07d 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -188,7 +188,7 @@ Library resourcet >= 1.1 && < 1.3, scientific >= 0.3.4 && < 0.4, tagsoup >= 0.13.1 && < 0.15, - template-haskell >= 2.14 && < 2.16, + template-haskell >= 2.14 && < 2.17, text >= 0.11 && < 1.3, time >= 1.8 && < 1.10, time-locale-compat >= 0.1 && < 0.2, @@ -232,7 +232,7 @@ Library Other-Modules: Hakyll.Web.Pandoc.Binary Build-Depends: - pandoc >= 2.0.5 && < 2.10, + pandoc >= 2.10 && < 2.11, pandoc-citeproc >= 0.14 && < 0.18 Cpp-options: -DUSE_PANDOC @@ -265,7 +265,7 @@ Test-suite hakyll-tests Build-Depends: hakyll, - QuickCheck >= 2.8 && < 2.14, + QuickCheck >= 2.8 && < 2.15, tasty >= 0.11 && < 1.4, tasty-hunit >= 0.9 && < 0.11, tasty-quickcheck >= 0.8 && < 0.11, @@ -327,4 +327,4 @@ Executable hakyll-website base >= 4 && < 5, directory >= 1.0 && < 1.4, filepath >= 1.0 && < 1.5, - pandoc >= 2.0.5 && < 2.10 + pandoc >= 2.10 && < 2.11 diff --git a/lib/Hakyll/Web/Pandoc/Binary.hs b/lib/Hakyll/Web/Pandoc/Binary.hs index deeaf08..5d3efea 100644 --- a/lib/Hakyll/Web/Pandoc/Binary.hs +++ b/lib/Hakyll/Web/Pandoc/Binary.hs @@ -14,6 +14,10 @@ import Text.Pandoc instance Binary Alignment instance Binary Block +instance Binary Caption +instance Binary Cell +instance Binary ColSpan +instance Binary ColWidth instance Binary CSL.Reference instance Binary Citation instance Binary CitationMode @@ -29,5 +33,11 @@ instance Binary REF.Literal instance Binary REF.RefDate instance Binary REF.RefType instance Binary REF.Season +instance Binary Row +instance Binary RowHeadColumns +instance Binary RowSpan instance Binary STY.Agent instance Binary STY.Formatted +instance Binary TableBody +instance Binary TableFoot +instance Binary TableHead diff --git a/stack.yaml b/stack.yaml index c3958dd..49c9f69 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-15.6 +resolver: lts-16.9 save-hackage-creds: false flags: @@ -22,4 +22,11 @@ build: haddock-hyperlink-source: true haddock-deps: false -extra-deps: [] +extra-deps: +- 'commonmark-0.1.0.2' +- 'commonmark-extensions-0.2.0.1' +- 'commonmark-pandoc-0.2.0.1' +- 'hslua-1.1.2' +- 'jira-wiki-markup-1.3.2' +- 'pandoc-2.10.1' +- 'pandoc-types-1.21' diff --git a/stack.yaml.lock b/stack.yaml.lock index ebcdead..5de18d3 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -3,10 +3,59 @@ # For more information, please see the documentation at: # https://docs.haskellstack.org/en/stable/lock_files -packages: [] +packages: +- completed: + hackage: commonmark-0.1.0.2@sha256:fbff7a2ade0ce7d699964a87f765e503a3a9e22542c05f0f02ba7aad64e38af4,3278 + pantry-tree: + size: 1346 + sha256: 991da6da60804286b9ea23a1522e18ceeabddfdf416787231db9fd047c163f53 + original: + hackage: commonmark-0.1.0.2 +- completed: + hackage: commonmark-extensions-0.2.0.1@sha256:647aa8dba5fd46984ddedc15c3693c9c4d9655503d42006576bd8f0dadf8cd39,3176 + pantry-tree: + size: 2927 + sha256: 89e1ee05938d558834c397a3a22cdacc755a1941c144f4c1f3daf8a1ede943ce + original: + hackage: commonmark-extensions-0.2.0.1 +- completed: + hackage: commonmark-pandoc-0.2.0.1@sha256:529c6e2c6cabf61558b66a28123eafc1d90d3324be29819f59f024e430312c1f,1105 + pantry-tree: + size: 326 + sha256: d9954a15f73c8fe55a5097e1cc0957fa626d340ef36e2beefb8caae66008c3dc + original: + hackage: commonmark-pandoc-0.2.0.1 +- completed: + hackage: hslua-1.1.2@sha256:6c231b2af447430d1ed04f065d40bb6882ece93cc7f32f4051dc99deb69beeae,9694 + pantry-tree: + size: 6820 + sha256: 62e61f6d08191159a070dcbaa20284a581835de620105a254dbee1c7ddfabd9d + original: + hackage: hslua-1.1.2 +- completed: + hackage: jira-wiki-markup-1.3.2@sha256:b5f0901208a0ee07aff60f5356aeb851b7aa7950c75a18a15fd34247a35886d8,3819 + pantry-tree: + size: 1180 + sha256: 90fa545210a211b8ec88b59f92fe2877ebf2f9e55e2ce2fba6103a3615bd0ab9 + original: + hackage: jira-wiki-markup-1.3.2 +- completed: + hackage: pandoc-2.10.1@sha256:23d7ec480c7cb86740475a419d6ca4819987b6dd23bbae9b50bc3d42a7ed2f9f,36933 + pantry-tree: + size: 89646 + sha256: 08c8b20356152b9ee8161bacafda2dc1bed13d7db4cbf38ab040c1977b2d28d5 + original: + hackage: pandoc-2.10.1 +- completed: + hackage: pandoc-types-1.21@sha256:b61ed625da4d1a0d8057fcca4c0c5e174c9f45d94b41504db1532f3fc581e945,4037 + pantry-tree: + size: 713 + sha256: e26eb93747538e29168032985a03b428039a16000fea1a4a8d9b9b032ac98b5f + original: + hackage: pandoc-types-1.21 snapshots: - completed: - size: 491387 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/15/6.yaml - sha256: 8d81505a6de861e167a58534ab62330afb75bfa108735c7db1204f7ef2a39d79 - original: lts-15.6 + size: 532380 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/9.yaml + sha256: 14a7cec114424e4286adde73364438927a553ed248cc50f069a30a67e3ee1e69 + original: lts-16.9 -- cgit v1.2.3 From e9a8139152b166eae75083259fc3e824675de6fb Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Wed, 30 Sep 2020 14:07:59 +0200 Subject: Bump version to 4.13.4.1 --- CHANGELOG.md | 6 ++++++ hakyll.cabal | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9b29f4..31a10bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ title: Releases # Releases +## Hakyll 4.13.4.1 (2020-09-30) + +- Bump `pandoc` to 2.10.* +- Bump upper bound for `template-haskell` to 2.17 +- Bump `QuickCheck` upper bound to 2.15 + ## Hakyll 4.13.4.0 (2020-06-20) - Miscellaneous Windows-specific fixes and CI (by Laurent P. René de Cotret) diff --git a/hakyll.cabal b/hakyll.cabal index e7af07d..291f836 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -1,5 +1,5 @@ Name: hakyll -Version: 4.13.4.0 +Version: 4.13.4.1 Synopsis: A static website compiler library Description: -- cgit v1.2.3 From d993b493856331cc1a67c216728097da1dfc9e3d Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Thu, 12 Nov 2020 04:01:39 +0800 Subject: Allow file-embed 0.0.12 (#774) Builds fine and all tests pass here. --- hakyll.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hakyll.cabal b/hakyll.cabal index 291f836..bd3bfdc 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -174,7 +174,7 @@ Library data-default >= 0.4 && < 0.8, deepseq >= 1.3 && < 1.5, directory >= 1.2.7.0 && < 1.4, - file-embed >= 0.0.10.1 && < 0.0.12, + file-embed >= 0.0.10.1 && < 0.0.13, filepath >= 1.0 && < 1.5, lrucache >= 1.1.1 && < 1.3, memory >= 0.14.18 && < 0.16, -- cgit v1.2.3 From 6808e125e6281a200c18871d5c69d722001943d6 Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Thu, 12 Nov 2020 05:11:34 +0800 Subject: Allow random 1.2 (#792) Builds fine and all tests pass here. --- hakyll.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hakyll.cabal b/hakyll.cabal index bd3bfdc..d481485 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -183,7 +183,7 @@ Library optparse-applicative >= 0.12 && < 0.16, parsec >= 3.0 && < 3.2, process >= 1.6 && < 1.7, - random >= 1.0 && < 1.2, + random >= 1.0 && < 1.3, regex-tdfa >= 1.1 && < 1.4, resourcet >= 1.1 && < 1.3, scientific >= 0.3.4 && < 0.4, -- cgit v1.2.3 From 17b4c81c1457e00c17e0ca6c8b2dc9d6d596f349 Mon Sep 17 00:00:00 2001 From: Marko Dimjašević Date: Wed, 11 Nov 2020 22:12:19 +0100 Subject: Update a reference to Debian now that Hakyll is available in the Debian stable release (#798) --- web/tutorials/01-installation.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/tutorials/01-installation.markdown b/web/tutorials/01-installation.markdown index 16e73c8..c41d9a6 100644 --- a/web/tutorials/01-installation.markdown +++ b/web/tutorials/01-installation.markdown @@ -21,7 +21,7 @@ Hakyll. 3. There are also some Linux distro packages: - - [Debian unstable](http://packages.debian.org/source/sid/haskell-hakyll) + - [Debian](https://packages.debian.org/source/stable/haskell-hakyll) - [Fedora](https://apps.fedoraproject.org/packages/ghc-hakyll) - [Nix]: `$ nix-env -iA nixos.haskellPackages.hakyll` -- cgit v1.2.3 From 6ea0b9bf7c1920278809bc7e507a46ee224944dc Mon Sep 17 00:00:00 2001 From: Tobias Bora Date: Wed, 11 Nov 2020 22:19:08 +0100 Subject: Make sure the initial project is writable (#804) --- src/Init.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Init.hs b/src/Init.hs index 09f8ed7..63899e4 100644 --- a/src/Init.hs +++ b/src/Init.hs @@ -11,7 +11,8 @@ import Data.Char (isAlphaNum, isNumber) import Data.List (foldl', intercalate, isPrefixOf) import Data.Version (Version (..)) import System.Directory (canonicalizePath, copyFile, - doesFileExist) + doesFileExist, + setPermissions, getPermissions, writable) import System.Environment (getArgs, getProgName) import System.Exit (exitFailure) import System.FilePath (splitDirectories, ()) @@ -65,6 +66,10 @@ main = do putStrLn $ "Creating " ++ dst makeDirectories dst copyFile src dst + -- On some systems, the source folder may be readonly, + -- and copyFile will therefore create a readonly project... + p <- getPermissions dst + setPermissions dst (p {writable = True}) putStrLn $ "Creating " ++ cabalPath createCabal cabalPath name -- cgit v1.2.3 From b23e17a3ac868903241d0a05d9061dc890b0174b Mon Sep 17 00:00:00 2001 From: Yannik Sander Date: Wed, 11 Nov 2020 22:29:58 +0100 Subject: Bump pandoc version (#799) * Bump pandoc version * Bump Pandoc version for hakyll-website Co-authored-by: Alexander Batischev --- hakyll.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hakyll.cabal b/hakyll.cabal index d481485..1415d67 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -232,7 +232,7 @@ Library Other-Modules: Hakyll.Web.Pandoc.Binary Build-Depends: - pandoc >= 2.10 && < 2.11, + pandoc >= 2.10 && < 2.12, pandoc-citeproc >= 0.14 && < 0.18 Cpp-options: -DUSE_PANDOC @@ -327,4 +327,4 @@ Executable hakyll-website base >= 4 && < 5, directory >= 1.0 && < 1.4, filepath >= 1.0 && < 1.5, - pandoc >= 2.10 && < 2.11 + pandoc >= 2.10 && < 2.12 -- cgit v1.2.3 From ab9eea7029e2f666a0accce07ce5f5105f5c2155 Mon Sep 17 00:00:00 2001 From: Liang-Ting Chen Date: Thu, 12 Nov 2020 05:32:10 +0800 Subject: Remove unnecessary conditional compilation for parseTimeM (#781) --- lib/Hakyll/Web/Template/Context.hs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/Hakyll/Web/Template/Context.hs b/lib/Hakyll/Web/Template/Context.hs index 3f75466..9ce7440 100644 --- a/lib/Hakyll/Web/Template/Context.hs +++ b/lib/Hakyll/Web/Template/Context.hs @@ -60,8 +60,7 @@ import Data.List (intercalate, tails) import Data.Semigroup (Semigroup (..)) #endif import Data.Time.Clock (UTCTime (..)) -import Data.Time.Format (formatTime) -import qualified Data.Time.Format as TF +import Data.Time.Format (formatTime, parseTimeM) import Data.Time.Locale.Compat (TimeLocale, defaultTimeLocale) import Hakyll.Core.Compiler import Hakyll.Core.Compiler.Internal @@ -463,10 +462,3 @@ teaserFieldWithSeparator separator key snapshot = field key $ \item -> do missingField :: Context a missingField = Context $ \k _ _ -> noResult $ "Missing field '" ++ k ++ "' in context" - -parseTimeM :: Bool -> TimeLocale -> String -> String -> Maybe UTCTime -#if MIN_VERSION_time(1,5,0) -parseTimeM = TF.parseTimeM -#else -parseTimeM _ = TF.parseTime -#endif -- cgit v1.2.3 From 84157674d955778c806efdafda311b2732242b38 Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Thu, 12 Nov 2020 17:23:28 +0300 Subject: File.hs: +symlink-based static file compiler; for multi-gigabyte sites, this can be a major speedup (see #786) (#810) Co-authored-by: gwern --- lib/Hakyll/Core/File.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/Hakyll/Core/File.hs b/lib/Hakyll/Core/File.hs index 49af659..6a5775e 100644 --- a/lib/Hakyll/Core/File.hs +++ b/lib/Hakyll/Core/File.hs @@ -8,6 +8,8 @@ module Hakyll.Core.File , copyFileCompiler , TmpFile (..) , newTmpFile + , SymlinkFile (..) + , symlinkFileCompiler ) where @@ -20,6 +22,7 @@ import System.Directory (copyFileWithMetadata) import System.Directory (copyFile) #endif import System.Directory (doesFileExist, + createFileLink, renameFile) import System.FilePath (()) import System.Random (randomIO) @@ -56,6 +59,19 @@ copyFileCompiler = do provider <- compilerProvider <$> compilerAsk makeItem $ CopyFile $ resourceFilePath provider identifier +-------------------------------------------------------------------------------- +-- | This will not copy a file but create a symlink, which can save space & time for static sites with many large static files which would normally be handled by copyFileCompiler. (Note: the user will need to make sure their sync method handles symbolic links correctly!) +newtype SymlinkFile = SymlinkFile FilePath + deriving (Binary, Eq, Ord, Show, Typeable) +-------------------------------------------------------------------------------- +instance Writable SymlinkFile where + write dst (Item _ (SymlinkFile src)) = createFileLink src dst +-------------------------------------------------------------------------------- +symlinkFileCompiler :: Compiler (Item SymlinkFile) +symlinkFileCompiler = do + identifier <- getUnderlying + provider <- compilerProvider <$> compilerAsk + makeItem $ SymlinkFile $ resourceFilePath provider identifier -------------------------------------------------------------------------------- newtype TmpFile = TmpFile FilePath -- cgit v1.2.3 From 51d55b2577e2368980a912b2e029ca0d8f80079d Mon Sep 17 00:00:00 2001 From: Liang-Ting Chen Date: Sun, 15 Nov 2020 19:23:04 +0800 Subject: Bump Stackage LTS to 16.21 (#811) --- stack.yaml | 2 +- stack.yaml.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stack.yaml b/stack.yaml index 49c9f69..63ee6a4 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-16.9 +resolver: lts-16.21 save-hackage-creds: false flags: diff --git a/stack.yaml.lock b/stack.yaml.lock index 5de18d3..8636225 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -55,7 +55,7 @@ packages: hackage: pandoc-types-1.21 snapshots: - completed: - size: 532380 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/9.yaml - sha256: 14a7cec114424e4286adde73364438927a553ed248cc50f069a30a67e3ee1e69 - original: lts-16.9 + size: 532413 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/21.yaml + sha256: 7b5cac89352fa4a88606dc6cb250aee9291f21e2e988d464065f5aa51f5de33d + original: lts-16.21 -- cgit v1.2.3 From 850cf285897c22d2f8892695217a6085c2ce4875 Mon Sep 17 00:00:00 2001 From: Mario Lang Date: Mon, 16 Nov 2020 16:10:35 +0100 Subject: Derive Functor, Foldable and Traversable for Item (#815) --- lib/Hakyll/Core/Item.hs | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/lib/Hakyll/Core/Item.hs b/lib/Hakyll/Core/Item.hs index e05df42..af15b94 100644 --- a/lib/Hakyll/Core/Item.hs +++ b/lib/Hakyll/Core/Item.hs @@ -2,6 +2,7 @@ -- | An item is a combination of some content and its 'Identifier'. This way, we -- can still use the 'Identifier' to access metadata. {-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveTraversable #-} module Hakyll.Core.Item ( Item (..) , itemSetBody @@ -25,23 +26,7 @@ import Hakyll.Core.Identifier data Item a = Item { itemIdentifier :: Identifier , itemBody :: a - } deriving (Show, Typeable) - - --------------------------------------------------------------------------------- -instance Functor Item where - fmap f (Item i x) = Item i (f x) - - --------------------------------------------------------------------------------- -instance Foldable Item where - foldr f z (Item _ x) = f x z - - --------------------------------------------------------------------------------- -instance Traversable Item where - traverse f (Item i x) = Item i <$> f x - + } deriving (Show, Typeable, Functor, Foldable, Traversable) -------------------------------------------------------------------------------- instance Binary a => Binary (Item a) where -- cgit v1.2.3 From a9e877c43445cfdb7b1de1fb7ed9b626700851a3 Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Tue, 17 Nov 2020 21:23:37 +0300 Subject: Update actions/setup-haskell to 1.1.3 (#818) --- .github/workflows/main.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bfb65f2..a365310 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,6 +10,9 @@ jobs: cabal: name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} runs-on: ${{ matrix.os }} + env: + # Workaround for actions/setup-haskell@1.1.3 on Windows: https://github.com/actions/runner/pull/779 + ACTIONS_ALLOW_UNSECURE_COMMANDS: true strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] @@ -32,7 +35,7 @@ jobs: - uses: actions/checkout@v2 if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' - - uses: actions/setup-haskell@v1.1.1 + - uses: actions/setup-haskell@v1.1.3 id: setup-haskell-cabal name: Setup Haskell with: @@ -70,7 +73,7 @@ jobs: - uses: actions/checkout@v2 if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' - - uses: actions/setup-haskell@v1.1 + - uses: actions/setup-haskell@v1.1.3 name: Setup Haskell Stack with: ghc-version: ${{ matrix.ghc }} -- cgit v1.2.3 From 205f394f51c4b7b424eba9c19fc1d35ad1e438e3 Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Thu, 19 Nov 2020 16:13:33 +0300 Subject: Update actions/setup-haskell to 1.1.4 (#820) This removes the need for a workaround on Windows. --- .github/workflows/main.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a365310..12276e3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,9 +10,6 @@ jobs: cabal: name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} runs-on: ${{ matrix.os }} - env: - # Workaround for actions/setup-haskell@1.1.3 on Windows: https://github.com/actions/runner/pull/779 - ACTIONS_ALLOW_UNSECURE_COMMANDS: true strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] @@ -35,7 +32,7 @@ jobs: - uses: actions/checkout@v2 if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' - - uses: actions/setup-haskell@v1.1.3 + - uses: actions/setup-haskell@v1.1.4 id: setup-haskell-cabal name: Setup Haskell with: @@ -73,7 +70,7 @@ jobs: - uses: actions/checkout@v2 if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' - - uses: actions/setup-haskell@v1.1.3 + - uses: actions/setup-haskell@v1.1.4 name: Setup Haskell Stack with: ghc-version: ${{ matrix.ghc }} -- cgit v1.2.3 From 0c313aa6ef620d8da098bc200f62bbaf984736c2 Mon Sep 17 00:00:00 2001 From: Thomas Mahler Date: Mon, 23 Nov 2020 19:44:40 +0100 Subject: Issue #822: change tutorial to reflect recent GH Pages features (#823) --- web/tutorials/github-pages-tutorial.md | 126 +++++++++------------------------ 1 file changed, 34 insertions(+), 92 deletions(-) diff --git a/web/tutorials/github-pages-tutorial.md b/web/tutorials/github-pages-tutorial.md index f79605c..acecb38 100644 --- a/web/tutorials/github-pages-tutorial.md +++ b/web/tutorials/github-pages-tutorial.md @@ -10,10 +10,7 @@ type: article Working with Hakyll on a GitHub Pages-hosted website is complicated slightly due to Hakyll outputting files to a ```_site``` subdirectory, our desire to have the source code as well as the compiled site stored in a single repository, and our desire to automate it. -This guide will walkthrough the creation and setup of a GitHub site that has two independent branches. - -1. ```master``` - This is where your site lives. It's what you see when you go to ```https://.github.io```. This branch *needs* to be called master. -2. ```develop``` - This is where your website's source is. That's all your Haskell code, your posts and templates, etc, and it's where you do work from. This name was chosen arbitrarily and can be freely substituted for any name of your choosing. +This guide will walkthrough the creation and setup of a GitHub site that works on a single `master` branch. When you're finished, you will be able to, with one command, refresh your website's contents and send any changes to your GitHub Page. @@ -27,14 +24,15 @@ These instructions should be easy to adapt for any situation though. ## GitHub Setup -1. If required, create a new repository for your blog. -2. If required, create a ```master``` branch. -2. If applicable/desired, create/add to your repository any files that your site needs that will not be produced by your Hakyll project. For example, ```CNAME``` as outlined [here](https://help.github.com/articles/setting-up-your-pages-site-repository/). -3. Create a ```.gitignore``` file with at a minimum, the following entries: +1. If required, create a new GitHub repository for your blog. +2. If required, create a `master` branch. +3. in the Settings of your GitHub project define that the `/docs` folder from the `master` branch should be used as document-root of your site. + Please refer to the [documentation](https://docs.github.com/en/free-pro-team@latest/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#choosing-a-publishing-source) + in case of problems. +4. Create a .gitignore file with at a minimum, the following entries: ``` _cache/ -_site/ .stack-work/ ``` @@ -47,10 +45,8 @@ _site/ 2. Create a ```.gitignore``` file in your blog's directory with at a minimum, the same directories listed as in the GitHub repository. 3. Use the following git commands to setup your local repository. -``` +```bash git init -# create new branch called develop and switch to it. -git checkout -b develop # track all the source files for our blog. git add . # make our first commit @@ -59,130 +55,76 @@ git commit -m "initial commit." git remote add origin ``` -## Deployment +### Modify site.hs -So everything's all setup and we're ready to deploy. +In order to make Hakyll generate the site into the `/docs` folder you'll have to edit the Hakyll Main module (`site.hs` if you use the stack template): -> **Note:** Performing the following commands from your ```develop``` branch is recommended since you will end up back in that branch at the end. +```haskell +config :: Configuration +config = defaultConfiguration + { destinationDirectory = "docs" + } -Temporarily save any uncommitted changes that may exist in the current branch. - -``` -git stash +main :: IO () +main = do + hakyllWith config $ do + ... ``` -Ensure we are in the correct branch. +## Deployment -``` -git checkout develop -``` +So everything’s all setup, and we’re ready to deploy. -We need to be able to run the executable that generates the website, so we need -to compile it first. If you are using `stack`, this can be done using: +We need to be able to run the executable that generates the website, so we need to compile it first. If you are using stack, this can be done using: -``` +```bash stack build ``` -Now get a clean build of our site. +Next we get a clean build of our site: -``` +```bash stack exec myblog clean stack exec myblog build ``` -Update the local list of remote branches to ensure we're able to checkout the branch we want in the next step. - -``` -git fetch --all -``` - -Switch to the `master` branch. - -> **Note:** Checking out this branch does not overwrite the files that Hakyll just produced because we have '_site' listed in both .gitignore files. - -``` -git checkout -b master --track origin/master -``` - -Next, copy the freshly made contents of '_site' over the old ones. +After this step you should see a folder `docs` under your projects root folder, which contains the generated Hakyll site. -> **Note:** Deleting a file from your site's source will not remove it from your `master` repository if it has already been published. An alternative to `cp` is discussed at the end of this guide. +Now we commit our changes: -``` -cp -a _site/. . -``` - -Commit our changes. - -``` +```bash git add -A git commit -m "Publish." ``` -And send them to GitHub. +And send them to GitHub: -``` +```bash git push origin master:master ``` -Final clean up and return to the original state. +That's all. -``` -git checkout develop -git branch -D master -git stash pop -``` +Within a few seconds your Hakyll site should be visible under your GitHub Pages URL! ## Putting it all together Below is a complete listing of all the commands used to automate deployment to Github Pages. A `deployCommand` can be set as part of Hakyll's configuration options. More information and an example is provided [here](https://jaspervdj.be/hakyll/reference/Hakyll-Core-Configuration.html). ``` -# Temporarily store uncommited changes -git stash - # Verify correct branch -git checkout develop +git checkout master # Build new files stack exec myblog clean stack exec myblog build -# Get previous files -git fetch --all -git checkout -b master --track origin/master - -# Overwrite existing files with new files -cp -a _site/. . - # Commit git add -A git commit -m "Publish." # Push git push origin master:master - -# Restoration -git checkout develop -git branch -D master -git stash pop -``` - -*And that's it.* - -## Removing old files with `rsync` - -Earlier it was mentioned a flaw is that deleted files will persist in the published site until deleted manually. This is easily overcome by using `rsync` instead of `cp`. - -``` -rsync -a --filter='P _site/' \ - --filter='P _cache/' \ - --filter='P .git/' \ - --filter='P .gitignore' \ - --filter='P .stack-work' \ - --delete-excluded \ - _site/ . ``` -The only drawback this approach has is the requirement that *every* file in your site "go through" Hakyll. Fortunately, in many cases this is not an issue. +*And that's it.* \ No newline at end of file -- cgit v1.2.3 From e4d80f0397705950a087176723e31ac91397a08f Mon Sep 17 00:00:00 2001 From: erictapen Date: Thu, 26 Nov 2020 18:39:13 +0100 Subject: Allow file-embed 0.0.13 (#824) --- hakyll.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hakyll.cabal b/hakyll.cabal index 1415d67..a3c0cc3 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -174,7 +174,7 @@ Library data-default >= 0.4 && < 0.8, deepseq >= 1.3 && < 1.5, directory >= 1.2.7.0 && < 1.4, - file-embed >= 0.0.10.1 && < 0.0.13, + file-embed >= 0.0.10.1 && < 0.0.14, filepath >= 1.0 && < 1.5, lrucache >= 1.1.1 && < 1.3, memory >= 0.14.18 && < 0.16, -- cgit v1.2.3 From 77afcbc2937a4ee5db9666c1f3e0c090914d3980 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sun, 6 Dec 2020 19:24:06 +0100 Subject: Pandoc 2.11 compatibility (#826) * Pandoc 2.11 compatibility * Bump stack.yaml * Bump stack dependencies --- hakyll.cabal | 5 +- lib/Hakyll/Web/Pandoc/Biblio.hs | 102 ++++++++++++++++++++++------------------ lib/Hakyll/Web/Pandoc/Binary.hs | 12 ----- stack.yaml | 17 +++++-- stack.yaml.lock | 73 ++++++++++++++++++++-------- 5 files changed, 123 insertions(+), 86 deletions(-) diff --git a/hakyll.cabal b/hakyll.cabal index a3c0cc3..94bbab8 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -232,8 +232,7 @@ Library Other-Modules: Hakyll.Web.Pandoc.Binary Build-Depends: - pandoc >= 2.10 && < 2.12, - pandoc-citeproc >= 0.14 && < 0.18 + pandoc >= 2.11 && < 2.12 Cpp-options: -DUSE_PANDOC @@ -327,4 +326,4 @@ Executable hakyll-website base >= 4 && < 5, directory >= 1.0 && < 1.4, filepath >= 1.0 && < 1.5, - pandoc >= 2.10 && < 2.12 + pandoc >= 2.11 && < 2.12 diff --git a/lib/Hakyll/Web/Pandoc/Biblio.hs b/lib/Hakyll/Web/Pandoc/Biblio.hs index 5127d88..567f478 100644 --- a/lib/Hakyll/Web/Pandoc/Biblio.hs +++ b/lib/Hakyll/Web/Pandoc/Biblio.hs @@ -12,6 +12,7 @@ {-# LANGUAGE Arrows #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE OverloadedStrings #-} module Hakyll.Web.Pandoc.Biblio ( CSL , cslCompiler @@ -23,33 +24,31 @@ module Hakyll.Web.Pandoc.Biblio -------------------------------------------------------------------------------- -import Control.Monad (liftM, replicateM) -import Data.Binary (Binary (..)) -import Data.Typeable (Typeable) +import Control.Monad (liftM) +import Data.Binary (Binary (..)) +import qualified Data.ByteString as B +import qualified Data.ByteString.Lazy as BL +import qualified Data.Map as Map +import qualified Data.Time as Time +import Data.Typeable (Typeable) import Hakyll.Core.Compiler import Hakyll.Core.Compiler.Internal import Hakyll.Core.Identifier import Hakyll.Core.Item -import Hakyll.Core.Provider import Hakyll.Core.Writable import Hakyll.Web.Pandoc -import Hakyll.Web.Pandoc.Binary () -import qualified Text.CSL as CSL -import Text.CSL.Pandoc (processCites) -import Text.Pandoc (Pandoc, ReaderOptions (..), - enableExtension, Extension (..)) +import Text.Pandoc (Extension (..), Pandoc, + ReaderOptions (..), + enableExtension) +import qualified Text.Pandoc as Pandoc +import qualified Text.Pandoc.Citeproc as Pandoc (processCitations) -------------------------------------------------------------------------------- -data CSL = CSL - deriving (Show, Typeable) +newtype CSL = CSL {unCSL :: B.ByteString} + deriving (Binary, Show, Typeable) --------------------------------------------------------------------------------- -instance Binary CSL where - put CSL = return () - get = return CSL - -------------------------------------------------------------------------------- instance Writable CSL where @@ -59,21 +58,12 @@ instance Writable CSL where -------------------------------------------------------------------------------- cslCompiler :: Compiler (Item CSL) -cslCompiler = makeItem CSL - - --------------------------------------------------------------------------------- -newtype Biblio = Biblio [CSL.Reference] - deriving (Show, Typeable) +cslCompiler = fmap (CSL . BL.toStrict) <$> getResourceLBS -------------------------------------------------------------------------------- -instance Binary Biblio where - -- Ugly. - get = do - len <- get - Biblio <$> replicateM len get - put (Biblio rs) = put (length rs) >> mapM_ put rs +newtype Biblio = Biblio {unBiblio :: B.ByteString} + deriving (Binary, Show, Typeable) -------------------------------------------------------------------------------- @@ -84,12 +74,7 @@ instance Writable Biblio where -------------------------------------------------------------------------------- biblioCompiler :: Compiler (Item Biblio) -biblioCompiler = do - filePath <- getResourceFilePath - makeItem =<< unsafeCompiler (Biblio <$> CSL.readBiblioFile idpred filePath) - where - -- This is a filter on citations. We include all citations. - idpred = const True +biblioCompiler = fmap (Biblio . BL.toStrict) <$> getResourceLBS -------------------------------------------------------------------------------- @@ -99,19 +84,42 @@ readPandocBiblio :: ReaderOptions -> (Item String) -> Compiler (Item Pandoc) readPandocBiblio ropt csl biblio item = do - -- Parse CSL file, if given - provider <- compilerProvider <$> compilerAsk - style <- unsafeCompiler $ - CSL.readCSLFile Nothing . (resourceFilePath provider) . itemIdentifier $ csl - - -- We need to know the citation keys, add then *before* actually parsing the - -- actual page. If we don't do this, pandoc won't even consider them - -- citations! - let Biblio refs = itemBody biblio - pandoc <- itemBody <$> readPandocWith ropt item - let pandoc' = processCites style refs pandoc - - return $ fmap (const pandoc') item + -- It's not straightforward to use the Pandoc API as of 2.11 to deal with + -- citations, since it doesn't export many things in 'Text.Pandoc.Citeproc'. + -- The 'citeproc' package is also hard to use. + -- + -- So instead, we try treating Pandoc as a black box. Pandoc can read + -- specific csl and bilbio files based on metadata keys. + -- + -- So we load the CSL and Biblio files and pass them to Pandoc using the + -- ersatz filesystem. + Pandoc.Pandoc (Pandoc.Meta meta) blocks <- itemBody <$> + readPandocWith ropt item + + let cslFile = Pandoc.FileInfo zeroTime . unCSL $ itemBody csl + bibFile = Pandoc.FileInfo zeroTime . unBiblio $ itemBody biblio + addBiblioFiles = \st -> st + { Pandoc.stFiles = + Pandoc.insertInFileTree "_hakyll/style.csl" cslFile . + Pandoc.insertInFileTree "_hakyll/refs.bib" bibFile $ + Pandoc.stFiles st + } + biblioMeta = Pandoc.Meta . + Map.insert "csl" (Pandoc.MetaString "_hakyll/style.csl") . + Map.insert "bibliography" (Pandoc.MetaString "_hakyll/refs.bib") $ + meta + errOrPandoc = Pandoc.runPure $ do + Pandoc.modifyPureState addBiblioFiles + Pandoc.processCitations $ Pandoc.Pandoc biblioMeta blocks + + pandoc <- case errOrPandoc of + Left e -> compilerThrow ["Error during processCitations: " ++ show e] + Right x -> return x + + return $ fmap (const pandoc) item + + where + zeroTime = Time.UTCTime (toEnum 0) 0 -------------------------------------------------------------------------------- pandocBiblioCompiler :: String -> String -> Compiler (Item String) diff --git a/lib/Hakyll/Web/Pandoc/Binary.hs b/lib/Hakyll/Web/Pandoc/Binary.hs index 5d3efea..3f7f4fb 100644 --- a/lib/Hakyll/Web/Pandoc/Binary.hs +++ b/lib/Hakyll/Web/Pandoc/Binary.hs @@ -4,9 +4,6 @@ module Hakyll.Web.Pandoc.Binary where import Data.Binary (Binary (..)) -import qualified Text.CSL as CSL -import qualified Text.CSL.Reference as REF -import qualified Text.CSL.Style as STY import Text.Pandoc -------------------------------------------------------------------------------- @@ -18,7 +15,6 @@ instance Binary Caption instance Binary Cell instance Binary ColSpan instance Binary ColWidth -instance Binary CSL.Reference instance Binary Citation instance Binary CitationMode instance Binary Format @@ -27,17 +23,9 @@ instance Binary ListNumberDelim instance Binary ListNumberStyle instance Binary MathType instance Binary QuoteType -instance Binary REF.CLabel -instance Binary REF.CNum -instance Binary REF.Literal -instance Binary REF.RefDate -instance Binary REF.RefType -instance Binary REF.Season instance Binary Row instance Binary RowHeadColumns instance Binary RowSpan -instance Binary STY.Agent -instance Binary STY.Formatted instance Binary TableBody instance Binary TableFoot instance Binary TableHead diff --git a/stack.yaml b/stack.yaml index 63ee6a4..7820738 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,5 +1,7 @@ resolver: lts-16.21 save-hackage-creds: false +system-ghc: true +skip-ghc-check: true flags: hakyll: @@ -23,10 +25,15 @@ build: haddock-deps: false extra-deps: -- 'commonmark-0.1.0.2' -- 'commonmark-extensions-0.2.0.1' +- 'citeproc-0.2' +- 'commonmark-0.1.1.2' +- 'commonmark-extensions-0.2.0.4' - 'commonmark-pandoc-0.2.0.1' -- 'hslua-1.1.2' +- 'hslua-1.3.0' +- 'hslua-module-text-0.3.0.1' - 'jira-wiki-markup-1.3.2' -- 'pandoc-2.10.1' -- 'pandoc-types-1.21' +- 'pandoc-2.11.2' +- 'pandoc-types-1.22' +- 'rfc5051-0.2' +- 'skylighting-0.10.1' +- 'skylighting-core-0.10.1' diff --git a/stack.yaml.lock b/stack.yaml.lock index 8636225..caab7e9 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -5,19 +5,26 @@ packages: - completed: - hackage: commonmark-0.1.0.2@sha256:fbff7a2ade0ce7d699964a87f765e503a3a9e22542c05f0f02ba7aad64e38af4,3278 + hackage: citeproc-0.2@sha256:72a6b976a1d3ff2107043cfeb942e278ce2b93f0e31752da86bc6431b862ae19,5431 + pantry-tree: + size: 78527 + sha256: 1dd0f1ee7bc43367fbb745ba859ad6e2eb3b8d16d515c47deba31a5bd09bc0e2 + original: + hackage: citeproc-0.2 +- completed: + hackage: commonmark-0.1.1.2@sha256:c06ab05f0f224ab7982502a96e17952823a9b6dae8505fb35194b0baa9e2a975,3278 pantry-tree: size: 1346 - sha256: 991da6da60804286b9ea23a1522e18ceeabddfdf416787231db9fd047c163f53 + sha256: 6a187bbbfaf61b4b1bf87ee5027e7edb5b7157ad3380982b07b876e9a60cd63d original: - hackage: commonmark-0.1.0.2 + hackage: commonmark-0.1.1.2 - completed: - hackage: commonmark-extensions-0.2.0.1@sha256:647aa8dba5fd46984ddedc15c3693c9c4d9655503d42006576bd8f0dadf8cd39,3176 + hackage: commonmark-extensions-0.2.0.4@sha256:6a437bcfa3c757af4262b71336513619990eafb5cfdc33e57a499c93ad225608,3184 pantry-tree: - size: 2927 - sha256: 89e1ee05938d558834c397a3a22cdacc755a1941c144f4c1f3daf8a1ede943ce + size: 2928 + sha256: ac8993e356edabc65a40d6c6909696c5f2dfe2a5298089da820c29ca75852360 original: - hackage: commonmark-extensions-0.2.0.1 + hackage: commonmark-extensions-0.2.0.4 - completed: hackage: commonmark-pandoc-0.2.0.1@sha256:529c6e2c6cabf61558b66a28123eafc1d90d3324be29819f59f024e430312c1f,1105 pantry-tree: @@ -26,12 +33,19 @@ packages: original: hackage: commonmark-pandoc-0.2.0.1 - completed: - hackage: hslua-1.1.2@sha256:6c231b2af447430d1ed04f065d40bb6882ece93cc7f32f4051dc99deb69beeae,9694 + hackage: hslua-1.3.0@sha256:d9b758f6234286a7df267cae15332507a1d3be56baf03ff7ae073269bc55c4e8,11023 + pantry-tree: + size: 7716 + sha256: e2cc992f8ea4781718386c3c0def49f04be96b4b0c459b629df555b0c045efc2 + original: + hackage: hslua-1.3.0 +- completed: + hackage: hslua-module-text-0.3.0.1@sha256:e245d7bf9746101664dcde9c33b1c8cd792d404fddb8d9346ae6abb6b971dd93,1741 pantry-tree: - size: 6820 - sha256: 62e61f6d08191159a070dcbaa20284a581835de620105a254dbee1c7ddfabd9d + size: 415 + sha256: 70932f637ef2a81024d43270f3b28ce870d7b43c405fb399d51d07f170da76ea original: - hackage: hslua-1.1.2 + hackage: hslua-module-text-0.3.0.1 - completed: hackage: jira-wiki-markup-1.3.2@sha256:b5f0901208a0ee07aff60f5356aeb851b7aa7950c75a18a15fd34247a35886d8,3819 pantry-tree: @@ -40,19 +54,40 @@ packages: original: hackage: jira-wiki-markup-1.3.2 - completed: - hackage: pandoc-2.10.1@sha256:23d7ec480c7cb86740475a419d6ca4819987b6dd23bbae9b50bc3d42a7ed2f9f,36933 + hackage: pandoc-2.11.2@sha256:e21f0af1750c4d7a3cf9096c46403c55043c9ac06c7c37627ecb312499eb3136,39349 + pantry-tree: + size: 114848 + sha256: ef31f41960bd8ae1a1b02b2c56a692583398f2cb3fc7c0177583b698a6a60fdf + original: + hackage: pandoc-2.11.2 +- completed: + hackage: pandoc-types-1.22@sha256:15512ce011555ee720820f11cac0598317293406da5812337cbb1550d144e3bd,4071 + pantry-tree: + size: 737 + sha256: 28e43150f4bb0d4d880cf92ade20fefcd8705ee95cfe4a1d0bb5efd320982a9d + original: + hackage: pandoc-types-1.22 +- completed: + hackage: rfc5051-0.2@sha256:da5d77731f2ac6fe313a67919419b0833e09cd7f1a81869ed82a54dbf8962bf2,1678 + pantry-tree: + size: 446 + sha256: 191a30a13590a14dc8f606ff945298fee6afbb093a49bc5db71dbaf066f01930 + original: + hackage: rfc5051-0.2 +- completed: + hackage: skylighting-0.10.1@sha256:69f9175c606289164347a2ae1507218bf0c2479a1ed93356d24e83e4097ef493,10031 pantry-tree: - size: 89646 - sha256: 08c8b20356152b9ee8161bacafda2dc1bed13d7db4cbf38ab040c1977b2d28d5 + size: 10837 + sha256: 5b5516a196a75c6dffb33c3c9227d743d3c48e3d659fb7aad2cc01609e1e3a1f original: - hackage: pandoc-2.10.1 + hackage: skylighting-0.10.1 - completed: - hackage: pandoc-types-1.21@sha256:b61ed625da4d1a0d8057fcca4c0c5e174c9f45d94b41504db1532f3fc581e945,4037 + hackage: skylighting-core-0.10.1@sha256:da0b01c22322f1312e9a5e37343f2153a3a8ba65a3d88ef51cf9b1360c466e08,8159 pantry-tree: - size: 713 - sha256: e26eb93747538e29168032985a03b428039a16000fea1a4a8d9b9b032ac98b5f + size: 13517 + sha256: 48673ab1725d2aa6c019bb8a7d1419002d9a86a5dd54e2745b9d78846d793b29 original: - hackage: pandoc-types-1.21 + hackage: skylighting-core-0.10.1 snapshots: - completed: size: 532413 -- cgit v1.2.3 From 478a2e8590c160d0ca657bfbd8e5c852034f651f Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Mon, 7 Dec 2020 09:21:41 +0300 Subject: Add golden test for Pandoc.Biblio (#827) --- hakyll.cabal | 7 + tests/Hakyll/Web/Pandoc/Biblio/Tests.hs | 66 ++++ tests/TestSuite.hs | 2 + tests/data/biblio/biblio01.golden | 16 + tests/data/biblio/chicago.csl | 648 ++++++++++++++++++++++++++++++++ tests/data/biblio/default.html | 11 + tests/data/biblio/page.markdown | 5 + tests/data/biblio/refs.bib | 8 + 8 files changed, 763 insertions(+) create mode 100644 tests/Hakyll/Web/Pandoc/Biblio/Tests.hs create mode 100644 tests/data/biblio/biblio01.golden create mode 100644 tests/data/biblio/chicago.csl create mode 100644 tests/data/biblio/default.html create mode 100644 tests/data/biblio/page.markdown create mode 100644 tests/data/biblio/refs.bib diff --git a/hakyll.cabal b/hakyll.cabal index 94bbab8..66eec1d 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -59,6 +59,11 @@ Data-files: Extra-source-files: CHANGELOG.md + tests/data/biblio/biblio01.golden + tests/data/biblio/chicago.csl + tests/data/biblio/default.html + tests/data/biblio/page.markdown + tests/data/biblio/refs.bib tests/data/embed.html tests/data/example.md tests/data/example.md.metadata @@ -266,6 +271,7 @@ Test-suite hakyll-tests hakyll, QuickCheck >= 2.8 && < 2.15, tasty >= 0.11 && < 1.4, + tasty-golden >= 2.3 && < 2.4, tasty-hunit >= 0.9 && < 0.11, tasty-quickcheck >= 0.8 && < 0.11, -- Copy pasted from hakyll dependencies: @@ -291,6 +297,7 @@ Test-suite hakyll-tests If flag(usePandoc) Other-modules: + Hakyll.Web.Pandoc.Biblio.Tests Hakyll.Web.Pandoc.FileType.Tests Cpp-options: -DUSE_PANDOC diff --git a/tests/Hakyll/Web/Pandoc/Biblio/Tests.hs b/tests/Hakyll/Web/Pandoc/Biblio/Tests.hs new file mode 100644 index 0000000..fb98f08 --- /dev/null +++ b/tests/Hakyll/Web/Pandoc/Biblio/Tests.hs @@ -0,0 +1,66 @@ +-------------------------------------------------------------------------------- +{-# LANGUAGE OverloadedStrings #-} +module Hakyll.Web.Pandoc.Biblio.Tests + ( tests + ) where + + +-------------------------------------------------------------------------------- +import System.FilePath (()) +import Test.Tasty (TestTree, testGroup) +import Test.Tasty.Golden (goldenVsString) +import qualified Data.ByteString as B +import qualified Data.ByteString.Lazy as LBS + + +-------------------------------------------------------------------------------- +import Hakyll +import Hakyll.Core.Runtime +import Hakyll.Web.Pandoc.Biblio +import qualified Hakyll.Core.Logger as Logger +import TestSuite.Util + + +-------------------------------------------------------------------------------- +tests :: TestTree +tests = testGroup "Hakyll.Web.Pandoc.Biblio.Tests" $ + [ goldenTest01 + ] + +-------------------------------------------------------------------------------- +goldenTestsDataDir :: FilePath +goldenTestsDataDir = "tests/data/biblio" + +-------------------------------------------------------------------------------- +goldenTest01 :: TestTree +goldenTest01 = + goldenVsString + "biblio01" + (goldenTestsDataDir "biblio01.golden") + (do + -- Code lifted from https://github.com/jaspervdj/hakyll-citeproc-example. + logger <- Logger.new Logger.Error + let config = testConfiguration { providerDirectory = goldenTestsDataDir } + _ <- run config logger $ do + let myPandocBiblioCompiler = do + csl <- load "chicago.csl" + bib <- load "refs.bib" + getResourceBody >>= + readPandocBiblio defaultHakyllReaderOptions csl bib >>= + return . writePandoc + + match "default.html" $ compile templateCompiler + match "chicago.csl" $ compile cslCompiler + match "refs.bib" $ compile biblioCompiler + match "page.markdown" $ do + route $ setExtension "html" + compile $ + myPandocBiblioCompiler >>= + loadAndApplyTemplate "default.html" defaultContext + + output <- fmap LBS.fromStrict $ B.readFile $ + destinationDirectory testConfiguration "page.html" + + cleanTestEnv + + return output) diff --git a/tests/TestSuite.hs b/tests/TestSuite.hs index c3e32f8..7c18470 100644 --- a/tests/TestSuite.hs +++ b/tests/TestSuite.hs @@ -24,6 +24,7 @@ import qualified Hakyll.Web.CompressCss.Tests import qualified Hakyll.Web.Html.RelativizeUrls.Tests import qualified Hakyll.Web.Html.Tests #ifdef USE_PANDOC +import qualified Hakyll.Web.Pandoc.Biblio.Tests import qualified Hakyll.Web.Pandoc.FileType.Tests #endif import qualified Hakyll.Web.Template.Context.Tests @@ -48,6 +49,7 @@ main = defaultMain $ testGroup "Hakyll" , Hakyll.Web.Html.RelativizeUrls.Tests.tests , Hakyll.Web.Html.Tests.tests #ifdef USE_PANDOC + , Hakyll.Web.Pandoc.Biblio.Tests.tests , Hakyll.Web.Pandoc.FileType.Tests.tests #endif , Hakyll.Web.Tags.Tests.tests diff --git a/tests/data/biblio/biblio01.golden b/tests/data/biblio/biblio01.golden new file mode 100644 index 0000000..ace1e76 --- /dev/null +++ b/tests/data/biblio/biblio01.golden @@ -0,0 +1,16 @@ + + + + + This page cites a paper. + + +

This page cites a paper.

+

I would like to cite one of my favourite papers (Meijer, Fokkinga, and Paterson 1991) here.

+
+
+Meijer, Erik, Maarten Fokkinga, and Ross Paterson. 1991. “Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire.” In Conference on Functional Programming Languages and Computer Architecture, 124–44. Springer. +
+
+ + diff --git a/tests/data/biblio/chicago.csl b/tests/data/biblio/chicago.csl new file mode 100644 index 0000000..47d9eb8 --- /dev/null +++ b/tests/data/biblio/chicago.csl @@ -0,0 +1,648 @@ + + diff --git a/tests/data/biblio/default.html b/tests/data/biblio/default.html new file mode 100644 index 0000000..42197e0 --- /dev/null +++ b/tests/data/biblio/default.html @@ -0,0 +1,11 @@ + + + + + $title$ + + +

$title$

+ $body$ + + diff --git a/tests/data/biblio/page.markdown b/tests/data/biblio/page.markdown new file mode 100644 index 0000000..5a99ac0 --- /dev/null +++ b/tests/data/biblio/page.markdown @@ -0,0 +1,5 @@ +--- +title: This page cites a paper. +--- + +I would like to cite one of my favourite papers [@meijer1991functional] here. diff --git a/tests/data/biblio/refs.bib b/tests/data/biblio/refs.bib new file mode 100644 index 0000000..e4cd89f --- /dev/null +++ b/tests/data/biblio/refs.bib @@ -0,0 +1,8 @@ +@inproceedings{meijer1991functional, + title={Functional programming with bananas, lenses, envelopes and barbed wire}, + author={Meijer, Erik and Fokkinga, Maarten and Paterson, Ross}, + booktitle={Conference on Functional Programming Languages and Computer Architecture}, + pages={124--144}, + year={1991}, + organization={Springer} +} -- cgit v1.2.3 From ef1bad68d6e9d62da7a1115a7d75bad689b62817 Mon Sep 17 00:00:00 2001 From: Chris Jensen Date: Tue, 29 Dec 2020 17:07:28 +0000 Subject: Add documentation for the pandocBiblioCompiler (#828) * Add documentation for pandoc * Fix grammar --- lib/Hakyll/Web/Pandoc/Biblio.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Hakyll/Web/Pandoc/Biblio.hs b/lib/Hakyll/Web/Pandoc/Biblio.hs index 567f478..566c706 100644 --- a/lib/Hakyll/Web/Pandoc/Biblio.hs +++ b/lib/Hakyll/Web/Pandoc/Biblio.hs @@ -122,6 +122,7 @@ readPandocBiblio ropt csl biblio item = do zeroTime = Time.UTCTime (toEnum 0) 0 -------------------------------------------------------------------------------- +-- | Compiles a markdown file via Pandoc. Requires the .csl and .bib files to be known to the compiler via match statements. pandocBiblioCompiler :: String -> String -> Compiler (Item String) pandocBiblioCompiler cslFileName bibFileName = do csl <- load $ fromFilePath cslFileName -- cgit v1.2.3 From 87e93c6c95b86b435b532286e07b0a9b896aef8f Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Wed, 30 Dec 2020 15:48:40 +0300 Subject: Fix golden test failing with pandoc >= 2.11.3 (#829) The new version started wrapping Biblio references into

tags, so we now keep two different golden files for different Pandoc versions. I had to add Pandoc to dependencies of the test suite, otherwise GHC won't define `MIN_VERSION_pandoc` macro. --- hakyll.cabal | 2 ++ tests/Hakyll/Web/Pandoc/Biblio/Tests.hs | 5 +++++ tests/data/biblio/biblio01-pre-pandoc-2.11.3.golden | 16 ++++++++++++++++ tests/data/biblio/biblio01.golden | 2 +- 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/data/biblio/biblio01-pre-pandoc-2.11.3.golden diff --git a/hakyll.cabal b/hakyll.cabal index 66eec1d..d8f44f7 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -299,6 +299,8 @@ Test-suite hakyll-tests Other-modules: Hakyll.Web.Pandoc.Biblio.Tests Hakyll.Web.Pandoc.FileType.Tests + Build-Depends: + pandoc >= 2.11 && < 2.12 Cpp-options: -DUSE_PANDOC diff --git a/tests/Hakyll/Web/Pandoc/Biblio/Tests.hs b/tests/Hakyll/Web/Pandoc/Biblio/Tests.hs index fb98f08..9135086 100644 --- a/tests/Hakyll/Web/Pandoc/Biblio/Tests.hs +++ b/tests/Hakyll/Web/Pandoc/Biblio/Tests.hs @@ -1,5 +1,6 @@ -------------------------------------------------------------------------------- {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE CPP #-} module Hakyll.Web.Pandoc.Biblio.Tests ( tests ) where @@ -36,7 +37,11 @@ goldenTest01 :: TestTree goldenTest01 = goldenVsString "biblio01" +#if MIN_VERSION_pandoc(2,11,3) (goldenTestsDataDir "biblio01.golden") +#else + (goldenTestsDataDir "biblio01-pre-pandoc-2.11.3.golden") +#endif (do -- Code lifted from https://github.com/jaspervdj/hakyll-citeproc-example. logger <- Logger.new Logger.Error diff --git a/tests/data/biblio/biblio01-pre-pandoc-2.11.3.golden b/tests/data/biblio/biblio01-pre-pandoc-2.11.3.golden new file mode 100644 index 0000000..ace1e76 --- /dev/null +++ b/tests/data/biblio/biblio01-pre-pandoc-2.11.3.golden @@ -0,0 +1,16 @@ + + + + + This page cites a paper. + + +

This page cites a paper.

+

I would like to cite one of my favourite papers (Meijer, Fokkinga, and Paterson 1991) here.

+
+
+Meijer, Erik, Maarten Fokkinga, and Ross Paterson. 1991. “Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire.” In Conference on Functional Programming Languages and Computer Architecture, 124–44. Springer. +
+
+ + diff --git a/tests/data/biblio/biblio01.golden b/tests/data/biblio/biblio01.golden index ace1e76..9053456 100644 --- a/tests/data/biblio/biblio01.golden +++ b/tests/data/biblio/biblio01.golden @@ -9,7 +9,7 @@

I would like to cite one of my favourite papers (Meijer, Fokkinga, and Paterson 1991) here.

-Meijer, Erik, Maarten Fokkinga, and Ross Paterson. 1991. “Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire.” In Conference on Functional Programming Languages and Computer Architecture, 124–44. Springer. +

Meijer, Erik, Maarten Fokkinga, and Ross Paterson. 1991. “Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire.” In Conference on Functional Programming Languages and Computer Architecture, 124–44. Springer.

-- cgit v1.2.3 From f3881821328fae8cba848627f1caf2086121c903 Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Wed, 30 Dec 2020 22:50:58 +0300 Subject: Revert "Fix golden test failing with pandoc >= 2.11.3 (#829)" (#830) This reverts commit 87e93c6c95b86b435b532286e07b0a9b896aef8f. I screwed up with that one: the change in behaviour was a regression[1] in Pandoc, and I shouldn't have papered over it. It's fairly unlikely that someone would build Hakyll's test suite with one of the two Pandoc versions that regressed, so I simply revert my earlier commit. 1. https://github.com/jgm/pandoc/issues/6966 --- hakyll.cabal | 2 -- tests/Hakyll/Web/Pandoc/Biblio/Tests.hs | 5 ----- tests/data/biblio/biblio01-pre-pandoc-2.11.3.golden | 16 ---------------- tests/data/biblio/biblio01.golden | 2 +- 4 files changed, 1 insertion(+), 24 deletions(-) delete mode 100644 tests/data/biblio/biblio01-pre-pandoc-2.11.3.golden diff --git a/hakyll.cabal b/hakyll.cabal index d8f44f7..66eec1d 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -299,8 +299,6 @@ Test-suite hakyll-tests Other-modules: Hakyll.Web.Pandoc.Biblio.Tests Hakyll.Web.Pandoc.FileType.Tests - Build-Depends: - pandoc >= 2.11 && < 2.12 Cpp-options: -DUSE_PANDOC diff --git a/tests/Hakyll/Web/Pandoc/Biblio/Tests.hs b/tests/Hakyll/Web/Pandoc/Biblio/Tests.hs index 9135086..fb98f08 100644 --- a/tests/Hakyll/Web/Pandoc/Biblio/Tests.hs +++ b/tests/Hakyll/Web/Pandoc/Biblio/Tests.hs @@ -1,6 +1,5 @@ -------------------------------------------------------------------------------- {-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE CPP #-} module Hakyll.Web.Pandoc.Biblio.Tests ( tests ) where @@ -37,11 +36,7 @@ goldenTest01 :: TestTree goldenTest01 = goldenVsString "biblio01" -#if MIN_VERSION_pandoc(2,11,3) (goldenTestsDataDir "biblio01.golden") -#else - (goldenTestsDataDir "biblio01-pre-pandoc-2.11.3.golden") -#endif (do -- Code lifted from https://github.com/jaspervdj/hakyll-citeproc-example. logger <- Logger.new Logger.Error diff --git a/tests/data/biblio/biblio01-pre-pandoc-2.11.3.golden b/tests/data/biblio/biblio01-pre-pandoc-2.11.3.golden deleted file mode 100644 index ace1e76..0000000 --- a/tests/data/biblio/biblio01-pre-pandoc-2.11.3.golden +++ /dev/null @@ -1,16 +0,0 @@ - - - - - This page cites a paper. - - -

This page cites a paper.

-

I would like to cite one of my favourite papers (Meijer, Fokkinga, and Paterson 1991) here.

-
-
-Meijer, Erik, Maarten Fokkinga, and Ross Paterson. 1991. “Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire.” In Conference on Functional Programming Languages and Computer Architecture, 124–44. Springer. -
-
- - diff --git a/tests/data/biblio/biblio01.golden b/tests/data/biblio/biblio01.golden index 9053456..ace1e76 100644 --- a/tests/data/biblio/biblio01.golden +++ b/tests/data/biblio/biblio01.golden @@ -9,7 +9,7 @@

I would like to cite one of my favourite papers (Meijer, Fokkinga, and Paterson 1991) here.

-

Meijer, Erik, Maarten Fokkinga, and Ross Paterson. 1991. “Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire.” In Conference on Functional Programming Languages and Computer Architecture, 124–44. Springer.

+Meijer, Erik, Maarten Fokkinga, and Ross Paterson. 1991. “Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire.” In Conference on Functional Programming Languages and Computer Architecture, 124–44. Springer.
-- cgit v1.2.3 From a5cf4470511bdf4fe7fe709b3dcf274fd9832d16 Mon Sep 17 00:00:00 2001 From: Jean-Charles Quillet Date: Sat, 6 Mar 2021 16:56:54 +0100 Subject: Add jeancharles.quillet.org to examples (#834) --- web/examples.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/examples.markdown b/web/examples.markdown index 770eecb..4286d91 100644 --- a/web/examples.markdown +++ b/web/examples.markdown @@ -194,6 +194,8 @@ directly with the default Hakyll site. [source](https://github.com/thjread/thjread-blog) - , [source](https://github.com/xvw/planet) +- , + [source](https://github.com/jecaro/jeancharles.quillet) ## Hakyll 3.X -- cgit v1.2.3 From b54212c7e2b8a84f95815e93a13223e1525c4f85 Mon Sep 17 00:00:00 2001 From: Norman Liu <57917002+dreamsmasher@users.noreply.github.com> Date: Thu, 11 Mar 2021 16:38:21 -0500 Subject: Add `renderPandocWithTransform` and `renderPandocWithTransformM` * added function that allows for pre-pandoc transformations * modified haddock docstring * refactoring to avoid importing the kleisli fish * Renamed `applyPandoc` to `renderPandocWithTransformM`, added non-monadic variant. Exported previous new functions that I forgot to export. --- lib/Hakyll/Web/Pandoc.hs | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/Hakyll/Web/Pandoc.hs b/lib/Hakyll/Web/Pandoc.hs index 5f04de4..372465b 100644 --- a/lib/Hakyll/Web/Pandoc.hs +++ b/lib/Hakyll/Web/Pandoc.hs @@ -8,6 +8,8 @@ module Hakyll.Web.Pandoc , writePandocWith , renderPandoc , renderPandocWith + , renderPandocWithTransform + , renderPandocWithTransformM -- * Derived compilers , pandocCompiler @@ -103,6 +105,32 @@ renderPandocWith ropt wopt item = writePandocWith wopt <$> readPandocWith ropt item +-------------------------------------------------------------------------------- +-- | An extension of `renderPandocWith`, which allows you to specify a custom +-- Pandoc transformation on the input `Item`. +-- Useful if you want to do your own transformations before running +-- custom Pandoc transformations, e.g. using a `funcField` to transform raw content. +renderPandocWithTransform :: ReaderOptions -> WriterOptions + -> (Pandoc -> Pandoc) + -> Item String + -> Compiler (Item String) +renderPandocWithTransform ropt wopt f = + renderPandocWithTransformM ropt wopt (return . f) + + +-------------------------------------------------------------------------------- +-- | Similar to `renderPandocWithTransform`, but the Pandoc transformation is +-- monadic. This is useful when you want the pandoc +-- transformation to use the `Compiler` information such as routes, +-- metadata, etc. along with your own transformations beforehand. +renderPandocWithTransformM :: ReaderOptions -> WriterOptions + -> (Pandoc -> Compiler Pandoc) + -> Item String + -> Compiler (Item String) +renderPandocWithTransformM ropt wopt f i = + writePandocWith wopt <$> (traverse f =<< readPandocWith ropt i) + + -------------------------------------------------------------------------------- -- | Read a page render using pandoc pandocCompiler :: Compiler (Item String) @@ -137,9 +165,8 @@ pandocCompilerWithTransform ropt wopt f = pandocCompilerWithTransformM :: ReaderOptions -> WriterOptions -> (Pandoc -> Compiler Pandoc) -> Compiler (Item String) -pandocCompilerWithTransformM ropt wopt f = - writePandocWith wopt <$> - (traverse f =<< readPandocWith ropt =<< getResourceBody) +pandocCompilerWithTransformM ropt wopt f = + getResourceBody >>= renderPandocWithTransformM ropt wopt f -------------------------------------------------------------------------------- -- cgit v1.2.3 From 04aa10917e7a004277e955048040dbb7c451e6d8 Mon Sep 17 00:00:00 2001 From: Norman Liu <57917002+dreamsmasher@users.noreply.github.com> Date: Fri, 12 Mar 2021 15:58:09 -0500 Subject: add nliu.net to examples for shameless self-promotion (#836) * added nliu.net to examples for shameless self-promotion * fixed comma formatting --- web/examples.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/examples.markdown b/web/examples.markdown index 4286d91..c98937e 100644 --- a/web/examples.markdown +++ b/web/examples.markdown @@ -196,6 +196,8 @@ directly with the default Hakyll site. [source](https://github.com/xvw/planet) - , [source](https://github.com/jecaro/jeancharles.quillet) +- , + [source](https://github.com/dreamsmasher/site-haskell-source) ## Hakyll 3.X -- cgit v1.2.3 From 470ebef4d5234d4f4a39ac069aff1561a627fde6 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sun, 14 Mar 2021 13:47:17 +0100 Subject: Revert "File.hs: +symlink-based static file compiler; for multi-gigabyte sites, this can be a major speedup (see #786) (#810)" This reverts commit 84157674d955778c806efdafda311b2732242b38. --- lib/Hakyll/Core/File.hs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/lib/Hakyll/Core/File.hs b/lib/Hakyll/Core/File.hs index 6a5775e..49af659 100644 --- a/lib/Hakyll/Core/File.hs +++ b/lib/Hakyll/Core/File.hs @@ -8,8 +8,6 @@ module Hakyll.Core.File , copyFileCompiler , TmpFile (..) , newTmpFile - , SymlinkFile (..) - , symlinkFileCompiler ) where @@ -22,7 +20,6 @@ import System.Directory (copyFileWithMetadata) import System.Directory (copyFile) #endif import System.Directory (doesFileExist, - createFileLink, renameFile) import System.FilePath (()) import System.Random (randomIO) @@ -59,19 +56,6 @@ copyFileCompiler = do provider <- compilerProvider <$> compilerAsk makeItem $ CopyFile $ resourceFilePath provider identifier --------------------------------------------------------------------------------- --- | This will not copy a file but create a symlink, which can save space & time for static sites with many large static files which would normally be handled by copyFileCompiler. (Note: the user will need to make sure their sync method handles symbolic links correctly!) -newtype SymlinkFile = SymlinkFile FilePath - deriving (Binary, Eq, Ord, Show, Typeable) --------------------------------------------------------------------------------- -instance Writable SymlinkFile where - write dst (Item _ (SymlinkFile src)) = createFileLink src dst --------------------------------------------------------------------------------- -symlinkFileCompiler :: Compiler (Item SymlinkFile) -symlinkFileCompiler = do - identifier <- getUnderlying - provider <- compilerProvider <$> compilerAsk - makeItem $ SymlinkFile $ resourceFilePath provider identifier -------------------------------------------------------------------------------- newtype TmpFile = TmpFile FilePath -- cgit v1.2.3 From a35e1c35b138c2a25b27c05936a6bb95f5f3d9e6 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sun, 14 Mar 2021 13:52:46 +0100 Subject: Bump version to 4.14.0.0 --- CHANGELOG.md | 9 +++++++++ hakyll.cabal | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31a10bd..ac0bb3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ title: Releases # Releases +## Hakyll 4.14.0.0 (2021-03-14) + +- Add `renderPandocWithTransform` and `renderPandocWithTransformM` (by Norman + Liu) +- Make sure the initial project is writable (by Tobias Bora) +- Bump `pandoc` to 2.11.* +- Bump `file-embed` upper bound to 0.0.14 +- Bump `random` upper bound to 1.2 + ## Hakyll 4.13.4.1 (2020-09-30) - Bump `pandoc` to 2.10.* diff --git a/hakyll.cabal b/hakyll.cabal index 66eec1d..c582934 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -1,5 +1,5 @@ Name: hakyll -Version: 4.13.4.1 +Version: 4.14.0.0 Synopsis: A static website compiler library Description: -- cgit v1.2.3 From 59871e1f0928915a79543403d85f8661b8a5d6b2 Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Sun, 14 Mar 2021 18:00:14 +0300 Subject: Bump Stackage LTS to 17.5 (#837) --- stack.yaml | 14 +-------- stack.yaml.lock | 94 +++------------------------------------------------------ 2 files changed, 6 insertions(+), 102 deletions(-) diff --git a/stack.yaml b/stack.yaml index 7820738..ec28861 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-16.21 +resolver: lts-17.5 save-hackage-creds: false system-ghc: true skip-ghc-check: true @@ -25,15 +25,3 @@ build: haddock-deps: false extra-deps: -- 'citeproc-0.2' -- 'commonmark-0.1.1.2' -- 'commonmark-extensions-0.2.0.4' -- 'commonmark-pandoc-0.2.0.1' -- 'hslua-1.3.0' -- 'hslua-module-text-0.3.0.1' -- 'jira-wiki-markup-1.3.2' -- 'pandoc-2.11.2' -- 'pandoc-types-1.22' -- 'rfc5051-0.2' -- 'skylighting-0.10.1' -- 'skylighting-core-0.10.1' diff --git a/stack.yaml.lock b/stack.yaml.lock index caab7e9..fa953b3 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -3,94 +3,10 @@ # For more information, please see the documentation at: # https://docs.haskellstack.org/en/stable/lock_files -packages: -- completed: - hackage: citeproc-0.2@sha256:72a6b976a1d3ff2107043cfeb942e278ce2b93f0e31752da86bc6431b862ae19,5431 - pantry-tree: - size: 78527 - sha256: 1dd0f1ee7bc43367fbb745ba859ad6e2eb3b8d16d515c47deba31a5bd09bc0e2 - original: - hackage: citeproc-0.2 -- completed: - hackage: commonmark-0.1.1.2@sha256:c06ab05f0f224ab7982502a96e17952823a9b6dae8505fb35194b0baa9e2a975,3278 - pantry-tree: - size: 1346 - sha256: 6a187bbbfaf61b4b1bf87ee5027e7edb5b7157ad3380982b07b876e9a60cd63d - original: - hackage: commonmark-0.1.1.2 -- completed: - hackage: commonmark-extensions-0.2.0.4@sha256:6a437bcfa3c757af4262b71336513619990eafb5cfdc33e57a499c93ad225608,3184 - pantry-tree: - size: 2928 - sha256: ac8993e356edabc65a40d6c6909696c5f2dfe2a5298089da820c29ca75852360 - original: - hackage: commonmark-extensions-0.2.0.4 -- completed: - hackage: commonmark-pandoc-0.2.0.1@sha256:529c6e2c6cabf61558b66a28123eafc1d90d3324be29819f59f024e430312c1f,1105 - pantry-tree: - size: 326 - sha256: d9954a15f73c8fe55a5097e1cc0957fa626d340ef36e2beefb8caae66008c3dc - original: - hackage: commonmark-pandoc-0.2.0.1 -- completed: - hackage: hslua-1.3.0@sha256:d9b758f6234286a7df267cae15332507a1d3be56baf03ff7ae073269bc55c4e8,11023 - pantry-tree: - size: 7716 - sha256: e2cc992f8ea4781718386c3c0def49f04be96b4b0c459b629df555b0c045efc2 - original: - hackage: hslua-1.3.0 -- completed: - hackage: hslua-module-text-0.3.0.1@sha256:e245d7bf9746101664dcde9c33b1c8cd792d404fddb8d9346ae6abb6b971dd93,1741 - pantry-tree: - size: 415 - sha256: 70932f637ef2a81024d43270f3b28ce870d7b43c405fb399d51d07f170da76ea - original: - hackage: hslua-module-text-0.3.0.1 -- completed: - hackage: jira-wiki-markup-1.3.2@sha256:b5f0901208a0ee07aff60f5356aeb851b7aa7950c75a18a15fd34247a35886d8,3819 - pantry-tree: - size: 1180 - sha256: 90fa545210a211b8ec88b59f92fe2877ebf2f9e55e2ce2fba6103a3615bd0ab9 - original: - hackage: jira-wiki-markup-1.3.2 -- completed: - hackage: pandoc-2.11.2@sha256:e21f0af1750c4d7a3cf9096c46403c55043c9ac06c7c37627ecb312499eb3136,39349 - pantry-tree: - size: 114848 - sha256: ef31f41960bd8ae1a1b02b2c56a692583398f2cb3fc7c0177583b698a6a60fdf - original: - hackage: pandoc-2.11.2 -- completed: - hackage: pandoc-types-1.22@sha256:15512ce011555ee720820f11cac0598317293406da5812337cbb1550d144e3bd,4071 - pantry-tree: - size: 737 - sha256: 28e43150f4bb0d4d880cf92ade20fefcd8705ee95cfe4a1d0bb5efd320982a9d - original: - hackage: pandoc-types-1.22 -- completed: - hackage: rfc5051-0.2@sha256:da5d77731f2ac6fe313a67919419b0833e09cd7f1a81869ed82a54dbf8962bf2,1678 - pantry-tree: - size: 446 - sha256: 191a30a13590a14dc8f606ff945298fee6afbb093a49bc5db71dbaf066f01930 - original: - hackage: rfc5051-0.2 -- completed: - hackage: skylighting-0.10.1@sha256:69f9175c606289164347a2ae1507218bf0c2479a1ed93356d24e83e4097ef493,10031 - pantry-tree: - size: 10837 - sha256: 5b5516a196a75c6dffb33c3c9227d743d3c48e3d659fb7aad2cc01609e1e3a1f - original: - hackage: skylighting-0.10.1 -- completed: - hackage: skylighting-core-0.10.1@sha256:da0b01c22322f1312e9a5e37343f2153a3a8ba65a3d88ef51cf9b1360c466e08,8159 - pantry-tree: - size: 13517 - sha256: 48673ab1725d2aa6c019bb8a7d1419002d9a86a5dd54e2745b9d78846d793b29 - original: - hackage: skylighting-core-0.10.1 +packages: [] snapshots: - completed: - size: 532413 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/21.yaml - sha256: 7b5cac89352fa4a88606dc6cb250aee9291f21e2e988d464065f5aa51f5de33d - original: lts-16.21 + size: 565266 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/17/5.yaml + sha256: 78e8ebabf11406261abbc95b44f240acf71802630b368888f6d758de7fc3a2f7 + original: lts-17.5 -- cgit v1.2.3 From f3c3acf27cba275911d62e3c1ff902074884e970 Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Mon, 15 Mar 2021 23:41:39 +0800 Subject: Update some bounds (#838) All tests are passing here with the new versions. --- hakyll.cabal | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hakyll.cabal b/hakyll.cabal index c582934..b6b44d0 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -175,7 +175,7 @@ Library blaze-markup >= 0.5.1 && < 0.9, bytestring >= 0.9 && < 0.11, containers >= 0.3 && < 0.7, - cryptonite >= 0.25 && < 0.28, + cryptonite >= 0.25 && < 0.29, data-default >= 0.4 && < 0.8, deepseq >= 1.3 && < 1.5, directory >= 1.2.7.0 && < 1.4, @@ -185,7 +185,7 @@ Library memory >= 0.14.18 && < 0.16, mtl >= 1 && < 2.3, network-uri >= 2.6 && < 2.7, - optparse-applicative >= 0.12 && < 0.16, + optparse-applicative >= 0.12 && < 0.17, parsec >= 3.0 && < 3.2, process >= 1.6 && < 1.7, random >= 1.0 && < 1.3, @@ -270,7 +270,7 @@ Test-suite hakyll-tests Build-Depends: hakyll, QuickCheck >= 2.8 && < 2.15, - tasty >= 0.11 && < 1.4, + tasty >= 0.11 && < 1.5, tasty-golden >= 2.3 && < 2.4, tasty-hunit >= 0.9 && < 0.11, tasty-quickcheck >= 0.8 && < 0.11, -- cgit v1.2.3 From 0dc6127d81ff688e27c36ce469230320eee60246 Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Mon, 15 Mar 2021 23:17:55 +0300 Subject: Allow pandoc 2.12 (#839) This passed on my machine: cabal test all -j --enable-tests --constrain 'pandoc == 2.12' --- hakyll.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hakyll.cabal b/hakyll.cabal index b6b44d0..0ef3b04 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -237,7 +237,7 @@ Library Other-Modules: Hakyll.Web.Pandoc.Binary Build-Depends: - pandoc >= 2.11 && < 2.12 + pandoc >= 2.11 && < 2.13 Cpp-options: -DUSE_PANDOC @@ -333,4 +333,4 @@ Executable hakyll-website base >= 4 && < 5, directory >= 1.0 && < 1.4, filepath >= 1.0 && < 1.5, - pandoc >= 2.11 && < 2.12 + pandoc >= 2.11 && < 2.13 -- cgit v1.2.3 From af9e29b5456c105dc948bc46c93e989a650b5ed1 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Mon, 29 Mar 2021 23:01:26 +0300 Subject: Allow pandoc 2.13 (#840) --- hakyll.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hakyll.cabal b/hakyll.cabal index 0ef3b04..f799344 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -237,7 +237,7 @@ Library Other-Modules: Hakyll.Web.Pandoc.Binary Build-Depends: - pandoc >= 2.11 && < 2.13 + pandoc >= 2.11 && < 2.14 Cpp-options: -DUSE_PANDOC @@ -333,4 +333,4 @@ Executable hakyll-website base >= 4 && < 5, directory >= 1.0 && < 1.4, filepath >= 1.0 && < 1.5, - pandoc >= 2.11 && < 2.13 + pandoc >= 2.11 && < 2.14 -- cgit v1.2.3 From 122dd424891f6c9be15ff5225886484386dd0956 Mon Sep 17 00:00:00 2001 From: "Laurent P. René de Cotret" Date: Thu, 15 Apr 2021 15:51:38 -0400 Subject: Remove dependency on cryptonite and memory (#843) --- hakyll.cabal | 3 +-- lib/Hakyll/Core/Store.hs | 29 +++-------------------------- test.hs | 6 ++---- 3 files changed, 6 insertions(+), 32 deletions(-) diff --git a/hakyll.cabal b/hakyll.cabal index f799344..b09aff0 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -175,14 +175,13 @@ Library blaze-markup >= 0.5.1 && < 0.9, bytestring >= 0.9 && < 0.11, containers >= 0.3 && < 0.7, - cryptonite >= 0.25 && < 0.29, data-default >= 0.4 && < 0.8, deepseq >= 1.3 && < 1.5, directory >= 1.2.7.0 && < 1.4, file-embed >= 0.0.10.1 && < 0.0.14, filepath >= 1.0 && < 1.5, + hashable >= 1.0 && < 2, lrucache >= 1.1.1 && < 1.3, - memory >= 0.14.18 && < 0.16, mtl >= 1 && < 2.3, network-uri >= 2.6 && < 2.7, optparse-applicative >= 0.12 && < 0.17, diff --git a/lib/Hakyll/Core/Store.hs b/lib/Hakyll/Core/Store.hs index bfcd191..da16c6f 100644 --- a/lib/Hakyll/Core/Store.hs +++ b/lib/Hakyll/Core/Store.hs @@ -16,20 +16,14 @@ module Hakyll.Core.Store -------------------------------------------------------------------------------- -import qualified Data.ByteArray as BA -import qualified Crypto.Hash as CH +import qualified Data.Hashable as DH import Data.Binary (Binary, decode, encodeFile) -import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL import qualified Data.Cache.LRU.IO as Lru import Data.List (intercalate) import Data.Maybe (isJust) -import qualified Data.Text as T -import qualified Data.Text.Encoding as T import Data.Typeable (TypeRep, Typeable, cast, typeOf) -import Numeric (showHex) -import System.Directory (createDirectoryIfMissing) -import System.Directory (doesFileExist, removeFile) +import System.Directory (createDirectoryIfMissing, doesFileExist, removeFile) import System.FilePath (()) import System.IO (IOMode (..), hClose, openFile) import System.IO.Error (catchIOError, ioeSetFileName, @@ -194,21 +188,4 @@ deleteFile = (`catchIOError` \_ -> return ()) . removeFile -------------------------------------------------------------------------------- -- | Mostly meant for internal usage hash :: [String] -> String -hash = toHex . B.unpack . hashMD5 . T.encodeUtf8 . T.pack . intercalate "/" - where - toHex [] = "" - toHex (x : xs) | x < 16 = '0' : showHex x (toHex xs) - | otherwise = showHex x (toHex xs) - - --------------------------------------------------------------------------------- --- | Hash by MD5 -hashMD5 :: B.ByteString -> B.ByteString -hashMD5 x = - let - digest :: CH.Digest CH.MD5 - digest = CH.hash x - bytes :: B.ByteString - bytes = BA.convert digest - in - bytes +hash = show . DH.hash . intercalate "/" \ No newline at end of file diff --git a/test.hs b/test.hs index 8b3a2de..aea447c 100644 --- a/test.hs +++ b/test.hs @@ -1,9 +1,9 @@ {-# LANGUAGE BangPatterns #-} import Control.Monad (forM) -import qualified Crypto.Hash.SHA256 as SHA256 import qualified Data.ByteString.Base16 as Base16 import qualified Data.ByteString.Char8 as BS8 import qualified Data.ByteString.Lazy as BSL +import qualified Data.Hashable as DH import Data.Map (Map) import qualified Data.Map as Map import Hakyll @@ -20,9 +20,7 @@ mkFileHashes dir = do return (fromFilePath path1, h) where hash :: FilePath -> IO String - hash fp = do - !h <- SHA256.hashlazy <$> BSL.readFile fp - return $! BS8.unpack $! Base16.encode h + hash fp = (show . DH.hash) <$> BSL.readFile fp main :: IO () main = hakyll $ do -- cgit v1.2.3 From 8980133284d7d5f0d7cd71580796150c74b22f2d Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Wed, 26 May 2021 17:54:32 +0300 Subject: Docs: IRC channel moved from Freenode to Libera.Chat (#848) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no mention of this on the issue tracker, so here's my recap of what led to this change. There is some drama around Freenode. Their volunteer staff quit[1]. Then the new-ish management started enacting strange policy changes[2] and take over the channels[3]. On June 26th 2021 Freenode's bot tried to take over #hakyll, but failed; however, it did succeed in #haskell and many, many other channels. For the preceding week, me and IRC user henk were trying to move the channel off the Freenode, either to Libera.Chat or OFTC. Jasper, the founder of Hakyll, was absent from IRC and didn't respond to my emails. Me and henk are the most active IRC users on the channel. Also, I have Collaborator access to the repo, and henk has chanop access to the IRC channel. We believe that at this time, we're the ones who are the best positioned to execute the move, so we're doing it. We only considered Libera.Chat and OFTC. Libera.Chat was created a week earlier by the same staff who quit Freenode; I personally consider them to be a spiritual successor of Freenode. OFTC is a well-established network with good governance documentation. Both networks are FOSS-friendly. The choice wasn't obvious. Libera.Chat was picked because 10 users moved there (and 1 more did while I was typing this!), whereas only 2 joined OFTC (me and henk, and those weren't votes for OFTC — we were just ensuring that the channel is ours). Also, #haskell and #ghc are on Libera too, so it makes sense for a Haskell project such as Hakyll to be present on Libera. For posterity: info #hakyll -ChanServ(ChanServ@services.)- Information on #hakyll: -ChanServ(ChanServ@services.)- Founder : jaspervdj -ChanServ(ChanServ@services.)- Registered : Mar 01 13:29:17 2011 (10y 12w 5d ago) -ChanServ(ChanServ@services.)- Mode lock : +ntc-slk -ChanServ(ChanServ@services.)- *** End of Info *** 1. https://kline.sh 2. https://github.com/freenode/web-7.0/pull/513 3. https://www.devever.net/~hl/freenode_abuse --- hakyll.cabal | 2 +- web/index.markdown | 3 ++- web/templates/tutorial.html | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hakyll.cabal b/hakyll.cabal index b09aff0..89f251d 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -22,7 +22,7 @@ Description: . - * An IRC channel, @#hakyll@ on freenode + * An IRC channel, @#hakyll@ on irc.libera.chat (we *do not* have a channel on Freenode anymore) . diff --git a/web/index.markdown b/web/index.markdown index bde5289..fd4c6ff 100644 --- a/web/index.markdown +++ b/web/index.markdown @@ -39,4 +39,5 @@ using [stack] by using `stack install hakyll`. Then, you can: - read the [tutorials](/tutorials.html); - mail the [google discussion group](http://groups.google.com/group/hakyll); - ask questions on the IRC channel: `#hakyll` on - [freenode](http://freenode.net/). + [irc.libera.chat](https://libera.chat/) (we *do not* have a channel on + Freenode anymore). diff --git a/web/templates/tutorial.html b/web/templates/tutorial.html index 54af861..a9c4a27 100644 --- a/web/templates/tutorial.html +++ b/web/templates/tutorial.html @@ -18,4 +18,5 @@ you have a github account, you can use the If you run into any problems, all questions are welcome in the above google group, or you could try the IRC channel, #hakyll on -freenode. +irs.libera.chat (we do not have +a channel on Freenode anymore). -- cgit v1.2.3 From ef1e9b475cfd4886a01b0f26b9c4b30533fa7939 Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Sat, 29 May 2021 23:11:05 +0300 Subject: Fix binary's name in the first tutorial (#849) Fixes #847. --- web/tutorials/01-installation.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/tutorials/01-installation.markdown b/web/tutorials/01-installation.markdown index c41d9a6..fb19026 100644 --- a/web/tutorials/01-installation.markdown +++ b/web/tutorials/01-installation.markdown @@ -51,11 +51,11 @@ use `cabal new-run site [command]`. You can build the site using: - my-site build + site build And preview (and build) it using: - my-site watch + site watch Using stack =========== -- cgit v1.2.3 From 6e77b4e7d2f74da964fd95494dad1ee56d4c4536 Mon Sep 17 00:00:00 2001 From: "Laurent P. René de Cotret" Date: Sun, 30 May 2021 15:00:59 -0400 Subject: Async runtime with graph-based dependency cycle checks (#844) * Async runtime * Activate multi-threading in template repo * Style changes after feedback * Limiting the number of concurrent tasks * Revert "Limiting the number of concurrent tasks" This reverts commit 38984f6f5332632be8c4cab3e29d37e318492d70. --- hakyll.cabal | 3 + lib/Hakyll/Core/Runtime.hs | 319 +++++++++++++++++++++---------------- src/Init.hs | 2 +- tests/Hakyll/Core/Runtime/Tests.hs | 30 +++- 4 files changed, 216 insertions(+), 138 deletions(-) diff --git a/hakyll.cabal b/hakyll.cabal index 89f251d..74e63e0 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -169,6 +169,7 @@ Library Paths_hakyll Build-Depends: + array >= 0.5 && < 1, base >= 4.8 && < 5, binary >= 0.5 && < 0.10, blaze-html >= 0.5 && < 0.10, @@ -181,6 +182,7 @@ Library file-embed >= 0.0.10.1 && < 0.0.14, filepath >= 1.0 && < 1.5, hashable >= 1.0 && < 2, + lifted-async >= 0.10 && < 1, lrucache >= 1.1.1 && < 1.3, mtl >= 1 && < 2.3, network-uri >= 2.6 && < 2.7, @@ -191,6 +193,7 @@ Library regex-tdfa >= 1.1 && < 1.4, resourcet >= 1.1 && < 1.3, scientific >= 0.3.4 && < 0.4, + stm >= 2.3 && < 3, tagsoup >= 0.13.1 && < 0.15, template-haskell >= 2.14 && < 2.17, text >= 0.11 && < 1.3, diff --git a/lib/Hakyll/Core/Runtime.hs b/lib/Hakyll/Core/Runtime.hs index 922b676..e0edf5b 100644 --- a/lib/Hakyll/Core/Runtime.hs +++ b/lib/Hakyll/Core/Runtime.hs @@ -5,19 +5,24 @@ module Hakyll.Core.Runtime -------------------------------------------------------------------------------- -import Control.Monad (unless) -import Control.Monad.Except (ExceptT, runExceptT, throwError) -import Control.Monad.Reader (ask) -import Control.Monad.RWS (RWST, runRWST) -import Control.Monad.State (get, modify) -import Control.Monad.Trans (liftIO) -import Data.List (intercalate) -import Data.Map (Map) -import qualified Data.Map as M -import Data.Set (Set) -import qualified Data.Set as S -import System.Exit (ExitCode (..)) -import System.FilePath (()) +import Control.Concurrent.Async.Lifted (forConcurrently_) +import Control.Concurrent.STM (atomically, modifyTVar', readTVarIO, newTVarIO, TVar) +import Control.Monad (unless) +import Control.Monad.Except (ExceptT, runExceptT, throwError) +import Control.Monad.Reader (ask) +import Control.Monad.RWS (RWST, runRWST) +import Control.Monad.State (get) +import Control.Monad.Trans (liftIO) +import qualified Data.Array as A +import Data.Graph (Graph) +import qualified Data.Graph as G +import Data.List (intercalate) +import Data.Map (Map) +import qualified Data.Map as M +import Data.Set (Set) +import qualified Data.Set as S +import System.Exit (ExitCode (..)) +import System.FilePath (()) -------------------------------------------------------------------------------- @@ -67,11 +72,13 @@ run config logger rules = do , runtimeRoutes = rulesRoutes ruleSet , runtimeUniverse = M.fromList compilers } - state = RuntimeState - { runtimeDone = S.empty - , runtimeSnapshots = S.empty - , runtimeTodo = M.empty - , runtimeFacts = oldFacts + + state <- newTVarIO $ RuntimeState + { runtimeDone = S.empty + , runtimeSnapshots = S.empty + , runtimeTodo = M.empty + , runtimeFacts = oldFacts + , runtimeDependencies = M.empty } -- Run the program and fetch the resulting state @@ -83,7 +90,8 @@ run config logger rules = do return (ExitFailure 1, ruleSet) Right (_, s, _) -> do - Store.set store factsKey $ runtimeFacts s + facts <- fmap runtimeFacts . liftIO . readTVarIO $ s + Store.set store factsKey facts Logger.debug logger "Removing tmp directory..." removeDirectory $ tmpDirectory config @@ -107,15 +115,30 @@ data RuntimeRead = RuntimeRead -------------------------------------------------------------------------------- data RuntimeState = RuntimeState - { runtimeDone :: Set Identifier - , runtimeSnapshots :: Set (Identifier, Snapshot) - , runtimeTodo :: Map Identifier (Compiler SomeItem) - , runtimeFacts :: DependencyFacts + { runtimeDone :: Set Identifier + , runtimeSnapshots :: Set (Identifier, Snapshot) + , runtimeTodo :: Map Identifier (Compiler SomeItem) + , runtimeFacts :: DependencyFacts + , runtimeDependencies :: Map Identifier (Set Identifier) } -------------------------------------------------------------------------------- -type Runtime a = RWST RuntimeRead () RuntimeState (ExceptT String IO) a +type Runtime a = RWST RuntimeRead () (TVar RuntimeState) (ExceptT String IO) a + + +-------------------------------------------------------------------------------- +-- Because compilation of rules often revolves around IO, +-- it is not possible to live in the STM monad and hence benefit from +-- its guarantees. +-- Be very careful when modifying the state +modifyRuntimeState :: (RuntimeState -> RuntimeState) -> Runtime () +modifyRuntimeState f = get >>= \s -> liftIO . atomically $ modifyTVar' s f + + +-------------------------------------------------------------------------------- +getRuntimeState :: Runtime RuntimeState +getRuntimeState = liftIO . readTVarIO =<< get -------------------------------------------------------------------------------- @@ -135,13 +158,15 @@ scheduleOutOfDate = do logger <- runtimeLogger <$> ask provider <- runtimeProvider <$> ask universe <- runtimeUniverse <$> ask - facts <- runtimeFacts <$> get - todo <- runtimeTodo <$> get let identifiers = M.keys universe modified = S.fromList $ flip filter identifiers $ resourceModified provider - + + state <- getRuntimeState + let facts = runtimeFacts state + todo = runtimeTodo state + let (ood, facts', msgs) = outOfDate identifiers modified facts todo' = M.filterWithKey (\id' _ -> id' `S.member` ood) universe @@ -150,7 +175,7 @@ scheduleOutOfDate = do mapM_ (Logger.debug logger) msgs -- Update facts and todo items - modify $ \s -> s + modifyRuntimeState $ \s -> s { runtimeDone = runtimeDone s `S.union` (S.fromList identifiers `S.difference` ood) , runtimeTodo = todo `M.union` todo' @@ -161,116 +186,138 @@ scheduleOutOfDate = do -------------------------------------------------------------------------------- pickAndChase :: Runtime () pickAndChase = do - todo <- runtimeTodo <$> get - case M.minViewWithKey todo of - Nothing -> return () - Just ((id', _), _) -> do - chase [] id' - pickAndChase + todo <- runtimeTodo <$> getRuntimeState + unless (null todo) $ do + checkForDependencyCycle + forConcurrently_ (M.keys todo) chase + pickAndChase -------------------------------------------------------------------------------- -chase :: [Identifier] -> Identifier -> Runtime () -chase trail id' - | id' `elem` trail = throwError $ "Hakyll.Core.Runtime.chase: " ++ - "Dependency cycle detected: " ++ intercalate " depends on " - (map show $ dropWhile (/= id') (reverse trail) ++ [id']) - | otherwise = do - logger <- runtimeLogger <$> ask - todo <- runtimeTodo <$> get - provider <- runtimeProvider <$> ask - universe <- runtimeUniverse <$> ask - routes <- runtimeRoutes <$> ask - store <- runtimeStore <$> ask - config <- runtimeConfiguration <$> ask - Logger.debug logger $ "Processing " ++ show id' - - let compiler = todo M.! id' - read' = CompilerRead - { compilerConfig = config - , compilerUnderlying = id' - , compilerProvider = provider - , compilerUniverse = M.keysSet universe - , compilerRoutes = routes - , compilerStore = store - , compilerLogger = logger +-- | Check for cyclic dependencies in the current state +checkForDependencyCycle :: Runtime () +checkForDependencyCycle = do + deps <- runtimeDependencies <$> getRuntimeState + let (depgraph, nodeFromVertex, _) = G.graphFromEdges [(k, k, S.toList dps) | (k, dps) <- M.toList deps] + dependencyCycles = map ((\(_, k, _) -> k) . nodeFromVertex) $ cycles depgraph + + unless (null dependencyCycles) $ do + throwError $ "Hakyll.Core.Runtime.pickAndChase: " ++ + "Dependency cycle detected: " ++ intercalate ", " (map show dependencyCycles) ++ + " are inter-dependent." + where + cycles :: Graph -> [G.Vertex] + cycles g = map fst . filter (uncurry $ reachableFromAny g) . A.assocs $ g + + reachableFromAny :: Graph -> G.Vertex -> [G.Vertex] -> Bool + reachableFromAny graph node = elem node . concatMap (G.reachable graph) + + +-------------------------------------------------------------------------------- +chase :: Identifier -> Runtime () +chase id' = do + logger <- runtimeLogger <$> ask + provider <- runtimeProvider <$> ask + universe <- runtimeUniverse <$> ask + routes <- runtimeRoutes <$> ask + store <- runtimeStore <$> ask + config <- runtimeConfiguration <$> ask + + state <- getRuntimeState + + Logger.debug logger $ "Processing " ++ show id' + + let compiler = (runtimeTodo state) M.! id' + read' = CompilerRead + { compilerConfig = config + , compilerUnderlying = id' + , compilerProvider = provider + , compilerUniverse = M.keysSet universe + , compilerRoutes = routes + , compilerStore = store + , compilerLogger = logger + } + + result <- liftIO $ runCompiler compiler read' + case result of + -- Rethrow error + CompilerError e -> throwError $ case compilerErrorMessages e of + [] -> "Compiler failed but no info given, try running with -v?" + es -> intercalate "; " es + + -- Signal that a snapshot was saved -> + CompilerSnapshot snapshot c -> do + -- Update info. The next 'chase' will pick us again at some + -- point so we can continue then. + modifyRuntimeState $ \s -> s + { runtimeSnapshots = S.insert (id', snapshot) (runtimeSnapshots s) + , runtimeTodo = M.insert id' c (runtimeTodo s) + } + + + -- Huge success + CompilerDone (SomeItem item) cwrite -> do + -- Print some info + let facts = compilerDependencies cwrite + cacheHits + | compilerCacheHits cwrite <= 0 = "updated" + | otherwise = "cached " + Logger.message logger $ cacheHits ++ " " ++ show id' + + -- Sanity check + unless (itemIdentifier item == id') $ throwError $ + "The compiler yielded an Item with Identifier " ++ + show (itemIdentifier item) ++ ", but we were expecting " ++ + "an Item with Identifier " ++ show id' ++ " " ++ + "(you probably want to call makeItem to solve this problem)" + + -- Write if necessary + (mroute, _) <- liftIO $ runRoutes routes provider id' + case mroute of + Nothing -> return () + Just route -> do + let path = destinationDirectory config route + liftIO $ makeDirectories path + liftIO $ write path item + Logger.debug logger $ "Routed to " ++ path + + -- Save! (For load) + liftIO $ save store item + + modifyRuntimeState $ \s -> s + { runtimeDone = S.insert id' (runtimeDone s) + , runtimeTodo = M.delete id' (runtimeTodo s) + , runtimeFacts = M.insert id' facts (runtimeFacts s) + } + + -- Try something else first + CompilerRequire dep c -> do + let (depId, depSnapshot) = dep + Logger.debug logger $ + "Compiler requirement found for: " ++ show id' ++ + ", requirement: " ++ show depId + + let done = runtimeDone state + snapshots = runtimeSnapshots state + deps = runtimeDependencies state + + -- Done if we either completed the entire item (runtimeDone) or + -- if we previously saved the snapshot (runtimeSnapshots). + let depDone = + depId `S.member` done || + (depId, depSnapshot) `S.member` snapshots + + let deps' = if depDone + then deps + else M.insertWith S.union id' (S.singleton depId) deps + + modifyRuntimeState $ \s -> s + { runtimeTodo = M.insert id' + (if depDone then c else compilerResult result) + (runtimeTodo s) + , runtimeDependencies = deps' } - result <- liftIO $ runCompiler compiler read' - case result of - -- Rethrow error - CompilerError e -> throwError $ case compilerErrorMessages e of - [] -> "Compiler failed but no info given, try running with -v?" - es -> intercalate "; " es - - -- Signal that a snapshot was saved -> - CompilerSnapshot snapshot c -> do - -- Update info. The next 'chase' will pick us again at some - -- point so we can continue then. - modify $ \s -> s - { runtimeSnapshots = - S.insert (id', snapshot) (runtimeSnapshots s) - , runtimeTodo = M.insert id' c (runtimeTodo s) - } - - -- Huge success - CompilerDone (SomeItem item) cwrite -> do - -- Print some info - let facts = compilerDependencies cwrite - cacheHits - | compilerCacheHits cwrite <= 0 = "updated" - | otherwise = "cached " - Logger.message logger $ cacheHits ++ " " ++ show id' - - -- Sanity check - unless (itemIdentifier item == id') $ throwError $ - "The compiler yielded an Item with Identifier " ++ - show (itemIdentifier item) ++ ", but we were expecting " ++ - "an Item with Identifier " ++ show id' ++ " " ++ - "(you probably want to call makeItem to solve this problem)" - - -- Write if necessary - (mroute, _) <- liftIO $ runRoutes routes provider id' - case mroute of - Nothing -> return () - Just route -> do - let path = destinationDirectory config route - liftIO $ makeDirectories path - liftIO $ write path item - Logger.debug logger $ "Routed to " ++ path - - -- Save! (For load) - liftIO $ save store item - - -- Update state - modify $ \s -> s - { runtimeDone = S.insert id' (runtimeDone s) - , runtimeTodo = M.delete id' (runtimeTodo s) - , runtimeFacts = M.insert id' facts (runtimeFacts s) - } - - -- Try something else first - CompilerRequire dep c -> do - -- Update the compiler so we don't execute it twice - let (depId, depSnapshot) = dep - done <- runtimeDone <$> get - snapshots <- runtimeSnapshots <$> get - - -- Done if we either completed the entire item (runtimeDone) or - -- if we previously saved the snapshot (runtimeSnapshots). - let depDone = - depId `S.member` done || - (depId, depSnapshot) `S.member` snapshots - - modify $ \s -> s - { runtimeTodo = M.insert id' - (if depDone then c else compilerResult result) - (runtimeTodo s) - } - - -- If the required item is already compiled, continue, or, start - -- chasing that - Logger.debug logger $ "Require " ++ show depId ++ - " (snapshot " ++ depSnapshot ++ "): " ++ - (if depDone then "OK" else "chasing") - if depDone then chase trail id' else chase (id' : trail) depId + Logger.debug logger $ "Require " ++ show depId ++ + " (snapshot " ++ depSnapshot ++ ") " + \ No newline at end of file diff --git a/src/Init.hs b/src/Init.hs index 63899e4..c79a76e 100644 --- a/src/Init.hs +++ b/src/Init.hs @@ -120,7 +120,7 @@ createCabal path name = , " main-is: site.hs" , " build-depends: base == 4.*" , " , hakyll == " ++ version' ++ ".*" - , " ghc-options: -threaded" + , " ghc-options: -threaded -rtsopts -with-rtsopts=-N" , " default-language: Haskell2010" ] where diff --git a/tests/Hakyll/Core/Runtime/Tests.hs b/tests/Hakyll/Core/Runtime/Tests.hs index 9c23162..615aaf2 100644 --- a/tests/Hakyll/Core/Runtime/Tests.hs +++ b/tests/Hakyll/Core/Runtime/Tests.hs @@ -8,6 +8,7 @@ module Hakyll.Core.Runtime.Tests -------------------------------------------------------------------------------- import qualified Data.ByteString as B import System.FilePath (()) +import System.Exit (ExitCode (..)) import Test.Tasty (TestTree, testGroup) import Test.Tasty.HUnit (Assertion, (@?=)) @@ -22,7 +23,7 @@ import TestSuite.Util -------------------------------------------------------------------------------- tests :: TestTree tests = testGroup "Hakyll.Core.Runtime.Tests" $ - fromAssertions "run" [case01, case02] + fromAssertions "run" [case01, case02, case03] -------------------------------------------------------------------------------- @@ -94,3 +95,30 @@ case02 = do favicon @?= "Test" cleanTestEnv + + +-------------------------------------------------------------------------------- +-- Test that dependency cycles are correctly identified +case03 :: Assertion +case03 = do + logger <- Logger.new Logger.Error + (ec, _) <- run testConfiguration logger $ do + + create ["partial.html.out1"] $ do + route idRoute + compile $ do + example <- loadSnapshotBody "partial.html.out2" "raw" + makeItem example + >>= loadAndApplyTemplate "partial.html" defaultContext + + create ["partial.html.out2"] $ do + route idRoute + compile $ do + example <- loadSnapshotBody "partial.html.out1" "raw" + makeItem example + >>= loadAndApplyTemplate "partial.html" defaultContext + + + ec @?= ExitFailure 1 + + cleanTestEnv -- cgit v1.2.3 From e0c63558a82ac4347181d5d77dce7f763a1db410 Mon Sep 17 00:00:00 2001 From: "Laurent P. René de Cotret" Date: Tue, 1 Jun 2021 15:46:33 -0400 Subject: Allow Pandoc 2.14 (#852) * Bump allowed Pandoc version * Allow more recent version of Pandoc in hakyll-init exe --- hakyll.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hakyll.cabal b/hakyll.cabal index 74e63e0..914e64a 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -239,7 +239,7 @@ Library Other-Modules: Hakyll.Web.Pandoc.Binary Build-Depends: - pandoc >= 2.11 && < 2.14 + pandoc >= 2.11 && < 2.15 Cpp-options: -DUSE_PANDOC @@ -335,4 +335,4 @@ Executable hakyll-website base >= 4 && < 5, directory >= 1.0 && < 1.4, filepath >= 1.0 && < 1.5, - pandoc >= 2.11 && < 2.14 + pandoc >= 2.11 && < 2.15 -- cgit v1.2.3 From 591fbe693d87b84c73b1839acdd424cbc12da3b3 Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Wed, 2 Jun 2021 00:56:53 +0300 Subject: Bump some more dependencies (#853) * Allow file-embed 0.0.14.0 * Allow time 1.11 * Allow template-haskell 2.17 (i.e. GHC 9) --- hakyll.cabal | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hakyll.cabal b/hakyll.cabal index 914e64a..4699235 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -179,7 +179,7 @@ Library data-default >= 0.4 && < 0.8, deepseq >= 1.3 && < 1.5, directory >= 1.2.7.0 && < 1.4, - file-embed >= 0.0.10.1 && < 0.0.14, + file-embed >= 0.0.10.1 && < 0.0.15, filepath >= 1.0 && < 1.5, hashable >= 1.0 && < 2, lifted-async >= 0.10 && < 1, @@ -195,9 +195,9 @@ Library scientific >= 0.3.4 && < 0.4, stm >= 2.3 && < 3, tagsoup >= 0.13.1 && < 0.15, - template-haskell >= 2.14 && < 2.17, + template-haskell >= 2.14 && < 2.18, text >= 0.11 && < 1.3, - time >= 1.8 && < 1.10, + time >= 1.8 && < 1.12, time-locale-compat >= 0.1 && < 0.2, unordered-containers >= 0.2 && < 0.3, vector >= 0.11 && < 0.13, -- cgit v1.2.3 From 6d9bc845d5233c67e5eba3f54dcc7772ca1d79e2 Mon Sep 17 00:00:00 2001 From: Logan McGrath <81108848+ThisFieldWasGreen@users.noreply.github.com> Date: Sun, 6 Jun 2021 10:50:44 -0700 Subject: Allow demotion of headers by a given amount (#855) --- lib/Hakyll/Web/Html.hs | 12 ++++++++++-- tests/Hakyll/Web/Html/Tests.hs | 13 ++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/Hakyll/Web/Html.hs b/lib/Hakyll/Web/Html.hs index 8cbfaa3..7aa3804 100644 --- a/lib/Hakyll/Web/Html.hs +++ b/lib/Hakyll/Web/Html.hs @@ -7,6 +7,7 @@ module Hakyll.Web.Html -- * Headers , demoteHeaders + , demoteHeadersBy -- * Url manipulation , getUrls @@ -50,13 +51,20 @@ withTagList f = renderTags' . f . parseTags' -------------------------------------------------------------------------------- -- | Map every @h1@ to an @h2@, @h2@ to @h3@, etc. demoteHeaders :: String -> String -demoteHeaders = withTags $ \tag -> case tag of +demoteHeaders = demoteHeadersBy 1 + +-------------------------------------------------------------------------------- +-- | Maps any @hN@ to an @hN+amount@ for any @amount > 0 && 1 <= N+amount <= 6@. +demoteHeadersBy :: Int -> String -> String +demoteHeadersBy amount + | amount < 1 = id + | otherwise = withTags $ \tag -> case tag of TS.TagOpen t a -> TS.TagOpen (demote t) a TS.TagClose t -> TS.TagClose (demote t) t -> t where demote t@['h', n] - | isDigit n = ['h', intToDigit (min 6 $ digitToInt n + 1)] + | isDigit n = ['h', intToDigit (min 6 $ digitToInt n + amount)] | otherwise = t demote t = t diff --git a/tests/Hakyll/Web/Html/Tests.hs b/tests/Hakyll/Web/Html/Tests.hs index cd362f4..9ab10bc 100644 --- a/tests/Hakyll/Web/Html/Tests.hs +++ b/tests/Hakyll/Web/Html/Tests.hs @@ -20,7 +20,18 @@ tests :: TestTree tests = testGroup "Hakyll.Web.Html.Tests" $ concat [ fromAssertions "demoteHeaders" [ "

A h1 title

" @=? - demoteHeaders "

A h1 title

" + demoteHeaders "

A h1 title

" -- Assert single-step demotion + , "
A h6 title
" @=? + demoteHeaders "
A h6 title
" -- Assert maximum demotion is h6 + ] + + , fromAssertions "demoteHeadersBy" + [ "

A h1 title

" @=? + demoteHeadersBy 2 "

A h1 title

" + , "
A h5 title
" @=? + demoteHeadersBy 2 "
A h5 title
" -- Assert that h6 is the lowest possible demoted header. + , "

A h4 title

" @=? + demoteHeadersBy 0 "

A h4 title

" -- Assert that a demotion of @N < 1@ is a no-op. ] , fromAssertions "withUrls" -- cgit v1.2.3 From 6885325146aa46adf255c55de0e0345a0f84961e Mon Sep 17 00:00:00 2001 From: Fraser Tweedale Date: Wed, 23 Jun 2021 03:26:20 +1000 Subject: add 'forceCompile' rules modifier (#857) Compilers that use data from sources other than local files may need to be recompiled, but Hakyll's file-based dependency checking does not handle this situation. Add a new kind of dependency called 'AlwaysOutOfDate'. If an item has this dependency, it will be unconditionally rebuilt. Also add the 'forceCompile' rule modifier, which is a user-friendly way to force recompilation of specific items. Example usage: forceCompile $ create ["foo"] $ do route $ idRoute compile $ unsafeCompiler $ doSomeIO --- lib/Hakyll/Core/Dependencies.hs | 51 +++++++++++++++++++++++++++++++---------- lib/Hakyll/Core/Rules.hs | 9 ++++++++ 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/lib/Hakyll/Core/Dependencies.hs b/lib/Hakyll/Core/Dependencies.hs index 4a51b9c..f9b8048 100644 --- a/lib/Hakyll/Core/Dependencies.hs +++ b/lib/Hakyll/Core/Dependencies.hs @@ -33,6 +33,7 @@ import Hakyll.Core.Identifier.Pattern data Dependency = PatternDependency Pattern (Set Identifier) | IdentifierDependency Identifier + | AlwaysOutOfDate deriving (Show, Typeable) @@ -40,9 +41,11 @@ data Dependency instance Binary Dependency where put (PatternDependency p is) = putWord8 0 >> put p >> put is put (IdentifierDependency i) = putWord8 1 >> put i + put AlwaysOutOfDate = putWord8 2 get = getWord8 >>= \t -> case t of 0 -> PatternDependency <$> get <*> get 1 -> IdentifierDependency <$> get + 2 -> pure AlwaysOutOfDate _ -> error "Data.Binary.get: Invalid Dependency" @@ -84,13 +87,30 @@ markOod id' = State.modify $ \s -> -------------------------------------------------------------------------------- -dependenciesFor :: Identifier -> DependencyM [Identifier] +-- | Collection of dependencies that should be checked to determine +-- if an identifier needs rebuilding. +data Dependencies + = DependsOn [Identifier] + | MustRebuild + deriving (Show) + +instance Semigroup Dependencies where + DependsOn ids <> DependsOn moreIds = DependsOn (ids <> moreIds) + MustRebuild <> _ = MustRebuild + _ <> MustRebuild = MustRebuild + +instance Monoid Dependencies where + mempty = DependsOn [] + +-------------------------------------------------------------------------------- +dependenciesFor :: Identifier -> DependencyM Dependencies dependenciesFor id' = do facts <- dependencyFacts <$> State.get - return $ concatMap dependenciesFor' $ fromMaybe [] $ M.lookup id' facts + return $ foldMap dependenciesFor' $ fromMaybe [] $ M.lookup id' facts where - dependenciesFor' (IdentifierDependency i) = [i] - dependenciesFor' (PatternDependency _ is) = S.toList is + dependenciesFor' (IdentifierDependency i) = DependsOn [i] + dependenciesFor' (PatternDependency _ is) = DependsOn $ S.toList is + dependenciesFor' AlwaysOutOfDate = MustRebuild -------------------------------------------------------------------------------- @@ -113,6 +133,7 @@ checkChangedPatterns = do {dependencyFacts = M.insert id' deps' $ dependencyFacts s} where go _ ds (IdentifierDependency i) = return $ IdentifierDependency i : ds + go _ ds AlwaysOutOfDate = return $ AlwaysOutOfDate : ds go id' ds (PatternDependency p ls) = do universe <- ask let ls' = S.fromList $ filterMatches p universe @@ -136,11 +157,17 @@ bruteForce = do check (todo, changed) id' = do deps <- dependenciesFor id' - ood <- dependencyOod <$> State.get - case find (`S.member` ood) deps of - Nothing -> return (id' : todo, changed) - Just d -> do - tell [show id' ++ " is out-of-date because " ++ - show d ++ " is out-of-date"] - markOod id' - return (todo, True) + case deps of + DependsOn depList -> do + ood <- dependencyOod <$> State.get + case find (`S.member` ood) depList of + Nothing -> return (id' : todo, changed) + Just d -> do + tell [show id' ++ " is out-of-date because " ++ + show d ++ " is out-of-date"] + markOod id' + return (todo, True) + MustRebuild -> do + tell [show id' ++ " will be forcibly rebuilt"] + markOod id' + return (todo, True) diff --git a/lib/Hakyll/Core/Rules.hs b/lib/Hakyll/Core/Rules.hs index 41b9a73..695665a 100644 --- a/lib/Hakyll/Core/Rules.hs +++ b/lib/Hakyll/Core/Rules.hs @@ -29,6 +29,7 @@ module Hakyll.Core.Rules , preprocess , Dependency (..) , rulesExtraDependencies + , forceCompile ) where @@ -221,3 +222,11 @@ rulesExtraDependencies deps rules = | (i, c) <- rulesCompilers ruleSet ] } + + +-------------------------------------------------------------------------------- +-- | Force the item(s) to always be recompiled, whether or not the +-- dependencies are out of date. This can be useful if you are using +-- I/O to generate part (or all) of an item. +forceCompile :: Rules a -> Rules a +forceCompile = rulesExtraDependencies [AlwaysOutOfDate] -- cgit v1.2.3 From b273db4d067ef54248e9a52adedd3e558907d541 Mon Sep 17 00:00:00 2001 From: Peter Becich Date: Tue, 6 Jul 2021 06:33:23 -0700 Subject: update Github Actions (#859) * update Github Actions https://github.com/actions/setup-haskell has been archived. I believe https://github.com/haskell/actions/tree/main/setup is current. * try to fix stalling CI job --- .github/workflows/main.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 12276e3..86e5b92 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,18 +13,18 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - cabal: ["3.2"] + cabal: ["3.4"] ghc: - "8.6.5" - - "8.8.3" - - "8.10.1" + - "8.8.4" + - "8.10.4" exclude: - os: macOS-latest - ghc: 8.8.3 + ghc: 8.8.4 - os: macOS-latest ghc: 8.6.5 - os: windows-latest - ghc: 8.8.3 + ghc: 8.8.4 - os: windows-latest ghc: 8.6.5 @@ -32,7 +32,7 @@ jobs: - uses: actions/checkout@v2 if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' - - uses: actions/setup-haskell@v1.1.4 + - uses: haskell/actions/setup@v1 id: setup-haskell-cabal name: Setup Haskell with: @@ -63,14 +63,14 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - stack: ["2.3.1"] - ghc: ["8.8.3"] + stack: ["2.7.1"] + ghc: ["8.8.4"] steps: - uses: actions/checkout@v2 if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/master' - - uses: actions/setup-haskell@v1.1.4 + - uses: haskell/actions/setup@v1 name: Setup Haskell Stack with: ghc-version: ${{ matrix.ghc }} -- cgit v1.2.3 From 0ad582562ba79e082417d5aaa3d7733859e55306 Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Thu, 15 Jul 2021 18:50:47 +0300 Subject: Avoid "Empty 'do' block" error in GitHub tutorial (#861) Report and fix by @alexandroid000. Fixes #860. --- web/tutorials/github-pages-tutorial.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web/tutorials/github-pages-tutorial.md b/web/tutorials/github-pages-tutorial.md index acecb38..2f6e82b 100644 --- a/web/tutorials/github-pages-tutorial.md +++ b/web/tutorials/github-pages-tutorial.md @@ -66,8 +66,7 @@ config = defaultConfiguration } main :: IO () -main = do - hakyllWith config $ do +main = hakyllWith config $ do ... ``` -- cgit v1.2.3 From d739fd1eea40de9ded3b4f682c849d3c31eba92c Mon Sep 17 00:00:00 2001 From: Jim McStanton Date: Fri, 16 Jul 2021 14:13:43 -0500 Subject: Supporting different field names for tags. (#862) * Supporting different field names for tags. * Removed buildTagsByField Removed to avoid exponential growth of helper functions. Renamed field parameter in getTagsByField to fieldName to avoid shadowing. * Drop obsolete export Co-authored-by: Alexander Batischev --- lib/Hakyll/Web/Tags.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Hakyll/Web/Tags.hs b/lib/Hakyll/Web/Tags.hs index aab5d34..ccf34a5 100644 --- a/lib/Hakyll/Web/Tags.hs +++ b/lib/Hakyll/Web/Tags.hs @@ -43,6 +43,7 @@ module Hakyll.Web.Tags ( Tags (..) , getTags + , getTagsByField , getCategory , buildTagsWith , buildTags @@ -105,11 +106,16 @@ data Tags = Tags -- | Obtain tags from a page in the default way: parse them from the @tags@ -- metadata field. This can either be a list or a comma-separated string. getTags :: MonadMetadata m => Identifier -> m [String] -getTags identifier = do +getTags = getTagsByField "tags" + +-- | Obtain tags from a page by name of the metadata field. These can be a list +-- or a comma-separated string +getTagsByField :: MonadMetadata m => String -> Identifier -> m [String] +getTagsByField fieldName identifier = do metadata <- getMetadata identifier return $ fromMaybe [] $ - (lookupStringList "tags" metadata) `mplus` - (map trim . splitAll "," <$> lookupString "tags" metadata) + (lookupStringList fieldName metadata) `mplus` + (map trim . splitAll "," <$> lookupString fieldName metadata) -------------------------------------------------------------------------------- -- cgit v1.2.3