rss2irc 1.1 → 1.2
raw patch · 6 files changed
+29/−23 lines, 6 filesdep ~feeddep ~http-clientdep ~http-conduit
Dependency ranges changed: feed, http-client, http-conduit, resourcet, time
Files
- Base.hs +1/−1
- CHANGES +4/−0
- Feed.hs +11/−10
- Utils.hs +6/−5
- rss2irc.cabal +6/−6
- stack.yaml +1/−1
Base.hs view
@@ -27,7 +27,7 @@ progname = "rss2irc"-version = "1.1" -- sync with rss2irc.cabal+version = "1.2" -- sync with rss2irc.cabal progversion = progname ++ " " ++ version :: String defport = 6667 defusername = progname
CHANGES view
@@ -1,3 +1,7 @@+1.2 (2018/06/29)++* build with latest stackage LTS, feed 1.0.0.0 (#4)+ 1.1 (2016/11/1) * update for GHC 8, stackage lts-7
Feed.hs view
@@ -19,6 +19,7 @@ import qualified Data.ByteString.Lazy.Char8 as LB8 import Data.Maybe import Data.List+import qualified Data.Text as T import System.IO.Storage import Network.HTTP.Conduit import Network.HTTP.Types (hCacheControl, hUserAgent)@@ -96,8 +97,8 @@ writeList2Chan q $ map (toAnnouncement opts) $ reverse announceable when (debug_feed opts) $ logPoll fetched announceable polls numannounced -- start iterating- let seen = map (\i -> (itemId i, fromMaybe "" $ getItemTitle i)) fetched- lastpubdate = maybe Nothing getItemPublishDateString $ headMay unique+ let seen = map (\i -> (itemId i, fromMaybe "" $ T.unpack <$> getItemTitle i)) fetched+ lastpubdate = maybe Nothing (fmap T.unpack . getItemPublishDateString) $ headMay unique putSharedVar appvar $ maybeDecrementIterationsLeft app feedReaderPoll appvar polls seen lastpubdate numannounced @@ -114,7 +115,7 @@ -- detect announceable items let seenids = map fst seen hasunseenid = (`notElem` seenids).itemId- hasnewerdate = (`isNewerThan` lastpubdate).getItemPublishDateString+ hasnewerdate = (`isNewerThan` lastpubdate).fmap T.unpack.getItemPublishDateString isunseenandnewer i = hasnewerdate i && hasunseenid i isprevioustop = (== head seenids).itemId announceable = (if allow_duplicates opts then id else (elideDuplicates seen)) $@@ -125,9 +126,9 @@ -- send to announcer thread and iterate writeList2Chan q $ map (toAnnouncement opts) announceable let polls' = polls + 1- seen' = take windowsize $ (map (\i -> (itemId i, fromMaybe "" $ getItemTitle i)) fetched)+ seen' = take windowsize $ (map (\i -> (itemId i, fromMaybe "" $ T.unpack <$> getItemTitle i)) fetched) ++ seen where windowsize = 200- lastpubdate' = maybe lastpubdate getItemPublishDateString $ headMay announceable+ lastpubdate' = maybe lastpubdate (fmap T.unpack.getItemPublishDateString) $ headMay announceable numannounced' = numannounced + fromIntegral (length announceable) putSharedVar appvar $ maybeDecrementIterationsLeft app when (debug_feed opts) $ logPoll fetched announceable polls' numannounced'@@ -234,7 +235,7 @@ -- announcing on irc. elideDuplicates :: [(String,String)] -> [Item] -> [Item] elideDuplicates seen new =- filter (\a -> not $ fromMaybe "" (getItemTitle a) `elem` seentitles) $+ filter (\a -> not $ fromMaybe "" (T.unpack <$> getItemTitle a) `elem` seentitles) $ nubBy (\a b -> getItemTitle a == getItemTitle b) new where@@ -243,11 +244,11 @@ -- | Get the best available unique identifier for a feed item. itemId :: Item -> String itemId i = case getItemId i of - Just (_,s) -> s+ Just (_,t) -> T.unpack t Nothing -> case getItemTitle i of- Just s -> s+ Just t -> T.unpack t Nothing -> case getItemDate i of- Just s -> s+ Just t -> T.unpack t Nothing -> show i -- | Dump item details to the console for debugging.@@ -255,7 +256,7 @@ printItemDetails hdr is = printf "%s: %d\n%s" hdr count items >> hFlush stdout where items = unlines [printf " %-29s%s %-*s" d p twidth t | (d,p,t,_) <- fields]- twidth = maximum $ map (length.fromMaybe "".getItemTitle) is+ twidth = maximum $ map (length.fromMaybe "".fmap T.unpack.getItemTitle) is -- subhdr = "(date, (publish date if different), title)\n" -- subhdr' = if null is then "" else subhdr count = length is
Utils.hs view
@@ -18,6 +18,7 @@ import Control.Monad import Data.List import Data.Maybe+import qualified Data.Text as T import Data.Time.Clock (UTCTime,getCurrentTime) import Data.Time.Format (parseTimeM) import Data.Time.LocalTime (LocalTime,getCurrentTimeZone,utcToLocalTime)@@ -118,11 +119,11 @@ toAnnouncement:: Opts -> Item -> String toAnnouncement opts i = applyReplacements opts $ printf "%s%s%s%s%s" title desc author' date link' where- title = unlessopt no_title $ maybe "" (truncateWordsAt maxtitlelength "..." . clean) (getItemTitle i)- desc = ifopt description $ maybe "" ((" - "++) . truncateWordsAt maxdesclength "..." . clean) (getItemDescription i)- author' = ifopt author $ maybe "" ((" "++) . parenthesise . truncateWordsAt maxauthorlength "..." . clean) (getItemAuthor i)- date = ifopt time $ maybe "" ((" "++) . truncateAt maxdatelength "..." . clean) (getItemDate i)- link' = ifopt link_ $ maybe "" ((" "++) . truncateAt maxlinklength "..." . clean) (getItemLink i)+ title = unlessopt no_title $ maybe "" (truncateWordsAt maxtitlelength "..." . clean) (T.unpack <$> getItemTitle i)+ desc = ifopt description $ maybe "" ((" - "++) . truncateWordsAt maxdesclength "..." . clean) (T.unpack <$> getItemDescription i)+ author' = ifopt author $ maybe "" ((" "++) . parenthesise . truncateWordsAt maxauthorlength "..." . clean) (T.unpack <$> getItemAuthor i)+ date = ifopt time $ maybe "" ((" "++) . truncateAt maxdatelength "..." . clean) (T.unpack <$> getItemDate i)+ link' = ifopt link_ $ maybe "" ((" "++) . truncateAt maxlinklength "..." . clean) (T.unpack <$> getItemLink i) clean = oneline . trimwhitespace . striphtml . stripemail ifopt o = if o opts then id else const ""
rss2irc.cabal view
@@ -1,6 +1,6 @@ name: rss2irc -- also set version in Base.hs-version: 1.1+version: 1.2 homepage: http://hackage.haskell.org/package/rss2irc license: BSD3 license-file: LICENSE@@ -41,10 +41,10 @@ ,containers ,deepseq ,irc >= 0.6 && < 0.7- ,feed >= 0.3.9 && < 0.4- ,http-client >= 0.2.1 && < 0.5- ,http-conduit >= 1.9 && < 2.2- ,resourcet >= 0.4.4 && < 1.2+ ,feed >= 1 && < 1.1+ ,http-client >= 0.2.1 && < 0.6+ ,http-conduit >= 1.9 && < 2.4+ ,resourcet >= 0.4.4 && < 1.3 ,http-types >= 0.6.4 && < 1.0 ,io-storage >= 0.3 && < 0.4 ,network >= 2.6 && < 2.7@@ -57,7 +57,7 @@ ,stm >= 2.1 && < 3.0 ,text >= 0.11 && < 1.3 ,transformers >= 0.2 && < 0.6- ,time >= 1.5 && < 1.7+ ,time >= 1.5 && < 1.10 ,utf8-string ,SafeSemaphore
stack.yaml view
@@ -1,4 +1,4 @@-resolver: lts-7.7+resolver: lts-11.15 packages: - '.'