From b2bb90beff55d1aae2026f66840e6331734512d8 Mon Sep 17 00:00:00 2001 From: "\"Vincent Ambo ext:(%22)" Date: Wed, 7 Mar 2012 13:40:47 +0100 Subject: * comment adding fixed * JSON Encoding is broken in the current Hackage version of CouchDB, thus it is necessary to build it manually and to apply this fix: https://github.com/tbh/haskell-couchdb/commit/fafd63a43607ab8d6306fa46a264f93d4921a26c --- src/Blog.hs | 6 +++++- src/Main.hs | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Blog.hs b/src/Blog.hs index 201851cba01d..0b32b7b30bd6 100644 --- a/src/Blog.hs +++ b/src/Blog.hs @@ -14,7 +14,6 @@ import Text.Blaze.Html5 (Html, (!), a, form, input, p, toHtml, label) import Text.Blaze.Html5.Attributes (action, enctype, href, name, size, type_, value) import qualified Text.Blaze.Html5 as H import qualified Text.Blaze.Html5.Attributes as A -import System.Locale (defaultTimeLocale) import Locales @@ -40,9 +39,14 @@ data Entry = Entry{ blogText :: (a -> String) -> a -> Text blogText f = T.pack . f + +-- custom list functions intersperse' :: a -> [a] -> [a] intersperse' sep l = sep : intersperse sep l +replace :: Eq a => a -> a -> [a] -> [a] +replace x y = map (\z -> if z == x then y else z) + blogTemplate :: BlogLang -> Text -> Html -> Html blogTemplate lang t_append body = H.docTypeHtml $ do --add body H.head $ do diff --git a/src/Main.hs b/src/Main.hs index 769e2180a3aa..d84e1d5332d0 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -40,6 +40,7 @@ tazBlog = do , do dir " " $ nullDir seeOther ("https://plus.google.com/115916629925754851590" :: String) (toResponse ()) , path $ \(id_ :: Int) -> getEntryLink id_ + , path $ \(year :: Int) -> path $ \(month :: Int) -> path $ \(id_ :: String) -> formatOldLink year month id_ , dir "res" $ serveDirectory DisableBrowsing [] "../res" , dir "notice" $ ok $ toResponse showSiteNotice , serveDirectory DisableBrowsing [] "../res" @@ -57,6 +58,11 @@ blogHandler lang = showIndex lang ] +formatOldLink :: Int -> Int -> String -> ServerPart Response +formatOldLink y m id_ = + flip seeOther (toResponse ()) $ + concat $ intersperse' "/" ["de", show y, show m, replace '.' '/' id_] + showEntry :: BlogLang -> String -> ServerPart Response showEntry lang id_ = do entryJS <- liftIO $ runCouchDB' $ getDoc (db "tazblog") (doc id_) -- cgit 1.4.1