toggle old versions display
[pharext/replicator.pharext.org] / public / html.php
1 <?php
2 const INCLUDED = __FILE__;
3 const NCURRENT = 2;
4 require_once "index.php";
5
6 ob_start($res);
7
8 ?>
9 <!doctype html>
10 <html>
11 <head>
12 <meta charset="utf-8">
13 <title>Replicator</title>
14 <link rel="stylesheet" href="concise/css/concise.min.css">
15 <link href="//fonts.googleapis.com/css?family=Droid+Sans" rel="stylesheet" type="text/css">
16 <meta name="viewport" content="width=device-width, initial-scale=1">
17 <style>
18 body {
19 padding-bottom: 2em;
20 padding-top: 7em;
21 }
22 .header {
23 top: 0;
24 width: 100%;
25 }
26 .footer {
27 bottom: 0;
28 width: 100%;
29 text-align: center;
30 font-size: .9em;
31 }
32 .header, .footer {
33 position: fixed;
34 box-shadow: 0px 0px .8em .4em #89a;
35 background: #62B3E7;
36 padding: .5em 0;
37 }
38 .header h1 {
39 font-weight: bold;
40 }
41 .header h1 a, .footer a:hover {
42 text-decoration: none;
43 }
44 .header h1 a:hover {
45 text-decoration: underline;
46 }
47 .header h1 a {
48 /* normalize browser difference */
49 font-size: 1.3em;
50 }
51 .header h1 a, .footer, .footer a {
52 color: #fdfdfd;
53 text-shadow: grey 0 0 .1em;
54 }
55 .header h1 small {
56 color: #666;
57 font-size: 1.3rem;
58 text-shadow: white 0 0 .2em;
59 }
60 li {
61 list-style-type: circle;
62 }
63 pre.publickey {
64 font-size: .8rem;
65 line-height: 1rem;
66 }
67 pre.code {
68 background: #333;
69 color: #62B3E7;
70 padding: 0 1.5em 1.5em 1em;
71 border-radius: 4px;
72 margin-right: 2em;
73 display: inline-block;
74 }
75 pre.code>code {
76 font-size: .9rem;
77 }
78 .row>h3 {
79 margin-bottom: 0;
80 }
81 @media(max-width: 80em) {
82 .column-8 {
83 float: none;
84 width: auto;
85 }
86 }
87 .old-version, #new-toggle {
88 display: none;
89 }
90 </style>
91 </head>
92 <body>
93 <div class="header">
94 <header>
95 <h1 class="container">
96 <a href="?">Replicator</a><br>
97 <small>Replicating PECL releases as pharext packages since 2015</small>
98 </h1>
99 <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>
100 </header>
101 </div>
102 <div class="container">
103
104 <?php if (!empty($package)) : $versions = package_versions($package); ?>
105
106 <h2><?= htmlspecialchars($package) ?></h2>
107 <table class="table table-full versions">
108 <thead>
109 <tr>
110 <th class="text-left" colspan="2">Package</th>
111 <th class="text-left" colspan="<?= count(SIGS) ?>">Signatures</th>
112 <th class="text-left">Date</th>
113 <th class="text-right">Pharext</th>
114 </tr>
115 </thead>
116 <tbody>
117
118 <?php $i = 0; foreach (array_reverse($versions) as $version => $phars) : ++$i; ?>
119 <?php foreach (array_map("array_values", $phars) as $ext => list($phar, $date, $size, $pharext)) : ?>
120 <tr <?php if ($i > NCURRENT) : ?>class="old-version"<?php endif; ?> <?php if ($i === NCURRENT) : ?>id="old"<?php endif; ?>>
121 <?php if (empty($ext)) : ?>
122 <td class="text-left" rowspan="<?= count($phars) ?>">
123 <?= htmlspecialchars($package) ?>
124 <?= htmlspecialchars($version) ?>
125 </td>
126 <?php endif ?>
127
128 <td class="text-left">
129 &#10507;&nbsp;<a href="<?= htmlspecialchars($phar) ?>"
130 download>phar<?= htmlspecialchars($ext) ?></a>&nbsp;<small>(<?= human_size($size) ?>)</small><br>
131 </td>
132 <?php foreach (SIGS as $typ => $sig) : ?>
133 <td>
134 #&nbsp;<a href="<?= sigof($phar, $sig) ?>" download><?= "$typ.$sig" ?></a>
135 </td>
136 <?php endforeach; ?>
137 <td class="text-left">
138 <?= human_date($date); ?>
139
140 </td>
141 <td class="text-right <?= version_compare($pharext, "3.0.1", "<") ? "color-red":"" ?>">
142 v<?= $pharext ?>
143 </td>
144 </tr>
145 <?php endforeach; ?>
146 <?php endforeach; ?>
147
148 </tbody>
149 </table>
150 <?php if ($i >= 3) : ?>
151 <p class="small">
152 <a id="old-toggle" href="#old" onclick="toggleOldVersions(this)">Show
153 <?=count($versions)-NCURRENT?> older version(s) &raquo;</a>
154 <a id="new-toggle" href="#" onclick="toggleOldVersions(this)">Show
155 less versions &laquo;</a>
156 </p>
157 <?php endif; ?>
158 <?php else: ?>
159
160 <h2>Available Packages</h2>
161 <ul class="list-inline">
162 <?php foreach (array_map("htmlspecialchars", $packages) as $index => $pkg) : ?>
163 <?php $next = strtolower($pkg{0}); ?>
164 <?php if (isset($prev) && $next != $prev) : ?>
165
166 </ul>
167 <ul class="list-inline">
168 <?php endif; ?>
169
170 <li><a href="?<?= $pkg ?>"><?= $pkg ?></a></li>
171 <?php $prev = $next; ?>
172 <?php endforeach; ?>
173
174 </ul>
175 <?php endif; ?>
176 <hr>
177 <div class="row">
178 <?php if (empty($package)) : ?>
179 <h3>Public keys</h3>
180 <?php else : list($phar) = array_values(current(end($versions))); ?>
181 <h3>Download latest version and signatures:</h3>
182 <div class="column-16">
183 <pre class="code fit-code"><code>
184 curl -sS \
185 -O https://replicator.pharext.org/<?= htmlspecialchars($phar) ?><?php foreach (SIGS as $sig) : ?> \
186 -O https://replicator.pharext.org/<?= htmlspecialchars(sigof($phar, $sig)) ?><?php endforeach; ?></code></pre>
187 </div>
188 </div>
189 <div class="row">
190 <h3>Verify with a public key:</h3>
191 <?php endif; ?>
192
193 <div class="column-8">
194 <h4>RSA <small><a href="replicator.pub" download>replicator.pub</a></small></h4>
195 <?php if (!empty($phar)) : ?>
196 <pre class="code"><code>
197 curl -sSO https://replicator.pharext.org/replicator.pub
198
199 openssl dgst \
200 -verify replicator.pub \
201 -signature <?= htmlspecialchars(basename($phar)).".sig" ?> \
202 <?= htmlspecialchars(basename($phar)) ?></code></pre>
203 <?php endif; ?>
204 <pre class="publickey"><?php readfile("./replicator.pub") ?></pre>
205 </div>
206 <div class="column-8">
207 <h4>OpenPGP <small><a href="4093AEF6.pub" download>4093AEF6.pub</a></small></h4>
208 <?php if (!empty($phar)) : ?>
209 <pre class="code"><code>
210 curl -sSO https://replicator.pharext.org/4093AEF6.pub
211
212 gpg --import 4093AEF6.pub
213
214 gpg --verify <?= htmlspecialchars(basename($phar)).".asc" ?> \
215 <?= htmlspecialchars(basename($phar)) ?></code></pre>
216 <?php endif; ?>
217 <pre class="publickey"><?php readfile("./4093AEF6.pub") ?></pre>
218 </div>
219 </div>
220 </div>
221 <div class="footer">
222 <footer>
223 &copy; 2015 <a href="https://m6w6.name">m6w6</a>, Michael Wallner &mdash; Powered by <a href="//github.com/m6w6/pharext">pharext
224 <?php
225 require_once "../vendor/autoload.php";
226 printf("v%s\n", pharext\Metadata::version());
227 ?>
228 </a>
229 </footer>
230 </div>
231 <script type="text/javascript">
232 function toggleOldVersions(a) {
233 var nodes, row_style;
234
235 if (a.hash.substring(1) === "old") {
236 row_style = "table-row";
237 document.getElementById("old-toggle").style.display = "none";
238 document.getElementById("new-toggle").style.display = "inline";
239 } else {
240 row_style = "none";
241 document.getElementById("old-toggle").style.display = "inline";
242 document.getElementById("new-toggle").style.display = "none";
243 }
244
245 nodes = document.querySelectorAll("table.versions>tbody>tr.old-version");
246
247 for (var i = 0; i < nodes.length; ++i) {
248 nodes.item(i).style.display = row_style;
249 }
250 }
251 </script>
252 </body>
253 </html>
254 <?php
255 $res->send();
256 ?>