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:
parent
66cb093387
commit
f3b12ded69
3 changed files with 8 additions and 2 deletions
|
@ -33,5 +33,6 @@ database:
|
|||
|
||||
title: 00dani.me
|
||||
app-name: lebd
|
||||
username: dani
|
||||
repository: https://gitlab.com/00dani/lebd
|
||||
#analytics: UA-YOURCODE
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue