Update to be compatible with newer libraries.

parent d4fc466a
dontuse: dontuse:
echo "This makefile is for the convenience of the developer(s)." @echo "This makefile is for the convenience of the developer(s)."
echo "Use:" @echo "Use:"
echo "cabal configure" @echo "cabal configure"
echo "cabal build" @echo "cabal build"
echo "cabal install" @echo "cabal install"
configure: setup:
cabal-dev configure --ghc-options="-Werror" cabal sandbox init
cabal install --only-dependencies -j
cabal configure --ghc-options="-Werror"
cabal build
configure-profiling: takedown:
--enable-library-profiling --enable-executable-profiling cabal clean
cabal sandbox delete
build:
cabal-dev build
clean:
cabal-dev clean
run:
./dist/build/roguestar-server/roguestar-server +RTS -xc -p -s 2> ./log/stdout.log
check: clean
cabal-dev configure --ghc-options="-O0" --disable-library-profiling --disable-executable-profiling
cabal-dev build
depends:
cabal-dev install-deps -j
...@@ -15,7 +15,6 @@ module Roguestar.Lib.Data.MonsterData ...@@ -15,7 +15,6 @@ module Roguestar.Lib.Data.MonsterData
import Roguestar.Lib.Data.PersistantData import Roguestar.Lib.Data.PersistantData
import Data.Ratio import Data.Ratio
import qualified Data.Text as Text
import Data.Maybe import Data.Maybe
import Data.Aeson import Data.Aeson
import Roguestar.Lib.Data.FactionData import Roguestar.Lib.Data.FactionData
...@@ -166,4 +165,4 @@ creatureHealth c = case () of ...@@ -166,4 +165,4 @@ creatureHealth c = case () of
creature_max_health = creatureAbilityScore ToughnessTrait c } creature_max_health = creatureAbilityScore ToughnessTrait c }
instance GetFaction MonsterData where instance GetFaction MonsterData where
getFaction = creature_faction getFaction = creature_faction
\ No newline at end of file
...@@ -4,12 +4,8 @@ module Roguestar.Lib.HTML.Mustache (renderPage, roguestar_muconfig) where ...@@ -4,12 +4,8 @@ module Roguestar.Lib.HTML.Mustache (renderPage, roguestar_muconfig) where
import Text.Hastache import Text.Hastache
import Data.Text.Lazy as T import Data.Text.Lazy as T
import Data.Aeson as Aeson import Data.Aeson as Aeson
import Data.Attoparsec.Number as AesonNumber
import Data.HashMap.Strict as Map import Data.HashMap.Strict as Map
import Data.Vector as V import Data.Vector as V
import Data.Text.Encoding as Encoding
import Data.Text.Lazy.Encoding as LazyEncoding
import Control.Monad
import Control.Monad.IO.Class import Control.Monad.IO.Class
roguestar_muconfig :: (MonadIO m) => MuConfig m roguestar_muconfig :: (MonadIO m) => MuConfig m
...@@ -19,17 +15,16 @@ roguestar_muconfig = defaultConfig { ...@@ -19,17 +15,16 @@ roguestar_muconfig = defaultConfig {
muTemplateFileExt = Just ".mustache" } muTemplateFileExt = Just ".mustache" }
mkAesonContext :: (Monad m) => Aeson.Value -> MuContext m mkAesonContext :: (Monad m) => Aeson.Value -> MuContext m
mkAesonContext (Object obj) key = return $ maybe MuNothing aesonToMu $ Map.lookup (Encoding.decodeUtf8 key) obj mkAesonContext (Object obj) key = return $ maybe MuNothing aesonToMu $ Map.lookup key obj
mkAesonContext x _ = return $ aesonToMu x mkAesonContext x _ = return $ aesonToMu x
aesonToMu :: (Monad m) => Aeson.Value -> MuType m aesonToMu :: (Monad m) => Aeson.Value -> MuType m
aesonToMu obj@(Object {}) = MuList [mkAesonContext obj] aesonToMu obj@(Object {}) = MuList [mkAesonContext obj]
aesonToMu (Array arr) = MuList $ Prelude.map mkAesonContext $ V.toList arr aesonToMu (Array arr) = MuList $ Prelude.map mkAesonContext $ V.toList arr
aesonToMu (String txt) = MuVariable txt aesonToMu (String txt) = MuVariable txt
aesonToMu (Number (I num)) = MuVariable num aesonToMu (Number n) = MuVariable $ show n
aesonToMu (Number (D num)) = MuVariable num
aesonToMu (Bool bool) = MuBool bool aesonToMu (Bool bool) = MuBool bool
aesonToMu Null = MuNothing aesonToMu Null = MuNothing
renderPage :: FilePath -> Aeson.Value -> IO T.Text renderPage :: FilePath -> Aeson.Value -> IO T.Text
renderPage filepath value = liftM LazyEncoding.decodeUtf8 $ hastacheFile roguestar_muconfig filepath (mkAesonContext value) renderPage filepath value = hastacheFile roguestar_muconfig filepath (mkAesonContext value)
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
import Prelude import Prelude
import qualified Data.ByteString as BS import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy.Char8 as LBS8
import qualified Data.Text as T import qualified Data.Text as T
import qualified Data.Text.Lazy as LT
import Data.Text.Encoding import Data.Text.Encoding
import Control.Exception (SomeException) import Control.Exception (SomeException)
import qualified Control.Monad.CatchIO as CatchIO import qualified Control.Monad.CatchIO as CatchIO
...@@ -25,7 +25,6 @@ import Roguestar.Lib.Perception ...@@ -25,7 +25,6 @@ import Roguestar.Lib.Perception
import Roguestar.Lib.Data.SpeciesData import Roguestar.Lib.Data.SpeciesData
import Roguestar.Lib.Data.ToolData import Roguestar.Lib.Data.ToolData
import Roguestar.Lib.Data.TerrainData as TerrainData import Roguestar.Lib.Data.TerrainData as TerrainData
import Roguestar.Lib.Data.MonsterData
import Roguestar.Lib.Data.FacingData import Roguestar.Lib.Data.FacingData
import Roguestar.Lib.Logging import Roguestar.Lib.Logging
import Roguestar.Lib.UnitTests import Roguestar.Lib.UnitTests
...@@ -68,14 +67,15 @@ makeGlobals = ...@@ -68,14 +67,15 @@ makeGlobals =
handle500 :: MonadSnap m => m a -> m () handle500 :: MonadSnap m => m a -> m ()
handle500 m = (m >> return ()) `CatchIO.catch` \(e::SomeException) -> do handle500 m = (m >> return ()) `CatchIO.catch` \(e::SomeException) -> do
let t = LBS8.pack $ show e let t = LT.pack $ show e
putResponse r putResponse r
writeBS "<html><head><title>Internal Server Error</title></head>" writeText "<html><head><title>oh noes</title></head>"
writeBS "<body><h1>Internal Server Error</h1>" writeText "<body style=\"background:black; color:white;\"><h1>theirs a porblem</h1>"
writeBS "<p>A web handler threw an exception. Details:</p>" writeText "<p>i'm so sorry the website broke a little</p>"
writeBS "<pre>\n" writeText "<img src=\"static/art/TabularMonstrosity.svg\"/>"
writeLBS $ htmlEscape t writeText "<pre>\n"
writeBS "\n</pre></body></html>" writeLazyText $ htmlEscape t
writeText "\n</pre></body></html>"
where where
r = setContentType "text/html" $ r = setContentType "text/html" $
setResponseStatus 500 "Internal Server Error" emptyResponse setResponseStatus 500 "Internal Server Error" emptyResponse
...@@ -121,7 +121,10 @@ postFeedback = method POST $ ifTop $ ...@@ -121,7 +121,10 @@ postFeedback = method POST $ ifTop $
getMemoryStatistics :: IO String getMemoryStatistics :: IO String
getMemoryStatistics = getMemoryStatistics =
do ok <- getGCStatsEnabled do -- this requires ghc 7.6 but I'm still living in 7.4 world
-- just disable for now
-- ok <- getGCStatsEnabled
let ok = False
if ok then liftM show $ getGCStats if ok then liftM show $ getGCStats
else return "(Memory statistics disabled. Use +RTS -T -RTS to collect memory statistics.)" else return "(Memory statistics disabled. Use +RTS -T -RTS to collect memory statistics.)"
...@@ -344,12 +347,13 @@ oops action = ...@@ -344,12 +347,13 @@ oops action =
return $ error "oops: Unreachable code." return $ error "oops: Unreachable code."
Left (DBError bad) -> Left (DBError bad) ->
do putResponse r do putResponse r
writeBS "<html><head><title>Gameplay Error</title></head>" writeText "<html><head><title>gameplay error</title></head>"
writeBS "<body><h1>Gameplay Error</h1>" writeText "<body style=\"background:black; color:white;\"><h1>oh oh the game is confused</h1>"
writeBS "<p>Roguestar returned an error condition. Details:</p>" writeText "<p>some things happened and i didn't know what do</p>"
writeBS "<pre>\n" writeText "<img src=\"static/art/TabularMonstrosity.svg\"/>"
writeLBS $ htmlEscape $ LBS8.pack bad writeText "<pre>\n"
writeBS "\n</pre></body></html>" writeLazyText $ htmlEscape $ LT.pack bad
writeText "\n</pre></body></html>"
finishWith =<< getResponse finishWith =<< getResponse
where where
r = setContentType "text/html" $ r = setContentType "text/html" $
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment