Code forked from https://gist.github.com/cassidoo/9b6afeb92350bfbeccc7f968fbe89e5f
0
rss-styles.xml
1<?xml version="1.0" encoding="utf-8"?>
2<!--
3
4# Pretty Feed
5
6Styles an RSS/Atom feed, making it friendly for humans viewers, and adds a link
7to aboutfeeds.com for new user onboarding. See it in action:
8
9 https://interconnected.org/home/feed
10
11
12## How to use
13
141. Download this XML stylesheet from the following URL and host it on your own
15 domain (this is a limitation of XSL in browsers):
16
17 https://github.com/genmon/aboutfeeds/blob/main/tools/pretty-feed-v3.xsl
18
192. Include the XSL at the top of the RSS/Atom feed, like:
20
21```
22<?xml version="1.0" encoding="UTF-8"?>
23<?xml-stylesheet href="/PATH-TO-YOUR-STYLES/pretty-feed-v3.xsl" type="text/xsl"?>
24```
25
263. Serve the feed with the following HTTP headers:
27
28```
29Content-Type: application/xml; charset=utf-8 # not application/rss+xml
30x-content-type-options: nosniff
31```
32
33(These headers are required to style feeds for users with Safari on iOS/Mac.)
34
35## Limitations
36
37- Styling the feed *prevents* the browser from automatically opening a
38 newsreader application. This is a trade off, but it's a benefit to new users
39 who won't have a newsreader installed, and they are saved from seeing or
40 downloaded obscure XML content. For existing newsreader users, they will know
41 to copy-and-paste the feed URL, and they get the benefit of an in-browser feed
42 preview.
43- Feed styling, for all browsers, is only available to site owners who control
44 their own platform. The need to add both XML and HTTP headers makes this a
45 limited solution.
46
47
48## Credits
49
50pretty-feed is based on work by lepture.com:
51
52 https://lepture.com/en/2019/rss-style-with-xsl
53
54This current version is maintained by aboutfeeds.com:
55
56 https://github.com/genmon/aboutfeeds
57
58
59## Feedback
60
61This file is in BETA. Please test and contribute to the discussion:
62
63 https://github.com/genmon/aboutfeeds/issues/8
64
65-->
66<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
67 xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"
68 xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
69 <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
70 <xsl:template match="/">
71 <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
72 <head>
73 <title>cassidoo's web feed</title>
74 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
75 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
76 <style type="text/css">
77 :root {
78 --white: #faf5f6;
79 --transwhite: rgba(250, 245, 246, 0.7);
80 --moretranswhite: rgba(239, 239, 239, 0.1);
81 --black: #252525;
82 --transblack: rgba(37, 37, 37, 0.7);
83 --moretransblack: rgba(37, 37, 37, 0.1);
84 --gray: #6b6b6b;
85 --highlight: #e5ffc3;
86 --red: #e4002b;
87 --green: #24d05a;
88 --pink: #eb4888;
89 --blue: #10a2f5;
90 --yellow: #e9bc3f;
91 }
92
93 ::selection {
94 background-color: var(--highlight);
95 color: var(--black);
96 }
97 html,
98 body {
99 margin: auto;
100 padding: 20px;
101 max-width: 70ch;
102 background-color: var(--white);
103 word-wrap: break-word;
104 overflow-wrap: break-word;
105 color: var(--black);
106 line-height: 1.6;
107 }
108
109 html,
110 body,
111 button,
112 code,
113 input {
114 font-family: monospace;
115 }
116
117 h2, h3, h4, h5, h6 {
118 color: var(--gray);
119 }
120
121 a {
122 color: var(--pink);
123 text-decoration-thickness: 0.3ex;
124 text-underline-offset: 0.3ex;
125 }
126 </style>
127 </head>
128 <body>
129 <nav>
130 <a class="head_link" target="_blank">
131 <xsl:attribute name="href">
132 <xsl:value-of select="/rss/channel/link"/>
133 </xsl:attribute>
134 ← Go back to cassidoo.co
135 </a>
136 <p>
137 <strong>This is a web feed,</strong> also known as an RSS feed. You can <strong>subscribe</strong> by copying the URL from the address bar into your newsreader.
138 </p>
139 <p>
140 Visit <a href="https://aboutfeeds.com">About Feeds</a> to get started with newsreaders and subscribing. It’s free!
141 </p>
142 </nav>
143
144 <hr />
145
146 <div>
147 <header>
148 <h1>
149 <!-- https://commons.wikimedia.org/wiki/File:Feed-icon.svg -->
150 <svg xmlns="http://www.w3.org/2000/svg" version="1.1" style="vertical-align: text-bottom; width: 1.2em; height: 1.2em;" class="pr-1" id="RSSicon" viewBox="0 0 256 256">
151 <defs>
152 <linearGradient x1="0.085" y1="0.085" x2="0.915" y2="0.915" id="RSSg">
153 <stop offset="0.0" stop-color="#E3702D"/><stop offset="0.1071" stop-color="#EA7D31"/>
154 <stop offset="0.3503" stop-color="#F69537"/><stop offset="0.5" stop-color="#FB9E3A"/>
155 <stop offset="0.7016" stop-color="#EA7C31"/><stop offset="0.8866" stop-color="#DE642B"/>
156 <stop offset="1.0" stop-color="#D95B29"/>
157 </linearGradient>
158 </defs>
159 <rect width="256" height="256" rx="55" ry="55" x="0" y="0" fill="#CC5D15"/>
160 <rect width="246" height="246" rx="50" ry="50" x="5" y="5" fill="#F49C52"/>
161 <rect width="236" height="236" rx="47" ry="47" x="10" y="10" fill="url(#RSSg)"/>
162 <circle cx="68" cy="189" r="24" fill="#FFF"/>
163 <path d="M160 213h-34a82 82 0 0 0 -82 -82v-34a116 116 0 0 1 116 116z" fill="#FFF"/>
164 <path d="M184 213A140 140 0 0 0 44 73 V 38a175 175 0 0 1 175 175z" fill="#FFF"/>
165 </svg>
166
167 Web Feed Preview
168 </h1>
169 <p><xsl:value-of select="/rss/channel/description"/></p>
170 <a class="head_link" target="_blank">
171 <xsl:attribute name="href">
172 <xsl:value-of select="/rss/channel/link"/>
173 </xsl:attribute>
174 ← Go back to cassidoo.co
175 </a>
176 </header>
177
178 <h2>Recent Items</h2>
179 <xsl:for-each select="/rss/channel/item">
180 <div>
181 <h3>
182 <a target="_blank">
183 <xsl:attribute name="href">
184 <xsl:value-of select="link"/>
185 </xsl:attribute>
186 <xsl:value-of select="title"/>
187 </a>
188 </h3>
189 <small>
190 Published: <xsl:value-of select="pubDate" />
191 </small>
192 </div>
193 </xsl:for-each>
194 </div>
195 </body>
196 </html>
197 </xsl:template>
198</xsl:stylesheet>