diff options
-rw-r--r-- | .ghci | 1 | ||||
-rw-r--r-- | .github/workflows/main.yml | 91 | ||||
-rw-r--r-- | .gitignore | 31 | ||||
-rw-r--r-- | CODE_OF_CONDUCT.md | 45 | ||||
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | README.markdown | 9 | ||||
-rw-r--r-- | lib/Hakyll/Core/Configuration.hs | 20 | ||||
-rw-r--r-- | lib/Hakyll/Core/Identifier.hs | 4 | ||||
-rw-r--r-- | lib/Hakyll/Core/Provider.hs | 16 | ||||
-rw-r--r-- | lib/Hakyll/Core/Provider/Internal.hs | 10 | ||||
-rw-r--r-- | lib/Hakyll/Core/Provider/Metadata.hs | 5 | ||||
-rw-r--r-- | lib/Hakyll/Core/Runtime.hs | 4 | ||||
-rw-r--r-- | lib/Hakyll/Web/Template/Context.hs | 3 | ||||
-rw-r--r-- | logo.svg | 85 | ||||
-rw-r--r-- | stack.yaml | 27 | ||||
-rw-r--r-- | stack.yaml.lock | 12 | ||||
-rw-r--r-- | test.hs | 28 |
17 files changed, 42 insertions, 358 deletions
@@ -1 +0,0 @@ -:set -isrc -itests -idist/build/autogen -DPREVIEW_SERVER diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 86e5b92..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: CI - -# Trigger the workflow on push or pull request, but only for the master branch -on: - pull_request: - push: - branches: [master] - -jobs: - cabal: - name: ${{ matrix.os }} / ghc ${{ matrix.ghc }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] - cabal: ["3.4"] - ghc: - - "8.6.5" - - "8.8.4" - - "8.10.4" - exclude: - - os: macOS-latest - ghc: 8.8.4 - - os: macOS-latest - ghc: 8.6.5 - - os: windows-latest - ghc: 8.8.4 - - 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: haskell/actions/setup@v1 - 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: - 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: haskell/actions/setup@v1 - name: Setup Haskell Stack - with: - ghc-version: ${{ matrix.ghc }} - stack-version: ${{ matrix.stack }} - - - uses: actions/cache@v1 - name: Cache ~/.stack - with: - path: ~/.stack - key: ${{ runner.os }}-${{ matrix.ghc }}-stack - - - name: Build - run: | - stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks - - - name: Test - run: | - stack test --system-ghc diff --git a/.gitignore b/.gitignore deleted file mode 100644 index eab2fac..0000000 --- a/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -# Ignore swap files and stack/cabal output. -*.hi -*.o -*.swo -*.swp -*~ -.DS_Store -TAGS -dist -tags -cabal.sandbox.config -.cabal-sandbox/ -.stack-work -dist -dist-* -.ghc.environment.* - -# Ignore test builds. -tests/Main -_cache -_store -_site - -# Rest of the file: ignore examples -web/_cache -web/_site -web/site -web/reference - -# This is generated from the CHANGELOG -web/releases.markdown diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index b5295fb..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,45 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by [contacting the project team at m@jaspervdj.be](mailto:m@jaspervdj.be). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] - -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ diff --git a/Makefile b/Makefile deleted file mode 100644 index 5c71a12..0000000 --- a/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -PACKAGE="$(shell stack list-dependencies --separator='-' | grep hakyll)" -LOCAL_DOC_ROOT="$(shell stack path --local-doc-root)" - -# Generate the docs and copy them to the website dir -haddock: - stack build --haddock --no-haddock-deps - rsync -r "$(LOCAL_DOC_ROOT)/$(PACKAGE)/" web/reference/ - -.PHONY: haddock diff --git a/README.markdown b/README.markdown index e0a7604..26fbd51 100644 --- a/README.markdown +++ b/README.markdown @@ -1,15 +1,6 @@ # hakyll -![CI](https://github.com/jaspervdj/hakyll/workflows/CI/badge.svg) - Hakyll is a static site generator library in Haskell. More information (including a tutorial) can be found on [the hakyll homepage](http://jaspervdj.be/hakyll). -You can install this library using cabal: - - cabal install hakyll - -Or using stack: - - stack install hakyll diff --git a/lib/Hakyll/Core/Configuration.hs b/lib/Hakyll/Core/Configuration.hs index 52b23ec..4e32caa 100644 --- a/lib/Hakyll/Core/Configuration.hs +++ b/lib/Hakyll/Core/Configuration.hs @@ -8,14 +8,15 @@ module Hakyll.Core.Configuration -------------------------------------------------------------------------------- -import Data.Default (Default (..)) -import Data.List (isPrefixOf, isSuffixOf) -import System.Directory (canonicalizePath) -import System.Exit (ExitCode) -import System.FilePath (isAbsolute, normalise, takeFileName) -import System.IO.Error (catchIOError) -import System.Process (system) +import Data.Default (Default (..)) +import Data.List (isPrefixOf, isSuffixOf) +import System.Directory (canonicalizePath) +import System.Exit (ExitCode) +import System.FilePath (isAbsolute, normalise, takeFileName) +import System.IO.Error (catchIOError) +import System.Process (system) +import Hakyll.Core.Metadata -------------------------------------------------------------------------------- data Configuration = Configuration @@ -78,6 +79,10 @@ data Configuration = Configuration -- One can also override the port as a command line argument: -- ./site preview -p 1234 previewPort :: Int + , -- | Function to extract metadata from the files + -- + -- By default it returns empty metadata + provideMetadata :: FilePath -> IO Metadata } -------------------------------------------------------------------------------- @@ -98,6 +103,7 @@ defaultConfiguration = Configuration , inMemoryCache = True , previewHost = "127.0.0.1" , previewPort = 8000 + , provideMetadata = const (return mempty) } where ignoreFile' path diff --git a/lib/Hakyll/Core/Identifier.hs b/lib/Hakyll/Core/Identifier.hs index e9dced2..e5b3656 100644 --- a/lib/Hakyll/Core/Identifier.hs +++ b/lib/Hakyll/Core/Identifier.hs @@ -20,9 +20,7 @@ module Hakyll.Core.Identifier -------------------------------------------------------------------------------- import Control.DeepSeq (NFData (..)) -import Data.List (intercalate) -import System.FilePath (dropTrailingPathSeparator, splitPath, - pathSeparator, normalise) +import System.FilePath (normalise) -------------------------------------------------------------------------------- diff --git a/lib/Hakyll/Core/Provider.hs b/lib/Hakyll/Core/Provider.hs index 384f5b1..65e1507 100644 --- a/lib/Hakyll/Core/Provider.hs +++ b/lib/Hakyll/Core/Provider.hs @@ -5,6 +5,7 @@ module Hakyll.Core.Provider ( -- * Constructing resource providers Internal.Provider , newProvider + , newProvider' -- * Querying resource properties , Internal.resourceList @@ -24,20 +25,29 @@ module Hakyll.Core.Provider -------------------------------------------------------------------------------- +import Hakyll.Core.Metadata import qualified Hakyll.Core.Provider.Internal as Internal import qualified Hakyll.Core.Provider.MetadataCache as Internal import Hakyll.Core.Store (Store) -------------------------------------------------------------------------------- --- | Create a resource provider +-- | Create a resource provider with the void metadata provider newProvider :: Store -- ^ Store to use -> (FilePath -> IO Bool) -- ^ Should we ignore this file? -> FilePath -- ^ Search directory -> IO Internal.Provider -- ^ Resulting provider -newProvider store ignore directory = do +newProvider store ignore = newProvider' store ignore (const $ return mempty) + +-- | Create a resource provider +newProvider' :: Store -- ^ Store to use + -> (FilePath -> IO Bool) -- ^ Should we ignore this file? + -> (FilePath -> IO Metadata) -- ^ Metadata provider + -> FilePath -- ^ Search directory + -> IO Internal.Provider -- ^ Resulting provider +newProvider' store ignore metadata directory = do -- Delete metadata cache where necessary - p <- Internal.newProvider store ignore directory + p <- Internal.newProvider store ignore metadata directory mapM_ (Internal.resourceInvalidateMetadataCache p) $ filter (Internal.resourceModified p) $ Internal.resourceList p return p diff --git a/lib/Hakyll/Core/Provider/Internal.hs b/lib/Hakyll/Core/Provider/Internal.hs index c298653..777decb 100644 --- a/lib/Hakyll/Core/Provider/Internal.hs +++ b/lib/Hakyll/Core/Provider/Internal.hs @@ -45,6 +45,7 @@ import System.Time (formatCalendarTime, toCalendarTime) -------------------------------------------------------------------------------- import Hakyll.Core.Identifier +import Hakyll.Core.Metadata import Hakyll.Core.Store (Store) import qualified Hakyll.Core.Store as Store import Hakyll.Core.Util.File @@ -95,16 +96,19 @@ data Provider = Provider providerOldFiles :: Map Identifier ResourceInfo , -- | Underlying persistent store for caching providerStore :: Store - } deriving (Show) + -- | A custom function to extract metadata from files + , providerMetadata :: FilePath -> IO Metadata + } -------------------------------------------------------------------------------- -- | Create a resource provider newProvider :: Store -- ^ Store to use -> (FilePath -> IO Bool) -- ^ Should we ignore this file? + -> (FilePath -> IO Metadata) -- ^ Metadata provider -> FilePath -- ^ Search directory -> IO Provider -- ^ Resulting provider -newProvider store ignore directory = do +newProvider store ignore metadata directory = do list <- map fromFilePath <$> getRecursiveContents ignore directory let universe = S.fromList list files <- fmap (maxmtime . M.fromList) $ forM list $ \identifier -> do @@ -116,7 +120,7 @@ newProvider store ignore directory = do oldFiles <- fromMaybe mempty . Store.toMaybe <$> Store.get store oldKey oldFiles `deepseq` Store.set store oldKey files - return $ Provider directory files oldFiles store + return $ Provider directory files oldFiles store metadata where oldKey = ["Hakyll.Core.Provider.Internal.newProvider", "oldFiles"] diff --git a/lib/Hakyll/Core/Provider/Metadata.hs b/lib/Hakyll/Core/Provider/Metadata.hs index c74627b..1630b0c 100644 --- a/lib/Hakyll/Core/Provider/Metadata.hs +++ b/lib/Hakyll/Core/Provider/Metadata.hs @@ -27,7 +27,7 @@ import Hakyll.Core.Identifier import Hakyll.Core.Metadata import Hakyll.Core.Provider.Internal import System.IO as IO -import System.IO.Error (modifyIOError, ioeSetLocation) +import System.IO.Error (ioeSetLocation, modifyIOError) -------------------------------------------------------------------------------- @@ -42,7 +42,8 @@ loadMetadata p identifier = do Nothing -> return mempty Just mi' -> loadMetadataFile $ resourceFilePath p mi' - return (md <> emd, body) + mdp <- providerMetadata p fp + return (md <> emd <> mdp, body) where normal = setVersion Nothing identifier fp = resourceFilePath p identifier diff --git a/lib/Hakyll/Core/Runtime.hs b/lib/Hakyll/Core/Runtime.hs index e0edf5b..cc15b3e 100644 --- a/lib/Hakyll/Core/Runtime.hs +++ b/lib/Hakyll/Core/Runtime.hs @@ -52,8 +52,8 @@ run config logger rules = do Logger.message logger "Creating store..." store <- Store.new (inMemoryCache config) $ storeDirectory config Logger.message logger "Creating provider..." - provider <- newProvider store (shouldIgnoreFile config) $ - providerDirectory config + provider <- newProvider' store (shouldIgnoreFile config) (provideMetadata config) + (providerDirectory config) Logger.message logger "Running rules..." ruleSet <- runRules rules provider diff --git a/lib/Hakyll/Web/Template/Context.hs b/lib/Hakyll/Web/Template/Context.hs index 9ce7440..97f0930 100644 --- a/lib/Hakyll/Web/Template/Context.hs +++ b/lib/Hakyll/Web/Template/Context.hs @@ -326,6 +326,8 @@ titleField = mapContext takeBaseName . pathField -- -- * @2010-09-06@ -- +-- * @06.09.2010@ +-- -- * @September 06, 2010@ -- -- Alternatively, when the metadata has a field called @path@ in a @@ -394,6 +396,7 @@ getItemUTC locale id' = do , "%B %e, %Y %l:%M %p" , "%B %e, %Y" , "%b %d, %Y" + , "%d.%m.%Y" ] diff --git a/logo.svg b/logo.svg deleted file mode 100644 index 0408c38..0000000 --- a/logo.svg +++ /dev/null @@ -1,85 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> - -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="221.42857" - height="221.42857" - id="svg2" - version="1.1" - inkscape:version="0.47 r22583" - sodipodi:docname="logo.svg" - inkscape:export-filename="/home/jasper/Documents/ZuriHac/logo.png" - inkscape:export-xdpi="81.290001" - inkscape:export-ydpi="81.290001"> - <defs - id="defs4"> - <inkscape:perspective - sodipodi:type="inkscape:persp3d" - inkscape:vp_x="0 : 526.18109 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_z="744.09448 : 526.18109 : 1" - inkscape:persp3d-origin="372.04724 : 350.78739 : 1" - id="perspective10" /> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="3.4096774" - inkscape:cx="110.71429" - inkscape:cy="110.71429" - inkscape:document-units="px" - inkscape:current-layer="layer1" - showgrid="false" - inkscape:window-width="1262" - inkscape:window-height="1006" - inkscape:window-x="1287" - inkscape:window-y="7" - inkscape:window-maximized="0" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title></dc:title> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1" - transform="translate(-7.8571436,-9.5050393)"> - <path - sodipodi:type="arc" - style="fill:#000000;fill-opacity:1;stroke:none" - id="path2820" - sodipodi:cx="52.5" - sodipodi:cy="54.147896" - sodipodi:rx="44.642857" - sodipodi:ry="44.642857" - d="m 97.142857,54.147896 c 0,24.655569 -19.987288,44.642856 -44.642857,44.642856 -24.655569,0 -44.6428566,-19.987287 -44.6428566,-44.642856 0,-24.655569 19.9872876,-44.6428568 44.6428566,-44.6428568 24.655569,0 44.642857,19.9872878 44.642857,44.6428568 z" - transform="matrix(2.304,0,0,2.304,-2.3885719,-4.5374282)" /> - <g - style="font-size:211.77316284px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Times New Roman;-inkscape-font-specification:'Times New Roman,'" - id="text2816"> - <path - d="m 171.48526,157.26037 3.72258,0 c -1e-4,10.892 -1.79245,18.8197 -5.37705,23.78312 -3.51586,4.96343 -7.9278,7.44515 -13.23583,7.44515 -4.34308,0 -8.51374,-1.62001 -12.51199,-4.86003 -3.99839,-3.30895 -7.58308,-12.09835 -10.7541,-26.36824 l -8.89282,-40.12109 -30.814649,69.90169 -19.54352,0 44.257279,-95.339285 c -2.34388,-12.33954 -5.17028,-21.473627 -8.4792,-27.40229 -3.30899,-5.928416 -7.41071,-8.892686 -12.305174,-8.892818 -3.929407,1.32e-4 -7.376233,1.516735 -10.340487,4.549814 -2.895349,2.964397 -4.515357,7.583143 -4.860029,13.856252 l -3.722575,0 C 78.834498,63.67909 80.868125,55.57905 84.728582,49.5125 c 3.860432,-6.135212 8.685987,-9.202886 14.476681,-9.203033 3.722547,1.47e-4 7.238307,1.551218 10.547297,4.653219 3.37785,3.033348 6.27318,8.272523 8.68601,15.717539 2.48167,7.376333 6.30764,22.714706 11.47794,46.015165 l 7.34174,32.77934 c 2.96421,13.58054 6.06635,22.68016 9.30644,27.29889 3.30888,4.54983 7.23826,6.82473 11.78816,6.82472 7.7208,1e-5 12.09827,-5.44597 13.13241,-16.33797" - style="" - id="path2844" /> - </g> - </g> -</svg> diff --git a/stack.yaml b/stack.yaml deleted file mode 100644 index ec28861..0000000 --- a/stack.yaml +++ /dev/null @@ -1,27 +0,0 @@ -resolver: lts-17.5 -save-hackage-creds: false -system-ghc: true -skip-ghc-check: true - -flags: - hakyll: - previewServer: true - watchServer: true - checkExternal: true - usePandoc: true - buildWebsite: true - -packages: - - '.' - -nix: - enable: false - packages: - - zlib - -build: - haddock: true - haddock-hyperlink-source: true - haddock-deps: false - -extra-deps: diff --git a/stack.yaml.lock b/stack.yaml.lock deleted file mode 100644 index fa953b3..0000000 --- a/stack.yaml.lock +++ /dev/null @@ -1,12 +0,0 @@ -# This file was autogenerated by Stack. -# You should not edit this file by hand. -# For more information, please see the documentation at: -# https://docs.haskellstack.org/en/stable/lock_files - -packages: [] -snapshots: -- completed: - size: 565266 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/17/5.yaml - sha256: 78e8ebabf11406261abbc95b44f240acf71802630b368888f6d758de7fc3a2f7 - original: lts-17.5 diff --git a/test.hs b/test.hs deleted file mode 100644 index aea447c..0000000 --- a/test.hs +++ /dev/null @@ -1,28 +0,0 @@ -{-# LANGUAGE BangPatterns #-} -import Control.Monad (forM) -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 -import System.FilePath ((</>)) - -type FileHashes = Map Identifier String - -mkFileHashes :: FilePath -> IO FileHashes -mkFileHashes dir = do - allFiles <- getRecursiveContents (\_ -> return False) dir - fmap Map.fromList $ forM allFiles $ \path0 -> do - let path1 = dir </> path0 - !h <- hash path1 - return (fromFilePath path1, h) - where - hash :: FilePath -> IO String - hash fp = (show . DH.hash) <$> BSL.readFile fp - -main :: IO () -main = hakyll $ do - fileHashes <- preprocess (mkFileHashes "images") - undefined |