hackage2hwn 0.3 → 0.4
raw patch · 2 files changed
+20/−62 lines, 2 filesdep +feeddep −filepathdep −xmldep ~tagsoup
Dependencies added: feed
Dependencies removed: filepath, xml
Dependency ranges changed: tagsoup
Files
- Main.hs +18/−60
- hackage2hwn.cabal +2/−2
Main.hs view
@@ -1,7 +1,7 @@ -------------------------------------------------------------------- -- | -- Module : hackage2hwn--- Copyright : (c) Galois, Inc. 2007+-- Copyright : (c) Galois, Inc. 2007-2008 -- License : BSD3 -- -- Maintainer: Don Stewart <dons@galois.com>@@ -14,73 +14,31 @@ module Main (main) where -import Text.XML.Light import Data.Maybe import Data.List import Data.Char -import Debug.Trace-import System.FilePath import Text.HTML.Download import Text.HTML.TagSoup-import Control.Applicative +import Text.Feed.Import+import Text.RSS.Syntax+import Text.Feed.Types+ url = "http://hackage.haskell.org/packages/archive/recent.rss" main = do- putStrLn "'''Recent Package Updates'''\n"- mapM_ ppr . render . parseXMLDoc =<< openURL url- putStrLn $ " [http://hackage.haskell.org/packages/archive/pkg-list.html More...]\n[http://hackage.haskell.org/packages/archive/recent.rss RSS]"---- pretty print in human readable format-ppr (HackageItem title url _ _ synopsis) = putStrLn $- unlines- [(";" ++ "[" ++ url ++ " "++ title ++ "]")- ,(":" ++ synopsis)]----- parse xml into hackage items-render Nothing = error "Unable to download hackage"-render (Just e) = map process items- where v = elContent e- [es] = [ x | Elem x <- v ]- body = elContent es- items = map onlyElems [ (elContent e) | Elem e <- drop 10 body ]--- process xs@[a,b,c,d,e] =- HackageItem proj- projurl- name- author- synopsis- where- proj = strContent a- projurl = strContent b- name = takeFileName projurl- descr = strContent e- author =- let (h:rest) =- reverse . takeWhile ( not . isSpace) . reverse- . takeWhile (/= ',')- $ head [ e | TagText e <- parseTags descr ]-- (first,last) = break isUpper rest- in (h:first ++ " " ++ last)-- synopsis = last [ e | TagText e <- parseTags descr ]---- hackage items in the haskell weekly news-data HackageItem =- HackageItem- Title- Url- CanonicalName- Author- Body+ putStrLn "'''Recent Package Updates''' [http://hackage.haskell.org/packages/archive/recent.rss http://haskell.org/sitewiki/images/0/09/Rss.png]\n"+ RSSFeed is <- (fromJust . parseFeedString) `fmap` openURL url+ mapM_ (putStr . pprRSS) (rssItems . rssChannel $ is)+ putStrLn $ "[http://hackage.haskell.org/packages/archive/pkg-list.html More...]" -type Title = String-type Url = String-type Author = String-type CanonicalName = String-type Body = String+pprRSS :: RSSItem -> String+pprRSS r = unlines+ [(";" ++ "[" ++ url ++ " "++ title ++ "]")+ ,(":" ++ synopsis)]+ where+ Just title = rssItemTitle $ r+ Just url = rssItemLink $ r+ synopsis = last [ e | TagText e <- parseTags+ (fromJust . rssItemDescription $ r) ]
hackage2hwn.cabal view
@@ -1,5 +1,5 @@ Name: hackage2hwn-Version: 0.3+Version: 0.4 homepage: http://code.haskell.org/~dons/code/hackage2hwn Synopsis: Convert Hackage RSS feeds to wiki format for publishing on Haskell.org Description: Convert Hackage RSS feeds to wiki format for publishing on Haskell.org@@ -8,7 +8,7 @@ License-file: LICENSE Author: Don Stewart Maintainer: <dons@galois.com>-Build-Depends: base, filepath, tagsoup ==0.4, xml+Build-Depends: base, tagsoup, feed Build-type: Simple Executable: hackage2hwn