forked from filipg/gonito
switch to Stack LTS 9.5, remove Fay
This commit is contained in:
parent
f858b7dfe7
commit
40cd97ee2b
@ -29,7 +29,6 @@ import Network.Wai.Middleware.RequestLogger (Destination (Logger),
|
|||||||
mkRequestLogger, outputFormat)
|
mkRequestLogger, outputFormat)
|
||||||
import System.Log.FastLogger (defaultBufSize, newStdoutLoggerSet,
|
import System.Log.FastLogger (defaultBufSize, newStdoutLoggerSet,
|
||||||
toLogStr)
|
toLogStr)
|
||||||
import Yesod.Fay (getFaySite)
|
|
||||||
|
|
||||||
import qualified Data.IntMap as IntMap
|
import qualified Data.IntMap as IntMap
|
||||||
|
|
||||||
@ -37,7 +36,6 @@ import qualified Data.IntMap as IntMap
|
|||||||
-- Don't forget to add new modules to your cabal file!
|
-- Don't forget to add new modules to your cabal file!
|
||||||
import Handler.Common
|
import Handler.Common
|
||||||
import Handler.Discussion
|
import Handler.Discussion
|
||||||
import Handler.Fay
|
|
||||||
import Handler.Graph
|
import Handler.Graph
|
||||||
import Handler.Home
|
import Handler.Home
|
||||||
import Handler.CreateChallenge
|
import Handler.CreateChallenge
|
||||||
@ -72,7 +70,6 @@ makeFoundation appSettings = do
|
|||||||
appStatic <-
|
appStatic <-
|
||||||
(if appMutableStatic appSettings then staticDevel else static)
|
(if appMutableStatic appSettings then staticDevel else static)
|
||||||
(appStaticDir appSettings)
|
(appStaticDir appSettings)
|
||||||
let appFayCommandHandler = onCommand
|
|
||||||
|
|
||||||
jobs <- newTVarIO IntMap.empty
|
jobs <- newTVarIO IntMap.empty
|
||||||
nextJob <- newTVarIO 1
|
nextJob <- newTVarIO 1
|
||||||
|
@ -8,7 +8,6 @@ import Yesod.Auth.Message (AuthMessage (InvalidLogin))
|
|||||||
import qualified Yesod.Core.Unsafe as Unsafe
|
import qualified Yesod.Core.Unsafe as Unsafe
|
||||||
import Yesod.Core.Types (Logger)
|
import Yesod.Core.Types (Logger)
|
||||||
import Yesod.Default.Util (addStaticContentExternal)
|
import Yesod.Default.Util (addStaticContentExternal)
|
||||||
import Yesod.Fay
|
|
||||||
|
|
||||||
instance HashDBUser User where
|
instance HashDBUser User where
|
||||||
userPasswordHash = userPassword
|
userPasswordHash = userPassword
|
||||||
@ -24,7 +23,6 @@ data App = App
|
|||||||
, appConnPool :: ConnectionPool -- ^ Database connection pool.
|
, appConnPool :: ConnectionPool -- ^ Database connection pool.
|
||||||
, appHttpManager :: Manager
|
, appHttpManager :: Manager
|
||||||
, appLogger :: Logger
|
, appLogger :: Logger
|
||||||
, appFayCommandHandler :: CommandHandler App
|
|
||||||
, jobs :: TVar (IntMap (TChan (Maybe Text)))
|
, jobs :: TVar (IntMap (TChan (Maybe Text)))
|
||||||
, nextJob :: TVar Int
|
, nextJob :: TVar Int
|
||||||
}
|
}
|
||||||
@ -173,15 +171,6 @@ instance Yesod App where
|
|||||||
|
|
||||||
makeLogger = return . appLogger
|
makeLogger = return . appLogger
|
||||||
|
|
||||||
instance YesodJquery App
|
|
||||||
instance YesodFay App where
|
|
||||||
|
|
||||||
fayRoute = FaySiteR
|
|
||||||
|
|
||||||
yesodFayCommand render command = do
|
|
||||||
master <- getYesod
|
|
||||||
appFayCommandHandler master render command
|
|
||||||
|
|
||||||
-- How to run database actions.
|
-- How to run database actions.
|
||||||
instance YesodPersist App where
|
instance YesodPersist App where
|
||||||
type YesodPersistBackend App = SqlBackend
|
type YesodPersistBackend App = SqlBackend
|
||||||
|
@ -8,7 +8,7 @@ import Text.Pandoc.Shared (stringify)
|
|||||||
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
|
||||||
import System.IO (withFile, IOMode(..))
|
import System.IO (withFile, IOMode(..), readFile)
|
||||||
|
|
||||||
extractHeaders :: Block -> [String]
|
extractHeaders :: Block -> [String]
|
||||||
extractHeaders (Header 1 _ x) = [stringify x]
|
extractHeaders (Header 1 _ x) = [stringify x]
|
||||||
@ -50,5 +50,5 @@ getTitleAndDescription contents = (title, description)
|
|||||||
|
|
||||||
extractTitleAndDescription :: FilePath -> IO (String, String)
|
extractTitleAndDescription :: FilePath -> IO (String, String)
|
||||||
extractTitleAndDescription fp = do
|
extractTitleAndDescription fp = do
|
||||||
contents <- readFile fp
|
contents <- System.IO.readFile fp
|
||||||
return $ getTitleAndDescription contents
|
return $ getTitleAndDescription contents
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
module Handler.Fay where
|
|
||||||
|
|
||||||
import Fay.Convert (readFromFay)
|
|
||||||
import Import
|
|
||||||
import Prelude ((!!))
|
|
||||||
import Yesod.Fay
|
|
||||||
|
|
||||||
fibs :: [Int]
|
|
||||||
fibs = 0 : 1 : zipWith (+) fibs (drop 1 fibs)
|
|
||||||
|
|
||||||
onCommand :: CommandHandler App
|
|
||||||
onCommand render command =
|
|
||||||
case readFromFay command of
|
|
||||||
Just (GetFib index r) -> render r $ fibs !! index
|
|
||||||
Nothing -> invalidArgs ["Invalid command"]
|
|
@ -22,4 +22,3 @@ getHomeR = do
|
|||||||
aDomId <- newIdent
|
aDomId <- newIdent
|
||||||
setTitle "Welcome To Gonito.net!"
|
setTitle "Welcome To Gonito.net!"
|
||||||
$(widgetFile "homepage")
|
$(widgetFile "homepage")
|
||||||
$(fayFile "Home")
|
|
||||||
|
@ -6,7 +6,7 @@ import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3,
|
|||||||
|
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
|
|
||||||
import qualified Data.Text.Lazy as TL
|
import qualified Data.Text.Lazy as TL
|
||||||
import Text.Markdown
|
import Text.Markdown
|
||||||
|
|
||||||
import System.Directory (doesFileExist)
|
import System.Directory (doesFileExist)
|
||||||
@ -27,6 +27,8 @@ import PersistSHA1
|
|||||||
|
|
||||||
import Options.Applicative
|
import Options.Applicative
|
||||||
|
|
||||||
|
import System.IO (readFile)
|
||||||
|
|
||||||
getShowChallengeR :: Text -> Handler Html
|
getShowChallengeR :: Text -> Handler Html
|
||||||
getShowChallengeR name = do
|
getShowChallengeR name = do
|
||||||
(Entity challengeId challenge) <- runDB $ getBy404 $ UniqueName name
|
(Entity challengeId challenge) <- runDB $ getBy404 $ UniqueName name
|
||||||
@ -47,8 +49,8 @@ challengeReadme name = do
|
|||||||
let repoId = challengePublicRepo challenge
|
let repoId = challengePublicRepo challenge
|
||||||
repoDir <- getRepoDir repoId
|
repoDir <- getRepoDir repoId
|
||||||
let readmeFilePath = repoDir </> readmeFile
|
let readmeFilePath = repoDir </> readmeFile
|
||||||
contents <- readFile readmeFilePath
|
contents <- liftIO $ System.IO.readFile readmeFilePath
|
||||||
return $ markdown def $ TL.fromStrict contents
|
return $ markdown def $ TL.pack contents
|
||||||
|
|
||||||
showChallengeWidget muserId challenge test repo leaderboard = $(widgetFile "show-challenge")
|
showChallengeWidget muserId challenge test repo leaderboard = $(widgetFile "show-challenge")
|
||||||
where leaderboardWithRanks = zip [1..] leaderboard
|
where leaderboardWithRanks = zip [1..] leaderboard
|
||||||
|
@ -5,7 +5,3 @@ module Import
|
|||||||
import Foundation as Import
|
import Foundation as Import
|
||||||
import Import.NoFoundation as Import
|
import Import.NoFoundation as Import
|
||||||
import Language.Haskell.TH.Syntax (Exp (ConE))
|
import Language.Haskell.TH.Syntax (Exp (ConE))
|
||||||
import Yesod.Fay (FayFile)
|
|
||||||
|
|
||||||
fayFile :: FayFile
|
|
||||||
fayFile = fayFile' (ConE 'StaticR)
|
|
||||||
|
@ -6,7 +6,6 @@ import ClassyPrelude.Yesod as Import
|
|||||||
import Model as Import
|
import Model as Import
|
||||||
import Settings as Import
|
import Settings as Import
|
||||||
import Settings.StaticFiles as Import
|
import Settings.StaticFiles as Import
|
||||||
import SharedTypes as Import
|
|
||||||
import Yesod.Auth as Import
|
import Yesod.Auth as Import
|
||||||
import Yesod.Core.Types as Import (loggerSet)
|
import Yesod.Core.Types as Import (loggerSet)
|
||||||
import Yesod.Default.Config2 as Import
|
import Yesod.Default.Config2 as Import
|
||||||
|
20
Settings.hs
20
Settings.hs
@ -6,7 +6,7 @@
|
|||||||
module Settings where
|
module Settings where
|
||||||
|
|
||||||
import ClassyPrelude.Yesod
|
import ClassyPrelude.Yesod
|
||||||
import Control.Exception (throw)
|
import qualified Control.Exception as Exception
|
||||||
import Data.Aeson (Result (..), fromJSON, withObject, (.!=),
|
import Data.Aeson (Result (..), fromJSON, withObject, (.!=),
|
||||||
(.:?))
|
(.:?))
|
||||||
import Data.FileEmbed (embedFile)
|
import Data.FileEmbed (embedFile)
|
||||||
@ -17,7 +17,6 @@ import Network.Wai.Handler.Warp (HostPreference)
|
|||||||
import Yesod.Default.Config2 (applyEnvValue, configSettingsYml)
|
import Yesod.Default.Config2 (applyEnvValue, configSettingsYml)
|
||||||
import Yesod.Default.Util (WidgetFileSettings, widgetFileNoReload,
|
import Yesod.Default.Util (WidgetFileSettings, widgetFileNoReload,
|
||||||
widgetFileReload)
|
widgetFileReload)
|
||||||
import Yesod.Fay
|
|
||||||
|
|
||||||
-- | Runtime settings to configure this application. These settings can be
|
-- | Runtime settings to configure this application. These settings can be
|
||||||
-- loaded from various sources: defaults, environment variables, config files,
|
-- loaded from various sources: defaults, environment variables, config files,
|
||||||
@ -108,27 +107,14 @@ widgetFile = (if appReloadTemplates compileTimeAppSettings
|
|||||||
else widgetFileNoReload)
|
else widgetFileNoReload)
|
||||||
widgetFileSettings
|
widgetFileSettings
|
||||||
|
|
||||||
fayFile' :: Exp -> FayFile
|
|
||||||
fayFile' staticR moduleName =
|
|
||||||
(if appReloadTemplates compileTimeAppSettings
|
|
||||||
then fayFileReload
|
|
||||||
else fayFileProd)
|
|
||||||
settings
|
|
||||||
where
|
|
||||||
settings = (yesodFaySettings moduleName)
|
|
||||||
{ yfsSeparateRuntime = Just ("static", staticR)
|
|
||||||
-- , yfsPostProcess = readProcess "java" ["-jar", "closure-compiler.jar"]
|
|
||||||
, yfsExternal = Just ("static", staticR)
|
|
||||||
, yfsPackages = ["fay-dom"]
|
|
||||||
}
|
|
||||||
|
|
||||||
-- | Raw bytes at compile time of @config/settings.yml@
|
-- | Raw bytes at compile time of @config/settings.yml@
|
||||||
configSettingsYmlBS :: ByteString
|
configSettingsYmlBS :: ByteString
|
||||||
configSettingsYmlBS = $(embedFile configSettingsYml)
|
configSettingsYmlBS = $(embedFile configSettingsYml)
|
||||||
|
|
||||||
-- | @config/settings.yml@, parsed to a @Value@.
|
-- | @config/settings.yml@, parsed to a @Value@.
|
||||||
configSettingsYmlValue :: Value
|
configSettingsYmlValue :: Value
|
||||||
configSettingsYmlValue = either throw id $ decodeEither' configSettingsYmlBS
|
configSettingsYmlValue = either Exception.throw id
|
||||||
|
$ decodeEither' configSettingsYmlBS
|
||||||
|
|
||||||
-- | A version of @AppSettings@ parsed at compile time from @config/settings.yml@.
|
-- | A version of @AppSettings@ parsed at compile time from @config/settings.yml@.
|
||||||
compileTimeAppSettings :: AppSettings
|
compileTimeAppSettings :: AppSettings
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
/static StaticR Static appStatic
|
/static StaticR Static appStatic
|
||||||
/auth AuthR Auth getAuth
|
/auth AuthR Auth getAuth
|
||||||
/fay-command FaySiteR FaySite getFaySite
|
|
||||||
|
|
||||||
/favicon.ico FaviconR GET
|
/favicon.ico FaviconR GET
|
||||||
/robots.txt RobotsR GET
|
/robots.txt RobotsR GET
|
||||||
|
20
gonito.cabal
20
gonito.cabal
@ -18,7 +18,7 @@ Flag library-only
|
|||||||
Default: False
|
Default: False
|
||||||
|
|
||||||
library
|
library
|
||||||
hs-source-dirs: ., fay-shared, app
|
hs-source-dirs: ., app
|
||||||
exposed-modules: Application
|
exposed-modules: Application
|
||||||
Foundation
|
Foundation
|
||||||
Import
|
Import
|
||||||
@ -28,11 +28,9 @@ library
|
|||||||
PersistSHA1
|
PersistSHA1
|
||||||
Settings
|
Settings
|
||||||
Settings.StaticFiles
|
Settings.StaticFiles
|
||||||
SharedTypes
|
|
||||||
Handler.Common
|
Handler.Common
|
||||||
Handler.CreateChallenge
|
Handler.CreateChallenge
|
||||||
Handler.Discussion
|
Handler.Discussion
|
||||||
Handler.Fay
|
|
||||||
Handler.Graph
|
Handler.Graph
|
||||||
Handler.Home
|
Handler.Home
|
||||||
Handler.ListChallenges
|
Handler.ListChallenges
|
||||||
@ -84,30 +82,28 @@ library
|
|||||||
, yesod-auth >= 1.4.0 && < 1.5
|
, yesod-auth >= 1.4.0 && < 1.5
|
||||||
, yesod-static >= 1.4.0.3 && < 1.6
|
, yesod-static >= 1.4.0.3 && < 1.6
|
||||||
, yesod-form >= 1.4.0 && < 1.5
|
, yesod-form >= 1.4.0 && < 1.5
|
||||||
, yesod-fay >= 0.8 && < 0.9
|
|
||||||
, fay >= 0.21.2.1 && < 0.24
|
|
||||||
, classy-prelude >= 0.10.2
|
, classy-prelude >= 0.10.2
|
||||||
, classy-prelude-conduit >= 0.10.2
|
, classy-prelude-conduit >= 0.10.2
|
||||||
, classy-prelude-yesod >= 0.10.2
|
, classy-prelude-yesod >= 0.10.2
|
||||||
, bytestring >= 0.9 && < 0.11
|
, bytestring >= 0.9 && < 0.11
|
||||||
, text >= 0.11 && < 2.0
|
, text >= 0.11 && < 2.0
|
||||||
, persistent >= 2.0 && < 2.3
|
, persistent >= 2.0 && < 2.8
|
||||||
, persistent-postgresql >= 2.1.1 && < 2.3
|
, persistent-postgresql >= 2.1.1 && < 2.7
|
||||||
, persistent-template >= 2.0 && < 2.3
|
, persistent-template >= 2.0 && < 2.6
|
||||||
, template-haskell
|
, template-haskell
|
||||||
, shakespeare >= 2.0 && < 2.1
|
, shakespeare >= 2.0 && < 2.1
|
||||||
, monad-control >= 0.3 && < 1.1
|
, monad-control >= 0.3 && < 1.1
|
||||||
, wai-extra >= 3.0 && < 3.1
|
, wai-extra >= 3.0 && < 3.1
|
||||||
, yaml >= 0.8 && < 0.9
|
, yaml >= 0.8 && < 0.9
|
||||||
, http-conduit >= 2.1 && < 2.2
|
, http-conduit >= 2.1 && < 2.3
|
||||||
, directory >= 1.1 && < 1.3
|
, directory >= 1.1 && < 1.4
|
||||||
, warp >= 3.0 && < 3.3
|
, warp >= 3.0 && < 3.3
|
||||||
, data-default
|
, data-default
|
||||||
, aeson >= 0.6 && < 0.12
|
, aeson >= 0.6 && < 1.2
|
||||||
, conduit >= 1.0 && < 2.0
|
, conduit >= 1.0 && < 2.0
|
||||||
, monad-logger >= 0.3 && < 0.4
|
, monad-logger >= 0.3 && < 0.4
|
||||||
, fast-logger >= 2.2 && < 2.5
|
, fast-logger >= 2.2 && < 2.5
|
||||||
, wai-logger >= 2.2 && < 2.3
|
, wai-logger >= 2.2 && < 2.4
|
||||||
, file-embed
|
, file-embed
|
||||||
, safe
|
, safe
|
||||||
, unordered-containers
|
, unordered-containers
|
||||||
|
@ -5,5 +5,5 @@ flags:
|
|||||||
packages:
|
packages:
|
||||||
- '.'
|
- '.'
|
||||||
- '../geval'
|
- '../geval'
|
||||||
extra-deps: [markdown-0.1.13.2,geval-0.3.2.0,cond-0.4.1.1,wai-handler-fastcgi-3.0.0.2,murmur3-1.0.3,extra-1.4.10]
|
extra-deps: [markdown-0.1.13.2,geval-0.3.3.0,cond-0.4.1.1,wai-handler-fastcgi-3.0.0.2,murmur3-1.0.3,extra-1.4.10]
|
||||||
resolver: lts-6.24
|
resolver: lts-9.5
|
||||||
|
Loading…
Reference in New Issue
Block a user