diff options
author | Vincent Ambo <tazjin@google.com> | 2020-02-09T00·43+0000 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-02-09T00·43+0000 |
commit | 05ab6825b3451687fbaf6f8c987e94e616b6d4ff (patch) | |
tree | d1e8ad284bc89f6f6eb6156121151465fa3e3672 /web/tazblog/src/Server.hs | |
parent | 9fc9b58301b3e0c538ffb8b7e4e7a7dab9fbc243 (diff) |
chore(web): Delete //web/tazblog r/499
Deleting this code feels strange. This project has been around for a decade, and despite occasionally needing a bunch of tweaks it had aged well and worked fine for a very long time. I've reached a strange point where I don't really feel like using Haskell anymore, and every interaction with this project in recent years has been fighting dependency management tooling for Haskell, or dealing with strange build problems. The simple fact is that the service never really did anything other than render Markdown dynamically, and at this point I can do that much better with //tools/cheddar instead. So, tazblog-hs, it's time to say goodbye. Rest in peace!
Diffstat (limited to 'web/tazblog/src/Server.hs')
-rw-r--r-- | web/tazblog/src/Server.hs | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/web/tazblog/src/Server.hs b/web/tazblog/src/Server.hs deleted file mode 100644 index 40129988393b..000000000000 --- a/web/tazblog/src/Server.hs +++ /dev/null @@ -1,81 +0,0 @@ -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE ScopedTypeVariables #-} - -module Server where - -import Blog -import BlogStore -import Control.Applicative (optional) -import Control.Monad (msum) -import Control.Monad.IO.Class (liftIO) -import Data.Maybe (maybe) -import qualified Data.Text as T -import Happstack.Server hiding (Session) -import RSS - -pageSize :: Int -pageSize = 3 - -tmpPolicy :: BodyPolicy -tmpPolicy = defaultBodyPolicy "/tmp" 0 200000 1000 - -runBlog :: Int -> String -> IO () -runBlog port respath = - withCache "blog.tazj.in." $ \cache -> - simpleHTTP nullConf {port = port} $ tazblog cache respath - -tazblog :: BlogCache -> String -> ServerPart Response -tazblog cache resDir = - msum - [ -- legacy language-specific routes - dir "de" $ blogHandler cache, - dir "en" $ blogHandler cache, - dir "static" $ staticHandler resDir, - blogHandler cache, - staticHandler resDir, - notFound $ toResponse $ showError "Not found" "Page not found" - ] - -blogHandler :: BlogCache -> ServerPart Response -blogHandler cache = - msum - [ path $ \(eId :: Integer) -> showEntry cache $ EntryId eId, - nullDir >> showIndex cache, - dir "rss" $ nullDir >> showRSS cache, - dir "rss.xml" $ nullDir >> showRSS cache - ] - -staticHandler :: String -> ServerPart Response -staticHandler resDir = do - setHeaderM "cache-control" "max-age=630720000" - setHeaderM "expires" "Tue, 20 Jan 2037 04:20:42 GMT" - serveDirectory DisableBrowsing [] resDir - -showEntry :: BlogCache -> EntryId -> ServerPart Response -showEntry cache eId = do - entry <- getEntry cache eId - tryEntry entry - -tryEntry :: Maybe Entry -> ServerPart Response -tryEntry Nothing = notFound $ toResponse $ showError "Not found" "Blog entry not found" -tryEntry (Just entry) = ok $ toResponse $ blogTemplate eTitle $ renderEntry entry - where - eTitle = T.append ": " (title entry) - -offset :: Maybe Int -> Int -offset = maybe 0 (pageSize *) - -showIndex :: BlogCache -> ServerPart Response -showIndex cache = do - (page :: Maybe Int) <- optional $ lookRead "page" - entries <- listEntries cache (offset page) pageSize - ok $ toResponse $ blogTemplate "" - $ renderEntries entries (Just $ showLinks page) - -showRSS :: BlogCache -> ServerPart Response -showRSS cache = do - entries <- listEntries cache 0 4 - feed <- liftIO $ renderFeed entries - setHeaderM "content-type" "text/xml" - ok $ toResponse feed |