Make the user who's displayed on the homepage a configurable setting, so it's easier to use lebd if your name isn't Dani

This commit is contained in:
Danielle McLean 2017-10-11 12:55:24 +11:00
parent 66cb093387
commit f3b12ded69
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
3 changed files with 8 additions and 2 deletions

View file

@ -33,5 +33,6 @@ database:
title: 00dani.me title: 00dani.me
app-name: lebd app-name: lebd
username: dani
repository: https://gitlab.com/00dani/lebd repository: https://gitlab.com/00dani/lebd
#analytics: UA-YOURCODE #analytics: UA-YOURCODE

View file

@ -14,8 +14,9 @@ import Widget.Feed ( hFeed )
getHomeR :: Handler Html getHomeR :: Handler Html
getHomeR = do getHomeR = do
userE@(Entity userId user) <- runDB . getBy404 $ UniqueUser "dani" settings <- asks appSettings
title <- asks $ siteTitle . appSettings userE@(Entity userId user) <- runDB . getBy404 . UniqueUser . siteUsername $ settings
let title = siteTitle settings
entries <- runDB $ selectList [EntryAuthorId ==. userId] [Desc EntryPublished] entries <- runDB $ selectList [EntryAuthorId ==. userId] [Desc EntryPublished]
defaultLayout $ do defaultLayout $ do
atomLink FeedR title atomLink FeedR title

View file

@ -64,6 +64,9 @@ data AppSettings = AppSettings
-- ^ Google Analytics code -- ^ Google Analytics code
, siteTitle :: Text , siteTitle :: Text
-- ^ Site-wide title. -- ^ Site-wide title.
, siteUsername :: Text
-- ^ Username of the site's main user, whose h-card will appear on the
-- homepage.
, appAuthDummyLogin :: Bool , appAuthDummyLogin :: Bool
-- ^ Indicate if auth dummy login should be enabled. -- ^ Indicate if auth dummy login should be enabled.
@ -94,6 +97,7 @@ instance FromJSON AppSettings where
appAnalytics <- o .:? "analytics" appAnalytics <- o .:? "analytics"
siteTitle <- o .: "title" siteTitle <- o .: "title"
siteUsername <- o .: "username"
-- This code enables MySQL's strict mode, without which MySQL will truncate data. -- This code enables MySQL's strict mode, without which MySQL will truncate data.
-- See https://github.com/yesodweb/persistent/wiki/Database-Configuration#strict-mode for details -- See https://github.com/yesodweb/persistent/wiki/Database-Configuration#strict-mode for details