From a65a9bd5ff0c805bbd1f791caaab12b9bce03bc9 Mon Sep 17 00:00:00 2001 From: Tom Streller Date: Wed, 7 Mar 2012 22:15:19 +0100 Subject: [PATCH 1/6] tumblr oauth --- yesod-auth-oauth/Yesod/Auth/OAuth.hs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/yesod-auth-oauth/Yesod/Auth/OAuth.hs b/yesod-auth-oauth/Yesod/Auth/OAuth.hs index 615cdb15..de531d01 100644 --- a/yesod-auth-oauth/Yesod/Auth/OAuth.hs +++ b/yesod-auth-oauth/Yesod/Auth/OAuth.hs @@ -5,6 +5,8 @@ module Yesod.Auth.OAuth , oauthUrl , authTwitter , twitterUrl + , authTumblr + , tumblrUrl , module Web.Authenticate.OAuth ) where @@ -101,5 +103,28 @@ authTwitter key secret = authOAuth twitterUrl :: AuthRoute twitterUrl = oauthUrl "twitter" +authTumblr :: YesodAuth m + => ByteString -- ^ Consumer Key + -> ByteString -- ^ Consumer Secret + -> AuthPlugin m +authTumblr key secret = authOAuth + (newOAuth { oauthServerName = "tumblr" + , oauthRequestUri = "http://www.tumblr.com/oauth/request_token" + , oauthAccessTokenUri = "http://www.tumblr.com/oauth/access_token" + , oauthAuthorizeUri = "http://www.tumblr.com/oauth/authorize" + , oauthSignatureMethod = HMACSHA1 + , oauthConsumerKey = key + , oauthConsumerSecret = secret + , oauthVersion = OAuth10a + }) + extractCreds + where + extractCreds (Credential dic) = do + let crId = decodeUtf8With lenientDecode $ fromJust $ lookup "name" dic + return $ Creds "tumblr" crId $ map (bsToText *** bsToText ) dic + +tumblrUrl :: AuthRoute +tumblrUrl = oauthUrl "tumblr" + bsToText :: ByteString -> Text bsToText = decodeUtf8With lenientDecode From 65a0c0f198a976f5da991ce032483ae446545495 Mon Sep 17 00:00:00 2001 From: Andrew Myers Date: Sat, 10 Mar 2012 13:14:33 -0500 Subject: [PATCH 2/6] Updated Heroku code for Yesod 0.10.2.1 --- yesod/scaffold/deploy/Procfile.cg | 91 +++++++++++++++---------------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/yesod/scaffold/deploy/Procfile.cg b/yesod/scaffold/deploy/Procfile.cg index 28d63220..b7f0d4d7 100644 --- a/yesod/scaffold/deploy/Procfile.cg +++ b/yesod/scaffold/deploy/Procfile.cg @@ -12,62 +12,61 @@ # # * Create an empty package.json # echo '{ "name": "~project~", "version": "0.0.1", "dependencies": {} }' >> package.json -# +# # Postgresql Yesod setup: # -# * add code to read the DATABASE_URL environment variable. -# -# import System.Environment -# main = do -# # parse env variable -# durl <- getEnv "DATABASE_URL" -# # pass settings to withConnectionPool instead of directly using loadConnStr -# defaultMain (fromArgsExtra loadExtra) withYesodHeroku -# # * add a dependency on the "heroku" package in your cabal file -# -# * add code in Application.hs to turn the url into connection parameters. The below works for Postgresql. # -# #ifdef !DEVELOPMENT -# import qualified Web.Heroku -# #endif +# * add code in Application.hs to use the heroku package and load the connection parameters. +# The below works for Postgresql. +# +# #if !DEVELOPMENT +# import qualified Web.Heroku +# #endif # # -# canonicalizeKey :: (Text, val) -> (Text, val) -# canonicalizeKey ("dbname", val) = ("database", val) -# canonicalizeKey pair = pair +# getApplication :: AppConfig DefaultEnv Extra -> Logger -> IO Application +# getApplication conf logger = do +# manager <- newManager def +# s <- staticSite +# hconfig <- loadHerokuConfig +# dbconf <- withYamlEnvironment "config/postgresql.yml" (appEnv conf) +# (Database.Persist.Store.loadConfig . combineMappings hconfig) >>= +# Database.Persist.Store.applyEnv +# p <- Database.Persist.Store.createPoolConfig (dbconf :: Settings.PersistConfig) +# Database.Persist.Store.runPool dbconf (runMigration migrateAll) p +# let foundation = ~sitearg~ conf setLogger s p manager dbconf +# app <- toWaiAppPlain foundation +# return $ logWare app +# where +##ifdef DEVELOPMENT +# logWare = logCallbackDev (logBS setLogger) +# setLogger = logger +##else +# setLogger = toProduction logger -- by default the logger is set for development +# logWare = logCallback (logBS setLogger) +##endif # -# toMapping :: [(key, val)] -> DO.Object key val -# toMapping = DO.Mapping . map (\(key, val) -> (key, DO.Scalar val)) +# #if !DEVELOPMENT +# canonicalizeKey :: (Text, val) -> (Text, val) +# canonicalizeKey ("dbname", val) = ("database", val) +# canonicalizeKey pair = pair # -# combineMappings :: DO.Object key val -> DO.Object key val -> DO.Object key val -# combineMappings (DO.Mapping m1) (DO.Mapping m2) = DO.Mapping $ m1 ++ m2 -# combineMappings _ _ = error "Data.Object is not a Mapping." +# toMapping :: [(Text, Text)] -> AT.Value +# toMapping xs = AT.Object $ M.fromList $ map (\(key, val) -> (key, AT.String val)) xs +# #endif # -# loadHerokuConfig :: DO.TextObject -> IO Settings.PersistConfig -# loadHerokuConfig ymlenv = do -# #if DEVELOPMENT -# let urlMap = DO.Mapping [] -# #else -# urlMap <- Web.Heroku.dbConnParams >>= return . toMapping . map canonicalizeKey -# #endif -# either error return $ Database.Persist.Base.loadConfig (combineMappings urlMap ymlenv) +# combineMappings :: AT.Value -> AT.Value -> AT.Value +# combineMappings (AT.Object m1) (AT.Object m2) = AT.Object $ m1 `M.union` m2 +# combineMappings _ _ = error "Data.Object is not a Mapping." # -# -# withYesodHeroku :: AppConfig DefaultEnv () -> Logger -> (Application -> IO ()) -> IO () -# withYesodHeroku conf logger f = do -# s <- staticSite -# dbconf <- withYamlEnvironment "config/postgresql.yml" (appEnv conf) loadHerokuConfig -# Database.Persist.Base.withPool (dbconf :: Settings.PersistConfig) $ \p -> do -# Database.Persist.Base.runPool dbconf (runMigration migrateAll) p -# let h = YesodHeroku conf logger s p -# defaultRunner (f . logWare) h -# where -# #ifdef DEVELOPMENT -# logWare = logStdoutDev -# #else -# logWare = logStdout -# #endif +# loadHerokuConfig :: IO AT.Value +# loadHerokuConfig = do +# #if DEVELOPMENT +# return $ AT.Object M.empty +# #else +# Web.Heroku.dbConnParams >>= return . toMapping . map canonicalizeKey +# #endif From 437a82d6c4a06306a9eb002e9e45b22f743c0144 Mon Sep 17 00:00:00 2001 From: Greg Weber Date: Wed, 14 Mar 2012 08:34:49 -0700 Subject: [PATCH 3/6] scaffold version bounds for shakespeare-text --- yesod/scaffold/project.cabal.cg | 2 +- yesod/scaffold/tiny/project.cabal.cg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/yesod/scaffold/project.cabal.cg b/yesod/scaffold/project.cabal.cg index 79c75c47..dde270a9 100644 --- a/yesod/scaffold/project.cabal.cg +++ b/yesod/scaffold/project.cabal.cg @@ -91,7 +91,7 @@ executable ~project~ , hamlet >= 0.10 && < 0.11 , shakespeare-css >= 0.10 && < 0.11 , shakespeare-js >= 0.11 && < 0.12 - , shakespeare-text >= 0.10 && < 0.11 + , shakespeare-text >= 0.10 && < 0.12 , hjsmin >= 0.0.14 && < 0.1 , monad-control >= 0.3 && < 0.4 , wai-extra >= 1.0 && < 1.2 diff --git a/yesod/scaffold/tiny/project.cabal.cg b/yesod/scaffold/tiny/project.cabal.cg index 2c55a800..4d329231 100644 --- a/yesod/scaffold/tiny/project.cabal.cg +++ b/yesod/scaffold/tiny/project.cabal.cg @@ -74,7 +74,7 @@ executable ~project~ , text >= 0.11 && < 0.12 , template-haskell , hamlet >= 0.10 && < 0.11 - , shakespeare-text >= 0.10 && < 0.11 + , shakespeare-text >= 0.10 && < 0.12 , wai >= 1.1 && < 1.2 , wai-extra >= 1.1 && < 1.2 , transformers >= 0.2 && < 0.3 From bc7e8f364384de464bdfa5a02ecf2d97dc93539b Mon Sep 17 00:00:00 2001 From: Greg Weber Date: Wed, 14 Mar 2012 08:37:53 -0700 Subject: [PATCH 4/6] be clear that we are using the yesod-core version --- yesod/main.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yesod/main.hs b/yesod/main.hs index 72a7c9b1..2c854df3 100755 --- a/yesod/main.hs +++ b/yesod/main.hs @@ -36,7 +36,7 @@ main = do ["touch"] -> touch #endif "devel":rest -> devel isDev rest - ["version"] -> putStrLn yesodVersion + ["version"] -> putStrLn $ "yesod-core version:" ++ yesodVersion "configure":rest -> rawSystem cmd ("configure":rest) >>= exitWith _ -> do putStrLn "Usage: yesod " From 94f85edea2068bea3c51e83ca5e3f80aea4412ee Mon Sep 17 00:00:00 2001 From: Greg Weber Date: Wed, 14 Mar 2012 09:27:29 -0700 Subject: [PATCH 5/6] use #ifdef not #if --- yesod/scaffold/deploy/Procfile.cg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yesod/scaffold/deploy/Procfile.cg b/yesod/scaffold/deploy/Procfile.cg index b7f0d4d7..837d0001 100644 --- a/yesod/scaffold/deploy/Procfile.cg +++ b/yesod/scaffold/deploy/Procfile.cg @@ -20,7 +20,7 @@ # * add code in Application.hs to use the heroku package and load the connection parameters. # The below works for Postgresql. # -# #if !DEVELOPMENT +# #ifndef DEVELOPMENT # import qualified Web.Heroku # #endif # @@ -47,7 +47,7 @@ # logWare = logCallback (logBS setLogger) ##endif # -# #if !DEVELOPMENT +# #ifndef DEVELOPMENT # canonicalizeKey :: (Text, val) -> (Text, val) # canonicalizeKey ("dbname", val) = ("database", val) # canonicalizeKey pair = pair @@ -62,7 +62,7 @@ # # loadHerokuConfig :: IO AT.Value # loadHerokuConfig = do -# #if DEVELOPMENT +# #ifdef DEVELOPMENT # return $ AT.Object M.empty # #else # Web.Heroku.dbConnParams >>= return . toMapping . map canonicalizeKey From 18d4b98d41aaee022cc54c96f2aee4de56ad4e81 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 15 Mar 2012 14:00:44 +0200 Subject: [PATCH 6/6] Added yesod-platform and creation scripts --- .gitignore | 1 + yesod-platform/LICENSE | 25 +++++++++++++++++++++++ yesod-platform/Setup.lhs | 7 +++++++ yesod-platform/Yesod/Platform.hs | 7 +++++++ yesod-platform/make-cabal.sh | 10 +++++++++ yesod-platform/to-cabal.hs | 35 ++++++++++++++++++++++++++++++++ 6 files changed, 85 insertions(+) create mode 100644 yesod-platform/LICENSE create mode 100755 yesod-platform/Setup.lhs create mode 100644 yesod-platform/Yesod/Platform.hs create mode 100755 yesod-platform/make-cabal.sh create mode 100644 yesod-platform/to-cabal.hs diff --git a/.gitignore b/.gitignore index d724137c..fe358fd0 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ dist client_session_key.aes cabal-dev/ yesod/foobar/ +yesod-platform/yesod-platform.cabal diff --git a/yesod-platform/LICENSE b/yesod-platform/LICENSE new file mode 100644 index 00000000..8643e5d8 --- /dev/null +++ b/yesod-platform/LICENSE @@ -0,0 +1,25 @@ +The following license covers this documentation, and the source code, except +where otherwise indicated. + +Copyright 2010, Michael Snoyman. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* 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. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "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 COPYRIGHT HOLDERS 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. diff --git a/yesod-platform/Setup.lhs b/yesod-platform/Setup.lhs new file mode 100755 index 00000000..06e2708f --- /dev/null +++ b/yesod-platform/Setup.lhs @@ -0,0 +1,7 @@ +#!/usr/bin/env runhaskell + +> module Main where +> import Distribution.Simple + +> main :: IO () +> main = defaultMain diff --git a/yesod-platform/Yesod/Platform.hs b/yesod-platform/Yesod/Platform.hs new file mode 100644 index 00000000..5d8a533d --- /dev/null +++ b/yesod-platform/Yesod/Platform.hs @@ -0,0 +1,7 @@ +-- | This module contains nothing import, it just re-exports @Yesod@. It is +-- provided simply to make this a complete package. +module Yesod.Platform + ( module Yesod + ) where + +import Yesod diff --git a/yesod-platform/make-cabal.sh b/yesod-platform/make-cabal.sh new file mode 100755 index 00000000..e169d6e4 --- /dev/null +++ b/yesod-platform/make-cabal.sh @@ -0,0 +1,10 @@ +#!/bin/bash -e + +#cabal update + +if ! which cabal-nirvana-generate &>/dev/null +then + cabal install cabal-nirvana -fgenerate +fi + +cabal-nirvana-generate yesod | runghc to-cabal.hs > yesod-platform.cabal diff --git a/yesod-platform/to-cabal.hs b/yesod-platform/to-cabal.hs new file mode 100644 index 00000000..06997a45 --- /dev/null +++ b/yesod-platform/to-cabal.hs @@ -0,0 +1,35 @@ +import Data.List (intercalate, isPrefixOf) +import Control.Applicative ((<$>)) + +main = do + pkgs <- map (intercalate " == ") + . filter (\xs -> not $ ["parsec"] `isPrefixOf` xs) + . map words + . filter (not . null) + . lines + <$> getContents + putStrLn "name: yesod-platform" + putStrLn "version: FIXME" + putStrLn "license: BSD3" + putStrLn "license-file: LICENSE" + putStrLn "author: Michael Snoyman " + putStrLn "maintainer: Michael Snoyman " + putStrLn "synopsis: Meta package for Yesod" + putStrLn "description: Instead of allowing version ranges of dependencies, this package requires specific versions to avoid dependency hell" + putStrLn "category: Web, Yesod" + putStrLn "stability: Stable" + putStrLn "cabal-version: >= 1.6" + putStrLn "build-type: Simple" + putStrLn "homepage: http://www.yesodweb.com/" + putStrLn "" + putStrLn "library" + putStrLn " build-depends: base >= 4 && < 5" + mapM_ go pkgs + putStrLn "" + putStrLn " exposed-modules: Yesod.Platform" + putStrLn "" + putStrLn "source-repository head" + putStrLn " type: git" + putStrLn " location: https://github.com/yesodweb/yesod" + +go s = putStrLn $ concat [" , ", s]