From 39d63c72c63a3e1ac35ba5b05e4cbf054970ec20 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 29 Mar 2015 05:01:39 +0200 Subject: Some cleanup and working url generation --- build/generate-rss.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'build') 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 addItem' :: FilePath -> S.StateT FeedState IO () addItem' mdFile = do url <- S.liftIO $ mkUrl mdFile - fileStatus <- S.liftIO $ F.getFileStatus mdFile + fileStatus <- S.liftIO $ F.getSymbolicLinkStatus mdFile fileContents <- S.liftIO $ readFile mdFile let title = extract_title $ document contents = writeAsciiDoc def document @@ -63,15 +63,14 @@ addItem' mdFile = do mkUrl :: FilePath -> IO String mkUrl link = do - status <- F.getFileStatus link + status <- F.getSymbolicLinkStatus link if F.isSymbolicLink status then - F.readSymbolicLink link >>= mkUrl + do target <- F.readSymbolicLink link + mkUrl $ FP.combine (FP.takeDirectory link) target else return $ mkUrl' link mkUrl' :: FilePath -> String -mkUrl' path = (++) "http://dirty-haskell.org/posts/" $ switchExt ".md" ".html" $ FP.takeFileName path - -switchExt prev after str = if ('.':prev) `isSuffixOf` str then (dropWhileEnd (/= '.') str) ++ after else str +mkUrl' path = (++) "http://dirty-haskell.org/posts/" $ (flip FP.replaceExtension) "html" $ FP.takeFileName path (<->) :: [(a -> b)] -> a -> [b] [] <-> _ = [] -- cgit v1.2.3