simple js search
[pharext/replicator.pharext.org] / public / html.php
1 <?php
2 const INCLUDED = __FILE__;
3 const NCURRENT = 2;
4
5 $css = "concise/css/concise.min.css";
6 $fnt = "//fonts.googleapis.com/css?family=Droid+Sans";
7
8 require_once "index.php";
9
10 ob_start($res);
11 $res->addHeader("Link", "<" . dirname((new http\Env\Url)->path) . $css . ">; rel=preload; as=style");
12
13 ?>
14 <!doctype html>
15 <html>
16 <head>
17 <meta charset="utf-8">
18 <title>Replicator</title>
19 <link rel="stylesheet" href="<?=$css?>">
20 <link rel="stylesheet" href="<?=$fnt?>">
21 <meta name="viewport" content="width=device-width, initial-scale=1">
22 <style>
23 body {
24 padding-bottom: 2em;
25 padding-top: 7em;
26 }
27 .header {
28 top: 0;
29 width: 100%;
30 }
31 .footer {
32 bottom: 0;
33 width: 100%;
34 text-align: center;
35 font-size: .9em;
36 }
37 .header, .footer {
38 position: fixed;
39 box-shadow: 0px 0px .8em .4em #89a;
40 background: #62B3E7;
41 padding: .5em 0;
42 }
43 .header h1 {
44 font-weight: bold;
45 }
46 .header h1 a, .footer a:hover {
47 text-decoration: none;
48 }
49 .header h1 a:hover {
50 text-decoration: underline;
51 }
52 .header h1 a {
53 /* normalize browser difference */
54 font-size: 1.3em;
55 }
56 .header h1 a, .footer, .footer a {
57 color: #fdfdfd;
58 text-shadow: grey 0 0 .1em;
59 }
60 .header h1 small {
61 color: #666;
62 font-size: 1.3rem;
63 text-shadow: white 0 0 .2em;
64 }
65 li {
66 list-style-type: circle;
67 }
68 pre.publickey {
69 font-size: .8rem;
70 line-height: 1rem;
71 }
72 pre.code {
73 background: #333;
74 color: #62B3E7;
75 padding: 0 1.5em 1.5em 1em;
76 border-radius: 4px;
77 margin-right: 2em;
78 display: inline-block;
79 }
80 pre.code>code {
81 font-size: .9rem;
82 }
83 .row>h3 {
84 margin-bottom: 0;
85 }
86 @media(max-width: 80em) {
87 .column-8 {
88 float: none;
89 width: auto;
90 }
91 }
92 .old-version, #new-toggle {
93 display: none;
94 }
95 .package-description {
96 white-space: pre-line;
97 }
98 form * {
99 display: inline-block;
100 margin-right: 1em;
101 }
102 form label input{
103 margin-left: 1em;
104 vertical-align: middle;
105 }
106 form input[type=reset] {
107 padding: 0;
108 }
109 </style>
110 </head>
111 <body>
112 <div class="header">
113 <header>
114 <h1 class="container">
115 <a href="?">Replicator</a><br>
116 <small>Replicating PECL releases as pharext packages since 2015</small>
117 </h1>
118 <a href="https://github.com/m6w6/replicator"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"></a>
119 </header>
120 </div>
121 <div class="container">
122
123 <?php if (!empty($package)) : $versions = package_versions($package); $info = package_info($package); ?>
124
125 <h2><?= htmlspecialchars($package) ?></h2>
126 <?php if ($info) : ?>
127 <h3><?= htmlspecialchars($info["title"]) ?><br>
128 <small>License: <?= htmlspecialchars($info["license"]) ?></small></h3>
129 <p class="package-description"><?= htmlspecialchars($info["description"]) ?></p>
130 <?php endif; ?>
131 <table class="table table-full versions">
132 <thead>
133 <tr>
134 <th class="text-left" colspan="2">Package</th>
135 <th class="text-left" colspan="<?= count(SIGS) ?>">Signatures</th>
136 <th class="text-left">Date</th>
137 <th class="text-right">Pharext</th>
138 </tr>
139 </thead>
140 <tbody>
141
142 <?php $i = 0; foreach (array_reverse($versions) as $version => $phars) : ++$i; ?>
143 <?php foreach (array_map("array_values", $phars) as $ext => list($phar, $date, $size, $pharext)) : ?>
144 <tr <?php if ($i > NCURRENT) : ?>class="old-version"<?php endif; ?> <?php if ($i === NCURRENT) : ?>id="old"<?php endif; ?>>
145 <?php if (empty($ext)) : ?>
146 <td class="text-left" rowspan="<?= count($phars) ?>">
147 <?= htmlspecialchars($package) ?>
148 <?= htmlspecialchars($version) ?>
149 </td>
150 <?php endif ?>
151
152 <td class="text-left">
153 &#10507;&nbsp;<a href="<?= htmlspecialchars($phar) ?>"
154 download>phar<?= htmlspecialchars($ext) ?></a>&nbsp;<small>(<?= human_size($size) ?>)</small><br>
155 </td>
156 <?php foreach (SIGS as $typ => $sig) : ?>
157 <td>
158 #&nbsp;<a href="<?= sigof($phar, $sig) ?>" download><?= "$typ.$sig" ?></a>
159 </td>
160 <?php endforeach; ?>
161 <td class="text-left">
162 <?= human_date($date); ?>
163
164 </td>
165 <td class="text-right <?= version_compare($pharext, "3.0.1", "<") ? "color-red":"" ?>">
166 v<?= $pharext ?>
167 </td>
168 </tr>
169 <?php endforeach; ?>
170 <?php endforeach; ?>
171
172 </tbody>
173 </table>
174 <?php if ($i >= 3) : ?>
175 <p class="small">
176 <a id="old-toggle" href="#old" onclick="toggleOldVersions(this)">Show
177 <?=count($versions)-NCURRENT?> older version(s) &raquo;</a>
178 <a id="new-toggle" href="#" onclick="toggleOldVersions(this)">Show
179 less versions &laquo;</a>
180 </p>
181 <?php endif; ?>
182 <?php else: ?>
183
184 <h2>Available Packages</h2>
185 <form name="search"></form>
186 <ul class="list-inline package-list">
187 <?php foreach (array_map("htmlspecialchars", $packages) as $index => $pkg) : ?>
188 <?php $next = strtolower($pkg{0}); ?>
189 <?php if (isset($prev) && $next != $prev) : ?>
190
191 </ul>
192 <ul class="list-inline package-list">
193 <?php endif; ?>
194
195 <li id="<?= strtolower($pkg) ?>"><a href="?<?= $pkg ?>"><?= $pkg ?></a></li>
196 <?php $prev = $next; ?>
197 <?php endforeach; ?>
198
199 </ul>
200 <?php endif; ?>
201 <hr>
202 <div class="row">
203 <?php if (empty($package)) : ?>
204 <h3>Public keys</h3>
205 <?php else : list($phar) = array_values(current(end($versions))); ?>
206 <h3>Download latest version and signatures:</h3>
207 <div class="column-16">
208 <pre class="code fit-code"><code>
209 curl -sS \
210 -O https://replicator.pharext.org/<?= htmlspecialchars($phar) ?><?php foreach (SIGS as $sig) : ?> \
211 -O https://replicator.pharext.org/<?= htmlspecialchars(sigof($phar, $sig)) ?><?php endforeach; ?></code></pre>
212 </div>
213 </div>
214 <div class="row">
215 <h3>Verify with a public key:</h3>
216 <?php endif; ?>
217
218 <div class="column-8">
219 <h4>RSA <small><a href="replicator.pub" download>replicator.pub</a></small></h4>
220 <?php if (!empty($phar)) : ?>
221 <pre class="code"><code>
222 curl -sSO https://replicator.pharext.org/replicator.pub
223
224 openssl dgst \
225 -verify replicator.pub \
226 -signature <?= htmlspecialchars(basename($phar)).".sig" ?> \
227 <?= htmlspecialchars(basename($phar)) ?></code></pre>
228 <?php endif; ?>
229 <pre class="publickey"><?php readfile("./replicator.pub") ?></pre>
230 </div>
231 <div class="column-8">
232 <h4>OpenPGP <small><a href="4093AEF6.pub" download>4093AEF6.pub</a></small></h4>
233 <?php if (!empty($phar)) : ?>
234 <pre class="code"><code>
235 curl -sSO https://replicator.pharext.org/4093AEF6.pub
236
237 gpg --import 4093AEF6.pub
238
239 gpg --verify <?= htmlspecialchars(basename($phar)).".asc" ?> \
240 <?= htmlspecialchars(basename($phar)) ?></code></pre>
241 <?php endif; ?>
242 <pre class="publickey"><?php readfile("./4093AEF6.pub") ?></pre>
243 </div>
244 </div>
245 </div>
246 <div class="footer">
247 <footer>
248 &copy; 2015 <a href="https://m6w6.name">m6w6</a>, Michael Wallner &mdash; Powered by <a href="//github.com/m6w6/pharext">pharext
249 <?php
250 require_once "../vendor/autoload.php";
251 printf("v%s\n", pharext\Metadata::version());
252 ?>
253 </a>
254 </footer>
255 </div>
256 <script type="text/javascript">
257 function searchPackages(search, regex) {
258 console.log("searchPackages", search, regex);
259 document.querySelectorAll("ul.package-list li").forEach(function(li) {
260 if (regex) {
261 if (li.id.match(search.toLowerCase())) {
262 li.style.removeProperty("display");
263 } else {
264 li.style.display = "none";
265 }
266 } else {
267 if (li.id.startsWith(search.toLowerCase())) {
268 li.style.removeProperty("display");
269 } else {
270 li.style.display = "none";
271 }
272 }
273 });
274 }
275
276 document.body.onload = function() {
277 var form = document.querySelector("form[name=search]");
278 var input = document.createElement("input");
279 var reset = document.createElement("input");
280 var prefix_label = document.createElement("label");
281 var prefix = document.createElement("input");
282 var regex_label = document.createElement("label");
283 var regex = document.createElement("input");
284
285 form.onreset = function() {
286 searchPackages("", false);
287 };
288
289 input.id = "s";
290 input.autocomplete = "off";
291 input.name = "s";
292 input.type = "search";
293 input.placeholder = "Search...";
294 input.oninput = function() {
295 searchPackages(input.value, regex.checked);
296 };
297 input.style.paddingRight = "4ch";
298 form.appendChild(input);
299
300 reset.id = "r";
301 reset.name = "r";
302 reset.type = "reset";
303 reset.value = "☒";
304 reset.title = "Reset";
305 reset.style.marginLeft = "-4ch";
306 reset.style.marginRight = "4ch";
307 reset.style.border = "none";
308 reset.style.background = "transparent";
309 form.appendChild(reset);
310
311 prefix.id = "prefix";
312 prefix.name = "by";
313 prefix.value = "prefix";
314 prefix.type = "radio";
315 prefix.defaultChecked = true;
316 prefix.checked = true;
317 prefix.onchange = function() {
318 searchPackages(input.value, regex.checked);
319 };
320 //form.appendChild(prefix);
321 prefix_label.innerText = "by Prefix";
322 prefix_label.appendChild(prefix);
323 form.appendChild(prefix_label);
324
325 regex.id = "regex";
326 regex.name = "by";
327 regex.value = "regex";
328 regex.type = "radio";
329 regex.checked = false;
330 regex.onchange = function() {
331 searchPackages(input.value, regex.checked);
332 };
333 //form.appendChild(regex);
334 regex_label.innerText = "by RegExp";
335 regex_label.appendChild(regex);
336 form.appendChild(regex_label);
337
338 input.focus();
339 };
340
341 function toggleOldVersions(a) {
342 var nodes, row_style;
343
344 if (a.hash.substring(1) === "old") {
345 row_style = "table-row";
346 document.getElementById("old-toggle").style.display = "none";
347 document.getElementById("new-toggle").style.display = "inline";
348 } else {
349 row_style = "none";
350 document.getElementById("old-toggle").style.display = "inline";
351 document.getElementById("new-toggle").style.display = "none";
352 }
353
354 nodes = document.querySelectorAll("table.versions>tbody>tr.old-version");
355
356 for (var i = 0; i < nodes.length; ++i) {
357 nodes.item(i).style.display = row_style;
358 }
359 }
360 </script>
361 </body>
362 </html>
363 <?php
364 $res->send();
365 ?>