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
app-name: lebd
username: dani
repository: https://gitlab.com/00dani/lebd
#analytics: UA-YOURCODE

View file

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

View file

@ -64,6 +64,9 @@ data AppSettings = AppSettings
-- ^ Google Analytics code
, siteTitle :: Text
-- ^ Site-wide title.
, siteUsername :: Text
-- ^ Username of the site's main user, whose h-card will appear on the
-- homepage.
, appAuthDummyLogin :: Bool
-- ^ Indicate if auth dummy login should be enabled.
@ -94,6 +97,7 @@ instance FromJSON AppSettings where
appAnalytics <- o .:? "analytics"
siteTitle <- o .: "title"
siteUsername <- o .: "username"
-- 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