Skip to content

Commit

Permalink
Externalize site name
Browse files Browse the repository at this point in the history
  • Loading branch information
koterpillar committed Jan 15, 2015
1 parent c789f99 commit 8588e29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/Views.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Language
import Models
import Routes

data PageContent a = PageContent { pcTitle :: String
data PageContent a = PageContent { pcTitle :: Maybe String
, pcContent :: HtmlUrl a
}

Expand All @@ -38,9 +38,9 @@ instance Linkable Meta where
link = MetaView . mtSlug

defaultPage :: PageContent a
defaultPage = PageContent { pcTitle = "", pcContent = mempty }
defaultPage = PageContent { pcTitle = Nothing, pcContent = mempty }

mkPage :: String -> HtmlUrl a -> PageContent a
mkPage :: Maybe String -> HtmlUrl a -> PageContent a
mkPage title content = defaultPage { pcTitle = title
, pcContent = content
}
Expand All @@ -65,17 +65,17 @@ template lang page = do
articleListDisplay :: (MonadRoute m, URL m ~ Sitemap, MonadState AppState m, MonadPlus m) =>
LanguagePreference -> [Article] -> m Markup
articleListDisplay lang articles = template lang $
mkPage "List" $(hamletFile "templates/list.hamlet")
mkPage Nothing $(hamletFile "templates/list.hamlet")

articleDisplay :: (MonadRoute m, URL m ~ Sitemap, MonadState AppState m, MonadPlus m) =>
LanguagePreference -> Article -> m Markup
articleDisplay lang article = template lang $
mkPage (langTitle lang article) $(hamletFile "templates/article.hamlet")
mkPage (Just $ langTitle lang article) $(hamletFile "templates/article.hamlet")

metaDisplay :: (MonadRoute m, URL m ~ Sitemap, MonadState AppState m, MonadPlus m) =>
LanguagePreference -> Meta -> m Markup
metaDisplay lang meta = template lang $
mkPage (langTitle lang meta) $(hamletFile "templates/meta.hamlet")
mkPage (Just $ langTitle lang meta) $(hamletFile "templates/meta.hamlet")

langTitle :: HasContent a => LanguagePreference -> a -> String
langTitle lang = fromMaybe "untitled" . listToMaybe . query extractTitle . langContent lang
Expand Down
6 changes: 5 additions & 1 deletion templates/base.hamlet
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ $doctype 5
<html>
<head>
<meta charset="utf-8">
<title>#{pcTitle page}
<title>
$maybe title <- pcTitle page
#{title} - #{langString "siteName"}
$nothing
#{langString "siteName"}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
Expand Down

0 comments on commit 8588e29

Please sign in to comment.