twidge 1.0.4 → 1.0.6
raw patch · 6 files changed
+62/−14 lines, 6 filesdep ~hoauth
Dependency ranges changed: hoauth
Files
- Commands/Setup.hs +17/−0
- Config.hs +5/−4
- OAuth.hs +18/−2
- TwidgeHttpClient.hs +5/−1
- doc/twidge-manpage.sgml +15/−5
- twidge.cabal +2/−2
Commands/Setup.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {- Copyright (C) 2010 John Goerzen <jgoerzen@complete.org> @@ -73,15 +74,25 @@ liftIO $ d "ignite done. trying request 1." reqres1 <- tryRequest reqUrl case reqres1 of+#if MIN_VERSION_hoauth(0,2,4) AccessToken _ _ -> return () _ -> -- hack around hoauth bug for identica+#else+ Left x -> -- hack around hoauth bug for identica+#endif do liftIO $ d "request 1 failed. attempting workaround." putToken $ AccessToken {application = app, oauthParams = empty} reqres2 <- tryRequest reqUrl case reqres2 of +#if MIN_VERSION_hoauth(0,2,4) AccessToken _ _ -> return () _ -> fail $ "Error from oauthRequest."+#else+ Left x -> fail $ "Error from oauthRequest: " ++ show x+ Right _ -> return ()+ Right _ -> return ()+#endif twidgeAskAuthorization authUrl oauthRequest HMACSHA1 Nothing accUrl tok <- getToken@@ -108,7 +119,13 @@ else permFail "Aborting setup at user request." tryRequest reqUrl = do reqres <- oauthRequest HMACSHA1 Nothing reqUrl+#if MIN_VERSION_hoauth(0,2,4) liftIO $ d $ "reqres params: " ++ (show (oauthParams reqres))+#else+ liftIO $ d $ "reqres params: " ++ case reqres of+ Left x -> " error " ++ x+ Right y -> show (oauthParams y)+#endif return reqres -- Work around a hoauth bug - identica doesn't return -- oauth_callback_confirmed
Config.hs view
@@ -40,10 +40,11 @@ getDefaultCP = do return $ forceEither $ - do cp <- set startingcp "DEFAULT" "urlbase" "https://twitter.com"- cp <- set cp "DEFAULT" "oauthrequesttoken" "%(urlbase)s/oauth/request_token"- cp <- set cp "DEFAULT" "oauthaccesstoken" "%(urlbase)s/oauth/access_token"- cp <- set cp "DEFAULT" "oauthauthorize" "%(urlbase)s/oauth/authorize"+ do cp <- set startingcp "DEFAULT" "serverbase" "https://api.twitter.com"+ cp <- set cp "DEFAULT" "urlbase" "%(serverbase)s/1"+ cp <- set cp "DEFAULT" "oauthrequesttoken" "%(serverbase)s/oauth/request_token"+ cp <- set cp "DEFAULT" "oauthaccesstoken" "%(serverbase)s/oauth/access_token"+ cp <- set cp "DEFAULT" "oauthauthorize" "%(serverbase)s/oauth/authorize" cp <- set cp "DEFAULT" "sendmail" "/usr/sbin/sendmail" cp <- set cp "DEFAULT" "shortenurls" "yes" return cp
OAuth.hs view
@@ -38,14 +38,30 @@ import Utils import Data.Either.Utils -twitterKeys = ("t5TWz01unNDrmwngl4fQ",- "QR2RJVx8R6zdxWybdGDaLlPMqdRrhZDwO7Kn1uoZUc")+obfuscatedTwitterKeys = ("jRlf9pXnU7uEV5ZcxrJmc",+ "L17bXFykkLYz4TBCmet1wuX9VtXbLq8Xj4Lif42O4ew") identicaKeys = ("f027d666f9d0e7b80beaed528aec473c", "d84c9b3dafb14becb5e05a002886b60c")+twitterKeys = (twitterDeObfuscator (fst obfuscatedTwitterKeys),+ twitterDeObfuscator (snd obfuscatedTwitterKeys)) +twitterDeObfuscator :: String -> String+twitterDeObfuscator = reverse . map rot13++rot13 :: Char -> Char+rot13 x = + case lookup x trans of+ Just y -> y+ Nothing -> x+ where trans = zip (lcbase ++ ucbase) (part lcbase ++ part ucbase)+ lcbase = ['a' .. 'z']+ ucbase = ['A' .. 'Z']+ part x = drop 13 x ++ take 13 x+ getDefaultKeys :: ConfigParser -> Maybe (String, String) getDefaultKeys cp = case serverHost cp of+ "api.twitter.com" -> Just twitterKeys "twitter.com" -> Just twitterKeys "identi.ca" -> Just identicaKeys
TwidgeHttpClient.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE GeneralizedNewtypeDeriving, CPP #-} -- Copyright (c) 2009, Diego Souza -- All rights reserved.@@ -48,7 +48,11 @@ deriving (Monad,MonadIO,MonadFix,Functor) instance Network.OAuth.Http.HttpClient.HttpClient CurlM where+#if MIN_VERSION_hoauth(0,2,4) unpack = unCurlM+#else+ unlift = unCurlM+#endif request req = CurlM $ withCurlDo $ do c <- initialize setopts c opts
doc/twidge-manpage.sgml view
@@ -728,12 +728,22 @@ section. </para> <variablelist>+ <varlistentry><term>serverbase</term>+ <listitem><para>+ The base URL to access the API of the microblogging+ site. This should contain the server name but not the+ API path. The default is+ <literal>https://api.twitter.com</literal>. For Identica,+ you would use <literal>http://identi.ca/api (note that some users have trouble if attempting to use SSL with identica).</literal>.+ </para>+ </listitem>+ </varlistentry> <varlistentry><term>urlbase</term> <listitem><para> The URL to access the API of the microblogging site.- The default, <literal>https://twitter.com</literal> is+ The default, <literal>%(serverbase)s/1</literal> is for Twitter. To use Identica, you would specify- <literal>http://identi.ca/api</literal>. Do not put a+ <literal>%(serverbase)s</literal>. Do not put a trailing slash on this option. </para></listitem> </varlistentry>@@ -741,7 +751,7 @@ <listitem><para> The URL to access the oAuth request token interface. The default,- <literal>%(urlbase)s/oauth/request_token</literal>, will+ <literal>%(serverbase)s/oauth/request_token</literal>, will work with most environments. </para> </listitem>@@ -749,13 +759,13 @@ <varlistentry><term>oauthaccesstoken</term> <listitem><para> The oAuth access token URL. Default is- <literal>%(urlbase)s/oauth/access_token</literal>.+ <literal>%(serverbase)s/oauth/access_token</literal>. </para></listitem> </varlistentry> <varlistentry><term>oauthauthorize</term> <listitem><para> The oAuth authorize URL. Default is- <literal>%(urlbase)s/oauth/authorize</literal>.+ <literal>%(serverbase)s/oauth/authorize</literal>. </para> </listitem> </varlistentry>
twidge.cabal view
@@ -1,5 +1,5 @@ Name: twidge-Version: 1.0.4+Version: 1.0.6 License: GPL Maintainer: John Goerzen <jgoerzen@complete.org> Author: John Goerzen@@ -48,7 +48,7 @@ Executable twidge Build-Depends: network, unix, parsec, MissingH>=1.0.0,- mtl, base >= 4 && < 5, HaXml>=1.13.2, HaXml<1.19, hslogger, hoauth>=0.2.4,+ mtl, base >= 4 && < 5, HaXml>=1.13.2, HaXml<1.19, hslogger, hoauth>=0.2.3, ConfigFile, directory, HSH, regex-posix, utf8-string, binary, bytestring, curl