diff options
author | tdro <tdro@noreply.example.com> | 2022-05-17 04:22:38 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2022-05-17 04:22:38 -0400 |
commit | bf1d45824563376491c721d36051545fceb1c10a (patch) | |
tree | 645a7eadd705f7961f49a7737f2a3925f7652788 | |
parent | efebd74d531e87d7dfb1bec88ab3969eae5c99c7 (diff) | |
download | canory-bf1d45824563376491c721d36051545fceb1c10a.tar.gz canory-bf1d45824563376491c721d36051545fceb1c10a.tar.bz2 canory-bf1d45824563376491c721d36051545fceb1c10a.zip |
themes/default/layouts/_default/rss: Style feed
-rw-r--r-- | config.json | 14 | ||||
-rw-r--r-- | config.toml | 13 | ||||
-rw-r--r-- | config.yaml | 11 | ||||
-rw-r--r-- | themes/default/layouts/_default/home.rss-style.xsl | 143 | ||||
-rw-r--r-- | themes/default/layouts/_default/rss.xml | 8 |
5 files changed, 183 insertions, 6 deletions
diff --git a/config.json b/config.json index f800b12..e523e53 100644 --- a/config.json +++ b/config.json @@ -162,6 +162,13 @@ } } }, + "mediaTypes": { + "application/xslt+xml": { + "suffixes": [ + "xsl" + ] + } + }, "outputFormats": { "html": { "baseName": "index", @@ -173,7 +180,11 @@ }, "rss": { "baseName": "rss", - "mediaType": "application/xml" + "mediaType": "application/rss+xml" + }, + "rss-style": { + "baseName": "rss", + "mediaType": "application/xslt+xml" }, "authors": { "path": "authors", @@ -208,6 +219,7 @@ "home": [ "html", "rss", + "rss-style", "json", "authors", "sources", diff --git a/config.toml b/config.toml index 90a38c5..0f9e24f 100644 --- a/config.toml +++ b/config.toml @@ -115,6 +115,11 @@ enableRobotsTXT = true [params.search.verification] +[mediaTypes] + + [mediaTypes."application/xslt+xml"] + suffixes = ["xsl"] + [outputFormats] [outputFormats.html] @@ -127,7 +132,11 @@ enableRobotsTXT = true [outputFormats.rss] baseName = "rss" - mediaType = "application/xml" + mediaType = "application/rss+xml" + + [outputFormats.rss-style] + baseName = "rss" + mediaType = "application/xslt+xml" [outputFormats.authors] path = "authors" @@ -158,7 +167,7 @@ enableRobotsTXT = true mediaType = "application/manifest+json" [outputs] - home = ["html", "rss", "json", "authors", "sources", "browserconfig", "archive-messages", "archive-tags", "webmanifest"] + home = ["html", "rss", "rss-style", "json", "authors", "sources", "browserconfig", "archive-messages", "archive-tags", "webmanifest"] section = ["html", "rss"] taxonomy = ["html", "rss"] term = ["html", "rss"] diff --git a/config.yaml b/config.yaml index 4b00fed..be1b7d8 100644 --- a/config.yaml +++ b/config.yaml @@ -102,6 +102,11 @@ params: bing: yandex: +mediaTypes: + application/xslt+xml: + suffixes: + - xsl + outputFormats: html: baseName: index @@ -111,7 +116,10 @@ outputFormats: mediaType: application/json rss: baseName: rss - mediaType: application/xml + mediaType: application/rss+xml + rss-style: + baseName: rss + mediaType: application/xslt+xml authors: path: authors baseName: index @@ -139,6 +147,7 @@ outputs: home: - html - rss + - rss-style - json - authors - sources diff --git a/themes/default/layouts/_default/home.rss-style.xsl b/themes/default/layouts/_default/home.rss-style.xsl new file mode 100644 index 0000000..d7b0d23 --- /dev/null +++ b/themes/default/layouts/_default/home.rss-style.xsl @@ -0,0 +1,143 @@ +{{- print "<?xml version=\"1.0\" encoding=\"utf-8\"?>" | safeHTML }} +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="3.0"> + <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/> + <xsl:template match="/"> + <html xmlns="http://www.w3.org/1999/xhtml"> + <head> + {{- print "<title><xsl:value-of select=\"/rss/channel/title\"/> Web Feed</title>" | safeHTML }} + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/> + <link rel="stylesheet" type="text/css" href="/css/default.css"/> + </head> + <body> + <column-left> + </column-left> + <column-middle> + <main> + <nav> + <icon-button> + <a id="top" href="#"> + {{ safeHTML (readFile "static/icons/feather/arrow-up.svg") }} + <small>Top</small> + </a> + </icon-button> + + <section> + <h2><xsl:value-of select="/rss/channel/title"/> Feed</h2> + <small>Web Feed Preview</small> + </section> + + <icon-navigator hidden=""> + <icon-button> + <a id="nav-middle-home" href="/"> + {{ safeHTML (readFile "static/icons/feather/home.svg") }} + <small>Home</small> + </a> + </icon-button> + </icon-navigator> + + <icon-navigator hidden=""> + <icon-button> + <a id="nav-middle-tag" href="/tags/"> + {{ safeHTML (readFile "static/icons/feather/tag.svg") }} + <small>Tags</small> + </a> + </icon-button> + </icon-navigator> + + <icon-navigator hidden=""> + <icon-button> + <a id="nav-middle-clock" href="/archives/messages/"> + {{ safeHTML (readFile "static/icons/tabler/clock.svg") }} + <small>History</small> + </a> + </icon-button> + </icon-navigator> + + <icon-navigator hidden=""> + <icon-button> + <a id="nav-middle-book-2" href="/archives/tags/"> + {{ safeHTML (readFile "static/icons/tabler/book-2.svg") }} + <small>Records</small> + </a> + </icon-button> + </icon-navigator> + + <icon-navigator hidden=""> + <icon-button> + <a id="nav-middle-users" href="/authors/"> + {{ safeHTML (readFile "static/icons/feather/users.svg") }} + <small>Authors</small> + </a> + </icon-button> + </icon-navigator> + + <icon-navigator hidden=""> + <icon-button> + <a id="nav-middle-rss" href="/rss.xml"> + {{ safeHTML (readFile "static/icons/feather/rss.svg") }} + <small>RSS</small> + </a> + </icon-button> + </icon-navigator> + + <icon-navigator hidden=""> + <icon-button> + <a id="nav-middle-circle" href="/index.json"> + {{ safeHTML (readFile "static/icons/feather/circle.svg") }} + <small>JSON</small> + </a> + </icon-button> + </icon-navigator> + + <icon-navigator hidden=""> + <icon-button> + <a id="nav-middle-git-commit" href="/sources/"> + {{ safeHTML (readFile "static/icons/feather/git-commit.svg") }} + <small>Sources</small> + </a> + </icon-button> + </icon-navigator> + </nav> + <navigation-separator><hr hidden=""></hr></navigation-separator> + <xsl:for-each select="/rss/channel/item"> + <micro-card> + <micro-summary> + <micro-thumbnail> + <figure> + <a target="_blank"><xsl:attribute name="href"><xsl:value-of select="/rss/channel/link"/></xsl:attribute> + <picture> + {{- $file := "/profile/picture.png" -}} + {{- $image := imageConfig (print "content/" (partial "author-media-path.html" .) $file) -}} + <img + loading="lazy" + width="{{ $image.Width }}" + height="{{ $image.Height }}"> + <xsl:attribute name="alt"><xsl:value-of select="/rss/channel/category"/></xsl:attribute> + <xsl:attribute name="title"><xsl:value-of select="/rss/channel/category"/></xsl:attribute> + <xsl:attribute name="src">{{ .Site.BaseURL }}/<xsl:value-of select="/rss/channel/category"/>/media/profile/picture.png</xsl:attribute> + </img> + </picture> + </a> + </figure> + </micro-thumbnail> + <micro-content> + <h2> + <a target="_blank"> + <xsl:attribute name="href"><xsl:value-of select="link" /></xsl:attribute> + <xsl:value-of select="title" /> + </a> + </h2> + <small> Published: <xsl:value-of select="pubDate" /> </small> + </micro-content> + </micro-summary> + </micro-card> + </xsl:for-each> + </main> + </column-middle> + <column-right> + </column-right> + </body> + </html> + </xsl:template> +</xsl:stylesheet> diff --git a/themes/default/layouts/_default/rss.xml b/themes/default/layouts/_default/rss.xml index eac25c4..293541b 100644 --- a/themes/default/layouts/_default/rss.xml +++ b/themes/default/layouts/_default/rss.xml @@ -5,17 +5,21 @@ {{- if ge $limit 1 -}} {{- $pages = $pages | first $limit -}} {{- end -}} -{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} +{{- print "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} +{{- print "<?xml-stylesheet href=\"/rss.xsl\" type=\"text/xsl\"?>" | safeHTML }} + <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>{{ partial "site-title" . }}</title> <link>{{ .Permalink }}</link> <description>Recent from {{ partial "site-title" . }}</description> <language>{{ .Site.LanguageCode }}</language> + <category>{{ partial "author-user" . }}</category> + <image>{{ .Site.BaseURL }}/{{ partial "author-media-path.html" . }}/profile/picture.png</image> {{- if not .Date.IsZero -}} <lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }} {{ with .OutputFormats.Get "RSS" }} - {{- printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink "application/rss+xml" | safeHTML -}} + {{- printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML -}} {{ end }} {{- range $pages -}} {{ if and (ne .Params.hidden true) (not .Params.Unlisted) (not .ExpiryDate) }} |