-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatom.xsl
More file actions
115 lines (106 loc) · 3.87 KB
/
atom.xsl
File metadata and controls
115 lines (106 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<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><xsl:value-of select="atom:feed/atom:title"/></title>
<link href="stylesheets/reset.css" rel="stylesheet"/>
<link href="stylesheets/fonts.css" rel="stylesheet"/>
<link href="stylesheets/base.css" rel="stylesheet"/>
<link href="stylesheets/utils.css" rel="stylesheet"/>
<link href="stylesheets/page.css" rel="stylesheet"/>
<style type="text/css">
.entry {
margin-bottom: 2rem;
}
.entry h2 {
margin-bottom: 0;
display: inline-block;
font-family: 'DINdong', sans-serif !important;
}
.entry time {
font-style: italic;
margin-left: 1rem;
}
header {
border-bottom: none !important;
}
.entry p {
margin: 0.5rem 0;
}
</style>
</head>
<body>
<header>
<a href="/index.html">← Max Bo</a>
<h1><xsl:value-of select="atom:feed/atom:title"/></h1>
<div class="alert">
<p>This is an <a href="https://andrewstiefel.com/style-atom-xsl/">XLST-styled Atom feed</a>.
Subscribe by copying the URL from the address bar into your <a href="https://www.theverge.com/24036427/rss-feed-reader-best">RSS/Atom reader</a>.</p>
</div>
</header>
<section>
<xsl:apply-templates select="atom:feed/atom:entry" />
</section>
</body>
</html>
</xsl:template>
<xsl:template match="atom:feed">
</xsl:template>
<xsl:template match="atom:entry">
<div class="entry">
<div>
<h2>
<a target="_blank">
<xsl:attribute name="href">
<xsl:value-of select="atom:id"/>
</xsl:attribute>
<xsl:value-of select="atom:title"/>
</a>
</h2>
<time>
<xsl:attribute name="datetime">
<xsl:value-of select="atom:updated"/>
</xsl:attribute>
<xsl:call-template name="format-date">
<xsl:with-param name="date" select="atom:updated"/>
</xsl:call-template>
</time>
</div>
<p>
<xsl:value-of select="atom:summary" disable-output-escaping="yes" />
</p>
</div>
</xsl:template>
<xsl:template name="format-date">
<xsl:param name="date"/>
<xsl:variable name="year" select="substring($date, 1, 4)"/>
<xsl:variable name="month" select="substring($date, 6, 2)"/>
<xsl:variable name="day" select="substring($date, 9, 2)"/>
<xsl:choose>
<xsl:when test="$month = '01'">January</xsl:when>
<xsl:when test="$month = '02'">February</xsl:when>
<xsl:when test="$month = '03'">March</xsl:when>
<xsl:when test="$month = '04'">April</xsl:when>
<xsl:when test="$month = '05'">May</xsl:when>
<xsl:when test="$month = '06'">June</xsl:when>
<xsl:when test="$month = '07'">July</xsl:when>
<xsl:when test="$month = '08'">August</xsl:when>
<xsl:when test="$month = '09'">September</xsl:when>
<xsl:when test="$month = '10'">October</xsl:when>
<xsl:when test="$month = '11'">November</xsl:when>
<xsl:when test="$month = '12'">December</xsl:when>
</xsl:choose>
<xsl:text> </xsl:text>
<xsl:value-of select="number($day)"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="$year"/>
</xsl:template>
</xsl:stylesheet>