-
Notifications
You must be signed in to change notification settings - Fork 4
/
triton.html
707 lines (638 loc) · 19.3 KB
/
triton.html
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
<!doctype html>
<!--
Triton Changelog made pretty
Author: Dave Eddy <[email protected]>
License: MIT
-->
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Triton Changelog</title>
<script>
// URI (in the case, relative to our domain) where SmartOS releases
// are stored in Manta
var BASE_URI = '/Joyent_Dev/public/SmartDataCenter';
// The base repository URL where all repos in the Triton Changelogs can be found
var BASE_REPO = 'https://github.com/TritonDataCenter';
// The URIs to use for bug/issue numbers extracted from commit messages
var SMARTOS_BUG_URI = 'http://smartos.org/bugview/:bug';
var ILLUMOS_BUG_URI = 'https://www.illumos.org/issues/:bug';
// Headers to send to manta with each request
var MANTA_HEADERS = {
'Cache-Control': 'no-cache',
'Pragma': 'no-cache'
};
// Number of releases to show on the left side by default
var MAX_RELEASES = 50;
// A Map of repo names in the Changelog, to the repo name found on GitHub.
// At the time of this writing, the repo in the changelog is "illumos", but on
// GitHub it is called "illumos-joyent"
var REPO_MAP = {
'illumos': 'illumos-joyent',
'kvm': 'illumos-kvm',
'kvm-cmd': 'illumos-kvm-cmd',
'platform': 'smartos-live',
};
// Directories to skip when pulling releases
var BLACKLIST_DIRS = [
'hotpatches',
'build-cache'
];
/**
* simple function to make a request and get the text back
*
* ex:
* request('/foobar.txt', function(err, text) {
* console.log(text);
* });
*/
function request(uri, method, data, headers, cb) {
if (typeof method === 'function') {
cb = method;
method = undefined;
}
if (typeof data === 'function') {
cb = data;
data = undefined;
}
if (typeof headers === 'function') {
cb = headers;
headers = undefined;
}
method = method || 'GET';
headers = headers || {};
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
var e;
if (xhr.readyState !== 4)
return;
if (xhr.status !== 200) {
e = new Error('request failed');
e.xhr = xhr;
cb(e);
return;
}
cb(null, xhr.responseText);
};
xhr.open(method, uri, true);
Object.keys(headers).forEach(function(header) {
xhr.setRequestHeader(header, headers[header]);
});
xhr.send(data);
return xhr;
}
/**
* Print a human readable timestamp to the terminal
* given a number representing seconds
*
* taken from https://github.com/bahamas10/human
*
* Author: Dave Eddy <[email protected]>
* Date: 8/18/2014
* License: MIT
*/
function human(seconds) {
if (seconds instanceof Date)
seconds = Math.round((Date.now() - seconds.getTime()) / 1000);
var suffix = seconds < 0 ? 'from now' : 'ago';
seconds = Math.abs(seconds);
var times = [
seconds / 60 / 60 / 24 / 365, // years
seconds / 60 / 60 / 24 / 30, // months
seconds / 60 / 60 / 24, // days
seconds / 60 / 60, // hours
seconds / 60, // minutes
seconds // seconds
];
var names = ['year', 'month', 'day', 'hour', 'minute', 'second'];
for (var i = 0; i < names.length; i++) {
var time = Math.floor(times[i]);
if (time > 1)
return time + ' ' + names[i] + 's ' + suffix;
else if (time === 1)
return time + ' ' + names[i] + ' ' + suffix;
}
return '0 seconds ' + suffix;
}
/**
* Append content to the given <ul> object by parsing the md5sums.txt
* file from the given url. At the moment, we only need this to
* determine the name of the platform tarball, which differs across
* releases.
* We pass in name_date and compressed_suffix which are also needed
* for the correct link creation.
*/
function generate_file_links(release_json, name, name_date, compressed_suffix, ul) {
request(release_json, 'GET', undefined, MANTA_HEADERS, function(err, data) {
var release_data = JSON.parse(data);
var files = [];
var img_types = [
'usb',
'coal',
'iso',
'ipxe'
]
/**
* Parse release.json for downloadable
* images. We only include full HN
* images here. Not gz-tools or boot.
*/
Object.keys(release_data).forEach(function (k) {
if (img_types.indexOf(k) !== -1) {
var pad = ' ';
if (k.length === 3) {
pad = pad + ' ';
}
files.push({
href: BASE_URI + '/' + name + '/headnode/' + release_data[k],
name: 'download ' + k.toUpperCase() + pad + release_data[k]
})
}
})
files.push(null); // spacer
// Triton currently doesn't have a download page.
// Should we add one?
// {
// href: BASE_URI + '/' + name + '/index.html',
// name: 'download page'
// },
files.push({
href: BASE_URI + '/' + name + '/changelog.txt',
name: 'raw changelog'
});
files.forEach(function (o) {
if (o === null) {
ul.appendChild(document.createElement('br'));
return;
}
var li = document.createElement('li');
var a = document.createElement('a');
var pre = document.createElement('pre');
pre.style.display = 'inline';
a.href = o.href;
a.target = '_blank';
pre.textContent = o.name;
a.appendChild(pre);
li.appendChild(a);
ul.appendChild(li);
});
});
}
/**
* Load a Triton Changelog given both the name of the release, and
* the URL to the changelog.txt file
*
* This function returns nothing, and creates, basically, the majority
* of the HTML site seen
*/
function load_changelog(name, url) {
// strip off any "-toxic" or release suffix
var branch_stub, branch_date, name_date, hash;
var name_a = name.split('-');
var branch = name_a[0] + '-' + name_a[1];
var stamp = name_a[2];
var hash = name_a[3];
var name_date = [ branch, stamp, hash ].join('-');
// Releases newer than 20190425-20190425T015956Z
// will have the git hash at the end.
// if (typeof hash !== "undefined") {
// name_date = name_date + '-' + hash;
// }
// grab the changelog text
request(url, 'GET', undefined, MANTA_HEADERS, function(err, txt) {
var a;
commits.innerHTML = '';
// the main title, the name of the smartos release
var h1 = document.createElement('h1');
a = document.createElement('a');
a.textContent = name;
a.target = '_blank';
a.href = BASE_URI + '/' + name + '/index.html';
h1.appendChild(a);
commits.appendChild(h1);
if (err) {
var p = document.createElement('p');
p.textContent = 'failed to load ' + url + ': ' + err.message;
commits.appendChild(p);
return;
}
var d = parse_commits(txt);
// the raw-changelog link and the time of the release
var div = document.createElement('div');
div.className = 'raw-changelog';
var newboot_date = new Date('2019-04-10');
// If the release is this or older, we need
// to figure out what the hash will be for the
// filenames because it's not in the dirname.
var hash_included_date = new Date('2019-04-25');
// the release date in relative form
var p = document.createElement('p');
// NOTE: javascript doesn't accept YYYYMMDDTHHMMSSZ time format, so we have to use regex
// to break it into something `new Date()` accepts
var stamp = name_date.split('-')[2];
var date = new Date(stamp.replace(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/, '$1-$2-$3T$4:$5:$6.000Z'));
var compressed_suffix = 'bz2';
if (date > newboot_date)
compressed_suffix = 'gz';
p.textContent = 'released ' + human(date);
div.appendChild(p);
// spacer
div.appendChild(document.createElement('br'));
// links
var ul = document.createElement('ul');
ul.className = 'links';
// We determine the platform name by parsing the md5sums
// file since these vary by release.
var release_json = BASE_URI + '/' + name + '/headnode/release.json';
generate_file_links(release_json, name, name_date, compressed_suffix, ul);
div.appendChild(ul);
commits.appendChild(div);
// loop each repo
Object.keys(d).forEach(function(repo) {
if (!d[repo].length)
return;
// repo title
var h2 = document.createElement('h2');
a = document.createElement('a');
a.target = '_blank';
a.href = BASE_REPO + '/' + (REPO_MAP[repo] || repo);
a.textContent = repo;
h2.appendChild(a);
commits.appendChild(h2);
// loop each commit
for (var i = 0; i < d[repo].length; i++) {
var o = d[repo][i];
var p = document.createElement('p');
p.className = 'commit';
a = document.createElement('a');
a.href = BASE_REPO + '/' + (REPO_MAP[repo] || repo) + '/commit/' + o.hash;
a.target = '_blank';
var span;
span = document.createElement('span');
span.className = 'hash';
span.textContent = o.hash.substr(0, 8);
a.appendChild(span);
span = document.createElement('span');
span.className = 'author';
span.textContent = ' ' + o.author;
p.appendChild(a);
p.appendChild(span);
// loop each line of the commit message
o.message.forEach(function(message) {
var _p = document.createElement('pre');
var match;
// triton bug
match = message.match(/^([a-zA-Z]+-[0-9]+):? (.*)$/);
if (match) {
var bugid = match[1];
var url = SMARTOS_BUG_URI.replace(':bug', bugid);
a = document.createElement('a');
a.href = url;
a.target = '_blank';
a.textContent = bugid;
_p.appendChild(a);
message = ' ' + match[2];
}
// illumos bug
match = message.match(/^( {4})?([0-9]+) (.*)$/);
if (repo.match(/^illumos/) && match) {
var padding = match[1] || '';
var _s = document.createElement('span');
_s.textContent = padding;
_p.appendChild(_s);
var bugid = match[2];
var url = ILLUMOS_BUG_URI.replace(':bug', bugid);
a = document.createElement('a');
a.href = url;
a.target = '_blank';
a.textContent = '#' + bugid;
_p.appendChild(a);
message = ' ' + match[3];
}
span = document.createElement('span');
span.textContent = message;
_p.appendChild(span);
p.appendChild(_p);
});
commits.appendChild(p);
}
});
commits_div.scrollTop = 0;
});
}
/**
* given commits in the format of the Triton Changelog,
* return an object like
* {
* "repo": [
* {
* "author": "Some Name",
* "hash": "<commit hash>",
* "date": <Date Object>,
* "message": [array, of, commit, messages]
* },
* ...
* ]
* }
*
* The `txt` argument is simply the plaintext as found in changelog.txt
*/
function parse_commits(txt) {
var data = {};
var current_repo;
var current_commit;
txt.trim().split('\n').forEach(function(line) {
// titles are prefixed with two hash marks
if (line.match(/^## /)) {
current_repo = line.match(/^## (.*)/)[1];
data[current_repo] = [];
return;
}
// process commits
var match;
if (match = line.match(/^([0-9a-f]+) - (([A-Z]+-)?[0-9]+:? .*) <(.*)>$/)) {
current_commit = data[current_repo].length;
data[current_repo][current_commit] = {
hash: match[1],
message: [match[2]],
author: match[4]
};
}
});
return data;
}
window.addEventListener('load', init);
var releases_ul;
var commits_div;
var about_div;
function init() {
releases_ul = document.getElementById('releases');
commits_div = document.getElementById('commits');
about_div = document.getElementById('about');
var hash = window.location.hash.substr(1);
// make all links open in a new window
var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++)
links[i].target = links[i].target || '_blank';
// Request all releases, including a 'limit' query parameter.
// (otherwise we would default to 256 releases) Note that this
// is separate to MAX_RELEASES, which only defines the visible
// number of releases.
request(BASE_URI + '?limit=1024', 'GET', undefined, MANTA_HEADERS, function(err, text) {
if (err) {
alert('failed to find releases: ' + err.message);
return;
}
var releases = [];
// parse the Manta directory format of newline separated JSON blobs
text.trim().split('\n').forEach(function(line) {
var o = JSON.parse(line);
if (o.type === 'directory' && BLACKLIST_DIRS.indexOf(o.name) < 0)
releases.push(o.name);
});
// sort releases by reverse date (newest first)
releases = releases.sort(function(a, b) {
return a > b ? -1 : 1;
});
// releases is now a reverse sorted array with the names
// of all smartos releases
var hidden = [];
releases.forEach(function(name, i) {
var li = document.createElement('li');
var a = document.createElement('a');
// this URI will fail on older smartos releases that don't have changelogs
a.href = BASE_URI + '/' + name + '/changelog.txt';
a.textContent = name;
a.onclick = function() {
window.location.hash = name;
return false;
};
li.appendChild(a);
if (i >= MAX_RELEASES) {
li.style.display = 'none';
hidden.push(li);
}
releases_ul.appendChild(li);
if (!hash && i === 0) {
// no hash supplied in the URI, click the first one (newest)
window.location.replace(window.location + '#' + name);
} else if (hash && hash == name) {
// a hash was supplied and a link matches the given hash, load it
var href = BASE_URI + '/' + name + '/changelog.txt';
load_changelog(name, href);
}
});
// add load more if > MAX_RELEASES releases seen
if (hidden.length > 0) {
var li = document.createElement('li');
var a = document.createElement('a');
a.href = '#';
a.textContent = hidden.length + ' more...';
a.onclick = function() {
li.style.display = 'none';
hidden.forEach(function (h) {
h.style.display = 'block';
});
return false;
};
li.appendChild(a);
releases_ul.appendChild(li);
}
});
}
// handle back button and hashchange
window.addEventListener('popstate', popstate);
function popstate(event) {
var name = window.location.hash.substr(1);
if (!name)
return;
var href = BASE_URI + '/' + name + '/changelog.txt';
load_changelog(name, href);
}
</script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
-moz-box-sizing: border-box;
}
body {
background-color: #497b94;
color: #f9f9f9;
font-size: 11pt;
font-family: monospace;
}
a {
color: white;
text-decoration: none;
}
#top-bar {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 40px;
background-color: #396b84;
z-index: 1;
font-family: sans-serif;
text-align: right;
padding: 0 10px;
}
#top-bar h1 {
float: left;
}
#top-bar h1 a {
font-size: 24pt;
}
#top-bar > a {
color: white;
text-decoration: none;
font-size: 9pt;
}
#content {
margin-top: 40px;
position: relative;
}
#left-side {
position: relative;
width: 200px;
padding: 5px;
}
#releases {
list-style: none;
}
#releases li {
margin: 4px;
border-radius: 5px;
}
#releases li a {
display: block;
text-decoration: none;
color: #89abd4;
padding: 5px;
background-color: #396b84;
border-radius: 5px;
}
#releases li a:hover {
background-color: #497b94;
}
#right-side {
position: fixed;
right: 0;
top: 40px;
bottom: 0;
left: 200px;
}
ul.links {
list-style: none;
}
ul.links li:before {
content: "- ";
position: relative;
}
#commits {
position: absolute;
border-radius: 5px;
margin-right: 10px;
margin-top: 10px;
margin-bottom: 10px;
padding: 10px;
border: 1px solid #396b84;
background-color: #396b84;
overflow-x: auto;
overflow-y: auto;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
#commits h1 {
border-bottom: 2px solid white;
margin-bottom: 15px;
}
#commits h2 {
font-weight: normal;
border-bottom: 1px dashed white;
margin-bottom: 13px;
}
#commits a {
text-decoration: none;
color: white;
}
#commits a:hover {
text-decoration: underline;
}
#commits div.raw-changelog {
font-size: 8pt;
display: block;
margin: 10px;
}
#commits p.commit {
margin-bottom: 12px;
color: #bbb;
font-size: 9pt;
}
#commits p pre {
margin-left: 18px;
}
#commits p a {
font-size: 10pt;
color: #a1ccff;
}
#commits p a:hover {
text-decoration: underline;
}
#commits span.hash {
font-family: monospace;
}
#commits span.author {
color: #fdfdfd;
}
#about {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
padding: 100px;
color: #dfdfdf;
border: 1px solid #396b84;
background-color: #598ba4;
font-family: sans-serif;
font-size: 10pt;
}
#about p {
margin: 20px 0;
}
#about a:hover {
text-decoration: underline;
}
.hidden {
display: none;
}
</style>
</head>
<body>
<div id="top-bar">
<h1><a href="" onclick="location.reload();" target="_self">Triton Changelog</a></h1>
<a href="" onclick="about_div.className = about_div.className ? '' : 'hidden'; return false;">about</a>
</div>
<div id="content">
<div id="left-side">
<ul id="releases"></ul>
</div>
<div id="right-side">
<div id="commits"></div>
</div>
</div>
<div id="about" class="hidden">
<p>This site provides a dynamically updated Changelog for the <a href="http://tritondatacenter.com/">Triton Data Center</a> cloud platform.</p>
<p>The page is generated by parsing the list of releases located at <a href="https://us-central.manta.mnx.io/Joyent_Dev/public/SmartDataCenter/">https://us-central.manta.mnx.io/Joyent_Dev/public/SmartDataCenter/</a>, and then looking for a <code>changelog.txt</code> file to extract the commit messages from. Commit hashs are automatically linked to the diffs on GitHub, and bug IDs to their respective page on <a href="http://smartos.org/bugview/">http://smartos.org/bugview/</a>.</p>
<p>Also, check out <a href="https://chrome.google.com/webstore/detail/manta-directory-listing/ekhnojbkmjgplcpnecfnlbpldcoddahe">this chrome extension</a> to easily browse directories on Manta. It makes browsing SmartOS (and other) releases through Manta very easy.</p>
<small>Source Code: <a href="https://github.com/TritonDataCenter/smartos-changelog">https://github.com/TritonDataCenter/smartos-changelog</a></small><br />
<small>Creator: <a href="https://github.com/bahamas10">Dave Eddy <bahamas10></a></small><br /><br />
<a href="" onclick="about_div.className = 'hidden'; return false;">← back</a>
</div>
</body>
</html>