Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

description metadata #265

Open
gwern opened this Issue · 2 comments

2 participants

@gwern

(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()$
@jgm
Owner
@gwern

Testing? This doesn't even compile. (Apparently the suggestively named 'page' variable is actually a PageLayout, whatever that is, with no obvious route to the Page or its metadata.)

Or did you mean the element itself and the description: field? It works fine in Hakyll (recently edited to imitate Gitit's trailing '...'). You can see it on gwern.net - validates and everything: http://validator.w3.org/check?uri=http%3A%2F%2Fwww.gwern.net&charset=%28detect+automatically%29&doctype=Inline&group=0

@gwern gwern closed this
@gwern gwern reopened this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.