description metadata
- Dominant language
- Haskell
- Stars
- 2.3k
- Forks
- 231
- PR merge metrics
- No merged PRs in 30d
Description
(Didn't realize the Google bugtracker was closed and posted to https://code.google.com/p/gitit/issues/detail?id=121 )
Currently Gitit only supports format/categories/toc/title (http://gitit.johnmacfarlane.net/README#page-metadata). There's another obvious bit of metadata, a description, which maps onto a standard HTML tag which is apparently widely used by search engines and other tools.
So one could have a
---
description: Listings and reviews of Dutch cheeses
...
And using
get
Adding a new metadata field turns out to be... not as easy as I had hoped. Gitit's dependencies are taking forever to install so I can't test this now, but I think something close to this change should work to define a new metadata field and then conditionally include it in an appropriate metadata HTML tag:
diff --git a/Network/Gitit/Layout.hs b/Network/Gitit/Layout.hs
index 7073df1..78b6a7c 100644
--- a/Network/Gitit/Layout.hs
+++ b/Network/Gitit/Layout.hs
@@ -106,6 +106,7 @@ filledPageTemplate base' cfg layout htmlContents templ =
T.setAttribute "messages" (pgMessages layout) .
T.setAttribute "usecache" (useCache cfg) .
T.setAttribute "content" (renderHtmlFragment htmlContents) .
- setBoolAttr "descriptionExists" (pageDescription page /= "")
setBoolAttr "wikiupload" ( uploadsAllowed cfg) $
templ
diff --git a/Network/Gitit/Page.hs b/Network/Gitit/Page.hs
index e0fc274..3f89612 100644
--- a/Network/Gitit/Page.hs
+++ b/Network/Gitit/Page.hs
@@ -96,6 +96,7 @@ stringToPage conf pagename raw =
, pageLHS = defaultLHS conf
, pageTOC = tableOfContents conf
, pageTitle = pagename
- ```
, pageDescription = ""
, pageCategories = []
, pageText = filter (/= '\r') rest
, pageMeta = ls }
```
@@ -109,6 +110,7 @@ adjustPage ("toc", val) page' = page' {
pageTOC = map toLower val `elem` ["yes","true"] }
adjustPage ("categories", val) page' =
page' { pageCategories = splitCategories val ++ pageCategories page' }
+adjustPage ("description", val) page' = page' { description = val }
adjustPage (_, _) page' = page'
-- | Write a string (the contents of a page file) corresponding to
diff --git a/Network/Gitit/Types.hs b/Network/Gitit/Types.hs
index 67b70c2..d121ea6 100644
--- a/Network/Gitit/Types.hs
+++ b/Network/Gitit/Types.hs
@@ -153,6 +153,7 @@ data Page = Page {
, pageTOC :: Bool
, pageTitle :: String
, pageCategories :: [String]
- , pageDescription :: String
, pageText :: String
, pageMeta :: [(String, String)]
} deriving (Read, Show)
diff --git a/data/templates/page.st b/data/templates/page.st
index e1a1725..5e6af16 100644
--- a/data/templates/page.st
+++ b/data/templates/page.st
@@ -3,6 +3,9 @@
- $if(descriptionExists)$
-
- $endif$
$if(feed)$
@@ -21,7 +24,7 @@
$userbox()$
- $tabs$
- $tabs$
$content()$
$footer()$
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.