Adds Atom feed generation
Implements Atom feed generation for blog posts, photos, and the main site feed. This allows users to subscribe to content using Atom-compatible feed readers. Includes an XSLT stylesheet for rendering Atom feeds in a human-readable format in browsers.
This commit is contained in:
@@ -32,10 +32,18 @@ related:
|
|||||||
- name: date
|
- name: date
|
||||||
weight: 10
|
weight: 10
|
||||||
|
|
||||||
|
mediaTypes:
|
||||||
|
application/atom+xml:
|
||||||
|
suffixes:
|
||||||
|
- xml
|
||||||
|
|
||||||
outputFormats:
|
outputFormats:
|
||||||
SearchIndex:
|
SearchIndex:
|
||||||
baseName: search
|
baseName: search
|
||||||
mediaType: application/json
|
mediaType: application/json
|
||||||
|
Atom:
|
||||||
|
mediaType: "application/atom+xml"
|
||||||
|
baseName: atom
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
home:
|
home:
|
||||||
@@ -43,6 +51,12 @@ outputs:
|
|||||||
- rss
|
- rss
|
||||||
- SearchIndex
|
- SearchIndex
|
||||||
- json
|
- json
|
||||||
|
- Atom
|
||||||
|
section:
|
||||||
|
- html
|
||||||
|
- rss
|
||||||
|
- json
|
||||||
|
- Atom
|
||||||
|
|
||||||
services:
|
services:
|
||||||
rss:
|
rss:
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ images:
|
|||||||
- /img/Opengraph.png
|
- /img/Opengraph.png
|
||||||
favicon: "apple-touch-icon.png"
|
favicon: "apple-touch-icon.png"
|
||||||
icon: "apple-touch-icon.png"
|
icon: "apple-touch-icon.png"
|
||||||
|
icon96: "favicon-96x96.png"
|
||||||
defaultColor:
|
defaultColor:
|
||||||
"dark" # set color mode: dark, light, auto
|
"dark" # set color mode: dark, light, auto
|
||||||
# Setting it to 'auto' applies the color scheme based on the visitor's device color preference.If you don't specify anything, ignore this parameter, or leave it blank,
|
# Setting it to 'auto' applies the color scheme based on the visitor's device color preference.If you don't specify anything, ignore this parameter, or leave it blank,
|
||||||
@@ -71,3 +72,7 @@ Hcard:
|
|||||||
bridgy:
|
bridgy:
|
||||||
- "mastodon"
|
- "mastodon"
|
||||||
- "bluesky"
|
- "bluesky"
|
||||||
|
|
||||||
|
dateFormatAtomFeed: "2006-01-02T15:04:05-07:00"
|
||||||
|
dateFormatTag: "2006"
|
||||||
|
feedUUID: "43c22089-5c06-4cc4-8fd2-5b3563d5d257"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ This page collects content I'm producing in some way or the other, and is consum
|
|||||||
|
|
||||||
You can follow me here:
|
You can follow me here:
|
||||||
|
|
||||||
* [All stuff from my blog](/index.xml)
|
* All stuff from my blog [Atom](/atom.xml) [RSS](/index.xml) [Json](/index.json)
|
||||||
* [All my post from my blog](/post/index.xml)
|
* All my post from my blog [Atom](/post/atom.xml) [RSS](/post/index.xml) [Json](/post/index.json)
|
||||||
* [All my photo from my blog](/photos/index.xml)
|
* All my photo from my blog [Atom](/photos/atom.xml) [RSS](/photos/index.xml) [Json](/photos/index.json)
|
||||||
* [My personal Newsletter](https://newsletter.digitaltearoom.com/index.xml)
|
* My personal Newsletter [RSS](https://newsletter.digitaltearoom.com/index.xml)
|
||||||
|
|||||||
60
layouts/_default/list.atom.xml
Normal file
60
layouts/_default/list.atom.xml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
{{- $pctx := . }}
|
||||||
|
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
|
||||||
|
{{- $pages := slice }}
|
||||||
|
{{- if or $.IsHome $.IsSection }}
|
||||||
|
{{- $pages = $pctx.RegularPages }}
|
||||||
|
{{- else }}
|
||||||
|
{{- $pages = $pctx.Pages }}
|
||||||
|
{{- end }}
|
||||||
|
{{- $limit := .Site.Config.Services.RSS.Limit }}
|
||||||
|
{{- if ge $limit 1 }}
|
||||||
|
{{- $pages = $pages | first $limit }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Site.Config.Services.RSS.Limit -}}
|
||||||
|
{{- if ge . 1 -}}
|
||||||
|
{{- $pages = $pages | first . -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{ print "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
|
||||||
|
{{- printf "<?xml-stylesheet href=\"/atom.xsl\" type=\"text/xsl\"?>" | safeHTML }}
|
||||||
|
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:webfeeds="http://webfeeds.org/rss/1.0">
|
||||||
|
{{ with .Site.Author.name }}
|
||||||
|
<author>
|
||||||
|
<name>{{ . }}</name>
|
||||||
|
<uri>{{ $.Site.BaseURL }}</uri>
|
||||||
|
</author>
|
||||||
|
{{ end }}
|
||||||
|
<generator uri="https://gohugo.io">Hugo {{ .Site.Hugo.Version }}</generator>
|
||||||
|
<id>{{ if .Site.Params.feedUUID }}urn:uuid:{{.Site.Params.feedUUID }}{{ else }}{{ .Permalink }}{{ end }}</id>
|
||||||
|
{{ with .OutputFormats.Get "atom" }}
|
||||||
|
{{ printf `<link rel="self" type="%s" href="%s" hreflang="%s"/>` .MediaType.Type .Permalink $.Site.LanguageCode | safeHTML }}
|
||||||
|
{{ end }}
|
||||||
|
{{ range .AlternativeOutputFormats }}
|
||||||
|
{{ printf `<link rel="alternate" type="%s" href="%s" hreflang="%s"/>` .MediaType.Type .Permalink $.Site.LanguageCode | safeHTML }}
|
||||||
|
{{ end }}
|
||||||
|
{{ with .Site.Params.icon }}<icon>{{ . | absURL }}</icon>{{ end }}
|
||||||
|
{{ with .Site.Params.logo }}<logo>{{ . | absURL }}</logo>{{ end }}
|
||||||
|
{{ with .Site.Copyright }}<rights>{{ replace . "{year}" now.Year }}</rights>{{ end }}
|
||||||
|
{{ with .Site.Params.Description }}<subtitle>{{ . }}</subtitle>{{ end }}
|
||||||
|
<title>{{ .Site.Title }}</title>
|
||||||
|
<updated>{{ now.Format .Site.Params.dateFormatAtomFeed | safeHTML }}</updated>
|
||||||
|
{{ with .Site.Params.icon96 }}<webfeeds:icon>{{ . | absURL }}</webfeeds:icon>{{ end }}
|
||||||
|
{{ range $pages }}
|
||||||
|
<entry>
|
||||||
|
{{ with .Params.Author }}
|
||||||
|
<author>
|
||||||
|
<name>{{ . }}</name>
|
||||||
|
</author>
|
||||||
|
{{ end }}
|
||||||
|
<id>tag:{{ $u := urls.Parse .Permalink }}{{ $u.Hostname }},{{ .Date.Format .Site.Params.dateFormatTag }}:{{ replace $u.Path "#" "_" }}</id>
|
||||||
|
<link rel="alternate" href="{{ .Permalink }}"/>
|
||||||
|
<title>{{ .Title }}</title>
|
||||||
|
<published>{{ .Date.Format .Site.Params.dateFormatAtomFeed | safeHTML }}</published>
|
||||||
|
<updated>{{ .Lastmod.Format .Site.Params.dateFormatAtomFeed | safeHTML }}</updated>
|
||||||
|
{{ with .Description }}<summary type="text">{{ . }}</summary>{{ end }}
|
||||||
|
<content type="html" xml:base="{{ .Site.BaseURL }}" xml:lang="en">
|
||||||
|
{{ printf "<![CDATA[%s]]>" .Content | safeHTML }}
|
||||||
|
</content>
|
||||||
|
</entry>
|
||||||
|
{{ end }}
|
||||||
|
</feed>
|
||||||
@@ -8,3 +8,7 @@
|
|||||||
|
|
||||||
{{- $style := resources.Get "sass/add.scss" | resources.ExecuteAsTemplate "add.scss" . | toCSS (dict "targetPath" "add.css") | minify | fingerprint }}
|
{{- $style := resources.Get "sass/add.scss" | resources.ExecuteAsTemplate "add.scss" . | toCSS (dict "targetPath" "add.css") | minify | fingerprint }}
|
||||||
<link href="{{ $style.RelPermalink }}" rel="stylesheet">
|
<link href="{{ $style.RelPermalink }}" rel="stylesheet">
|
||||||
|
|
||||||
|
{{ with .OutputFormats.Get "atom" }}
|
||||||
|
<link href="{{ .RelPermalink }}" rel="alternate" type="{{.MediaType.Type}}" title="{{ $.Site.Title }}">
|
||||||
|
{{ end }}
|
||||||
|
|||||||
77
static/atom.xsl
Normal file
77
static/atom.xsl
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<xsl:stylesheet
|
||||||
|
version="1.0"
|
||||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
|
xmlns:atom="http://www.w3.org/2005/Atom"
|
||||||
|
exclude-result-prefixes="atom"
|
||||||
|
>
|
||||||
|
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
||||||
|
<xsl:template match="/">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
|
||||||
|
<title>Web Feed • <xsl:value-of select="atom:feed/atom:title"/></title>
|
||||||
|
<style type="text/css">
|
||||||
|
body{max-width:768px;margin:0 auto;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:16px;line-height:1.5em}section{margin:30px 15px}h1{font-size:2em;margin:.67em 0;line-height:1.125em}h2{border-bottom:1px solid #eaecef;padding-bottom:.3em}.alert{background:#fff5b1;padding:4px 12px;margin:0 -12px}a{text-decoration:none}.entry h3{margin-bottom:0}.entry p{margin:4px 0}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<section>
|
||||||
|
<div class="alert">
|
||||||
|
<p><strong>This is a web feed</strong>, also known as an RSS feed. <strong>Subscribe</strong> by copying the URL from the address bar into your newsreader app.</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<xsl:apply-templates select="atom:feed" />
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<h2>Recent Items</h2>
|
||||||
|
<xsl:apply-templates select="atom:feed/atom:entry" />
|
||||||
|
</section>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="atom:feed">
|
||||||
|
<h1><xsl:value-of select="atom:title"/>'s Web Feed Preview</h1>
|
||||||
|
<p>This RSS feed provides the latest posts from <xsl:value-of select="atom:title"/>'s blog.
|
||||||
|
|
||||||
|
<a class="head_link" target="_blank">
|
||||||
|
<xsl:attribute name="href">
|
||||||
|
<xsl:value-of select="atom:link[@rel='alternate']/@href"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
Visit Website →
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h2>What is an RSS feed?</h2>
|
||||||
|
<p>An RSS feed is a data format that contains the latest content from a website, blog, or podcast. You can use feeds to <strong>subscribe</strong> to websites and get the <strong>latest content in one place</strong>.</p>
|
||||||
|
<ul>
|
||||||
|
<li><strong>Feeds put you in control.</strong> Unlike social media apps, there is no algorithm deciding what you see or read. You always get the latest content from the creators you care about.</li>
|
||||||
|
<li><strong>Feed are private by design.</strong> No one owns web feeds, so no one is harvesting your personal information and profiting by selling it to advertisers.</li>
|
||||||
|
<li><strong>Feeds are spam-proof.</strong> Had enough? Easy, just unsubscribe from the feed.</li>
|
||||||
|
</ul>
|
||||||
|
<p>All you need to do to get started is to add the URL (web address) for this feed to a special app called a newsreader. Visit <a href="https://aboutfeeds.com/">About Feeds</a> to get started with newsreaders and subscribing. It’s free. </p>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="atom:entry">
|
||||||
|
<div class="entry">
|
||||||
|
<h3>
|
||||||
|
<a target="_blank">
|
||||||
|
<xsl:attribute name="href">
|
||||||
|
<xsl:value-of select="atom:id"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
<xsl:value-of select="atom:title"/>
|
||||||
|
</a>
|
||||||
|
</h3>
|
||||||
|
<p>
|
||||||
|
<xsl:value-of select="atom:summary" disable-output-escaping="yes" />
|
||||||
|
</p>
|
||||||
|
<small>
|
||||||
|
Published: <xsl:value-of select="atom:updated" />
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
||||||
@@ -7,9 +7,7 @@
|
|||||||
<title><xsl:value-of select="/rss/channel/title"/> RSS Feed</title>
|
<title><xsl:value-of select="/rss/channel/title"/> RSS Feed</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>=
|
||||||
|
|
||||||
<link type="text/css" rel="stylesheet" href="https://xaselgio.net/css/styles.d225b84765ebd5eb4ab83f06e7e09371032e7199475bda8157f1f285bac0e0720482db82ed01710cced83ed937c019f9d0dfe2da88e3600f24c09c6903e360ee.css" integrity="sha512-0iW4R2Xr1etKuD8G5+CTcQMucZlHW9qBV/HyhbrA4HIEgtuC7QFxDM7YPtk3wBn50N/i2ojjYA8kwJxpA+Ng7g==" />
|
|
||||||
<style>
|
<style>
|
||||||
.aboutfeeds {
|
.aboutfeeds {
|
||||||
margin: 24px 0; padding: 12px;
|
margin: 24px 0; padding: 12px;
|
||||||
|
|||||||
Reference in New Issue
Block a user