Refactor excessive do notation. Complete oldschool and gibberish generators. Add frontend functionality for selecting from multiple generator styles. Add config requirement for admin email. Add admin email to header.

This commit is contained in:
2022-08-07 16:22:09 -05:00
parent 3c4c4f8d30
commit 2a4787fc84
16 changed files with 197 additions and 159 deletions

View File

@ -6,6 +6,7 @@ import Core.Templates (renderIndex, renderStyle)
import Feature.Sharing.HTTP as Sharing
import Feature.Generation.HTTP as Generation
import Control.Monad.Reader (ask, lift)
import Data.Maybe (Maybe (Nothing))
import Network.Wai.Middleware.RequestLogger (logStdoutDev)
import Network.Wai.Middleware.Static
@ -19,7 +20,8 @@ app = do
-- Core Routes
get "/" $ do
html $ renderIndex "/"
conf <- lift ask
html $ renderIndex "/" (adminEmail conf)
get "/style.css" $ do
setHeader "Content-Type" "text/css"

View File

@ -22,11 +22,10 @@ main db = do
close conn
dbPath :: PurrAction String
dbPath = do
conf <- lift ask
return $ dbFile conf
dbPath = lift ask >>= (\a -> return $ dbFile a)
encKey :: PurrAction String
encKey = do
conf <- lift ask
return $ dbKey conf
encKey = lift ask >>= (\a -> return $ dbKey a)
confLinkLength :: PurrAction Int
confLinkLength = lift ask >>= (\a -> return $ linkLength a)

View File

@ -13,8 +13,8 @@ import qualified Data.Text.Lazy as LT
import Prelude
renderIndex :: String -> LT.Text
renderIndex link = renderHtml ( $(shamletFile "./views/index.hamlet") )
renderIndex :: String -> String -> LT.Text
renderIndex link email = renderHtml ( $(shamletFile "./views/index.hamlet") )
where
hsUserLink = hxVals "userLink" link

View File

@ -22,4 +22,5 @@ data DhallConfig = DhallConfig
, dbFile :: String
, dbKey :: String
, linkLength :: Int
, adminEmail :: String
} deriving (Generic, Show)