diff --git a/Makefile b/Makefile index f5f52fa2f99dd69defccd78fb6045a2d0ef87e71..59aba0c729ef859cffc826895fed8e697a72e507 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,16 @@ dontuse: - echo "This makefile is for the convenience of the developer(s)." - echo "Use:" - echo "cabal configure" - echo "cabal build" - echo "cabal install" + @echo "This makefile is for the convenience of the developer(s)." + @echo "Use:" + @echo "cabal configure" + @echo "cabal build" + @echo "cabal install" -configure: - cabal-dev configure --ghc-options="-Werror" +setup: + cabal sandbox init + cabal install --only-dependencies -j + cabal configure --ghc-options="-Werror" + cabal build -configure-profiling: - --enable-library-profiling --enable-executable-profiling - -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 +takedown: + cabal clean + cabal sandbox delete diff --git a/Roguestar/Lib/Data/MonsterData.hs b/Roguestar/Lib/Data/MonsterData.hs index 25b6d76489384342782900cccd7abdc2a62f7bd2..b7781c40a9285ef72785bfe96687deb172a56567 100644 --- a/Roguestar/Lib/Data/MonsterData.hs +++ b/Roguestar/Lib/Data/MonsterData.hs @@ -15,7 +15,6 @@ module Roguestar.Lib.Data.MonsterData import Roguestar.Lib.Data.PersistantData import Data.Ratio -import qualified Data.Text as Text import Data.Maybe import Data.Aeson import Roguestar.Lib.Data.FactionData @@ -166,4 +165,4 @@ creatureHealth c = case () of creature_max_health = creatureAbilityScore ToughnessTrait c } instance GetFaction MonsterData where - getFaction = creature_faction \ No newline at end of file + getFaction = creature_faction diff --git a/Roguestar/Lib/HTML/Mustache.hs b/Roguestar/Lib/HTML/Mustache.hs index 46803eda91a2a8e32102bd2dc2d0bcdbb9c5078e..dc3d31e4c73a5dbc7aac3d725ea0f79181a270ef 100644 --- a/Roguestar/Lib/HTML/Mustache.hs +++ b/Roguestar/Lib/HTML/Mustache.hs @@ -4,12 +4,8 @@ module Roguestar.Lib.HTML.Mustache (renderPage, roguestar_muconfig) where import Text.Hastache import Data.Text.Lazy as T import Data.Aeson as Aeson -import Data.Attoparsec.Number as AesonNumber import Data.HashMap.Strict as Map 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 roguestar_muconfig :: (MonadIO m) => MuConfig m @@ -19,17 +15,16 @@ roguestar_muconfig = defaultConfig { muTemplateFileExt = Just ".mustache" } 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 aesonToMu :: (Monad m) => Aeson.Value -> MuType m aesonToMu obj@(Object {}) = MuList [mkAesonContext obj] aesonToMu (Array arr) = MuList $ Prelude.map mkAesonContext $ V.toList arr aesonToMu (String txt) = MuVariable txt -aesonToMu (Number (I num)) = MuVariable num -aesonToMu (Number (D num)) = MuVariable num +aesonToMu (Number n) = MuVariable $ show n aesonToMu (Bool bool) = MuBool bool aesonToMu Null = MuNothing 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) diff --git a/Roguestar/Server/Main.hs b/Roguestar/Server/Main.hs index 4e6fa0c7825a414cb6a03458311f20a11d19f2d0..fe087daf0daed47a857106d60ab5bbf3c52bce77 100644 --- a/Roguestar/Server/Main.hs +++ b/Roguestar/Server/Main.hs @@ -2,8 +2,8 @@ import Prelude import qualified Data.ByteString as BS -import qualified Data.ByteString.Lazy.Char8 as LBS8 import qualified Data.Text as T +import qualified Data.Text.Lazy as LT import Data.Text.Encoding import Control.Exception (SomeException) import qualified Control.Monad.CatchIO as CatchIO @@ -25,7 +25,6 @@ import Roguestar.Lib.Perception import Roguestar.Lib.Data.SpeciesData import Roguestar.Lib.Data.ToolData import Roguestar.Lib.Data.TerrainData as TerrainData -import Roguestar.Lib.Data.MonsterData import Roguestar.Lib.Data.FacingData import Roguestar.Lib.Logging import Roguestar.Lib.UnitTests @@ -68,14 +67,15 @@ makeGlobals = handle500 :: MonadSnap m => m a -> m () handle500 m = (m >> return ()) `CatchIO.catch` \(e::SomeException) -> do - let t = LBS8.pack $ show e + let t = LT.pack $ show e putResponse r - writeBS "Internal Server Error" - writeBS "

Internal Server Error

" - writeBS "

A web handler threw an exception. Details:

" - writeBS "
\n"
-    writeLBS $ htmlEscape t
-    writeBS "\n
" + writeText "oh noes" + writeText "

theirs a porblem

" + writeText "

i'm so sorry the website broke a little

" + writeText "" + writeText "
\n"
+    writeLazyText $ htmlEscape t
+    writeText "\n
" where r = setContentType "text/html" $ setResponseStatus 500 "Internal Server Error" emptyResponse @@ -121,7 +121,10 @@ postFeedback = method POST $ ifTop $ getMemoryStatistics :: IO String 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 else return "(Memory statistics disabled. Use +RTS -T -RTS to collect memory statistics.)" @@ -344,12 +347,13 @@ oops action = return $ error "oops: Unreachable code." Left (DBError bad) -> do putResponse r - writeBS "Gameplay Error" - writeBS "

Gameplay Error

" - writeBS "

Roguestar returned an error condition. Details:

" - writeBS "
\n"
-                  writeLBS $ htmlEscape $ LBS8.pack bad
-                  writeBS "\n
" + writeText "gameplay error" + writeText "

oh oh the game is confused

" + writeText "

some things happened and i didn't know what do

" + writeText "" + writeText "
\n"
+                  writeLazyText $ htmlEscape $ LT.pack bad
+                  writeText "\n
" finishWith =<< getResponse where r = setContentType "text/html" $