From 18b1d5ebb9a903bc40325ac82c7df2b643301908 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Sat, 2 Mar 2024 13:37:06 +0100 Subject: add atom feed --- app/Main.hs | 110 +++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 86 insertions(+), 24 deletions(-) (limited to 'app/Main.hs') diff --git a/app/Main.hs b/app/Main.hs index 6462846..4e9b373 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BlockArguments #-} +{-# LANGUAGE MultiWayIf #-} {-# LANGUAGE OverlappingInstances #-} {-# LANGUAGE OverloadedRecordDot #-} {-# LANGUAGE OverloadedStrings #-} @@ -8,6 +9,7 @@ module Main where +import Conduit import Control.Arrow hiding (app) import Control.Concurrent import Control.Exception @@ -30,11 +32,14 @@ import Network.Wai.Handler.Warp import System.Environment import System.FilePath import System.IO.Unsafe +import Text.Atom.Conduit.Render +import Text.Atom.Types import Text.Blaze import Text.Blaze.Html.Renderer.Utf8 import Text.Cassius import Text.Hamlet import Text.Printf +import Text.XML.Stream.Render env_REPOSITORIES :: [String] env_REPOSITORIES = @@ -57,30 +62,87 @@ main = do app app :: Application -app _ resp = do - resp . responseStream status200 [] $ \write _ -> do - commits <- - reverse . sortOn (.createdAt) - <$> getCommitsConcurrently env_REPOSITORIES - let commitsPerDay = - (map (\xs -> (utctDay . (.createdAt) $ head xs, xs))) $ - groupBy ((==) `on` (utctDay . (.createdAt))) commits - write $ - renderHtmlBuilder - [shamlet| - - - - feed.nomath.org - - - -