From 40cd97ee2bc4df2336d9833d2699c40bb46024fa Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Fri, 22 Sep 2017 14:23:03 +0200 Subject: [PATCH] switch to Stack LTS 9.5, remove Fay --- Application.hs | 3 --- Foundation.hs | 11 ----------- Handler/Extract.hs | 4 ++-- Handler/Fay.hs | 15 --------------- Handler/Home.hs | 1 - Handler/ShowChallenge.hs | 8 +++++--- Import.hs | 4 ---- Import/NoFoundation.hs | 1 - Settings.hs | 20 +++----------------- config/routes | 1 - gonito.cabal | 20 ++++++++------------ stack.yaml | 4 ++-- 12 files changed, 20 insertions(+), 72 deletions(-) delete mode 100644 Handler/Fay.hs diff --git a/Application.hs b/Application.hs index f750074..ab57aa4 100644 --- a/Application.hs +++ b/Application.hs @@ -29,7 +29,6 @@ import Network.Wai.Middleware.RequestLogger (Destination (Logger), mkRequestLogger, outputFormat) import System.Log.FastLogger (defaultBufSize, newStdoutLoggerSet, toLogStr) -import Yesod.Fay (getFaySite) 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! import Handler.Common import Handler.Discussion -import Handler.Fay import Handler.Graph import Handler.Home import Handler.CreateChallenge @@ -72,7 +70,6 @@ makeFoundation appSettings = do appStatic <- (if appMutableStatic appSettings then staticDevel else static) (appStaticDir appSettings) - let appFayCommandHandler = onCommand jobs <- newTVarIO IntMap.empty nextJob <- newTVarIO 1 diff --git a/Foundation.hs b/Foundation.hs index 56f4b73..7e45f37 100644 --- a/Foundation.hs +++ b/Foundation.hs @@ -8,7 +8,6 @@ import Yesod.Auth.Message (AuthMessage (InvalidLogin)) import qualified Yesod.Core.Unsafe as Unsafe import Yesod.Core.Types (Logger) import Yesod.Default.Util (addStaticContentExternal) -import Yesod.Fay instance HashDBUser User where userPasswordHash = userPassword @@ -24,7 +23,6 @@ data App = App , appConnPool :: ConnectionPool -- ^ Database connection pool. , appHttpManager :: Manager , appLogger :: Logger - , appFayCommandHandler :: CommandHandler App , jobs :: TVar (IntMap (TChan (Maybe Text))) , nextJob :: TVar Int } @@ -173,15 +171,6 @@ instance Yesod App where 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. instance YesodPersist App where type YesodPersistBackend App = SqlBackend diff --git a/Handler/Extract.hs b/Handler/Extract.hs index 6e6b60d..53d573a 100644 --- a/Handler/Extract.hs +++ b/Handler/Extract.hs @@ -8,7 +8,7 @@ import Text.Pandoc.Shared (stringify) import Data.Maybe -import System.IO (withFile, IOMode(..)) +import System.IO (withFile, IOMode(..), readFile) extractHeaders :: Block -> [String] extractHeaders (Header 1 _ x) = [stringify x] @@ -50,5 +50,5 @@ getTitleAndDescription contents = (title, description) extractTitleAndDescription :: FilePath -> IO (String, String) extractTitleAndDescription fp = do - contents <- readFile fp + contents <- System.IO.readFile fp return $ getTitleAndDescription contents diff --git a/Handler/Fay.hs b/Handler/Fay.hs deleted file mode 100644 index 42320ab..0000000 --- a/Handler/Fay.hs +++ /dev/null @@ -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"] diff --git a/Handler/Home.hs b/Handler/Home.hs index 9c30f42..310f5d2 100644 --- a/Handler/Home.hs +++ b/Handler/Home.hs @@ -22,4 +22,3 @@ getHomeR = do aDomId <- newIdent setTitle "Welcome To Gonito.net!" $(widgetFile "homepage") - $(fayFile "Home") diff --git a/Handler/ShowChallenge.hs b/Handler/ShowChallenge.hs index b58093c..adbea1d 100644 --- a/Handler/ShowChallenge.hs +++ b/Handler/ShowChallenge.hs @@ -6,7 +6,7 @@ import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3, import Data.Monoid -import qualified Data.Text.Lazy as TL +import qualified Data.Text.Lazy as TL import Text.Markdown import System.Directory (doesFileExist) @@ -27,6 +27,8 @@ import PersistSHA1 import Options.Applicative +import System.IO (readFile) + getShowChallengeR :: Text -> Handler Html getShowChallengeR name = do (Entity challengeId challenge) <- runDB $ getBy404 $ UniqueName name @@ -47,8 +49,8 @@ challengeReadme name = do let repoId = challengePublicRepo challenge repoDir <- getRepoDir repoId let readmeFilePath = repoDir readmeFile - contents <- readFile readmeFilePath - return $ markdown def $ TL.fromStrict contents + contents <- liftIO $ System.IO.readFile readmeFilePath + return $ markdown def $ TL.pack contents showChallengeWidget muserId challenge test repo leaderboard = $(widgetFile "show-challenge") where leaderboardWithRanks = zip [1..] leaderboard diff --git a/Import.hs b/Import.hs index 0862ef7..6a7f3df 100644 --- a/Import.hs +++ b/Import.hs @@ -5,7 +5,3 @@ module Import import Foundation as Import import Import.NoFoundation as Import import Language.Haskell.TH.Syntax (Exp (ConE)) -import Yesod.Fay (FayFile) - -fayFile :: FayFile -fayFile = fayFile' (ConE 'StaticR) diff --git a/Import/NoFoundation.hs b/Import/NoFoundation.hs index b432e41..15bf2dc 100644 --- a/Import/NoFoundation.hs +++ b/Import/NoFoundation.hs @@ -6,7 +6,6 @@ import ClassyPrelude.Yesod as Import import Model as Import import Settings as Import import Settings.StaticFiles as Import -import SharedTypes as Import import Yesod.Auth as Import import Yesod.Core.Types as Import (loggerSet) import Yesod.Default.Config2 as Import diff --git a/Settings.hs b/Settings.hs index 3fd079d..a1de958 100644 --- a/Settings.hs +++ b/Settings.hs @@ -6,7 +6,7 @@ module Settings where import ClassyPrelude.Yesod -import Control.Exception (throw) +import qualified Control.Exception as Exception import Data.Aeson (Result (..), fromJSON, withObject, (.!=), (.:?)) import Data.FileEmbed (embedFile) @@ -17,7 +17,6 @@ import Network.Wai.Handler.Warp (HostPreference) import Yesod.Default.Config2 (applyEnvValue, configSettingsYml) import Yesod.Default.Util (WidgetFileSettings, widgetFileNoReload, widgetFileReload) -import Yesod.Fay -- | Runtime settings to configure this application. These settings can be -- loaded from various sources: defaults, environment variables, config files, @@ -108,27 +107,14 @@ widgetFile = (if appReloadTemplates compileTimeAppSettings else widgetFileNoReload) 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@ configSettingsYmlBS :: ByteString configSettingsYmlBS = $(embedFile configSettingsYml) -- | @config/settings.yml@, parsed to a @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@. compileTimeAppSettings :: AppSettings diff --git a/config/routes b/config/routes index d0dddb4..3321b60 100644 --- a/config/routes +++ b/config/routes @@ -1,6 +1,5 @@ /static StaticR Static appStatic /auth AuthR Auth getAuth -/fay-command FaySiteR FaySite getFaySite /favicon.ico FaviconR GET /robots.txt RobotsR GET diff --git a/gonito.cabal b/gonito.cabal index dc2e192..57fb33c 100644 --- a/gonito.cabal +++ b/gonito.cabal @@ -18,7 +18,7 @@ Flag library-only Default: False library - hs-source-dirs: ., fay-shared, app + hs-source-dirs: ., app exposed-modules: Application Foundation Import @@ -28,11 +28,9 @@ library PersistSHA1 Settings Settings.StaticFiles - SharedTypes Handler.Common Handler.CreateChallenge Handler.Discussion - Handler.Fay Handler.Graph Handler.Home Handler.ListChallenges @@ -84,30 +82,28 @@ library , yesod-auth >= 1.4.0 && < 1.5 , yesod-static >= 1.4.0.3 && < 1.6 , 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-conduit >= 0.10.2 , classy-prelude-yesod >= 0.10.2 , bytestring >= 0.9 && < 0.11 , text >= 0.11 && < 2.0 - , persistent >= 2.0 && < 2.3 - , persistent-postgresql >= 2.1.1 && < 2.3 - , persistent-template >= 2.0 && < 2.3 + , persistent >= 2.0 && < 2.8 + , persistent-postgresql >= 2.1.1 && < 2.7 + , persistent-template >= 2.0 && < 2.6 , template-haskell , shakespeare >= 2.0 && < 2.1 , monad-control >= 0.3 && < 1.1 , wai-extra >= 3.0 && < 3.1 , yaml >= 0.8 && < 0.9 - , http-conduit >= 2.1 && < 2.2 - , directory >= 1.1 && < 1.3 + , http-conduit >= 2.1 && < 2.3 + , directory >= 1.1 && < 1.4 , warp >= 3.0 && < 3.3 , data-default - , aeson >= 0.6 && < 0.12 + , aeson >= 0.6 && < 1.2 , conduit >= 1.0 && < 2.0 , monad-logger >= 0.3 && < 0.4 , fast-logger >= 2.2 && < 2.5 - , wai-logger >= 2.2 && < 2.3 + , wai-logger >= 2.2 && < 2.4 , file-embed , safe , unordered-containers diff --git a/stack.yaml b/stack.yaml index afefb86..e0c8855 100644 --- a/stack.yaml +++ b/stack.yaml @@ -5,5 +5,5 @@ flags: packages: - '.' - '../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] -resolver: lts-6.24 +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-9.5