diff options
author | tdro <tdro@noreply.example.com> | 2022-12-06 22:13:01 -0500 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2022-12-06 22:13:01 -0500 |
commit | abcab1b57d6bc3e6e44ff4d143f33bee8cc15a4d (patch) | |
tree | c8b4a1bac29ecd349a4d8e76ee264dbb21f1768e | |
parent | 848f6a7f9dc8db283766e657c19aa7d2bfecfb2a (diff) | |
download | canory-0.11.8.tar.gz canory-0.11.8.tar.bz2 canory-0.11.8.zip |
themes/default/layouts/_default/sitemap.xml: Add schema and transform0.11.8
Validate with schema. Switch to xml-data identifier attribute and
adjust file name-spacing in configuration
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | assets/css/default.css | 8 | ||||
-rw-r--r-- | assets/schemas/sitemap-v0.9.xsd | 113 | ||||
-rw-r--r-- | assets/schemas/sitemapindex-v0.9.xsd | 71 | ||||
-rw-r--r-- | config.json | 14 | ||||
-rw-r--r-- | config.toml | 13 | ||||
-rw-r--r-- | config.yaml | 13 | ||||
-rw-r--r-- | themes/default/layouts/_default/home.xslt.rss.xsl (renamed from themes/default/layouts/_default/home.xslt.xsl) | 2 | ||||
-rw-r--r-- | themes/default/layouts/_default/home.xslt.sitemap.xsl | 97 | ||||
-rw-r--r-- | themes/default/layouts/_default/sitemap.xml | 68 | ||||
-rw-r--r-- | themes/default/layouts/partials/base-footer.html | 3 | ||||
-rw-r--r-- | themes/default/layouts/shortcodes/version.html | 2 |
12 files changed, 378 insertions, 32 deletions
@@ -47,7 +47,11 @@ test-xml: test-rss: xmllint --noout --relaxng assets/schemas/rss-v2.0.rng public/rss.xml -# xmllint --noout --schema assets/schemas/rss-v2.0.xsd public/rss.xml +# xmllint --noout --schema assets/schemas/rss-v2.0.xsd public/rss.xml + +test-sitemap: + xmllint --noout --schema assets/schemas/sitemap-v0.9.xsd public/sitemap.xml +# xmllint --noout --schema assets/schemas/sitemapindex-v0.9.xsd public/sitemap.xml test-jsonfeed: check-jsonschema --schemafile assets/schemas/jsonfeed-v1.1.json public/index.json diff --git a/assets/css/default.css b/assets/css/default.css index b7840e5..312a180 100644 --- a/assets/css/default.css +++ b/assets/css/default.css @@ -1908,14 +1908,18 @@ main micro-card:first-of-type reaction-tip img { padding-left: 2rem; } -[data="xml"] micro-thumbnail { +[xml-data] micro-thumbnail { display: block; } -[data="xml"] column-middle nav section { +[xml-data] column-middle nav section { flex-grow: 1; } +[xml-data="sitemap"] main section { + padding: 1rem; +} + /* ----- Responsive ----- */ @media screen and (max-width: 1220px) { diff --git a/assets/schemas/sitemap-v0.9.xsd b/assets/schemas/sitemap-v0.9.xsd new file mode 100644 index 0000000..e27680e --- /dev/null +++ b/assets/schemas/sitemap-v0.9.xsd @@ -0,0 +1,113 @@ +<?xml version="1.0"?> +<xsd:schema + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" + targetNamespace="http://www.sitemaps.org/schemas/sitemap/0.9" + elementFormDefault="qualified" + > + <xsd:annotation> + <xsd:documentation> + XML Schema for Sitemap files. + Last Modifed 2008-03-26 + </xsd:documentation> + </xsd:annotation> + <xsd:element name="urlset"> + <xsd:annotation> + <xsd:documentation> + Container for a set of up to 50,000 document elements. + This is the root element of the XML file. + </xsd:documentation> + </xsd:annotation> + <xsd:complexType> + <xsd:sequence> + <xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="strict"/> + <xsd:element name="url" type="tUrl" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:complexType name="tUrl"> + <xsd:annotation> + <xsd:documentation> + Container for the data needed to describe a document to crawl. + </xsd:documentation> + </xsd:annotation> + <xsd:sequence> + <xsd:element name="loc" type="tLoc"/> + <xsd:element name="lastmod" type="tLastmod" minOccurs="0"/> + <xsd:element name="changefreq" type="tChangeFreq" minOccurs="0"/> + <xsd:element name="priority" type="tPriority" minOccurs="0"/> + <xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="strict"/> + </xsd:sequence> + </xsd:complexType> + <xsd:simpleType name="tLoc"> + <xsd:annotation> + <xsd:documentation> + REQUIRED: The location URI of a document. + The URI must conform to RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt). + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:anyURI"> + <xsd:minLength value="12"/> + <xsd:maxLength value="2048"/> + </xsd:restriction> + </xsd:simpleType> + <xsd:simpleType name="tLastmod"> + <xsd:annotation> + <xsd:documentation> + OPTIONAL: The date the document was last modified. The date must conform + to the W3C DATETIME format (http://www.w3.org/TR/NOTE-datetime). + Example: 2005-05-10 + Lastmod may also contain a timestamp. + Example: 2005-05-10T17:33:30+08:00 + </xsd:documentation> + </xsd:annotation> + <xsd:union> + <xsd:simpleType> + <xsd:restriction base="xsd:date"/> + </xsd:simpleType> + <xsd:simpleType> + <xsd:restriction base="xsd:dateTime"/> + </xsd:simpleType> + </xsd:union> + </xsd:simpleType> + <xsd:simpleType name="tChangeFreq"> + <xsd:annotation> + <xsd:documentation> + OPTIONAL: Indicates how frequently the content at a particular URL is + likely to change. The value "always" should be used to describe + documents that change each time they are accessed. The value "never" + should be used to describe archived URLs. Please note that web + crawlers may not necessarily crawl pages marked "always" more often. + Consider this element as a friendly suggestion and not a command. + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="always"/> + <xsd:enumeration value="hourly"/> + <xsd:enumeration value="daily"/> + <xsd:enumeration value="weekly"/> + <xsd:enumeration value="monthly"/> + <xsd:enumeration value="yearly"/> + <xsd:enumeration value="never"/> + </xsd:restriction> + </xsd:simpleType> + <xsd:simpleType name="tPriority"> + <xsd:annotation> + <xsd:documentation> + OPTIONAL: The priority of a particular URL relative to other pages + on the same site. The value for this element is a number between + 0.0 and 1.0 where 0.0 identifies the lowest priority page(s). + The default priority of a page is 0.5. Priority is used to select + between pages on your site. Setting a priority of 1.0 for +100 4451 100 4451 0 0 15017 0 --:--:-- --:--:-- --:--:-- 15037 +all URLs + will not help you, as the relative priority of pages on your site + is what will be considered. + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:decimal"> + <xsd:minInclusive value="0.0"/> + <xsd:maxInclusive value="1.0"/> + </xsd:restriction> + </xsd:simpleType> +</xsd:schema> diff --git a/assets/schemas/sitemapindex-v0.9.xsd b/assets/schemas/sitemapindex-v0.9.xsd new file mode 100644 index 0000000..c35d50a --- /dev/null +++ b/assets/schemas/sitemapindex-v0.9.xsd @@ -0,0 +1,71 @@ +<?xml version="1.0"?> +<xsd:schema + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" + targetNamespace="http://www.sitemaps.org/schemas/sitemap/0.9" + elementFormDefault="qualified" + > + <xsd:annotation> + <xsd:documentation> + XML Schema for Sitemap index files. + Last Modifed 2009-04-08 + </xsd:documentation> + </xsd:annotation> + <xsd:element name="sitemapindex"> + <xsd:annotation> + <xsd:documentation> + Container for a set of up to 50,000 sitemap URLs. + This is the root element of the XML file. + </xsd:documentation> + </xsd:annotation> + <xsd:complexType> + <xsd:sequence> + <xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="strict"/> + <xsd:element name="sitemap" type="tSitemap" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:complexType name="tSitemap"> + <xsd:annotation> + <xsd:documentation> + Container for the data needed to describe a sitemap. + </xsd:documentation> + </xsd:annotation> + <xsd:sequence> + <xsd:element name="loc" type="tLocSitemap"/> + <xsd:element name="lastmod" type="tLastmodSitemap" minOccurs="0"/> + <xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="strict"/> + </xsd:sequence> + </xsd:complexType> + <xsd:simpleType name="tLocSitemap"> + <xsd:annotation> + <xsd:documentation> + REQUIRED: The location URI of a sitemap. + The URI must conform to RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt). + </xsd:documentation> + </xsd:annotation> + <xsd:restriction base="xsd:anyURI"> + <xsd:minLength value="12"/> + <xsd:maxLength value="2048"/> + </xsd:restriction> + </xsd:simpleType> + <xsd:simpleType name="tLastmodSitemap"> + <xsd:annotation> + <xsd:documentation> + OPTIONAL: The date the document was last modified. The date must conform + to the W3C DATETIME format (http://www.w3.org/TR/NOTE-datetime). + Example: 2005-05-10 + Lastmod may also contain a timestamp. + Example: 2005-05-10T17:33:30+08:00 + </xsd:documentation> + </xsd:annotation> + <xsd:union> + <xsd:simpleType> + <xsd:restriction base="xsd:date"/> + </xsd:simpleType> + <xsd:simpleType> + <xsd:restriction base="xsd:dateTime"/> + </xsd:simpleType> + </xsd:union> + </xsd:simpleType> +</xsd:schema> diff --git a/config.json b/config.json index 25762ab..f4fad5d 100644 --- a/config.json +++ b/config.json @@ -203,10 +203,14 @@ "baseName": "rss", "mediaType": "application/rss+xml" }, - "xslt": { + "xslt.rss": { "baseName": "rss", "mediaType": "application/xslt+xml" }, + "xslt.sitemap": { + "baseName": "sitemap", + "mediaType": "application/xslt+xml" + }, "authors": { "path": "authors", "baseName": "index", @@ -240,7 +244,8 @@ "home": [ "html", "rss", - "xslt", + "xslt.rss", + "xslt.sitemap", "json", "authors", "sources", @@ -347,5 +352,10 @@ "target": "assets/public" } ] + }, + "sitemap": { + "changefreq": "weekly", + "filename": "sitemap.xml", + "priority": 0.5 } } diff --git a/config.toml b/config.toml index e8e9778..ce885d1 100644 --- a/config.toml +++ b/config.toml @@ -146,10 +146,14 @@ enableRobotsTXT = true baseName = "rss" mediaType = "application/rss+xml" - [outputFormats.xslt] + [outputFormats."xslt.rss"] baseName = "rss" mediaType = "application/xslt+xml" + [outputFormats."xslt.sitemap"] + baseName = "sitemap" + mediaType = "application/xslt+xml" + [outputFormats.authors] path = "authors" baseName = "index" @@ -179,7 +183,7 @@ enableRobotsTXT = true mediaType = "application/manifest+json" [outputs] - home = ["html", "rss", "xslt", "json", "authors", "sources", "browserconfig", "history", "records", "webmanifest"] + home = ["html", "rss", "xslt.rss", "xslt.sitemap", "json", "authors", "sources", "browserconfig", "history", "records", "webmanifest"] section = ["html", "rss"] taxonomy = ["html", "rss"] term = ["html", "rss"] @@ -264,3 +268,8 @@ enableRobotsTXT = true [[module.mounts]] source = "public" target = "assets/public" + +[sitemap] + changefreq = "weekly" + filename = "sitemap.xml" + priority = 0.5 diff --git a/config.yaml b/config.yaml index 5dbe841..3177b5a 100644 --- a/config.yaml +++ b/config.yaml @@ -131,9 +131,12 @@ outputFormats: rss: baseName: rss mediaType: application/rss+xml - xslt: + xslt.rss: baseName: rss mediaType: application/xslt+xml + xslt.sitemap: + baseName: sitemap + mediaType: application/xslt+xml authors: path: authors baseName: index @@ -161,7 +164,8 @@ outputs: home: - html - rss - - xslt + - xslt.rss + - xslt.sitemap - json - authors - sources @@ -231,3 +235,8 @@ module: target: data/authors - source: public target: assets/public + +sitemap: + changefreq: weekly + filename: sitemap.xml + priority: 0.5 diff --git a/themes/default/layouts/_default/home.xslt.xsl b/themes/default/layouts/_default/home.xslt.rss.xsl index c242f70..e0be815 100644 --- a/themes/default/layouts/_default/home.xslt.xsl +++ b/themes/default/layouts/_default/home.xslt.rss.xsl @@ -8,7 +8,7 @@ > <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> - <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" data="xml"> + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" xml-data=""> <head> {{ printf `<title><xsl:value-of select="/rss/channel/title"/> Web Feed</title>` | safeHTML }} <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> diff --git a/themes/default/layouts/_default/home.xslt.sitemap.xsl b/themes/default/layouts/_default/home.xslt.sitemap.xsl new file mode 100644 index 0000000..167b773 --- /dev/null +++ b/themes/default/layouts/_default/home.xslt.sitemap.xsl @@ -0,0 +1,97 @@ +{{- printf `<?xml version="1.0" encoding="utf-8"?>` | safeHTML }} +<xsl:stylesheet + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9" + version="1.1" +> + <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/> + <xsl:template match="/"> + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" xml-data="sitemap"> + <head> + <title>{{ $.Site.Title }} Site Map</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/> + {{- $default := resources.Get "css/default.css" -}} + {{- if .Site.Params.site.production -}} + {{ $css := slice $default | resources.Concat "css/bundle.css" | resources.Minify | fingerprint }} + <link rel="stylesheet" type="text/css" href="{{ $css.Permalink }}"/> + {{- else }} + <link rel="stylesheet" type="text/css" href="{{ $default.Permalink }}"/> + {{- end }} + </head> + <body> + <column-left> + </column-left> + <column-middle> + <main> + <nav> + <icon-button> + <a onclick="window.history.go(-1); return false;"> + {{ safeHTML (readFile (print (partial "function-paths.html" "static") "/icons/feather/arrow-left.svg")) }} + <small>Back</small> + </a> + </icon-button> + <section> + <h2>{{ $.Site.Title }} Site Map</h2> + <small>Site Map Preview</small> + </section> + {{ if .Site.Menus.main }} + {{ range .Site.Menus.main }} + <icon-navigator hidden=""> + <icon-button> + <a + id="nav-middle-{{ path.Base .Identifier }}" + href="{{ .URL | absURL }}" + > + {{ with .Identifier }} {{ $icon := print (partial + "function-paths.html" "static") "/icons/" . ".svg" }} {{ safeHTML + (readFile $icon) }} {{ end }} + <small>{{ delimit (first 1 (split .Name " ")) " " }}</small> + </a> + </icon-button> + </icon-navigator> + {{ end }} + {{ end }} + </nav> + <navigation-separator><hr hidden=""></hr></navigation-separator> + <section> + <table> + <thead> + <tr> + <th> + <code> + <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> + Uniform Resource Locators (URLs) + </code> + </th> + </tr> + </thead> + <tbody> + <xsl:for-each select="sitemap:urlset/sitemap:url"> + <tr> + <td> + <a> + <xsl:attribute name="href"> + <xsl:value-of select="sitemap:loc" /> + </xsl:attribute> + <xsl:attribute name="title"> + Last Modified: <xsl:value-of select="sitemap:lastmod" /> + Frequency: <xsl:value-of select="sitemap:changefreq" /> + Priority: <xsl:value-of select="sitemap:priority" /> + </xsl:attribute> + <xsl:value-of select="sitemap:loc" /> + </a> + </td> + </tr> + </xsl:for-each> + </tbody> + </table> + </section> + </main> + </column-middle> + <column-right> + </column-right> + </body> + </html> + </xsl:template> +</xsl:stylesheet> diff --git a/themes/default/layouts/_default/sitemap.xml b/themes/default/layouts/_default/sitemap.xml index 63f5119..b751f65 100644 --- a/themes/default/layouts/_default/sitemap.xml +++ b/themes/default/layouts/_default/sitemap.xml @@ -1,22 +1,50 @@ -{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} -<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" - xmlns:xhtml="http://www.w3.org/1999/xhtml"> - {{ range .Data.Pages }} - <url> - <loc>{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }} - <lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }} - <changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }} - <priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }} - <xhtml:link - rel="alternate" - hreflang="{{ .Language.Lang }}" - href="{{ .Permalink }}" - />{{ end }} - <xhtml:link - rel="alternate" - hreflang="{{ .Language.Lang }}" - href="{{ .Permalink }}" - />{{ end }} - </url> +{{- printf `<?xml version="1.0" encoding="utf-8" standalone="yes"?>` | safeHTML }} +{{ printf `<?xml-stylesheet href="/sitemap.xsl" type="text/xsl"?>` | safeHTML }} + +{{- $changefreq := "weekly" -}} +{{- $priority := 0.5 -}} +{{- $lastmod := now.Format "2006-01-02T15:04:05-07:00" }} + +<urlset + xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" + xmlns:xhtml="http://www.w3.org/1999/xhtml" +> + {{- $notExpired := where .Data.Pages "Params.expirydate" "eq" nil -}} + {{- $notUnlisted := where .Data.Pages "Params.unlisted" "eq" nil -}} + {{- $filteredPages := $notExpired | intersect $notUnlisted -}} + {{- range $filteredPages }} + + {{- with .Sitemap.ChangeFreq -}} + {{- $changefreq = . -}} + {{- end -}} + + {{- if ge .Sitemap.Priority 0.0 -}} + {{- $priority = .Sitemap.Priority -}} + {{- end -}} + + {{- if not .Lastmod.IsZero -}} + {{- $lastmod = safeHTML (.Lastmod.Format "2006-01-02T15:04:05-07:00") -}} + {{- end }} + + <url> + <loc>{{ .Permalink }}</loc> + <lastmod>{{ $lastmod }}</lastmod> + <changefreq>{{ $changefreq }}</changefreq> + <priority>{{ $priority }}</priority> + {{- if .IsTranslated -}} + {{ range .Translations }} + <xhtml:link + rel="alternate" + hreflang="{{ .Language.Lang }}" + href="{{ .Permalink }}" + /> + {{- end -}} + <xhtml:link + rel="alternate" + hreflang="{{ .Language.Lang }}" + href="{{ .Permalink }}" + /> + {{ end }} + </url> {{ end }} </urlset> diff --git a/themes/default/layouts/partials/base-footer.html b/themes/default/layouts/partials/base-footer.html index bda969c..f24b8d6 100644 --- a/themes/default/layouts/partials/base-footer.html +++ b/themes/default/layouts/partials/base-footer.html @@ -8,5 +8,6 @@ {{ $author.title }} {{- end -}} {{- end }} - | Copyright © {{ now.Format "2006"}} + · Copyright © {{ now.Format "2006"}} + · <a href="/sitemap.xml" >Site Map</a> </footer> diff --git a/themes/default/layouts/shortcodes/version.html b/themes/default/layouts/shortcodes/version.html index 9c993b3..48aed2c 100644 --- a/themes/default/layouts/shortcodes/version.html +++ b/themes/default/layouts/shortcodes/version.html @@ -1,4 +1,4 @@ -{{- $version := "0.11.7" -}} +{{- $version := "0.11.8" -}} {{- $number := default false (.Get "number" | default (.Get 0)) -}} {{- $clone := default false (.Get "clone" | default (.Get 1)) -}} |