Open GoogleCodeExporter opened 9 years ago
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 <meta> 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 <meta name="description" content="$description$"/> get <meta name="description" content="Listings and reviews of Dutch cheeses"/> 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 @@ <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + $if(descriptionExists)$ + <meta name="description" content="$description$"/> + $endif$ $if(feed)$ <link href="$base$/_feed/" type="application/atom+xml" rel="alternate" title="Sitewide ATOM Feed" /> <link href="$base$/_feed$pageUrl$" type="application/atom+xml" rel="alternate" title="This page's ATOM Feed" /> @@ -21,7 +24,7 @@ <div id="yui-main"> <div id="maincol" class="yui-b"> $userbox()$ - $tabs$ + $tabs$ $content()$ $footer()$ </div>
Original issue reported on code.google.com by gwe...@gmail.com on 17 Jul 2011 at 1:59
gwe...@gmail.com
Attachments:
mirrored at new bugtracker: https://github.com/jgm/gitit/issues/265
Original comment by gwe...@gmail.com on 19 Jul 2011 at 10:25
Original issue reported on code.google.com by
gwe...@gmail.com
on 17 Jul 2011 at 1:59Attachments: