From: Lady Date: Sat, 24 Dec 2022 19:24:21 +0000 (-0800) Subject: Add basic microdata support X-Git-Tag: 0.3.1 X-Git-Url: https://git.ladys.computer/Shrine-XSLT/commitdiff_plain/a88092b64fd8b21e71ae97d4ded3f11374334886?hp=b165654fb546b6262512b33a590b2dacf00eb92c Add basic microdata support --- diff --git a/README.markdown b/README.markdown index 00dd2b5..93ff7c1 100644 --- a/README.markdown +++ b/README.markdown @@ -31,14 +31,14 @@ of these files should typically be an H·T·M·L `
` element (remember to declare the X·H·T·M·L namespace!), and you should give it a `@lang` attribute as well. An example is provided. -The `@data-shrine-header` and `@data-shrine-footer` attributes on the -root elements of your pages specify the names of the header and footer -to use on the page. You can use headers and footers to supply page -navigation, branding, and so forth. For each header and footer you -specify, you will need to create a corresponding `$-header.xml` or -`$-footer.xml` (where `$` is the header/footer name) which provides -the contents. These files should be placed in *this* (repository root) -directory, not in `sources/`. +The (entirely optional) `@data-shrine-header` and `@data-shrine-footer` +attributes on the root elements of your pages specify the names of the +header and footer to use on the page. You can use headers and footers +to supply page navigation, branding, and so forth. For each header and +footer you specify, you will need to create a corresponding +`$-header.xml` or `$-footer.xml` (where `$` is the header/footer name) +which provides the contents. These files should be placed in *this* +(repository root) directory, not in `sources/`. The `template.xml` file in this directory contains the main page template, and you should edit it to add styling and so forth to your @@ -50,7 +50,42 @@ Finally, just run `make` from this directory, and H·T·M·L files corresponding to your source files will be created in the `public/` directory (which you can then serve statically from your server). -## Atom Feeds +## Advanced Features + +### Slots + +You can use the `@slot` attribute with a few special values to insert +content in various places :— + +- `@slot="shrine-head"` will place the content into the `` of + the resulting document. This is especially useful for ``, + `<meta>`, and `<style>` elements. + +- For `shrine-header` and `shrine-footer`, there are `-before` and + `-after` slot names which will place content into the beginning or + ending of the shrine header or footer, respectively. + +- You can define your own slots with `<slot>` in templates, headers, + and footers; this will enable a corresponding `@slot` name beginning + with `shrine-template-slot-`, `shrine-header-slot-` or + `shrine-footer-slot`, respectively. + +### Microdata + +You can use the H·T·M·L `@itemprop` attribute to define metadata for +your site pages. The following values are supported :— + +- `shrine-title`: The title of the page. + +- `shrine-id`: A persistent, globally‐unique identifier for the page. + +- `shrine-updated`: The datetime that the page was last updated. + +Multiple values for a single `@itemprop` are not currently supported. +Where possible, X·M·L markup will be preserved when accessing metadata +values. + +### Atom Feeds Any `.atom` files you provide will automatically be filled out with `<id>`s, `<updated>` values, and other necessary information before @@ -59,23 +94,10 @@ feature, you will need to provide a `BASEIRI` variable when you run `make` to allow the X·S·L·T to transform relative links into absolute ones. -It is recommended that :— - -- You do *not* provide your own `<id>`s and rely on the generated ones - (which will be an `oai:` URI derived from the file path). - -- You *do* manually provide `<updated>` times for individual entries - (although not the feed as a whole); otherwise every entry will be - marked as updated every time the feed is generated. - -- All `<link rel="alternate">` elements in `<entry>` elements use a - relative `@href` with a leading slash. This should point to the - *final* location of the entry (within, but not including, `public/`). - There’s an example `feed.atom` provided so you can see what this - feature might look like in practice. +feature might look like in practice. -## Notes +## Additional Notes - The created files have a `.html` extension and need to be served with a `text/html` media type. @@ -100,22 +122,6 @@ There’s an example `feed.atom` provided so you can see what this (`<html>`) element of the template, as will `@lang` and `@xml:lang`. You can use this to help configure page‐specific styling. -- You can use the `@slot` attribute with a few special values to insert - content in various places :— - - - `@slot="shrine-head"` will place the content into the `<head>` of - the resulting document. This is especially useful for `<title>`, - `<meta>`, and `<style>` elements. - - - For `shrine-header` and `shrine-footer`, there are `-before` and - `-after` slot names which will place content into the beginning or - ending of the shrine header or footer, respectively. - - - You can define your own slots with `<slot>` in templates, headers, - and footers; this will enable a corresponding `@slot` name - beginning with `shrine-template-slot-`, `shrine-header-slot-` or - `shrine-footer-slot`, respectively. - - If you delete files from `sources/`, the corresponding files in `public/` will **not** be deleted and will need to be manually removed. An easy way to ensure that there are no outdated files in diff --git a/sources/blog/1972-12-31.xml b/sources/blog/1972-12-31.xml index 9b28668..6c2e54c 100644 --- a/sources/blog/1972-12-31.xml +++ b/sources/blog/1972-12-31.xml @@ -1,3 +1,4 @@ <article xmlns="http://www.w3.org/1999/xhtml" lang="en"> - <h1>My Blog Post</h1> + <h2 itemprop="shrine-title">My Blog Post</h2> + <meta itemprop="shrine-updated" content="1972-12-31T00:00:00Z"/> </article> diff --git a/sources/feed.atom b/sources/feed.atom index 2246fd4..c6f0b53 100644 --- a/sources/feed.atom +++ b/sources/feed.atom @@ -3,7 +3,5 @@ <author>Me</author> <entry> <link rel="alternate" href="/blog/1972-12-31/" type="text/html"/> - <title>My Blog Post - 1972-12-31T00:00:00Z diff --git a/transform.xslt b/transform.xslt index e8ecb3d..876841f 100644 --- a/transform.xslt +++ b/transform.xslt @@ -22,9 +22,13 @@ ___ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. --> + + +]> @@ -82,14 +86,14 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h --> - + - placeholder for slotted element + placeholder for slotted element @@ -100,6 +104,15 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h + + + + placeholder for metadata element + + + @@ -155,10 +168,20 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h - - - <xslt:apply-templates select="$source//html:h1" mode="text"/> - + + + + + + + + + + + <xslt:apply-templates select="$source//html:h1[1]" mode="text"/> + + + @@ -246,7 +269,7 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h --> - + @@ -306,38 +329,97 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h --> + + ./sources + + + + .xml + + + + xml + + + + + + + - + - - - - oai: - - : - - - - / - - - - + + + + + + + + + + + + + oai: + + : + + + + / + + + + + + - Untitled + + + + + + + + + + + + + + + + + + + + + Untitled + + - - - + + + + + + + + + + + + @@ -345,10 +427,10 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h - + @@ -369,6 +451,60 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + xhtml + +
+ +
+
+
+
+
+
+
+