-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwishlist.xslt
163 lines (121 loc) · 4.57 KB
/
wishlist.xslt
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- ======================= EDIT YOUR FILTER SETTINGS =================== -->
<!-- Specify what you consider a significant price *change*.
Products with a significantly reduced price are listed separately (CHEAP_PRICE).
Default: 2.00 -->
<xsl:variable name="SIGNIFICANT_PRICE_CUT" select="2.00" />
<!-- Specify what you consider a low book price, e.g.,
less than 2 euro for a book -->
<xsl:variable name="CHEAP_PRICE">2.00</xsl:variable>
<xsl:variable name="CURRENCY">EUR </xsl:variable>
<!-- ===================================================================== -->
<xsl:template match="/amazon">
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Amazon-Lists Used & New</title>
<link rel="stylesheet" href="wishlist.css" />
</head>
<body>
<h1>Amazon-Lists Used & New</h1>
<a class="credits" href="https://github.com/andre-st/amazon-wishless" target="_blank">GitHub</a>
<section class="smartlist latest">
<h2>Latest price-cut</h2>
<xsl:apply-templates select="wishlist/product[@price >= 0 and @price <= @buyprice and @pricecut >= $SIGNIFICANT_PRICE_CUT]">
<xsl:sort select="@priority" data-type="number" order="descending" />
<xsl:sort select="@price" data-type="number" order="ascending" />
</xsl:apply-templates>
</section>
<section class="smartlist higher">
<h2>Higher priority</h2>
<xsl:apply-templates select="wishlist/product[@price >= 0 and @price <= @buyprice and @priority > 0]">
<xsl:sort select="@priority" data-type="number" order="descending" />
<xsl:sort select="@price" data-type="number" order="ascending" />
</xsl:apply-templates>
</section>
<section class="smartlist cheap">
<h2>
Products ≤
<xsl:value-of select="$CURRENCY" />
<xsl:value-of select="$CHEAP_PRICE" />
</h2>
<xsl:apply-templates select="wishlist/product[@price >= 0 and @price <= $CHEAP_PRICE and @priority >= 0]">
<xsl:sort select="@priority" data-type="number" order="descending" />
<xsl:sort select="@price" data-type="number" order="ascending" />
</xsl:apply-templates>
</section>
<section class="nav">
<h2>Jump to list</h2>
<ul>
<xsl:for-each select="wishlist">
<xsl:sort select="title" data-type="text" order="ascending" />
<li>
<a>
<xsl:attribute name="href">#<xsl:value-of select="@id" /></xsl:attribute>
<xsl:value-of select="title" />
</a>
</li>
</xsl:for-each>
</ul>
</section>
<xsl:apply-templates select="wishlist">
<xsl:sort select="title" data-type="text" order="ascending" />
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="product">
<wl-product>
<xsl:attribute name="class">
<xsl:if test="@prime='True'">prime</xsl:if>
</xsl:attribute>
<xsl:attribute name="data-priority">
<xsl:value-of select="@priority" />
</xsl:attribute>
<figure>
<a target="_blank" class="product-link">
<xsl:attribute name="href">
<xsl:value-of select="url" />
</xsl:attribute>
<img>
<xsl:attribute name="src">
<xsl:value-of select="picture" />
</xsl:attribute>
</img>
</a>
</figure>
<wl-info>
<wl-price><xsl:value-of select="price" /></wl-price>
<wl-title><xsl:value-of select="title" /></wl-title>
<xsl:if test="by">
<wl-by><xsl:value-of select="by" /></wl-by>
</xsl:if>
<a target="_blank" class="list-link">
<xsl:attribute name="href"><xsl:value-of select="../url" />?sort=priority</xsl:attribute>
visit list
</a>
</wl-info>
</wl-product>
</xsl:template>
<xsl:template match="wishlist">
<section class="wishlist">
<xsl:attribute name="id">
<xsl:value-of select="@id" />
</xsl:attribute>
<h2>
<a target="_blank">
<xsl:attribute name="href">
<xsl:value-of select="url" />?sort=priority
</xsl:attribute>
<xsl:value-of select="title" />
</a>
(€<xsl:value-of select="$CHEAP_PRICE" />‒10.00)</h2> <!-- TODO: Max(@buyprice) only in Firefox-unsupported XSLT2 -->
<xsl:apply-templates select="product[@price > $CHEAP_PRICE and @price <= @buyprice]">
<xsl:sort select="@priority" data-type="number" order="descending" />
<xsl:sort select="@price" data-type="number" order="ascending" />
</xsl:apply-templates>
</section>
</xsl:template>
</xsl:stylesheet>