Paste server written in Haskell. Fork of Hpaste, fully freedom and privacy respecting and generally improved. At the time of writing there's an instance at <http://paste.rel4tion.org>.
Clone
HTTPS:
git clone https://vervis.peers.community/repos/aoqmo
SSH:
git clone USERNAME@vervis.peers.community:aoqmo
Branches
Tags
Activity.hs
{-# OPTIONS -Wall #-}
{-# LANGUAGE OverloadedStrings #-}
-- | Activity model.
module Hpaste.Model.Activity
(getCommits)
where
import Hpaste.Types
import Control.Monad.IO (io)
import Data.Maybe (mapMaybe)
import Data.Text.Lazy (pack)
import Data.Time
import Network.Curl.Download
import Snap.App.Types
import System.Locale
import Text.Feed.Query
-- | Get commits of this project from a commit feed.
getCommits :: String -> Model c s [Commit]
getCommits uri = io $ do
result <- openAsFeed uri
case result of
Left _ -> return []
Right feed -> return $
let items = getFeedItems feed
in mapMaybe makeCommit items
where makeCommit item = do
title <- getItemTitle item
datestr <- getItemDate item
date <- parseDateString datestr
link <- getItemLink item
return $ Commit {
commitTitle = pack $ title
, commitContent = "" -- Getting content from atom does not work.
, commitDate = date
, commitLink = pack link
}
-- E.g. 2011-06-11T11:15:11-07:00
parseDateString = parseTime defaultTimeLocale "%Y-%M-%dT%T%Z"
|