Simplify site title handling, automatically suffix site title to all pages
This commit is contained in:
parent
4088735c69
commit
1b8a07a5f6
8 changed files with 17 additions and 13 deletions
|
@ -1,4 +1,5 @@
|
|||
{-# LANGUAGE NoImplicitPrelude #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
module Handler.Entries where
|
||||
|
||||
|
@ -6,6 +7,7 @@ import Import
|
|||
|
||||
import Web.Slug ( Slug )
|
||||
import Yesod.AtomFeed ( atomLink )
|
||||
import qualified Data.Text as T
|
||||
|
||||
import qualified Entry.Kind as K
|
||||
import Widget.Entry ( entryR, hEntry )
|
||||
|
@ -14,9 +16,10 @@ import Widget.Feed ( hFeed )
|
|||
getEntriesR :: K.EntryKind -> Handler Html
|
||||
getEntriesR kind = do
|
||||
entries <- runDB $ selectList [EntryKind ==. kind] [Desc EntryPublished]
|
||||
title <- asks $ siteTitle . appSettings
|
||||
defaultLayout $ do
|
||||
setTitle . toHtml . K.pluralise $ kind
|
||||
FeedKindR kind `atomLink` K.pluralise kind
|
||||
atomLink (FeedKindR kind) $ T.concat [K.pluralise kind, " ~ ", title]
|
||||
$(widgetFile "entries")
|
||||
|
||||
checkMatching :: K.EntryKind -> Slug -> Entry -> Bool
|
||||
|
|
|
@ -32,7 +32,7 @@ toFeed entries@(latestEntry:_) = (toFeed [])
|
|||
, feedUpdated = entryUpdated $ entityVal latestEntry
|
||||
}
|
||||
toFeed [] = Feed
|
||||
{ feedTitle = fromMaybe "" . appTitle $ compileTimeAppSettings
|
||||
{ feedTitle = siteTitle compileTimeAppSettings
|
||||
, feedLinkSelf = FeedR
|
||||
, feedLinkHome = HomeR
|
||||
, feedAuthor = ""
|
||||
|
|
|
@ -15,14 +15,10 @@ import Widget.Feed ( hFeed )
|
|||
getHomeR :: Handler Html
|
||||
getHomeR = do
|
||||
userE@(Entity userId user) <- runDB . getBy404 $ UniqueUser "dani"
|
||||
maybeTitle <- asks $ appTitle . appSettings
|
||||
title <- asks $ siteTitle . appSettings
|
||||
entries <- runDB $ selectList [EntryAuthorId ==. userId] [Desc EntryPublished]
|
||||
defaultLayout $ do
|
||||
case maybeTitle of
|
||||
Just title -> do
|
||||
setTitle $ toHtml title
|
||||
atomLink FeedR title
|
||||
Nothing -> return ()
|
||||
atomLink FeedR title
|
||||
toWidgetHead
|
||||
[hamlet|
|
||||
<meta name="author" content=#{userFullName user}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue