forked from popcorn-time-ru/popcorn-ru
-
Notifications
You must be signed in to change notification settings - Fork 2
/
nginx_template.xslt
274 lines (256 loc) · 10.5 KB
/
nginx_template.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<?xml version="1.0"?>
<!--
dirlist.xslt - transform nginx's into lighttpd look-alike dirlistings
I'm currently switching over completely from lighttpd to nginx. If you come
up with a prettier stylesheet or other improvements, please tell me :)
-->
<!--
Copyright (c) 2016 by Moritz Wilhelmy <mw@barfooze.de>
All rights reserved
Redistribution and use in source and binary forms, with or without
modification, are permitted providing that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-->
<!DOCTYPE fnord [<!ENTITY nbsp " ">]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:func="http://exslt.org/functions" version="1.0" exclude-result-prefixes="xhtml" extension-element-prefixes="func">
<xsl:output method="xml" version="1.0" encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" indent="yes" media-type="application/xhtml+xml"/>
<xsl:strip-space elements="*" />
<xsl:template name="size">
<!-- transform a size in bytes into a human readable representation -->
<xsl:param name="bytes"/>
<xsl:choose>
<xsl:when test="$bytes < 1000"><xsl:value-of select="$bytes" />B</xsl:when>
<xsl:when test="$bytes < 1048576"><xsl:value-of select="format-number($bytes div 1024, '0.0')" />K</xsl:when>
<xsl:when test="$bytes < 1073741824"><xsl:value-of select="format-number($bytes div 1048576, '0.0')" />M</xsl:when>
<xsl:otherwise><xsl:value-of select="format-number(($bytes div 1073741824), '0.00')" />G</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="timestamp">
<!-- transform an ISO 8601 timestamp into a human readable representation -->
<xsl:param name="iso-timestamp" />
<xsl:value-of select="concat(substring($iso-timestamp, 0, 11), ' ', substring($iso-timestamp, 12, 5))" />
</xsl:template>
<xsl:template name="breadcrumb">
<xsl:param name="list" />
<xsl:param name="delimiter" select="'/'" />
<xsl:param name="reminder" select="$list" />
<xsl:variable name="newlist">
<xsl:choose>
<xsl:when test="contains($list, $delimiter)">
<xsl:value-of select="normalize-space($list)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(normalize-space($list), $delimiter)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="first" select="substring-before($newlist, $delimiter)" />
<xsl:variable name="remaining" select="substring-after($newlist, $delimiter)" />
<xsl:variable name="current" select="substring-before($reminder, $remaining)" />
<xsl:choose>
<xsl:when test="$remaining">
<xsl:choose>
<xsl:when test="$first = ''">
<li class="breadcrumb-item">
<i class="fas fa-home"></i><a href="/">Home</a>
</li>
</xsl:when>
<xsl:otherwise>
<li class="breadcrumb-item">
<a href="{$current}"><xsl:value-of select="$first" /></a>
</li>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="breadcrumb">
<xsl:with-param name="list" select="$remaining" />
<xsl:with-param name="delimiter" select="$delimiter" />
<xsl:with-param name="reminder" select="$reminder" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$first = ''">
<li class="breadcrumb-item">
<i class="fas fa-home"></i><a href="/">Home</a>
</li>
</xsl:when>
<xsl:otherwise>
<li class="breadcrumb-item active">
<a href="{$current}"><xsl:value-of select="$first" /></a>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="directory">
<tr>
<td class="n">
<a href="{current()}/">
<code>
<i class="far fa-folder" style="padding-right: 5px;"></i><xsl:value-of select="."/>
</code>
</a>
</td>
<td class="m">
<code>
<xsl:call-template name="timestamp"><xsl:with-param name="iso-timestamp" select="@mtime" /></xsl:call-template>
</code>
</td>
<td class="s">- </td>
</tr>
</xsl:template>
<xsl:template name="icon">
<xsl:param name="path"/>
<xsl:variable name="extension">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="$path" />
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$extension = 'bz2'">
<i class="far fa-file-archive" style="padding-right: 5px;"></i>
</xsl:when>
<xsl:when test="$extension = 'gz'">
<i class="far fa-file-archive" style="padding-right: 5px;"></i>
</xsl:when>
<xsl:when test="$extension = 'xz'">
<i class="far fa-file-archive" style="padding-right: 5px;"></i>
</xsl:when>
<xsl:when test="$extension = 'zip'">
<i class="far fa-file-archive" style="padding-right: 5px;"></i>
</xsl:when>
<xsl:otherwise>
<i class="far fa-file" style="padding-right: 5px;"></i>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="get-file-extension">
<xsl:param name="path"/>
<xsl:choose>
<xsl:when test="contains($path, '/')">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="substring-after($path, '/')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($path, '.')">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="substring-after($path, '.')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$path"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="file">
<tr>
<td class="n">
<a href="{current()}">
<code>
<xsl:call-template name="icon"><xsl:with-param name="path" select="." /></xsl:call-template>
<xsl:value-of select="." />
</code>
</a>
</td>
<td class="m">
<code>
<xsl:call-template name="timestamp"><xsl:with-param name="iso-timestamp" select="@mtime" /></xsl:call-template>
</code>
</td>
<td class="s">
<code>
<xsl:call-template name="size"><xsl:with-param name="bytes" select="@size" /></xsl:call-template>
</code>
</td>
</tr>
</xsl:template>
<xsl:template match="/">
<html>
<head>
<title>Popcorn Time</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha256-L/W5Wfqfa0sdBNIKN9cG6QA5F2qx4qICmU2VgLruv9Y=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
<style type="text/css">
/* Sticky footer styles
-------------------------------------------------- */
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 60px; /* Margin bottom by footer height */
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px; /* Set the fixed height of the footer here */
line-height: 60px; /* Vertically center the text there */
background-color: #f5f5f5;
}
/* Custom page CSS
-------------------------------------------------- */
.container {
width: auto;
max-width: 980px;
padding: 0 15px;
}
</style>
</head>
<body>
<!-- Begin page content -->
<main role="main" class="container">
<h1 class="mt-5">Popcorn Time</h1>
<h2>Слава Украине! Героям слава!</h2>
<ol class="breadcrumb"><xsl:call-template name="breadcrumb"><xsl:with-param name="list" select="$path" /></xsl:call-template></ol>
<div class="list">
<table class="table" summary="Directory Listing" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th class="n">Name</th>
<th class="m">Last Modified</th>
<th class="s">Size</th>
</tr>
</thead>
<tbody>
<tr>
<td class="n"><a href="../"><i class="fas fa-level-up-alt" style="padding-right: 5px;"></i>Parent Directory/</a></td>
<td class="m"> </td>
<td class="s">- </td>
</tr>
<xsl:apply-templates />
</tbody>
</table>
</div>
</main>
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-33769655-2"></script>
<script>
<![CDATA[
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-33769655-2');
]]>
</script>
</body>
</html>
</xsl:template>
</xsl:stylesheet>