mirror of
https://github.com/standardebooks/web.git
synced 2025-07-08 15:50:29 -04:00
Add XSLT stylesheet for RSS feed
This commit is contained in:
parent
30a3dd053f
commit
a3d823dd5a
5 changed files with 60 additions and 6 deletions
|
@ -35,7 +35,7 @@ krsort($sortedContentFiles);
|
||||||
|
|
||||||
$sortedContentFiles = array_slice($sortedContentFiles, 0, $rssLength);
|
$sortedContentFiles = array_slice($sortedContentFiles, 0, $rssLength);
|
||||||
|
|
||||||
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
|
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<?xml-stylesheet href=\"/rss/style\" type=\"application/xslt+xml\"?>\n");
|
||||||
?>
|
?>
|
||||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
<channel>
|
<channel>
|
||||||
|
|
|
@ -5,11 +5,15 @@ $highlight = $highlight ?? '';
|
||||||
$description = $description ?? '';
|
$description = $description ?? '';
|
||||||
$manual = $manual ?? false;
|
$manual = $manual ?? false;
|
||||||
$colorScheme = $_COOKIE['color-scheme'] ?? 'auto';
|
$colorScheme = $_COOKIE['color-scheme'] ?? 'auto';
|
||||||
|
$xmlDeclaration = $xmlDeclaration ?? true;
|
||||||
|
|
||||||
header('content-type: application/xhtml+xml');
|
if($xmlDeclaration){
|
||||||
print('<?xml version="1.0" encoding="utf-8"?>');
|
header('content-type: application/xhtml+xml');
|
||||||
print("\n");
|
print('<?xml version="1.0" encoding="utf-8"?>');
|
||||||
?><!DOCTYPE html>
|
print("\n");
|
||||||
|
print("<!DOCTYPE html>\n");
|
||||||
|
}
|
||||||
|
?>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||||
<head prefix="twitter: https://twitter.com/ schema: http://schema.org/"><? /* The `og` RDFa prefix is part of the RDFa spec */ ?>
|
<head prefix="twitter: https://twitter.com/ schema: http://schema.org/"><? /* The `og` RDFa prefix is part of the RDFa spec */ ?>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
|
|
|
@ -1376,6 +1376,11 @@ figure{
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rss ul.tags + p{
|
||||||
|
font-style: italic;
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
ul.tags{
|
ul.tags{
|
||||||
list-style: none;
|
list-style: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -1384,6 +1389,11 @@ ul.tags{
|
||||||
margin-top: .5rem;
|
margin-top: .5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rss ul.tags{
|
||||||
|
justify-content: flex-start;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
ul.tags li{
|
ul.tags li{
|
||||||
margin: .5rem;
|
margin: .5rem;
|
||||||
}
|
}
|
||||||
|
@ -1392,7 +1402,8 @@ ul.tags li:first-child{
|
||||||
margin: .5rem;
|
margin: .5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.tags li a{
|
ul.tags li a,
|
||||||
|
.rss ul.tags li p{
|
||||||
border: 1px solid var(--body-text);
|
border: 1px solid var(--body-text);
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
padding: .25rem .5rem;
|
padding: .25rem .5rem;
|
||||||
|
|
0
www/css/feed.css
Normal file
0
www/css/feed.css
Normal file
39
www/rss/style.php
Normal file
39
www/rss/style.php
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<?
|
||||||
|
require_once('Core.php');
|
||||||
|
header('content-type: application/xslt+xml');
|
||||||
|
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
||||||
|
?>
|
||||||
|
<xsl:stylesheet version="3.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
|
<xsl:output method="html" html-version="5.0" encoding="utf-8" indent="true"/>
|
||||||
|
<xsl:template match="/">
|
||||||
|
<?= Template::Header(['xmlDeclaration' => false]) ?>
|
||||||
|
<main>
|
||||||
|
<h1><xsl:value-of select="substring-after(/rss/channel/title, 'Standard Ebooks - ')"/></h1>
|
||||||
|
<p><xsl:value-of select="/rss/channel/description"/></p>
|
||||||
|
<p>This page is an RSS feed. The URL in your address bar (<a ><xsl:attribute name="href"><xsl:value-of select="/rss/channel/atom:link/@href"/></xsl:attribute><xsl:value-of select="/rss/channel/atom:link/@href"/></a>) can be used in any RSS reader.</p>
|
||||||
|
<ol class="rss">
|
||||||
|
<xsl:for-each select="/rss/channel/item">
|
||||||
|
<li>
|
||||||
|
<a>
|
||||||
|
<xsl:attribute name="href">
|
||||||
|
<xsl:value-of select="link"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
<xsl:value-of select="title"/>
|
||||||
|
</a>
|
||||||
|
<ul class="tags">
|
||||||
|
<xsl:for-each select="category">
|
||||||
|
<li>
|
||||||
|
<p><xsl:value-of select="."/></p>
|
||||||
|
</li>
|
||||||
|
</xsl:for-each>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
<xsl:value-of select="description"/>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
</xsl:for-each>
|
||||||
|
</ol>
|
||||||
|
</main>
|
||||||
|
<?= Template::Footer() ?>
|
||||||
|
</xsl:template>
|
||||||
|
</xsl:stylesheet>
|
Loading…
Add table
Add a link
Reference in a new issue