From f3b12ded69ffa722c6dfff60c962170691735797 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Wed, 11 Oct 2017 12:55:24 +1100 Subject: [PATCH] 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 --- config/settings.yml | 1 + src/Handler/Home.hs | 5 +++-- src/Settings.hs | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config/settings.yml b/config/settings.yml index 9975484..a783573 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -33,5 +33,6 @@ database: title: 00dani.me app-name: lebd +username: dani repository: https://gitlab.com/00dani/lebd #analytics: UA-YOURCODE diff --git a/src/Handler/Home.hs b/src/Handler/Home.hs index dd81310..5e2ad57 100644 --- a/src/Handler/Home.hs +++ b/src/Handler/Home.hs @@ -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 diff --git a/src/Settings.hs b/src/Settings.hs index 3f73892..0212013 100644 --- a/src/Settings.hs +++ b/src/Settings.hs @@ -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