X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;ds=inline;f=src%2FLWN%2FPage.hs;h=d4aeb3006cab8c331c76219a723d1a20baf6f623;hb=1d9b1f888c9dcb7c82ce35682b4e9f0210f93f0a;hp=620e3ec3d8bf66a9a67bff98cc3ac215a2a64b70;hpb=4220827f62d772d7edcbdcc1c2f13d6c2eb5f534;p=dead%2Flwn-epub.git diff --git a/src/LWN/Page.hs b/src/LWN/Page.hs index 620e3ec..d4aeb30 100644 --- a/src/LWN/Page.hs +++ b/src/LWN/Page.hs @@ -3,12 +3,15 @@ module LWN.Page where +import Control.Concurrent.ParallelIO (parallel) import qualified Data.Map as Map (lookup) import Data.Time (getCurrentTime) -import System.IO (Handle, hClose, hFlush) import qualified Data.ByteString.Lazy as B (ByteString, hPut) import Data.String.Utils (split, strip) +import qualified Data.Map as Map (Map, empty, insert) import Data.Maybe (catMaybes, fromJust, isNothing) +import Prelude hiding (readFile) +import System.IO (Handle, hClose, hFlush) import Test.HUnit (Assertion, assertEqual) import Test.Framework (Test, testGroup) import Test.Framework.Providers.HUnit (testCase) @@ -22,6 +25,7 @@ import Text.XML.HXT.Core ( ArrowXml, IOSArrow, XmlTree, + ($<), (>>>), (/>), (//>), @@ -29,30 +33,37 @@ import Text.XML.HXT.Core ( getAttrValue, getChildren, getText, - hasAttrValue, hasName, - isElem, - mkName, - none, processAttrl, processTopDown, + this, runX, - setElemName, xshow, when) import Text.HandsomeSoup (css, parseHtml) +import Configuration (Cfg, full_stories) import LWN.Article -import LWN.HTTP (ImageMap, download_image_urls) -import LWN.URI (URL, try_make_absolute_url) -import LWN.XHTML (XHTML, to_xhtml) -import Misc (contains) +import LWN.HTTP ( + ImageMap, + download_image_urls, + get_article_contents) +import LWN.URI (URL) +import LWN.XHTML ( + XHTML, + full_story_urls, + image_srcs, + full_story_link, + full_story_paragraph, + is_image, + preprocess, + remove_byline, + remove_title, + to_xhtml, + to_xml, + xml_from_contents) + --- Should be called *after* preprocessing. -download_images :: IOSArrow XmlTree XmlTree -> IO ImageMap -download_images xml = do - image_urls <- runX $ xml >>> image_srcs - download_image_urls image_urls data Page = @@ -77,9 +88,7 @@ instance XHTML Page where "