mediawiki 0.2.1 → 0.2.2
raw patch · 3 files changed
+31/−11 lines, 3 filesdep ~HTTPPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: HTTP
API changes (from Hackage documentation)
Files
- MediaWiki/API.hs +22/−8
- MediaWiki/API/Action/Login/Import.hs +1/−1
- mediawiki.cabal +8/−2
MediaWiki/API.hs view
@@ -1,4 +1,4 @@-{-# OPTIONS_GHC -XExistentialQuantification -XDeriveDataTypeable #-} +{-# OPTIONS_GHC -cpp -XExistentialQuantification -XDeriveDataTypeable #-} -------------------------------------------------------------------- -- | -- Module : MediaWiki.API @@ -102,7 +102,10 @@ QMeta s -> Query q{quMetas=(MetaKind s):quMetas q} (toReq qr) QGen s -> Query q{quGenerator=(Just (GeneratorKind s))} (toReq qr) --- | @loginWiki u usr pass +-- | @loginWiki u usr pass@ logs in to MediaWiki install at @url@ as +-- user @usr@ with password credentials @pass@. Notice that we don't +-- presently allow HTTP Auth to happen in conjunction with the Wiki +-- login. loginWiki :: URLString -> String -> String -> IO (Maybe LoginResponse) loginWiki url usr pwd = webPostXml Login.stringXml Nothing url "login" req where @@ -151,6 +154,7 @@ mwError :: MediaWikiError mwError = MediaWikiError{mwErrorCode="",mwErrorInfo=""} +#if defined(EXTENSIBLE_EXCEPTIONS) data SomeMWException = forall e . Exception e => SomeMWException e deriving Typeable @@ -171,12 +175,6 @@ toException = mwToException fromException = mwFromException -handleMW :: (MediaWikiError -> IO a) -> IO a -> IO a -handleMW h e = catchMW e h - -tryMW :: IO a -> IO (Either MediaWikiError a) -tryMW f = handleMW (\ x -> return (Left x)) (f >>= return.Right) - throwMWError :: MediaWikiError -> IO a throwMWError e = throwIO e @@ -184,6 +182,22 @@ catchMW f hdlr = CE.catch f (\ e1 -> hdlr e1) +#else +throwMWError :: MediaWikiError -> IO a +throwMWError mw = throwDyn mw + +catchMW :: IO a -> (MediaWikiError -> IO a) -> IO a +catchMW f hdlr = + CE.catchDyn f + (\ e1 -> hdlr e1) +#endif + +handleMW :: (MediaWikiError -> IO a) -> IO a -> IO a +handleMW h e = catchMW e h + +tryMW :: IO a -> IO (Either MediaWikiError a) +tryMW f = handleMW (\ x -> return (Left x)) (f >>= return.Right) + instance Show MediaWikiError where show x = unlines (
MediaWiki/API/Action/Login/Import.hs view
@@ -19,7 +19,6 @@ import MediaWiki.API.Action.Login import Text.XML.Light.Types-import Text.XML.Light.Proc ( strContent ) import Control.Monad import Data.Maybe@@ -39,6 +38,7 @@ let coo = pAttr "cookieprefix" p let ses = pAttr "sessionid" p case res of+ Nothing -> fail "missing 'result' api attribute" Just "Success" -> return LoginResponse{ lgSuccess=True , lgSession=UserSession
mediawiki.cabal view
@@ -1,5 +1,5 @@ Name: mediawiki -Version: 0.2.1 +Version: 0.2.2 License: BSD3 License-file: LICENSE Category: Web @@ -111,16 +111,22 @@ MediaWiki.Util.Codec.Percent, MediaWiki.Util.Codec.URLEncoder Ghc-Options: -Wall -O2 - Build-Depends: base, xml, HTTP, network, mime, utf8-string + Build-Depends: base, xml, HTTP >= 3001, network, mime, utf8-string + if impl(ghc >= 6.10) + cpp-options: -DEXTENSIBLE_EXCEPTIONS executable main { build-depends: base main-is: Main.hs ghc-options: -Wall -fglasgow-exts + if impl(ghc >= 6.10) + cpp-options: -DEXTENSIBLE_EXCEPTIONS } executable listCat { build-depends: base, pretty main-is: examples/ListCat.hs ghc-options: -Wall -fglasgow-exts -iexamples + if impl(ghc >= 6.10) + CPP-options: -DEXTENSIBLE_EXCEPTIONS }