switch to Stack LTS 9.5, remove Fay

This commit is contained in:
Filip Gralinski 2017-09-22 14:23:03 +02:00
parent f858b7dfe7
commit 40cd97ee2b
12 changed files with 20 additions and 72 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"]

View File

@ -22,4 +22,3 @@ getHomeR = do
aDomId <- newIdent
setTitle "Welcome To Gonito.net!"
$(widgetFile "homepage")
$(fayFile "Home")

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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