summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2015-03-29 05:01:39 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2015-03-29 05:01:39 +0200
commit39d63c72c63a3e1ac35ba5b05e4cbf054970ec20 (patch)
tree9e98303bcc9a0b9c687b96cd15500891e540591f /build
parentd6077616e02dc6d6ce68df643c8bdcc2569124e9 (diff)
downloaddirty-haskell.org-39d63c72c63a3e1ac35ba5b05e4cbf054970ec20.tar
dirty-haskell.org-39d63c72c63a3e1ac35ba5b05e4cbf054970ec20.tar.gz
dirty-haskell.org-39d63c72c63a3e1ac35ba5b05e4cbf054970ec20.tar.bz2
dirty-haskell.org-39d63c72c63a3e1ac35ba5b05e4cbf054970ec20.tar.xz
dirty-haskell.org-39d63c72c63a3e1ac35ba5b05e4cbf054970ec20.zip
Some cleanup and working url generation
Diffstat (limited to 'build')
-rwxr-xr-xbuild/generate-rss.hs11
1 files changed, 5 insertions, 6 deletions
diff --git a/build/generate-rss.hs b/build/generate-rss.hs
index b892424..f6ecfa6 100755
--- a/build/generate-rss.hs
+++ b/build/generate-rss.hs
@@ -46,7 +46,7 @@ main = do
46addItem' :: FilePath -> S.StateT FeedState IO () 46addItem' :: FilePath -> S.StateT FeedState IO ()
47addItem' mdFile = do 47addItem' mdFile = do
48 url <- S.liftIO $ mkUrl mdFile 48 url <- S.liftIO $ mkUrl mdFile
49 fileStatus <- S.liftIO $ F.getFileStatus mdFile 49 fileStatus <- S.liftIO $ F.getSymbolicLinkStatus mdFile
50 fileContents <- S.liftIO $ readFile mdFile 50 fileContents <- S.liftIO $ readFile mdFile
51 let title = extract_title $ document 51 let title = extract_title $ document
52 contents = writeAsciiDoc def document 52 contents = writeAsciiDoc def document
@@ -63,15 +63,14 @@ addItem' mdFile = do
63 63
64mkUrl :: FilePath -> IO String 64mkUrl :: FilePath -> IO String
65mkUrl link = do 65mkUrl link = do
66 status <- F.getFileStatus link 66 status <- F.getSymbolicLinkStatus link
67 if F.isSymbolicLink status then 67 if F.isSymbolicLink status then
68 F.readSymbolicLink link >>= mkUrl 68 do target <- F.readSymbolicLink link
69 mkUrl $ FP.combine (FP.takeDirectory link) target
69 else 70 else
70 return $ mkUrl' link 71 return $ mkUrl' link
71mkUrl' :: FilePath -> String 72mkUrl' :: FilePath -> String
72mkUrl' path = (++) "http://dirty-haskell.org/posts/" $ switchExt ".md" ".html" $ FP.takeFileName path 73mkUrl' path = (++) "http://dirty-haskell.org/posts/" $ (flip FP.replaceExtension) "html" $ FP.takeFileName path
73
74switchExt prev after str = if ('.':prev) `isSuffixOf` str then (dropWhileEnd (/= '.') str) ++ after else str
75 74
76(<->) :: [(a -> b)] -> a -> [b] 75(<->) :: [(a -> b)] -> a -> [b]
77[] <-> _ = [] 76[] <-> _ = []