diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2015-11-06 02:12:44 +0000 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2015-11-06 02:12:44 +0000 |
commit | f0e10a9ea21f351f2617b23f2e615f8d82f089bd (patch) | |
tree | ebe24c3b87fb3cb4dde3ea5887ba40516042b9e9 | |
parent | 6294d6107ba6462bdf4a9b302b7bdd1ff7a69c15 (diff) | |
download | dirty-haskell.org-f0e10a9ea21f351f2617b23f2e615f8d82f089bd.tar dirty-haskell.org-f0e10a9ea21f351f2617b23f2e615f8d82f089bd.tar.gz dirty-haskell.org-f0e10a9ea21f351f2617b23f2e615f8d82f089bd.tar.bz2 dirty-haskell.org-f0e10a9ea21f351f2617b23f2e615f8d82f089bd.tar.xz dirty-haskell.org-f0e10a9ea21f351f2617b23f2e615f8d82f089bd.zip |
hashing for math filenames
-rw-r--r-- | blog.cabal | 3 | ||||
-rw-r--r-- | blog.nix | 4 | ||||
-rw-r--r-- | src/Site.hs | 6 |
3 files changed, 10 insertions, 3 deletions
@@ -27,3 +27,6 @@ executable site | |||
27 | , pandoc-types >=1.12 && <2 | 27 | , pandoc-types >=1.12 && <2 |
28 | , data-default >=0.5 && <0.6 | 28 | , data-default >=0.5 && <0.6 |
29 | , filepath >=1.3 && <2 | 29 | , filepath >=1.3 && <2 |
30 | , bytestring >=0.10 && <1 | ||
31 | , cryptohash >=0.11 && <1 | ||
32 | , hex >=0.1 && <1 | ||
@@ -1,7 +1,7 @@ | |||
1 | # This file was auto-generated by cabal2nix. Please do NOT edit manually! | 1 | # This file was auto-generated by cabal2nix. Please do NOT edit manually! |
2 | 2 | ||
3 | { mkDerivation, stdenv | 3 | { mkDerivation, stdenv |
4 | , hakyll, containers, pandoc, data-default, filepath | 4 | , hakyll, containers, pandoc, data-default, filepath, hex, cryptohash |
5 | }: | 5 | }: |
6 | 6 | ||
7 | mkDerivation { | 7 | mkDerivation { |
@@ -11,7 +11,7 @@ mkDerivation { | |||
11 | isExecutable = true; | 11 | isExecutable = true; |
12 | isLibrary = false; | 12 | isLibrary = false; |
13 | buildDepends = [ | 13 | buildDepends = [ |
14 | hakyll containers pandoc data-default filepath | 14 | hakyll containers pandoc data-default filepath hex cryptohash |
15 | ]; | 15 | ]; |
16 | license = stdenv.lib.licenses.publicDomain; | 16 | license = stdenv.lib.licenses.publicDomain; |
17 | } | 17 | } |
diff --git a/src/Site.hs b/src/Site.hs index 279532f..1bda7ec 100644 --- a/src/Site.hs +++ b/src/Site.hs | |||
@@ -17,6 +17,10 @@ import Text.Pandoc.Walk (query) | |||
17 | import Text.Pandoc.Error | 17 | import Text.Pandoc.Error |
18 | import Control.Applicative (Alternative(..), Applicative(..)) | 18 | import Control.Applicative (Alternative(..), Applicative(..)) |
19 | 19 | ||
20 | import qualified Crypto.Hash.SHA256 as SHA256 (hash) | ||
21 | import qualified Data.ByteString.Char8 as CBS | ||
22 | import Data.Hex | ||
23 | |||
20 | import System.FilePath (takeBaseName, (</>), (<.>)) | 24 | import System.FilePath (takeBaseName, (</>), (<.>)) |
21 | 25 | ||
22 | main :: IO () | 26 | main :: IO () |
@@ -135,7 +139,7 @@ tagTranslation = mapMaybe charTrans | |||
135 | | otherwise = Nothing | 139 | | otherwise = Nothing |
136 | 140 | ||
137 | mathTranslation' :: String -> Identifier | 141 | mathTranslation' :: String -> Identifier |
138 | mathTranslation' = fromCapture "math/*.svg" . id -- TODO hash math | 142 | mathTranslation' = fromCapture "math/*.svg" . CBS.unpack . hex . SHA256.hash . CBS.pack |
139 | 143 | ||
140 | addTag :: MonadMetadata m => String -> Pattern -> Tags -> m Tags | 144 | addTag :: MonadMetadata m => String -> Pattern -> Tags -> m Tags |
141 | addTag name pattern tags = do | 145 | addTag name pattern tags = do |