Merge branch 'master' into beta
Conflicts: yesod/scaffold/project.cabal.cg yesod/scaffold/tiny/project.cabal.cg
This commit is contained in:
commit
072df2f06a
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ dist
|
|||||||
client_session_key.aes
|
client_session_key.aes
|
||||||
cabal-dev/
|
cabal-dev/
|
||||||
yesod/foobar/
|
yesod/foobar/
|
||||||
|
yesod-platform/yesod-platform.cabal
|
||||||
|
|||||||
@ -5,6 +5,8 @@ module Yesod.Auth.OAuth
|
|||||||
, oauthUrl
|
, oauthUrl
|
||||||
, authTwitter
|
, authTwitter
|
||||||
, twitterUrl
|
, twitterUrl
|
||||||
|
, authTumblr
|
||||||
|
, tumblrUrl
|
||||||
, module Web.Authenticate.OAuth
|
, module Web.Authenticate.OAuth
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@ -101,5 +103,28 @@ authTwitter key secret = authOAuth
|
|||||||
twitterUrl :: AuthRoute
|
twitterUrl :: AuthRoute
|
||||||
twitterUrl = oauthUrl "twitter"
|
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 :: ByteString -> Text
|
||||||
bsToText = decodeUtf8With lenientDecode
|
bsToText = decodeUtf8With lenientDecode
|
||||||
|
|||||||
25
yesod-platform/LICENSE
Normal file
25
yesod-platform/LICENSE
Normal file
@ -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.
|
||||||
7
yesod-platform/Setup.lhs
Executable file
7
yesod-platform/Setup.lhs
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env runhaskell
|
||||||
|
|
||||||
|
> module Main where
|
||||||
|
> import Distribution.Simple
|
||||||
|
|
||||||
|
> main :: IO ()
|
||||||
|
> main = defaultMain
|
||||||
7
yesod-platform/Yesod/Platform.hs
Normal file
7
yesod-platform/Yesod/Platform.hs
Normal file
@ -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
|
||||||
10
yesod-platform/make-cabal.sh
Executable file
10
yesod-platform/make-cabal.sh
Executable file
@ -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
|
||||||
35
yesod-platform/to-cabal.hs
Normal file
35
yesod-platform/to-cabal.hs
Normal file
@ -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 <michael@snoyman.com>"
|
||||||
|
putStrLn "maintainer: Michael Snoyman <michael@snoyman.com>"
|
||||||
|
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]
|
||||||
@ -36,7 +36,7 @@ main = do
|
|||||||
["touch"] -> touch
|
["touch"] -> touch
|
||||||
#endif
|
#endif
|
||||||
"devel":rest -> devel isDev rest
|
"devel":rest -> devel isDev rest
|
||||||
["version"] -> putStrLn yesodVersion
|
["version"] -> putStrLn $ "yesod-core version:" ++ yesodVersion
|
||||||
"configure":rest -> rawSystem cmd ("configure":rest) >>= exitWith
|
"configure":rest -> rawSystem cmd ("configure":rest) >>= exitWith
|
||||||
_ -> do
|
_ -> do
|
||||||
putStrLn "Usage: yesod <command>"
|
putStrLn "Usage: yesod <command>"
|
||||||
|
|||||||
@ -12,62 +12,61 @@
|
|||||||
#
|
#
|
||||||
# * Create an empty package.json
|
# * Create an empty package.json
|
||||||
# echo '{ "name": "~project~", "version": "0.0.1", "dependencies": {} }' >> package.json
|
# echo '{ "name": "~project~", "version": "0.0.1", "dependencies": {} }' >> package.json
|
||||||
#
|
#
|
||||||
# Postgresql Yesod setup:
|
# 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 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
|
# * add code in Application.hs to use the heroku package and load the connection parameters.
|
||||||
# import qualified Web.Heroku
|
# The below works for Postgresql.
|
||||||
# #endif
|
#
|
||||||
|
# #ifndef DEVELOPMENT
|
||||||
|
# import qualified Web.Heroku
|
||||||
|
# #endif
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# canonicalizeKey :: (Text, val) -> (Text, val)
|
# getApplication :: AppConfig DefaultEnv Extra -> Logger -> IO Application
|
||||||
# canonicalizeKey ("dbname", val) = ("database", val)
|
# getApplication conf logger = do
|
||||||
# canonicalizeKey pair = pair
|
# 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
|
# #ifndef DEVELOPMENT
|
||||||
# toMapping = DO.Mapping . map (\(key, val) -> (key, DO.Scalar val))
|
# 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
|
# toMapping :: [(Text, Text)] -> AT.Value
|
||||||
# combineMappings (DO.Mapping m1) (DO.Mapping m2) = DO.Mapping $ m1 ++ m2
|
# toMapping xs = AT.Object $ M.fromList $ map (\(key, val) -> (key, AT.String val)) xs
|
||||||
# combineMappings _ _ = error "Data.Object is not a Mapping."
|
# #endif
|
||||||
#
|
#
|
||||||
# loadHerokuConfig :: DO.TextObject -> IO Settings.PersistConfig
|
# combineMappings :: AT.Value -> AT.Value -> AT.Value
|
||||||
# loadHerokuConfig ymlenv = do
|
# combineMappings (AT.Object m1) (AT.Object m2) = AT.Object $ m1 `M.union` m2
|
||||||
# #if DEVELOPMENT
|
# combineMappings _ _ = error "Data.Object is not a Mapping."
|
||||||
# let urlMap = DO.Mapping []
|
|
||||||
# #else
|
|
||||||
# urlMap <- Web.Heroku.dbConnParams >>= return . toMapping . map canonicalizeKey
|
|
||||||
# #endif
|
|
||||||
# either error return $ Database.Persist.Base.loadConfig (combineMappings urlMap ymlenv)
|
|
||||||
#
|
#
|
||||||
#
|
# loadHerokuConfig :: IO AT.Value
|
||||||
# withYesodHeroku :: AppConfig DefaultEnv () -> Logger -> (Application -> IO ()) -> IO ()
|
# loadHerokuConfig = do
|
||||||
# withYesodHeroku conf logger f = do
|
# #ifdef DEVELOPMENT
|
||||||
# s <- staticSite
|
# return $ AT.Object M.empty
|
||||||
# dbconf <- withYamlEnvironment "config/postgresql.yml" (appEnv conf) loadHerokuConfig
|
# #else
|
||||||
# Database.Persist.Base.withPool (dbconf :: Settings.PersistConfig) $ \p -> do
|
# Web.Heroku.dbConnParams >>= return . toMapping . map canonicalizeKey
|
||||||
# Database.Persist.Base.runPool dbconf (runMigration migrateAll) p
|
# #endif
|
||||||
# let h = YesodHeroku conf logger s p
|
|
||||||
# defaultRunner (f . logWare) h
|
|
||||||
# where
|
|
||||||
# #ifdef DEVELOPMENT
|
|
||||||
# logWare = logStdoutDev
|
|
||||||
# #else
|
|
||||||
# logWare = logStdout
|
|
||||||
# #endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user