packages feed

hackage2hwn (empty) → 0.1

raw patch · 4 files changed

+113/−0 lines, 4 filesdep +basedep +tagsoupdep +xmlbuild-type:Customsetup-changed

Dependencies added: base, tagsoup, xml

Files

+ LICENSE view
@@ -0,0 +1,27 @@+Copyright (c) Galois Inc.++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:+1. Redistributions of source code must retain the above copyright+   notice, this list of conditions and the following disclaimer.+2. Redistributions in binary form must reproduce the above copyright+   notice, this list of conditions and the following disclaimer in the+   documentation and/or other materials provided with the distribution.+3. Neither the name of the author nor the names of his contributors+   may be used to endorse or promote products derived from this software+   without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF+SUCH DAMAGE.
+ Main.hs view
@@ -0,0 +1,68 @@+--------------------------------------------------------------------+-- |+-- Module    : hackage2hwn+-- Copyright : (c) Galois, Inc. 2007+-- License   : BSD3+--+-- Maintainer: Don Stewart <dons@galois.com>+-- Stability : provisional+--+-- Pulls the RSS feed from Hackage, pretty prints it in a form suitable for+-- inclusion in the Haskell Weekly News.+--+--------------------------------------------------------------------++module Main (main) where++import XML+import Data.Maybe+import Data.List+import Data.Char++import Data.Html.Download+import Data.Html.TagSoup+import Control.Applicative++url = "http://hackage.haskell.org/packages/archive/recent.rss"++main = mapM_ ppr . render . parseXMLDoc =<< openURL url++-- pretty print in human readable format+ppr (HackageItem a b c) = putStrLn $+    unlines [ "HackageItem"+            , show a+            , show b+            , show c ++ ","+            ]++-- parse xml into hackage items+render Nothing  = error "Unable to download hackage"+render (Just e) = map process items+    where Just v    = elContent e+          [es]      = [ x | Elem x <- v ]+          Just body = elContent es+          items    = map onlyElems [ fromJust (elContent e) | Elem e <- drop 10 body ]+++          process [a,b,c,d,e] =+                HackageItem proj+                            author+                            ("[" ++ projurl+                                 ++ " "+                                 ++ takeWhile (not.isSpace) proj+                                 ++ "]: " ++ synopsis ++ "."+                            )+             where+               proj     = strContent a+               projurl  = strContent b+               descr    = strContent e+               author   = reverse . takeWhile ( not . isSpace) . reverse+                                  . takeWhile (/= ',')+                                  $ head [ e |  TagText e <- parseTags descr ]+               synopsis = last [ e |  TagText e <- parseTags descr ]++-- hackage items in the haskell weekly news+data HackageItem = HackageItem Title Author Body+type Title  = String+type Author = String+type Body   = String
+ Setup.lhs view
@@ -0,0 +1,3 @@+#!/usr/bin/env runhaskell+> import Distribution.Simple+> main = defaultMain
+ hackage2hwn.cabal view
@@ -0,0 +1,15 @@+Name:                hackage2hwn+Version:             0.1+homepage:            http://code.haskell.org/~dons/code/hackage2hwn+Synopsis:            Convert Hackage RSS feeds to Haskell Weekly News format+Description:         Download and parse the Hackage RSS 2.0 feed for the+                     automatic inclusion in the Haskell Weekly News.+Category:            Text+License:             BSD3+License-file:        LICENSE+Author:              Don Stewart +Maintainer:          <dons@galois.com>+Build-Depends:       base, tagsoup, xml++Executable:          hackage2hwn+Main-is:             Main.hs