From 062dd10b9950bb510723d1aabbd21de365d98571 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Thu, 5 Oct 2017 09:58:32 +1100 Subject: [PATCH] Display lebd version info in the footer next to the license info --- config/settings.yml | 2 ++ package.yaml | 1 + src/Foundation.hs | 5 +++++ src/Settings.hs | 6 ++++++ templates/default-layout-wrapper.hamlet | 1 + templates/default-layout.cassius | 2 ++ templates/default-layout.hamlet | 8 ++++++-- 7 files changed, 23 insertions(+), 2 deletions(-) diff --git a/config/settings.yml b/config/settings.yml index 4db7bea..9975484 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -32,4 +32,6 @@ database: poolsize: "_env:MYSQL_POOLSIZE:10" title: 00dani.me +app-name: lebd +repository: https://gitlab.com/00dani/lebd #analytics: UA-YOURCODE diff --git a/package.yaml b/package.yaml index 6242801..e7a3a8f 100644 --- a/package.yaml +++ b/package.yaml @@ -46,6 +46,7 @@ dependencies: - time - case-insensitive - wai +- gitrev >= 1.3 && <1.4 - libravatar >=0.4 && <0.5 - yesod-sitemap >=1.4 && <1.5 diff --git a/src/Foundation.hs b/src/Foundation.hs index 03f2793..ac5ac45 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -20,6 +20,11 @@ import Yesod.Default.Util (addStaticContentExternal) import Yesod.Core.Types (Logger) import qualified Yesod.Core.Unsafe as Unsafe +import Development.GitRev (gitBranch) + +appVersion :: Text +appVersion = $(gitBranch) + -- | The foundation datatype for your application. This can be a good place to -- keep settings and values requiring initialization before your application -- starts running, such as database connections. Every handler will have diff --git a/src/Settings.hs b/src/Settings.hs index e1ea0d1..c127a64 100644 --- a/src/Settings.hs +++ b/src/Settings.hs @@ -64,6 +64,10 @@ data AppSettings = AppSettings -- ^ Google Analytics code , appTitle :: Maybe Text -- ^ Site-wide title. + , appName :: Text + -- ^ Name of application used to generate site. + , appRepository :: Text + -- ^ URL of repository for application source. , appAuthDummyLogin :: Bool -- ^ Indicate if auth dummy login should be enabled. @@ -94,6 +98,8 @@ instance FromJSON AppSettings where appAnalytics <- o .:? "analytics" appTitle <- o .:? "title" + appName <- o .: "app-name" + appRepository <- o .: "repository" -- 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 diff --git a/templates/default-layout-wrapper.hamlet b/templates/default-layout-wrapper.hamlet index 434486c..96a0d0a 100644 --- a/templates/default-layout-wrapper.hamlet +++ b/templates/default-layout-wrapper.hamlet @@ -7,6 +7,7 @@ $doctype 5 #{pageTitle pc} <meta name="description" content=""> <meta name="author" content=""> + <meta name="generator" content="#{appName $ appSettings master} #{appVersion}"> $maybe route <- mcurrentRoute <link rel="canonical" href=@{route}> diff --git a/templates/default-layout.cassius b/templates/default-layout.cassius index bb5af45..e5afefa 100644 --- a/templates/default-layout.cassius +++ b/templates/default-layout.cassius @@ -13,3 +13,5 @@ body > footer text-align: center padding-bottom: 1em + display: flex + justify-content: space-evenly diff --git a/templates/default-layout.hamlet b/templates/default-layout.hamlet index 3faa243..a3845b3 100644 --- a/templates/default-layout.hamlet +++ b/templates/default-layout.hamlet @@ -28,5 +28,9 @@ ^{widget} <footer> - All content on this site is licensed under - a <a rel="license" href="//creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>. + <p> + all content licensed under + <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">cc by-sa 4.0 + <p> + powered by + <a href="#{appRepository $ appSettings master}/tree/#{appVersion}">#{appName $ appSettings master} #{appVersion}