initial commit

This commit is contained in:
osmarks 2020-03-08 17:13:14 +00:00
commit ccd4f72d2d
54 changed files with 4730 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules
out

BIN
assets/images/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

12
assets/images/logo.svg Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg viewBox="0 0 384 384" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="128" height="128" shape-rendering="crispEdges" style="fill: none; stroke-width: 0;"></rect>
<rect x="128" y="0" width="128" height="128" shape-rendering="crispEdges" style="fill: white; stroke-width: 0;"></rect>
<rect x="256" y="0" width="128" height="128" shape-rendering="crispEdges" style="fill: none; stroke-width: 0;"></rect>
<rect x="0" y="128" width="128" height="128" shape-rendering="crispEdges" style="fill: none; stroke-width: 0;"></rect>
<rect x="128" y="128" width="128" height="128" shape-rendering="crispEdges" style="fill: none; stroke-width: 0;"></rect>
<rect x="256" y="128" width="128" height="128" shape-rendering="crispEdges" style="fill: white; stroke-width: 0;"></rect>
<rect x="0" y="256" width="128" height="128" shape-rendering="crispEdges" style="fill: white; stroke-width: 0;"></rect>
<rect x="128" y="256" width="128" height="128" shape-rendering="crispEdges" style="fill: white; stroke-width: 0;"></rect>
<rect x="256" y="256" width="128" height="128" shape-rendering="crispEdges" style="fill: white; stroke-width: 0;"></rect>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

337
assets/js/h4xx0r.js Normal file
View File

@ -0,0 +1,337 @@
// Chooses a random element from an array
function choose(arr) {
return arr[Math.floor(Math.random() * arr.length)]
}
String.prototype.capitalizeFirstLetter = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
// A collection of jargon
jargonWords = {
acronyms:
["TCP", "HTTP", "SDD", "RAM", "GB", "CSS", "SSL", "AGP", "SQL", "FTP", "PCI", "AI", "ADP",
"RSS", "XML", "EXE", "COM", "HDD", "THX", "SMTP", "SMS", "USB", "PNG", "PHP", "UDP",
"TPS", "RX", "ASCII", "CD-ROM", "CGI", "CPU", "DDR", "DHCP", "BIOS", "IDE", "IP", "MAC",
"MP3", "AAC", "PPPoE", "SSD", "SDRAM", "VGA", "XHTML", "Y2K", "GUI", "EPS"],
adjectives:
["auxiliary", "primary", "back-end", "digital", "open-source", "virtual", "cross-platform",
"redundant", "online", "haptic", "multi-byte", "bluetooth", "wireless", "1080p", "neural",
"optical", "solid state", "mobile", "unicode", "backup", "high speed", "56k", "analog",
"fiber optic", "central", "visual", "ethernet", "Griswold"],
nouns:
["driver", "protocol", "bandwidth", "panel", "microchip", "program", "port", "card",
"array", "interface", "system", "sensor", "firewall", "hard drive", "pixel", "alarm",
"feed", "monitor", "application", "transmitter", "bus", "circuit", "capacitor", "matrix",
"address", "form factor", "array", "mainframe", "processor", "antenna", "transistor",
"virus", "malware", "spyware", "network", "internet", "field", "acutator", "tetryon",
"beacon", "resonator"],
participles:
["backing up", "bypassing", "hacking", "overriding", "compressing", "copying", "navigating",
"indexing", "connecting", "generating", "quantifying", "calculating", "synthesizing",
"inputting", "transmitting", "programming", "rebooting", "parsing", "shutting down",
"injecting", "transcoding", "encoding", "attaching", "disconnecting", "networking",
"triaxilating", "multiplexing", "interplexing", "rewriting", "transducing",
"acutating", "polarising"
]};
// Generates a random piece of jargon
function jargon() {
let raw = choose(jargonWords.participles) + " " + choose(jargonWords.adjectives) + " " +
choose(jargonWords.acronyms) + " " + choose(jargonWords.nouns);
return raw.capitalizeFirstLetter()
}
/* Graphics stuff */
function Square(z) {
this.width = settings.canvas.width/2;
this.height = settings.canvas.height;
z = z || 0;
var canvas = settings.canvas;
this.points = [
new Point({
x: (canvas.width / 2) - this.width,
y: (canvas.height / 2) - this.height,
z: z,
}),
new Point({
x: (canvas.width / 2) + this.width,
y: (canvas.height / 2) - this.height,
z: z
}),
new Point({
x: (canvas.width / 2) + this.width,
y: (canvas.height / 2) + this.height,
z: z
}),
new Point( {
x: (canvas.width / 2) - this.width,
y: (canvas.height / 2) + this.height,
z: z
})
];
this.dist = 0;
}
Square.prototype.update = function () {
for (var p = 0; p < this.points.length; p++) {
this.points[p].rotateZ(0.001);
this.points[p].z -= 3;
if (this.points[p].z < -300) {
this.points[p].z = 2700;
}
this.points[p].map2D();
}
};
Square.prototype.render = function () {
settings.ctx.beginPath();
settings.ctx.moveTo(this.points[0].xPos, this.points[0].yPos);
for (var p = 1; p < this.points.length; p++) {
if (this.points[p].z > -(settings.focal - 50)) {
settings.ctx.lineTo(this.points[p].xPos, this.points[p].yPos);
}
}
settings.ctx.closePath();
settings.ctx.stroke();
this.dist = this.points[this.points.length - 1].z;
};
function Point(pos) {
this.x = pos.x - settings.canvas.width / 2 || 0;
this.y = pos.y - settings.canvas.height / 2 || 0;
this.z = pos.z || 0;
this.cX = 0;
this.cY = 0;
this.cZ = 0;
this.xPos = 0;
this.yPos = 0;
this.map2D();
}
Point.prototype.rotateZ = function (angleZ) {
var cosZ = Math.cos(angleZ),
sinZ = Math.sin(angleZ),
x1 = this.x * cosZ - this.y * sinZ,
y1 = this.y * cosZ + this.x * sinZ;
this.x = x1;
this.y = y1;
};
Point.prototype.map2D = function () {
var scaleX = settings.focal / (settings.focal + this.z + this.cZ),
scaleY = settings.focal / (settings.focal + this.z + this.cZ);
this.xPos = settings.vpx + (this.cX + this.x) * scaleX;
this.yPos = settings.vpy + (this.cY + this.y) * scaleY;
};
// ** Main function **//
function GuiHacker(){
this.squares = [];
this.barVals = [];
this.sineVal = [];
for (var i = 0; i < 15; i++) {
this.squares.push(new Square(-300 + (i * 200)));
}
// Console stuff
this.responses = [
'Authorizing ',
'Authorized...',
'Access Granted..',
'Going Deeper....',
'Compression Complete.',
'Compilation of Data Structures Complete..',
'Entering Security Console...',
'Encryption Unsuccesful Attempting Retry...',
'Waiting for response...',
'....Searching...',
'Calculating Space Requirements '
];
this.isProcessing = false;
this.processTime = 0;
this.lastProcess = 0;
this.render();
this.consoleOutput();
}
GuiHacker.prototype.render = function(){
var ctx = settings.ctx,
canvas = settings.canvas,
ctxBars = settings.ctxBars,
canvasBars = settings.canvasBars;
ctx.clearRect(0, 0, canvas.width, canvas.height);
this.squares.sort(function (a, b) {
return b.dist - a.dist;
});
for (var i = 0, len = this.squares.length; i < len; i++) {
var square = this.squares[i];
square.update();
square.render();
}
ctxBars.clearRect(0, 0, canvasBars.width, canvasBars.height);
ctxBars.beginPath();
var y = canvasBars.height/6;
ctxBars.moveTo(0,y);
for(i = 0; i < canvasBars.width; i++){
var ran = (Math.random()*20)-10;
if(Math.random() > 0.98){
ran = (Math.random()*50)-25;
}
ctxBars.lineTo(i, y + ran);
}
ctxBars.stroke();
for(i = 0; i < canvasBars.width; i+=20){
if(!this.barVals[i]){
this.barVals[i] = {
val : Math.random()*(canvasBars.height/2),
freq : 0.1,
sineVal : Math.random()*100
};
}
var barVal = this.barVals[i];
barVal.sineVal+=barVal.freq;
barVal.val+=Math.sin(barVal.sineVal*Math.PI/2)*5;
ctxBars.fillRect(i+5,canvasBars.height,15,-barVal.val);
}
var self = this;
requestAnimationFrame(function(){self.render();});
};
// Generates a random binary, hexadecimal or floating-point number (as a string)
function scaryNum() {
let rand = Math.random()
let rand2 = Math.random()
if (rand2 > 0.7) {
let bigNum = rand * 1000000000
return bigNum.toString(16).split('.')[0] // big hexadecimal
} else if (rand2 > 0.4) {
let longNum = rand * 100000000000
return longNum.toString(2).split('.')[0] // big binary
} else {
return rand.toString() // float
}
}
GuiHacker.prototype.consoleOutput = function(){
var textEl = document.createElement('p');
if(this.isProcessing){
textEl = document.createElement('span');
textEl.textContent += scaryNum() + " ";
if(Date.now() > this.lastProcess + this.processTime){
this.isProcessing = false;
}
}else{
var commandType = ~~(Math.random()*4);
switch(commandType){
case 0:
textEl.textContent = jargon()
break;
case 3:
this.isProcessing = true;
this.processTime = ~~(Math.random()*5000);
this.lastProcess = Date.now();
break;
default:
textEl.textContent = this.responses[~~(Math.random()*this.responses.length)];
break;
}
}
var outputConsole = settings.outputConsole;
outputConsole.scrollTop = outputConsole.scrollHeight;
outputConsole.appendChild(textEl);
if (outputConsole.scrollHeight > window.innerHeight) {
var removeNodes = outputConsole.querySelectorAll('*');
for(var n = 0; n < ~~(removeNodes.length/3); n++){
outputConsole.removeChild(removeNodes[n]);
}
}
var self = this;
setTimeout(function(){self.consoleOutput();}, ~~(Math.random()*200));
};
// Settings
var settings = {
canvas : document.querySelector(".hacker-3d-shiz"),
ctx : document.querySelector(".hacker-3d-shiz").getContext("2d"),
canvasBars : document.querySelector(".bars-and-stuff"),
ctxBars : document.querySelector(".bars-and-stuff").getContext("2d"),
outputConsole : document.querySelector(".output-console"),
vpx : 0,
vpy : 0,
focal : 0,
color : "#00FF00",
title : "Gui Hacker",
gui : true
},
hash = decodeURIComponent(document.location.hash.substring(1)),
userSettings = {};
if (hash){
userSettings = JSON.parse(hash);
if(userSettings && userSettings.title !== undefined){
document.title = userSettings.title;
}
if(userSettings && userSettings.gui !== undefined){
settings.gui = userSettings.gui;
}
settings.color = userSettings.color || settings.color;
}
var adjustCanvas = function(){
if(settings.gui){
settings.canvas.width = (window.innerWidth/3)*2;
settings.canvas.height = window.innerHeight / 3;
settings.canvasBars.width = window.innerWidth/3;
settings.canvasBars.height = settings.canvas.height;
settings.outputConsole.style.height = (window.innerHeight / 3) * 2 + 'px';
settings.outputConsole.style.top = window.innerHeight / 3 + 'px';
settings.focal = settings.canvas.width / 2;
settings.vpx = settings.canvas.width / 2;
settings.vpy = settings.canvas.height / 2;
settings.ctx.strokeStyle = settings.ctxBars.strokeStyle = settings.ctxBars.fillStyle = settings.color;
}else{
document.querySelector(".hacker-3d-shiz").style.display = "none";
document.querySelector(".bars-and-stuff").style.display = "none";
}
document.body.style.color = settings.color;
}(),
guiHacker = new GuiHacker(settings);
window.addEventListener('resize', adjustCanvas);

22
assets/js/hyperapp-html.min.js vendored Normal file
View File

@ -0,0 +1,22 @@
/*
Copyright © 2017-present [Quentin Gerodel](https://github.com/Swizz)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("hyperapp")):"function"==typeof define&&define.amd?define(["exports","hyperapp"],t):t(n.hyperappHtml={},n.hyperapp)}(this,function(n,u){"use strict";function r(r){return function(n,t){return"object"!=typeof n||Array.isArray(n)?u.h(r,{},n):u.h(r,n,t)}}n.a=function(n,t){return r("a")(n,t)},n.abbr=function(n,t){return r("abbr")(n,t)},n.address=function(n,t){return r("address")(n,t)},n.area=function(n,t){return r("area")(n,t)},n.article=function(n,t){return r("article")(n,t)},n.aside=function(n,t){return r("aside")(n,t)},n.audio=function(n,t){return r("audio")(n,t)},n.b=function(n,t){return r("b")(n,t)},n.bdi=function(n,t){return r("bdi")(n,t)},n.bdo=function(n,t){return r("bdo")(n,t)},n.blockquote=function(n,t){return r("blockquote")(n,t)},n.br=function(n,t){return r("br")(n,t)},n.button=function(n,t){return r("button")(n,t)},n.canvas=function(n,t){return r("canvas")(n,t)},n.caption=function(n,t){return r("caption")(n,t)},n.cite=function(n,t){return r("cite")(n,t)},n.code=function(n,t){return r("code")(n,t)},n.col=function(n,t){return r("col")(n,t)},n.colgroup=function(n,t){return r("colgroup")(n,t)},n.data=function(n,t){return r("data")(n,t)},n.datalist=function(n,t){return r("datalist")(n,t)},n.dd=function(n,t){return r("dd")(n,t)},n.del=function(n,t){return r("del")(n,t)},n.details=function(n,t){return r("details")(n,t)},n.dfn=function(n,t){return r("dfn")(n,t)},n.dialog=function(n,t){return r("dialog")(n,t)},n.div=function(n,t){return r("div")(n,t)},n.dl=function(n,t){return r("dl")(n,t)},n.dt=function(n,t){return r("dt")(n,t)},n.em=function(n,t){return r("em")(n,t)},n.embed=function(n,t){return r("embed")(n,t)},n.fieldset=function(n,t){return r("fieldset")(n,t)},n.figcaption=function(n,t){return r("figcaption")(n,t)},n.figure=function(n,t){return r("figure")(n,t)},n.footer=function(n,t){return r("footer")(n,t)},n.form=function(n,t){return r("form")(n,t)},n.h1=function(n,t){return r("h1")(n,t)},n.h2=function(n,t){return r("h2")(n,t)},n.h3=function(n,t){return r("h3")(n,t)},n.h4=function(n,t){return r("h4")(n,t)},n.h5=function(n,t){return r("h5")(n,t)},n.h6=function(n,t){return r("h6")(n,t)},n.header=function(n,t){return r("header")(n,t)},n.hr=function(n,t){return r("hr")(n,t)},n.i=function(n,t){return r("i")(n,t)},n.iframe=function(n,t){return r("iframe")(n,t)},n.img=function(n,t){return r("img")(n,t)},n.input=function(n,t){return r("input")(n,t)},n.ins=function(n,t){return r("ins")(n,t)},n.kbd=function(n,t){return r("kbd")(n,t)},n.label=function(n,t){return r("label")(n,t)},n.legend=function(n,t){return r("legend")(n,t)},n.li=function(n,t){return r("li")(n,t)},n.main=function(n,t){return r("main")(n,t)},n.map=function(n,t){return r("map")(n,t)},n.mark=function(n,t){return r("mark")(n,t)},n.menu=function(n,t){return r("menu")(n,t)},n.menuitem=function(n,t){return r("menuitem")(n,t)},n.meter=function(n,t){return r("meter")(n,t)},n.nav=function(n,t){return r("nav")(n,t)},n.object=function(n,t){return r("object")(n,t)},n.ol=function(n,t){return r("ol")(n,t)},n.optgroup=function(n,t){return r("optgroup")(n,t)},n.option=function(n,t){return r("option")(n,t)},n.output=function(n,t){return r("output")(n,t)},n.p=function(n,t){return r("p")(n,t)},n.param=function(n,t){return r("param")(n,t)},n.pre=function(n,t){return r("pre")(n,t)},n.progress=function(n,t){return r("progress")(n,t)},n.q=function(n,t){return r("q")(n,t)},n.rp=function(n,t){return r("rp")(n,t)},n.rt=function(n,t){return r("rt")(n,t)},n.rtc=function(n,t){return r("rtc")(n,t)},n.ruby=function(n,t){return r("ruby")(n,t)},n.s=function(n,t){return r("s")(n,t)},n.samp=function(n,t){return r("samp")(n,t)},n.section=function(n,t){return r("section")(n,t)},n.select=function(n,t){return r("select")(n,t)},n.small=function(n,t){return r("small")(n,t)},n.source=function(n,t){return r("source")(n,t)},n.span=function(n,t){return r("span")(n,t)},n.strong=function(n,t){return r("strong")(n,t)},n.sub=function(n,t){return r("sub")(n,t)},n.summary=function(n,t){return r("summary")(n,t)},n.sup=function(n,t){return r("sup")(n,t)},n.svg=function(n,t){return r("svg")(n,t)},n.table=function(n,t){return r("table")(n,t)},n.tbody=function(n,t){return r("tbody")(n,t)},n.td=function(n,t){return r("td")(n,t)},n.textarea=function(n,t){return r("textarea")(n,t)},n.tfoot=function(n,t){return r("tfoot")(n,t)},n.th=function(n,t){return r("th")(n,t)},n.thead=function(n,t){return r("thead")(n,t)},n.time=function(n,t){return r("time")(n,t)},n.tr=function(n,t){return r("tr")(n,t)},n.track=function(n,t){return r("track")(n,t)},n.u=function(n,t){return r("u")(n,t)},n.ul=function(n,t){return r("ul")(n,t)},n.video=function(n,t){return r("video")(n,t)},n.wbr=function(n,t){return r("wbr")(n,t)}});

23
assets/js/hyperapp.min.js vendored Normal file
View File

@ -0,0 +1,23 @@
// Hyperapp 1.2.10
/*
Copyright © 2017-present [Jorge Bucaran](https://github.com/jorgebucaran)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.hyperapp={})}(this,function(e){"use strict";e.h=function(e,n){for(var t=[],r=[],o=arguments.length;2<o--;)t.push(arguments[o]);for(;t.length;){var l=t.pop();if(l&&l.pop)for(o=l.length;o--;)t.push(l[o]);else null!=l&&!0!==l&&!1!==l&&r.push(l)}return"function"==typeof e?e(n||{},r):{nodeName:e,attributes:n||{},children:r,key:n&&n.key}},e.app=function(e,n,t,r){var o,l=[].map,u=r&&r.children[0]||null,i=u&&function n(e){return{nodeName:e.nodeName.toLowerCase(),attributes:{},children:l.call(e.childNodes,function(e){return 3===e.nodeType?e.nodeValue:n(e)})}}(u),f=[],m=!0,a=v(e),c=function e(r,o,l){for(var n in l)"function"==typeof l[n]?function(e,t){l[e]=function(e){var n=t(e);return"function"==typeof n&&(n=n(h(r,a),l)),n&&n!==(o=h(r,a))&&!n.then&&d(a=p(r,v(o,n),a)),n}}(n,l[n]):e(r.concat(n),o[n]=v(o[n]),l[n]=v(l[n]));return l}([],a,v(n));return d(),c;function g(e){return"function"==typeof e?g(e(a,c)):null!=e?e:""}function s(){o=!o;var e=g(t);for(r&&!o&&(u=function e(n,t,r,o,l){if(o===r);else if(null==r||r.nodeName!==o.nodeName){var u=k(o,l);n.insertBefore(u,t),null!=r&&T(n,t,r),t=u}else if(null==r.nodeName)t.nodeValue=o;else{x(t,r.attributes,o.attributes,l=l||"svg"===o.nodeName);for(var i={},f={},a=[],c=r.children,s=o.children,d=0;d<c.length;d++){a[d]=t.childNodes[d];var v=N(c[d]);null!=v&&(i[v]=[a[d],c[d]])}for(var d=0,p=0;p<s.length;){var v=N(c[d]),h=N(s[p]=g(s[p]));if(f[v])d++;else if(null==h||h!==N(c[d+1]))if(null==h||m)null==v&&(e(t,a[d],c[d],s[p],l),p++),d++;else{var y=i[h]||[];v===h?(e(t,y[0],y[1],s[p],l),d++):y[0]?e(t,t.insertBefore(y[0],a[d]),y[1],s[p],l):e(t,a[d],null,s[p],l),f[h]=s[p],p++}else null==v&&T(t,a[d],c[d]),d++}for(;d<c.length;)null==N(c[d])&&T(t,a[d],c[d]),d++;for(var d in i)f[d]||T(t,i[d][0],i[d][1])}return t}(r,u,i,i=e)),m=!1;f.length;)f.pop()()}function d(){o||(o=!0,setTimeout(s))}function v(e,n){var t={};for(var r in e)t[r]=e[r];for(var r in n)t[r]=n[r];return t}function p(e,n,t){var r={};return e.length?(r[e[0]]=1<e.length?p(e.slice(1),n,t[e[0]]):n,v(t,r)):n}function h(e,n){for(var t=0;t<e.length;)n=n[e[t++]];return n}function N(e){return e?e.key:null}function y(e){return e.currentTarget.events[e.type](e)}function b(e,n,t,r,o){if("key"===n);else if("style"===n)if("string"==typeof t)e.style.cssText=t;else for(var l in"string"==typeof r&&(r=e.style.cssText=""),v(r,t)){var u=null==t||null==t[l]?"":t[l];"-"===l[0]?e.style.setProperty(l,u):e.style[l]=u}else"o"===n[0]&&"n"===n[1]?(n=n.slice(2),e.events?r||(r=e.events[n]):e.events={},(e.events[n]=t)?r||e.addEventListener(n,y):e.removeEventListener(n,y)):n in e&&"list"!==n&&"type"!==n&&"draggable"!==n&&"spellcheck"!==n&&"translate"!==n&&!o?e[n]=null==t?"":t:null!=t&&!1!==t&&e.setAttribute(n,t),null!=t&&!1!==t||e.removeAttribute(n)}function k(e,n){var t="string"==typeof e||"number"==typeof e?document.createTextNode(e):(n=n||"svg"===e.nodeName)?document.createElementNS("http://www.w3.org/2000/svg",e.nodeName):document.createElement(e.nodeName),r=e.attributes;if(r){r.oncreate&&f.push(function(){r.oncreate(t)});for(var o=0;o<e.children.length;o++)t.appendChild(k(e.children[o]=g(e.children[o]),n));for(var l in r)b(t,l,r[l],null,n)}return t}function x(e,n,t,r){for(var o in v(n,t))t[o]!==("value"===o||"checked"===o?e[o]:n[o])&&b(e,o,t[o],n[o],r);var l=m?t.oncreate:t.onupdate;l&&f.push(function(){l(e,n)})}function T(e,n,t){function r(){e.removeChild(function e(n,t){var r=t.attributes;if(r){for(var o=0;o<t.children.length;o++)e(n.childNodes[o],t.children[o]);r.ondestroy&&r.ondestroy(n)}return n}(n,t))}var o=t.attributes&&t.attributes.onremove;o?o(n,r):r()}}});

43
assets/js/infiscroll.js Executable file
View File

@ -0,0 +1,43 @@
// infiscroll.js
// A really simple infinite-scroll system.
// Places an invisible marker element near the bottom of the screen and adds new content until it's offscreen.
function insertAfter(newNode, referenceNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
function addMarker(reference, markerPos) {
var markerPos = markerPos || "5vh";
var el = document.createElement("div");
el.style.position = "relative";
el.style.top = "-" + markerPos;
el.style.width = "1px";
el.style.height = "1px";
el.classList.add("marker");
insertAfter(el, reference)
return el;
}
function infiscroll(addNewContent, markerPos, reference, maxRetries) {
var maxRetries = maxRetries || 10
var marker = addMarker(reference, markerPos);
var handler = function() {
let i = 0;
var x = marker.getBoundingClientRect().bottom
while (x / document.documentElement.scrollHeight < 0.2 || x < window.innerHeight) {
i++
if (i - 1 == maxRetries) {
break
}
addNewContent()
}
}
handler()
window.addEventListener("scroll", handler)
setInterval(handler, 500) // evil bodge
}

61
assets/js/lorem.js Executable file
View File

@ -0,0 +1,61 @@
var Lorem;
(function() {
Lorem = {};
//Static variables
Lorem.IMAGE = 1;
Lorem.TEXT = 2;
Lorem.TYPE = {
PARAGRAPH: 1,
SENTENCE: 2,
WORD: 3
};
//Words to create lorem ipsum text.
Lorem.WORDS = [
"lorem", "ipsum", "dolor", "sit", "amet,", "consectetur", "adipiscing", "elit", "ut", "aliquam,", "purus", "sit", "amet", "luctus", "venenatis,", "lectus", "magna", "fringilla", "urna,", "porttitor", "rhoncus", "dolor", "purus", "non", "enim", "praesent", "elementum", "facilisis", "leo,", "vel", "fringilla", "est", "ullamcorper", "eget", "nulla", "facilisi", "etiam", "dignissim", "diam", "quis", "enim", "lobortis", "scelerisque", "fermentum", "dui", "faucibus", "in", "ornare", "quam", "viverra", "orci", "sagittis", "eu", "volutpat", "odio", "facilisis", "mauris", "sit", "amet", "massa", "vitae", "tortor", "condimentum", "lacinia", "quis", "vel", "eros", "donec", "ac", "odio", "tempor", "orci", "dapibus", "ultrices", "in", "iaculis", "nunc", "sed", "augue", "lacus,", "viverra", "vitae", "congue", "eu,", "consequat", "ac", "felis", "donec", "et", "odio", "pellentesque", "diam", "volutpat", "commodo", "sed", "egestas", "egestas", "fringilla", "phasellus", "faucibus", "scelerisque", "eleifend", "donec", "pretium", "vulputate", "sapien", "nec", "sagittis", "aliquam", "malesuada", "bibendum", "arcu", "vitae", "elementum",
"curabitur", "vitae", "nunc", "sed", "velit", "dignissim", "sodales", "ut", "eu", "sem", "integer", "vitae", "justo", "eget", "magna", "fermentum", "iaculis", "eu", "non", "diam", "phasellus", "vestibulum", "lorem", "sed", "risus", "ultricies", "tristique", "nulla", "aliquet", "enim", "tortor,", "at", "auctor", "urna", "nunc", "id", "cursus", "metus", "aliquam", "eleifend", "mi", "in", "nulla", "posuere", "sollicitudin", "aliquam", "ultrices", "sagittis", "orci,", "a", "scelerisque", "purus", "semper", "eget", "duis", "at", "tellus", "at", "urna", "condimentum", "mattis", "pellentesque", "id", "nibh", "tortor,", "id", "aliquet", "lectus", "proin", "nibh", "nisl,", "condimentum", "id", "venenatis", "a,", "condimentum", "vitae", "sapien", "pellentesque", "habitant", "morbi", "tristique", "senectus", "et", "netus", "et", "malesuada", "fames", "ac", "turpis", "egestas", "sed", "tempus,", "urna", "et", "pharetra", "pharetra,", "massa", "massa", "ultricies", "mi,", "quis", "hendrerit", "dolor", "magna", "eget", "est", "lorem", "ipsum", "dolor", "sit", "amet,", "consectetur", "adipiscing", "elit", "pellentesque", "habitant", "morbi", "tristique", "senectus", "et", "netus", "et", "malesuada", "fames", "ac", "turpis", "egestas", "integer", "eget", "aliquet", "nibh", "praesent", "tristique", "magna", "sit", "amet", "purus", "gravida", "quis", "blandit", "turpis", "cursus", "in", "hac", "habitasse", "platea", "dictumst", "quisque", "sagittis,", "purus", "sit", "amet", "volutpat", "consequat,", "mauris", "nunc", "congue", "nisi,", "vitae", "suscipit", "tellus", "mauris", "a", "diam",
"maecenas", "sed", "enim", "ut", "sem", "viverra", "aliquet", "eget", "sit", "amet", "tellus", "cras", "adipiscing", "enim", "eu", "turpis", "egestas", "pretium", "aenean", "pharetra,", "magna", "ac", "placerat", "vestibulum,", "lectus", "mauris", "ultrices", "eros,", "in", "cursus", "turpis", "massa", "tincidunt", "dui", "ut", "ornare", "lectus", "sit", "amet", "est", "placerat", "in", "egestas", "erat", "imperdiet", "sed", "euismod", "nisi", "porta", "lorem", "mollis", "aliquam", "ut", "porttitor", "leo", "a", "diam", "sollicitudin", "tempor", "id", "eu", "nisl", "nunc", "mi", "ipsum,", "faucibus", "vitae", "aliquet", "nec,", "ullamcorper", "sit", "amet", "risus", "nullam", "eget", "felis", "eget", "nunc", "lobortis", "mattis", "aliquam", "faucibus", "purus", "in", "massa", "tempor", "nec", "feugiat", "nisl", "pretium", "fusce", "id", "velit", "ut", "tortor", "pretium", "viverra", "suspendisse", "potenti", "nullam", "ac", "tortor", "vitae", "purus", "faucibus", "ornare", "suspendisse", "sed", "nisi", "lacus,", "sed", "viverra", "tellus", "in", "hac", "habitasse", "platea", "dictumst", "vestibulum", "rhoncus", "est", "pellentesque", "elit", "ullamcorper", "dignissim", "cras", "tincidunt", "lobortis", "feugiat", "vivamus", "at", "augue", "eget", "arcu", "dictum", "varius", "duis", "at", "consectetur", "lorem",
"donec", "massa", "sapien,", "faucibus", "et", "molestie", "ac,", "feugiat", "sed", "lectus", "vestibulum", "mattis", "ullamcorper", "velit", "sed", "ullamcorper", "morbi", "tincidunt", "ornare", "massa,", "eget", "egestas", "purus", "viverra", "accumsan", "in", "nisl", "nisi,", "scelerisque", "eu", "ultrices", "vitae,", "auctor", "eu", "augue", "ut", "lectus", "arcu,", "bibendum", "at", "varius", "vel,", "pharetra", "vel", "turpis", "nunc", "eget", "lorem", "dolor,", "sed", "viverra", "ipsum", "nunc", "aliquet", "bibendum", "enim,", "facilisis", "gravida", "neque", "convallis", "a", "cras", "semper", "auctor", "neque,", "vitae", "tempus", "quam", "pellentesque", "nec", "nam", "aliquam", "sem", "et", "tortor", "consequat", "id", "porta", "nibh", "venenatis", "cras", "sed", "felis", "eget", "velit", "aliquet", "sagittis", "id", "consectetur", "purus", "ut", "faucibus", "pulvinar", "elementum", "integer", "enim", "neque,", "volutpat", "ac", "tincidunt", "vitae,", "semper", "quis", "lectus", "nulla", "at", "volutpat", "diam", "ut", "venenatis", "tellus", "in", "metus", "vulputate", "eu", "scelerisque", "felis", "imperdiet", "proin", "fermentum", "leo", "vel", "orci", "porta", "non", "pulvinar", "neque", "laoreet", "suspendisse", "interdum", "consectetur", "libero,", "id", "faucibus", "nisl", "tincidunt", "eget", "nullam", "non", "nisi", "est,", "sit", "amet", "facilisis", "magna",
"etiam", "tempor,", "orci", "eu", "lobortis", "elementum,", "nibh", "tellus", "molestie", "nunc,", "non", "blandit", "massa", "enim", "nec", "dui", "nunc", "mattis", "enim", "ut", "tellus", "elementum", "sagittis", "vitae", "et", "leo", "duis", "ut", "diam", "quam", "nulla", "porttitor", "massa", "id", "neque", "aliquam", "vestibulum", "morbi", "blandit", "cursus", "risus,", "at", "ultrices", "mi", "tempus", "imperdiet", "nulla", "malesuada", "pellentesque", "elit", "eget", "gravida", "cum", "sociis", "natoque", "penatibus", "et", "magnis", "dis", "parturient", "montes,", "nascetur", "ridiculus", "mus", "mauris", "vitae", "ultricies", "leo", "integer", "malesuada", "nunc", "vel", "risus", "commodo", "viverra", "maecenas", "accumsan,", "lacus", "vel", "facilisis", "volutpat,", "est", "velit", "egestas", "dui,", "id", "ornare", "arcu", "odio", "ut", "sem", "nulla", "pharetra", "diam", "sit", "amet", "nisl", "suscipit", "adipiscing", "bibendum", "est", "ultricies", "integer", "quis", "auctor", "elit",
"sed", "vulputate", "mi", "sit", "amet", "mauris", "commodo", "quis", "imperdiet", "massa", "tincidunt", "nunc", "pulvinar", "sapien", "et", "ligula", "ullamcorper", "malesuada", "proin", "libero", "nunc,", "consequat", "interdum", "varius", "sit", "amet,", "mattis", "vulputate", "enim", "nulla", "aliquet", "porttitor", "lacus,", "luctus", "accumsan", "tortor", "posuere", "ac", "ut", "consequat", "semper", "viverra", "nam", "libero", "justo,", "laoreet", "sit", "amet", "cursus", "sit", "amet,", "dictum", "sit", "amet", "justo", "donec", "enim", "diam,", "vulputate", "ut", "pharetra", "sit", "amet,", "aliquam", "id", "diam", "maecenas", "ultricies", "mi", "eget", "mauris", "pharetra", "et", "ultrices", "neque", "ornare", "aenean", "euismod", "elementum", "nisi,", "quis", "eleifend", "quam", "adipiscing", "vitae", "proin", "sagittis,", "nisl", "rhoncus", "mattis", "rhoncus,", "urna", "neque", "viverra", "justo,", "nec", "ultrices", "dui", "sapien", "eget", "mi", "proin", "sed", "libero", "enim,", "sed", "faucibus", "turpis", "in", "eu", "mi", "bibendum", "neque", "egestas", "congue", "quisque", "egestas", "diam", "in", "arcu", "cursus", "euismod", "quis", "viverra", "nibh", "cras", "pulvinar", "mattis", "nunc,", "sed", "blandit", "libero", "volutpat", "sed", "cras", "ornare", "arcu", "dui", "vivamus", "arcu", "felis,", "bibendum", "ut", "tristique", "et,", "egestas", "quis", "ipsum", "suspendisse", "ultrices", "gravida", "dictum",
"fusce", "ut", "placerat", "orci", "nulla", "pellentesque", "dignissim", "enim,", "sit", "amet", "venenatis", "urna", "cursus", "eget", "nunc", "scelerisque", "viverra", "mauris,", "in", "aliquam", "sem", "fringilla", "ut", "morbi", "tincidunt", "augue", "interdum", "velit", "euismod", "in", "pellentesque", "massa", "placerat", "duis", "ultricies", "lacus", "sed", "turpis", "tincidunt", "id", "aliquet", "risus", "feugiat", "in", "ante", "metus,", "dictum", "at", "tempor", "commodo,", "ullamcorper", "a", "lacus", "vestibulum", "sed", "arcu", "non", "odio", "euismod", "lacinia", "at", "quis", "risus", "sed", "vulputate", "odio", "ut", "enim", "blandit", "volutpat", "maecenas", "volutpat", "blandit", "aliquam", "etiam", "erat", "velit,", "scelerisque", "in", "dictum", "non,", "consectetur", "a", "erat", "nam", "at", "lectus", "urna", "duis", "convallis", "convallis", "tellus,", "id", "interdum", "velit", "laoreet", "id", "donec", "ultrices", "tincidunt", "arcu,", "non", "sodales", "neque", "sodales", "ut", "etiam", "sit", "amet", "nisl", "purus,", "in", "mollis", "nunc",
"sed", "id", "semper", "risus", "in", "hendrerit", "gravida", "rutrum", "quisque", "non", "tellus", "orci,", "ac", "auctor", "augue", "mauris", "augue", "neque,", "gravida", "in", "fermentum", "et,", "sollicitudin", "ac", "orci", "phasellus", "egestas", "tellus", "rutrum", "tellus", "pellentesque", "eu", "tincidunt", "tortor", "aliquam", "nulla", "facilisi", "cras", "fermentum,", "odio", "eu", "feugiat", "pretium,", "nibh", "ipsum", "consequat", "nisl,", "vel", "pretium", "lectus", "quam", "id", "leo", "in", "vitae", "turpis", "massa", "sed", "elementum", "tempus", "egestas", "sed", "sed", "risus", "pretium", "quam", "vulputate", "dignissim", "suspendisse", "in", "est", "ante", "in", "nibh", "mauris,", "cursus", "mattis", "molestie", "a,", "iaculis", "at", "erat",
"pellentesque", "adipiscing", "commodo", "elit,", "at", "imperdiet", "dui", "accumsan", "sit", "amet", "nulla", "facilisi", "morbi", "tempus", "iaculis", "urna,", "id", "volutpat", "lacus", "laoreet", "non", "curabitur", "gravida", "arcu", "ac", "tortor", "dignissim", "convallis", "aenean", "et", "tortor", "at", "risus", "viverra", "adipiscing", "at", "in", "tellus", "integer", "feugiat", "scelerisque", "varius", "morbi", "enim", "nunc,", "faucibus", "a", "pellentesque", "sit", "amet,", "porttitor", "eget", "dolor", "morbi", "non", "arcu", "risus,", "quis", "varius", "quam", "quisque", "id", "diam", "vel", "quam", "elementum", "pulvinar", "etiam", "non", "quam", "lacus", "suspendisse", "faucibus", "interdum", "posuere", "lorem", "ipsum", "dolor", "sit", "amet,", "consectetur", "adipiscing", "elit", "duis", "tristique", "sollicitudin", "nibh", "sit", "amet", "commodo", "nulla", "facilisi",
"nullam", "vehicula", "ipsum", "a", "arcu", "cursus", "vitae", "congue", "mauris", "rhoncus", "aenean", "vel", "elit", "scelerisque", "mauris", "pellentesque", "pulvinar", "pellentesque", "habitant", "morbi", "tristique", "senectus", "et", "netus", "et", "malesuada", "fames", "ac", "turpis", "egestas", "maecenas", "pharetra", "convallis", "posuere", "morbi", "leo", "urna,", "molestie", "at", "elementum", "eu,", "facilisis", "sed", "odio", "morbi", "quis", "commodo", "odio", "aenean", "sed", "adipiscing", "diam", "donec", "adipiscing", "tristique", "risus", "nec", "feugiat", "in", "fermentum", "posuere", "urna", "nec", "tincidunt", "praesent", "semper", "feugiat", "nibh", "sed", "pulvinar", "proin", "gravida", "hendrerit", "lectus", "a", "molestie"
];
//random integer method.
Lorem.randomInt = function (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
};
//text creator method with parameters: how many, what
Lorem.createText = function(count, type) {
switch (type) {
//paragraphs are loads of sentences.
case Lorem.TYPE.PARAGRAPH:
var paragraphs = new Array;
for (var i = 0; i < count; i++) {
var paragraphLength = this.randomInt(10, 20);
var paragraph = this.createText(paragraphLength, Lorem.TYPE.SENTENCE);
paragraphs.push(paragraph + " ");
}
return paragraphs.join('\n');
//sentences are loads of words.
case Lorem.TYPE.SENTENCE:
var sentences = new Array;
for (var i = 0; i < count; i++) {
var sentenceLength = this.randomInt(5, 10);
var words = this.createText(sentenceLength, Lorem.TYPE.WORD).split(' ');
words[0] = words[0].substr(0, 1).toUpperCase() + words[0].substr(1);
var sentence = words.join(' ');
sentences.push(sentence);
}
return (sentences.join('. ') + '.');
//words are words
case Lorem.TYPE.WORD:
var wordIndex = this.randomInt(0, Lorem.WORDS.length - count - 1);
return Lorem.WORDS.slice(wordIndex, wordIndex + count).join(' ').replace(/[\.\,]/g,'');
}
};
})();

23
assets/js/mithril.js Normal file

File diff suppressed because one or more lines are too long

3
assets/js/moment.min.js vendored Normal file

File diff suppressed because one or more lines are too long

631
assets/js/mustache.js Normal file
View File

@ -0,0 +1,631 @@
/*!
* mustache.js - Logic-less {{mustache}} templates with JavaScript
* http://github.com/janl/mustache.js
*/
/*global define: false Mustache: true*/
(function defineMustache (global, factory) {
if (typeof exports === 'object' && exports && typeof exports.nodeName !== 'string') {
factory(exports); // CommonJS
} else if (typeof define === 'function' && define.amd) {
define(['exports'], factory); // AMD
} else {
global.Mustache = {};
factory(global.Mustache); // script, wsh, asp
}
}(this, function mustacheFactory (mustache) {
var objectToString = Object.prototype.toString;
var isArray = Array.isArray || function isArrayPolyfill (object) {
return objectToString.call(object) === '[object Array]';
};
function isFunction (object) {
return typeof object === 'function';
}
/**
* More correct typeof string handling array
* which normally returns typeof 'object'
*/
function typeStr (obj) {
return isArray(obj) ? 'array' : typeof obj;
}
function escapeRegExp (string) {
return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
}
/**
* Null safe way of checking whether or not an object,
* including its prototype, has a given property
*/
function hasProperty (obj, propName) {
return obj != null && typeof obj === 'object' && (propName in obj);
}
// Workaround for https://issues.apache.org/jira/browse/COUCHDB-577
// See https://github.com/janl/mustache.js/issues/189
var regExpTest = RegExp.prototype.test;
function testRegExp (re, string) {
return regExpTest.call(re, string);
}
var nonSpaceRe = /\S/;
function isWhitespace (string) {
return !testRegExp(nonSpaceRe, string);
}
var entityMap = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
'/': '&#x2F;',
'`': '&#x60;',
'=': '&#x3D;'
};
function escapeHtml (string) {
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
return entityMap[s];
});
}
var whiteRe = /\s*/;
var spaceRe = /\s+/;
var equalsRe = /\s*=/;
var curlyRe = /\s*\}/;
var tagRe = /#|\^|\/|>|\{|&|=|!/;
/**
* Breaks up the given `template` string into a tree of tokens. If the `tags`
* argument is given here it must be an array with two string values: the
* opening and closing tags used in the template (e.g. [ "<%", "%>" ]). Of
* course, the default is to use mustaches (i.e. mustache.tags).
*
* A token is an array with at least 4 elements. The first element is the
* mustache symbol that was used inside the tag, e.g. "#" or "&". If the tag
* did not contain a symbol (i.e. {{myValue}}) this element is "name". For
* all text that appears outside a symbol this element is "text".
*
* The second element of a token is its "value". For mustache tags this is
* whatever else was inside the tag besides the opening symbol. For text tokens
* this is the text itself.
*
* The third and fourth elements of the token are the start and end indices,
* respectively, of the token in the original template.
*
* Tokens that are the root node of a subtree contain two more elements: 1) an
* array of tokens in the subtree and 2) the index in the original template at
* which the closing tag for that section begins.
*/
function parseTemplate (template, tags) {
if (!template)
return [];
var sections = []; // Stack to hold section tokens
var tokens = []; // Buffer to hold the tokens
var spaces = []; // Indices of whitespace tokens on the current line
var hasTag = false; // Is there a {{tag}} on the current line?
var nonSpace = false; // Is there a non-space char on the current line?
// Strips all whitespace tokens array for the current line
// if there was a {{#tag}} on it and otherwise only space.
function stripSpace () {
if (hasTag && !nonSpace) {
while (spaces.length)
delete tokens[spaces.pop()];
} else {
spaces = [];
}
hasTag = false;
nonSpace = false;
}
var openingTagRe, closingTagRe, closingCurlyRe;
function compileTags (tagsToCompile) {
if (typeof tagsToCompile === 'string')
tagsToCompile = tagsToCompile.split(spaceRe, 2);
if (!isArray(tagsToCompile) || tagsToCompile.length !== 2)
throw new Error('Invalid tags: ' + tagsToCompile);
openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + '\\s*');
closingTagRe = new RegExp('\\s*' + escapeRegExp(tagsToCompile[1]));
closingCurlyRe = new RegExp('\\s*' + escapeRegExp('}' + tagsToCompile[1]));
}
compileTags(tags || mustache.tags);
var scanner = new Scanner(template);
var start, type, value, chr, token, openSection;
while (!scanner.eos()) {
start = scanner.pos;
// Match any text between tags.
value = scanner.scanUntil(openingTagRe);
if (value) {
for (var i = 0, valueLength = value.length; i < valueLength; ++i) {
chr = value.charAt(i);
if (isWhitespace(chr)) {
spaces.push(tokens.length);
} else {
nonSpace = true;
}
tokens.push([ 'text', chr, start, start + 1 ]);
start += 1;
// Check for whitespace on the current line.
if (chr === '\n')
stripSpace();
}
}
// Match the opening tag.
if (!scanner.scan(openingTagRe))
break;
hasTag = true;
// Get the tag type.
type = scanner.scan(tagRe) || 'name';
scanner.scan(whiteRe);
// Get the tag value.
if (type === '=') {
value = scanner.scanUntil(equalsRe);
scanner.scan(equalsRe);
scanner.scanUntil(closingTagRe);
} else if (type === '{') {
value = scanner.scanUntil(closingCurlyRe);
scanner.scan(curlyRe);
scanner.scanUntil(closingTagRe);
type = '&';
} else {
value = scanner.scanUntil(closingTagRe);
}
// Match the closing tag.
if (!scanner.scan(closingTagRe))
throw new Error('Unclosed tag at ' + scanner.pos);
token = [ type, value, start, scanner.pos ];
tokens.push(token);
if (type === '#' || type === '^') {
sections.push(token);
} else if (type === '/') {
// Check section nesting.
openSection = sections.pop();
if (!openSection)
throw new Error('Unopened section "' + value + '" at ' + start);
if (openSection[1] !== value)
throw new Error('Unclosed section "' + openSection[1] + '" at ' + start);
} else if (type === 'name' || type === '{' || type === '&') {
nonSpace = true;
} else if (type === '=') {
// Set the tags for the next time around.
compileTags(value);
}
}
// Make sure there are no open sections when we're done.
openSection = sections.pop();
if (openSection)
throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos);
return nestTokens(squashTokens(tokens));
}
/**
* Combines the values of consecutive text tokens in the given `tokens` array
* to a single token.
*/
function squashTokens (tokens) {
var squashedTokens = [];
var token, lastToken;
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
token = tokens[i];
if (token) {
if (token[0] === 'text' && lastToken && lastToken[0] === 'text') {
lastToken[1] += token[1];
lastToken[3] = token[3];
} else {
squashedTokens.push(token);
lastToken = token;
}
}
}
return squashedTokens;
}
/**
* Forms the given array of `tokens` into a nested tree structure where
* tokens that represent a section have two additional items: 1) an array of
* all tokens that appear in that section and 2) the index in the original
* template that represents the end of that section.
*/
function nestTokens (tokens) {
var nestedTokens = [];
var collector = nestedTokens;
var sections = [];
var token, section;
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
token = tokens[i];
switch (token[0]) {
case '#':
case '^':
collector.push(token);
sections.push(token);
collector = token[4] = [];
break;
case '/':
section = sections.pop();
section[5] = token[2];
collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
break;
default:
collector.push(token);
}
}
return nestedTokens;
}
/**
* A simple string scanner that is used by the template parser to find
* tokens in template strings.
*/
function Scanner (string) {
this.string = string;
this.tail = string;
this.pos = 0;
}
/**
* Returns `true` if the tail is empty (end of string).
*/
Scanner.prototype.eos = function eos () {
return this.tail === '';
};
/**
* Tries to match the given regular expression at the current position.
* Returns the matched text if it can match, the empty string otherwise.
*/
Scanner.prototype.scan = function scan (re) {
var match = this.tail.match(re);
if (!match || match.index !== 0)
return '';
var string = match[0];
this.tail = this.tail.substring(string.length);
this.pos += string.length;
return string;
};
/**
* Skips all text until the given regular expression can be matched. Returns
* the skipped string, which is the entire tail if no match can be made.
*/
Scanner.prototype.scanUntil = function scanUntil (re) {
var index = this.tail.search(re), match;
switch (index) {
case -1:
match = this.tail;
this.tail = '';
break;
case 0:
match = '';
break;
default:
match = this.tail.substring(0, index);
this.tail = this.tail.substring(index);
}
this.pos += match.length;
return match;
};
/**
* Represents a rendering context by wrapping a view object and
* maintaining a reference to the parent context.
*/
function Context (view, parentContext) {
this.view = view;
this.cache = { '.': this.view };
this.parent = parentContext;
}
/**
* Creates a new context using the given view with this context
* as the parent.
*/
Context.prototype.push = function push (view) {
return new Context(view, this);
};
/**
* Returns the value of the given name in this context, traversing
* up the context hierarchy if the value is absent in this context's view.
*/
Context.prototype.lookup = function lookup (name) {
var cache = this.cache;
var value;
if (cache.hasOwnProperty(name)) {
value = cache[name];
} else {
var context = this, names, index, lookupHit = false;
while (context) {
if (name.indexOf('.') > 0) {
value = context.view;
names = name.split('.');
index = 0;
/**
* Using the dot notion path in `name`, we descend through the
* nested objects.
*
* To be certain that the lookup has been successful, we have to
* check if the last object in the path actually has the property
* we are looking for. We store the result in `lookupHit`.
*
* This is specially necessary for when the value has been set to
* `undefined` and we want to avoid looking up parent contexts.
**/
while (value != null && index < names.length) {
if (index === names.length - 1)
lookupHit = hasProperty(value, names[index]);
value = value[names[index++]];
}
} else {
value = context.view[name];
lookupHit = hasProperty(context.view, name);
}
if (lookupHit)
break;
context = context.parent;
}
cache[name] = value;
}
if (isFunction(value))
value = value.call(this.view);
return value;
};
/**
* A Writer knows how to take a stream of tokens and render them to a
* string, given a context. It also maintains a cache of templates to
* avoid the need to parse the same template twice.
*/
function Writer () {
this.cache = {};
}
/**
* Clears all cached templates in this writer.
*/
Writer.prototype.clearCache = function clearCache () {
this.cache = {};
};
/**
* Parses and caches the given `template` and returns the array of tokens
* that is generated from the parse.
*/
Writer.prototype.parse = function parse (template, tags) {
var cache = this.cache;
var tokens = cache[template];
if (tokens == null)
tokens = cache[template] = parseTemplate(template, tags);
return tokens;
};
/**
* High-level method that is used to render the given `template` with
* the given `view`.
*
* The optional `partials` argument may be an object that contains the
* names and templates of partials that are used in the template. It may
* also be a function that is used to load partial templates on the fly
* that takes a single argument: the name of the partial.
*/
Writer.prototype.render = function render (template, view, partials) {
var tokens = this.parse(template);
var context = (view instanceof Context) ? view : new Context(view);
return this.renderTokens(tokens, context, partials, template);
};
/**
* Low-level method that renders the given array of `tokens` using
* the given `context` and `partials`.
*
* Note: The `originalTemplate` is only ever used to extract the portion
* of the original template that was contained in a higher-order section.
* If the template doesn't use higher-order sections, this argument may
* be omitted.
*/
Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate) {
var buffer = '';
var token, symbol, value;
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
value = undefined;
token = tokens[i];
symbol = token[0];
if (symbol === '#') value = this.renderSection(token, context, partials, originalTemplate);
else if (symbol === '^') value = this.renderInverted(token, context, partials, originalTemplate);
else if (symbol === '>') value = this.renderPartial(token, context, partials, originalTemplate);
else if (symbol === '&') value = this.unescapedValue(token, context);
else if (symbol === 'name') value = this.escapedValue(token, context);
else if (symbol === 'text') value = this.rawValue(token);
if (value !== undefined)
buffer += value;
}
return buffer;
};
Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate) {
var self = this;
var buffer = '';
var value = context.lookup(token[1]);
// This function is used to render an arbitrary template
// in the current context by higher-order sections.
function subRender (template) {
return self.render(template, context, partials);
}
if (!value) return;
if (isArray(value)) {
for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate);
}
} else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') {
buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate);
} else if (isFunction(value)) {
if (typeof originalTemplate !== 'string')
throw new Error('Cannot use higher-order sections without the original template');
// Extract the portion of the original template that the section contains.
value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);
if (value != null)
buffer += value;
} else {
buffer += this.renderTokens(token[4], context, partials, originalTemplate);
}
return buffer;
};
Writer.prototype.renderInverted = function renderInverted (token, context, partials, originalTemplate) {
var value = context.lookup(token[1]);
// Use JavaScript's definition of falsy. Include empty arrays.
// See https://github.com/janl/mustache.js/issues/186
if (!value || (isArray(value) && value.length === 0))
return this.renderTokens(token[4], context, partials, originalTemplate);
};
Writer.prototype.renderPartial = function renderPartial (token, context, partials) {
if (!partials) return;
var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
if (value != null)
return this.renderTokens(this.parse(value), context, partials, value);
};
Writer.prototype.unescapedValue = function unescapedValue (token, context) {
var value = context.lookup(token[1]);
if (value != null)
return value;
};
Writer.prototype.escapedValue = function escapedValue (token, context) {
var value = context.lookup(token[1]);
if (value != null)
return mustache.escape(value);
};
Writer.prototype.rawValue = function rawValue (token) {
return token[1];
};
mustache.name = 'mustache.js';
mustache.version = '2.3.0';
mustache.tags = [ '{{', '}}' ];
// All high-level mustache.* functions use this writer.
var defaultWriter = new Writer();
/**
* Clears all cached templates in the default writer.
*/
mustache.clearCache = function clearCache () {
return defaultWriter.clearCache();
};
/**
* Parses and caches the given template in the default writer and returns the
* array of tokens it contains. Doing this ahead of time avoids the need to
* parse templates on the fly as they are rendered.
*/
mustache.parse = function parse (template, tags) {
return defaultWriter.parse(template, tags);
};
/**
* Renders the `template` with the given `view` and `partials` using the
* default writer.
*/
mustache.render = function render (template, view, partials) {
if (typeof template !== 'string') {
throw new TypeError('Invalid template! Template should be a "string" ' +
'but "' + typeStr(template) + '" was given as the first ' +
'argument for mustache#render(template, view, partials)');
}
return defaultWriter.render(template, view, partials);
};
// This is here for backwards compatibility with 0.4.x.,
/*eslint-disable */ // eslint wants camel cased function name
mustache.to_html = function to_html (template, view, partials, send) {
/*eslint-enable*/
var result = mustache.render(template, view, partials);
if (isFunction(send)) {
send(result);
} else {
return result;
}
};
// Export the escaping function so that the user may override it.
// See https://github.com/janl/mustache.js/issues/244
mustache.escape = escapeHtml;
// Export these mainly for testing, but also for advanced usage.
mustache.Scanner = Scanner;
mustache.Context = Context;
mustache.Writer = Writer;
return mustache;
}));

289
assets/js/page.js Normal file
View File

@ -0,0 +1,289 @@
// https://github.com/jakearchibald/idb-keyval/blob/master/dist/idb-keyval-iife.min.js
// This is small enough that I decided to just embed it directly here to save hassle and network bandwidth.
const idbk=function(e){"use strict";class t{constructor(e="keyval-store",t="keyval"){this.storeName=t,this._dbp=new Promise((r,n)=>{const o=indexedDB.open(e,1);o.onerror=(()=>n(o.error)),o.onsuccess=(()=>r(o.result)),o.onupgradeneeded=(()=>{o.result.createObjectStore(t)})})}
_withIDBStore(e,t){return this._dbp.then(r=>new Promise((n,o)=>{const s=r.transaction(this.storeName,e);s.oncomplete=(()=>n()),s.onabort=s.onerror=(()=>o(s.error)),t(s.objectStore(this.storeName))}))}}let r;function n(){return r||(r=new t),r}return e.Store=t,e.get=function(e,t=n()){let r;return t._withIDBStore("readonly",t=>{r=t.get(e)}).then(()=>r.result)},e.set=function(e,t,r=n()){return r._withIDBStore("readwrite",r=>{r.put(t,e)})},e.del=function(e,t=n()){return t._withIDBStore("readwrite",t=>{t.delete(e)})},e.clear=function(e=n()){return e._withIDBStore("readwrite",e=>{e.clear()})},e.keys=function(e=n()){const t=[];return e._withIDBStore("readonly",e=>{(e.openKeyCursor||e.openCursor).call(e).onsuccess=function(){this.result&&(t.push(this.result.key),this.result.continue())}}).then(()=>t)},e}({});
// attempt to register service worker
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/sw.js", { scope: "/" }).then(reg => {
if (reg.installing) {
console.log("Service worker installing");
} else if (reg.waiting) {
console.log("Service worker installed");
} else if (reg.active) {
console.log("Service worker active");
}
}).catch(error => {
// registration failed
console.log("Registration failed with " + error);
});
} else {
console.log("Service workers are not supported.");
}
// https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
const hash = function(str, seed = 0) {
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed
for (let i = 0, ch; i < str.length; i++) {
ch = str.charCodeAt(i)
h1 = Math.imul(h1 ^ ch, 2654435761)
h2 = Math.imul(h2 ^ ch, 1597334677)
}
h1 = Math.imul(h1 ^ h1>>>16, 2246822507) ^ Math.imul(h2 ^ h2>>>13, 3266489909);
h2 = Math.imul(h2 ^ h2>>>16, 2246822507) ^ Math.imul(h1 ^ h1>>>13, 3266489909)
return 4294967296 * (2097151 & h2) + (h1>>>0)
}
const colHash = (str, saturation = 100, lightness = 70) => `hsl(${hash(str) % 360}, ${saturation}%, ${lightness}%)`
// Arbitrary Points code, wrapped in an IIFE to not pollute the global environment much more than it already is
window.points = (() => {
const achievementInfo = {
test: {
title: "Test",
conditions: "testing",
description: "This achievement is for testing purposes.",
points: 10
},
firstAchievement: {
title: "Achievement-Achieving Achievement™",
conditions: "unlocking another achievement",
description: "You achieved your first achievement, so here's an achievement to commemorate your achievement of an achievement! Enjoy the sense of achievement you get from this achievement!",
points: 5.5
},
timeSpent1Hour: {
title: "Causal Mondays",
conditions: "using the site for a total of 1 hour",
description: "Apparently you've spent an hour on this site. Weird. You get an achievement for it, though.",
points: 9.3
},
visitArbitraryPoints: {
title: "Arbitrary Arbitration",
conditions: "visiting the Arbitrary Points management page",
description: "You've now visited the Arbitrary Points page, from which you can see your achievements, point count and tracked metrics.",
points: 15
},
reset: {
title: "Burn It Down",
conditions: "resetting",
description: "So you wiped your Arbitrary Points data for whatever reason. Now you get this exclusive achievement!",
points: 11.4
},
pagesVisited64: {
title: "Real Dedication",
conditions: "visiting 64 pages",
points: 15.01,
description: "You've visited something between 64 pages or 1 page 64 times and are thus being rewarded for your frequent use of the site."
},
blindLuck: {
title: "Ridiculous Blind Luck",
conditions: "0.001% chance of getting this every second",
points: 66.6,
description: "Through sheer chance you have obtained this achievement, which provides more points than all the other ones. This is probably a metaphor for life."
},
offline: {
title: "Not The Dinosaur Game",
conditions: "seeing the offline page",
points: 10.1,
description: "Something broke somewhere and you're seeing this. Sadly this no longer has the Chrome dinosaur game, but you can use other stuff."
},
attemptedXSS: {
title: "1337 h4xx0r",
conditions: "attempting an XSS attack",
points: 43.01,
description: "You appear to have attempted a cross-site-scripting attack. This probably hasn't worked. If it has, please tell me as this is a problem."
},
emuwar10: {
title: "Emu Warrior",
conditions: "vanquishing 10 or more foes in Emu War",
points: 28.5,
description: "You have become a mighty Emu Warrior by defeating 10 or more monsters and/or probably things which live in Australia."
},
lorem400: {
title: "quare?",
conditions: "seeing 400 paragraphs of Lorem Ipsum",
points: 42.3,
description: "Apparently you viewed 400 paragraphs of randomly generated Lorem Ipsum. I don't know why."
},
firstComment: {
title: "That's just, like, your opinion, man",
conditions: "posting a comment",
points: 30.5,
description: "You (probably, the detection isn't 100% accurate) posted a comment! Enjoy expressing your opinion (or random meaningless message) to random internet people!"
}
}
const e = (cls, parent, content) => {
const element = document.createElement("div")
element.classList.add(cls)
if (content) { element.appendChild(document.createTextNode(content)) }
if (parent) { parent.appendChild(element) }
return element
}
const achievementsContainer = e("achievements", document.body)
const displayAchievement = (title, description, conditions, points) => {
const elem = e("achievement", achievementsContainer)
elem.title = "click to dismiss"
e("title", elem, "Achievement achieved!")
e("title", elem, title)
elem.style.backgroundColor = colHash(title)
e("description", elem, description)
e("conditions", elem, `Unlocked by: ${conditions}`)
e("points", elem, `${points} points`)
// disappear on click
elem.addEventListener("click", () => {
achievementsContainer.removeChild(elem)
})
}
const metricsStore = new idbk.Store("arbitrary-metrics", "metrics")
const dataStore = new idbk.Store("arbitrary-points", "data")
const fireUpdatedEvent = () => document.dispatchEvent(new Event("points-update"))
let pointsCount
const getPoints = async () => {
if (pointsCount) { return pointsCount }
let value = await idbk.get("points", dataStore)
if (value === undefined) {
await idbk.set("points", 0, dataStore)
value = 0
}
pointsCount = value
return value
}
const updateStoredValue = async (store, name, fn, def) => {
const newValue = fn(await idbk.get(name, store) || def)
await idbk.set(name, newValue, store)
return newValue
}
const updateMetric = async (name, fn, def) => {
const newValue = await updateStoredValue(metricsStore, name, fn, def)
switch (name) {
case "achievements":
if (newValue === 1) {
await unlockAchievement("firstAchievement")
}
break
}
return newValue
}
const incrementPoints = inc => {
pointsCount += inc
updateStoredValue(dataStore, "points", x => x + inc, 0)
fireUpdatedEvent()
}
// increment pages visited count, since this should be run when a page is visited
updateMetric("pagesVisited", x => x + 1, 0)
const visitStart = Date.now()
window.onbeforeunload = () => {
const elapsedMs = Date.now() - visitStart
updateMetric("timeSpent", x => x + (elapsedMs / 1000), 0)
}
const setMetric = (metric, value) => idbk.set(metric, value, metricsStore)
const readAllMetrics = async () => {
const keys = await idbk.keys(metricsStore)
const out = new Map()
await Promise.all(keys.map(async k => {
out.set(k, await idbk.get(k, metricsStore))
}))
return out
}
const reset = async () => {
pointsCount = 0
achievementsList = []
await idbk.clear(metricsStore)
await idbk.clear(dataStore)
await unlockAchievement("reset")
}
let achievementsList
const getAchievements = async () => {
if (achievementsList) { return achievementsList }
const value = await idbk.get("achievements", dataStore) || []
achievementsList = value
return value
}
const unlockAchievement = async id => {
const achievementsUnlocked = await getAchievements()
if (achievementsUnlocked.filter(a => a.id === id).length > 0) { return "already unlocked" }
const info = achievementInfo[id]
if (!info) { throw new Error("Achievement not recognized") }
info.points = info.points || 10
displayAchievement(info.title, info.description, info.conditions, info.points)
const item = {
id,
timestamp: Date.now(),
page: window.location.pathname,
points: info.points
}
achievementsList = achievementsList.concat([item])
await Promise.all([
idbk.set("achievements", achievementsList, dataStore),
updateMetric("achievements", x => x + 1, 0),
incrementPoints(info.points)
])
fireUpdatedEvent()
}
document.addEventListener("DOMContentLoaded", async () => {
const metrics = await readAllMetrics()
if (metrics.get("timeSpent") > 3600) { // one hour in seconds
unlockAchievement("timeSpent1Hour")
}
if (metrics.get("pagesVisited") > 64) {
unlockAchievement("pagesVisited64")
}
})
setInterval(() => {
if (Math.random() < 0.00001) {
unlockAchievement("blindLuck")
}
}, 1000)
window.addEventListener("input", e => {
if (e.target) {
const text = e.target.value || e.target.textContent
// extremely advanced XSS detection algorithm
if (text && (text.includes("<script") || text.includes("onload="))) {
unlockAchievement("attemptedXSS")
}
}
})
window.addEventListener("click", e => {
// detect clicking of comment "submit" button
if (e.target &&
e.target.value === "Submit" &&
e.target.parentElement &&
e.target.parentElement.parentElement &&
e.target.parentElement.parentElement.className === "auth-section") {
unlockAchievement("firstComment")
points.updateMetric("commentsPosted", function(x) { return x + 1 }, 0)
}
})
return {
reset,
updateMetric,
readAllMetrics,
getPoints,
incrementPoints,
unlockAchievement,
getAchievements,
achievementInfo,
setMetric
}
})()

6
assets/js/vue.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,21 @@
{
"dir": "ltr",
"lang": "en",
"name": "{{{name}}}",
"scope": "/",
"display": "browser",
"start_url": "https://{{domain}}/",
"short_name": "{{domain}}",
"theme_color": "transparent",
"description": "{{siteDescription}}",
"orientation": "any",
"background_color": "transparent",
"related_applications": "",
"prefer_related_applications": "false",
"icons": [
{
"src": "/assets/images/icon.png?reloadyoustupidicon=4",
"sizes": "96x96"
}
]
}

22
assets/offline.html Normal file
View File

@ -0,0 +1,22 @@
---
title: You Are Probably Offline
comments: off
---
<p>If you're seeing this page and this message, then:
<ul>
<li>you are offline.</li>
<li>this site is offline.</li>
<li>the "internet" connection on your end or this site's is limited somehow and so you can't connect.</li>
<li>you decided to look at the source or something and found this page.</li>
<li>the Earth has been destroyed or nuclear war has occured, threatening the integrity of the DNS system.</li>
<li>Contingency Iota has been initiated.</li>
<li>your browser is being weird.</li>
<li>I broke something somewhere quite badly.</li>
<li>your internet connection is too high-latency - the timeout on requests is 5 seconds.</li>
<li>???</li>
</ul>
This site uses a service worker to provide a limited offline mode, but it doesn't work for everything (dynamic pages, ones requiring a bit of server logic, the comments system, pages which haven't been cached), so you are being shown this instead.
</p>
<script defer>
window.addEventListener("load", function() { if ("points" in window) { points.unlockAchievement("offline") }})
</script>

87
assets/sw.js Normal file
View File

@ -0,0 +1,87 @@
const siteVersion = "{{buildID}}"
const offlinePage = "/assets/offline.html"
const cacheName = `${siteVersion}-v1`
const precache = [
offlinePage,
"/index.html",
"/assets/images/logo.svg",
"/assets/images/icon.png",
"/assets/js/page.js",
"/points/index.html",
"/points/index.js",
"/assets/js/mithril.js"
]
// Preload important things
self.addEventListener("install", async event => {
console.log("Installed service worker for site version", siteVersion)
event.waitUntil(
caches.open(cacheName)
.then(cache => cache.addAll(precache))
.then(self.skipWaiting())
)
})
// Delete caches from outdated versions of the site
self.addEventListener("activate", event => {
console.log("Activated service worker for site version", siteVersion)
event.waitUntil(
caches.keys()
.then(cacheNames => cacheNames.filter(cache => cacheName != cache))
.then(cachesToDelete => Promise.all(cachesToDelete.map(cacheToDelete => caches.delete(cacheToDelete))))
.then(() => self.clients.claim())
)
})
const ignorePaths = [
"/isso",
"/infipage"
]
const shouldRespond = req => {
if (req.method !== "GET") { return false } // do not respond to non-GET requests
if (!req.url.startsWith(self.location.origin)) { return false } // do not respond to cross-origin requests
const path = new URL(req.url).pathname
for (ignorePath of ignorePaths) {
if (path.startsWith(ignorePath)) { return false }
}
return true
}
const fetchWithTimeout = (req, timeout) =>
new Promise((resolve, reject) => {
const timerID = setTimeout(() => reject("timed out"), timeout)
fetch(req).then(res => {
clearTimeout(timerID)
resolve(res)
}).catch(reject)
})
const getResponse = async req => {
const cache = await caches.open(cacheName)
const cachedResponse = await cache.match(req)
if (cachedResponse) {
console.log("Serving", req.url, "from cache")
return cachedResponse
}
try {
console.log("Requesting", req.url)
const response = await fetchWithTimeout(req.clone(), 5000)
if (response.status < 400) {
console.log("Caching request to", req.url)
cache.put(req, response.clone())
} else {
console.log("Error requesting", req.url, "status", response.status)
}
return response
} catch(e) {
console.log("Error", e, "occured, sending offline page")
return cache.match(offlinePage)
}
}
self.addEventListener("fetch", event => {
if (shouldRespond(event.request)) {
event.respondWith(getResponse(event.request))
}
})

44
blog/FTL.md Executable file
View File

@ -0,0 +1,44 @@
---
title: FTL tips
description: We are not responsible if these tips cause your ship to implode/explode. Contains spoilers in vast quantities.
created: 16/08/2017
updated: 08/03/2020
---
* Use Cloaking *after* enemy weapons have fired so that they miss.
* Upgrade Shields as soon as possible; many early-sector enemies can't get through 2 shields.
* Any of your crew inside the medbay will be healed, they don't have to be standing still. With a lot of pausing and fiddling with crew movement you can heal 4 crew in a 3-slot medbay this way.
* Upgrade your Doors early on if your ship has trouble dealing with boarders. Higher-level doors slow down boarders trying to break through them.
* 2 Zoltans in a shield room leaves one unionizable shield layer - Zoltan-provided power ignores ion damage.
* Upgraded sensors can show you where crew are and even weapon charge levels, and thus may be worth considering.
* The enemy AI appears to consider Shields the most important system and will prioritize this over other many things.
* With the Rock C, naming the Crystal crewmember you start with "Ruwen" gives you a quest marker in the Rock Homeworlds. This leads to the Crystal sector portal.
* Upgrade your engines!
* You can teleport mind controlled enemy crew onto your own ship, and then kill them.
* Dropping your shields before an ion blast hits might make it hit somewhere unimportant instead of removing a shield layer for >=5 seconds. They do take some time to come up again, though.
* Killing the crew of a ship - usually by boarding, but there are many other ways - gets you more loot than destroying it.
* A Defense Drone I can often be better than Cloaking - assuming you have Shields.
* Firing two missiles can overwhelm a single defense drone. They also try and shoot asteroids.
* To unlock the Crystal Cruiser:
1. Get the Damaged Statis Pod from a Dense Asteroid Field.
2. Find some Zoltan scientists asking to take readings, and get them to open it.
3. Go to the Rock Homeworlds.
4. Find the quest marker and activate the portal.
5. Find the quest marker in the Crystal sector. Then you get the ship, along with some loot.
6. Brag to all your friends, shouting things like "HAHA, I unlocked the Crystal Cruiser!"
* Most stuff doesn't need to be on all the time - oxygen can stay off for a while without *horrible* problems, you barely ever need your medbay and engines/shields only need to be on just before a volley (though shields significantly before). Basically, be good at power management and pause lots to optimize this.
* Upgrade your engines more! Also subsystems and stuff like oxygen; the upgrades can often be unexpectedly helpful.
* Don't constantly stay 100% repaired (from shops) as free/cheap repairs come along frequently.
* Hostile sectors provide more loot too, as there is more combat. This also, obviously, makes them more dangerous.
* If a ship jumps away, you can jump before it does and skip the penalties (they often lead the fleet after you, etc).
* Beam weapons cannot miss, and can also go through shields if they have one or more damage per room than the ship being targeted has shield layers.
* Pausing to think or plan, or really just all the time, is a good idea.
* If a ship is incapable of actually damaging you, you can use it to train your shield/engine/pilot operators (sometimes weapons) without manual interaction to make them more effective.
* It's a good idea to save some scrap for emergencies or random good things you may encounter instead of spending it all at stores.
* Visit as many beacons in a sector as you can without the fleet catching you.
* Fire weapons in volleys so that stronger ones can hit the enemy ship after weaker ones take down shields. Autofire is bad for anything but ion weapons.
* Buying crew at stores is generally not worth it, unless you are really low somehow.
* Do not waste missiles. But also do *use* them, as missiles are often cheaper than the damage you might sustain if you avoid them too much.
* If your crew are not good fighters, you can open the doors to rooms containing boarders to vent out the oxygen, so they will slowly die. They can break the doors, though, or go through them freely if your doors are only level 1. If the situation is very dire and you aren't in ship-to-ship combat it may be worth moving all your crew to the medbay (or rooms adjacent to it, if there's not space in there) and venting all the ship except that. Of course, if the boarders are damaging your oxygen or door system (or just close to it), this is a bad idea and you should not do it.
* Don't jump to stores if you don't have things to sell or lots of scrap. You're missing out on scrap you might otherwise get (this is called "opportunity cost").
* Don't expect to win all the time or even particularly often. FTL is a roguelike. It's designed to be played repeatedly, not won all of the time, and involves heavy randomness.
* Ships' starting weapons are actually generally pretty good, often using less power and/or firing faster than purchaseable alternatives.

9
blog/new-website.md Normal file
View File

@ -0,0 +1,9 @@
---
title: New site design!
created: 25/01/2020
---
If you visit this frequently (why would you?) you may have noticed that since late last year there's been a page notifying you of service disruption and no actual content any more.
This is because the old code used to generate the HTML files making up the site was a several-year-old and somewhat flaky Haskell program, and I've been meaning to replace it for a while, but finally got round to it recently after quite a while of just leaving the service disruption page up.
This new site design should be somewhat easier for me to work on, has some extra features I wanted, comes with a nice new style, and should still allow most of the features you're used to to work.
The service worker for caching is much better (actually works properly now), so you can also use it offline to some extent!

View File

@ -0,0 +1,39 @@
---
title: Not Everyone Must "Code"
description: Why I think that government programs telling everyone to "code" are pointless.
slug: nemc
updated: 09/02/2020
created: 16/08/2017
---
Imagine that some politician said "Cars are an important part of our modern economy. Many jobs involve cars. Therefore, all students must learn how to build cars; we will be adding it to the curriculum."
This does (to me, anyway) seem pretty ridiculous on its own.
*Now* imagine that the students are being taught to make small car models out of card, whilst being told that this is actually how it's always done (this sort of falls apart, since with the car thing it's easy for the average person to tell; most people can't really distinguish these things with programming).
This is what the push to "learn to code" in schools (this was written in 2017, when the UK's government was making a big thing of this, but it still seems to be going on now, in 2020) seems like to me.
In fact, it's even worse, with hyperbolic claims of it being "the new literacy", often made by people who have never done anything beyond basic block-dragging in Scratch or some equivalent.
The average person is definitely going to have lots of interaction with things which have been programmed by someone else, given the increasing popularity of mobile phones.
This does not, however, mean, that they must know every detail of how they work (not that, at this point, anyone *can* - they're just too complex), and they wouldn't actually be taught this by the "learn to code" things now done in schools.
Most of the "learn to code" resources, especially those done in schools, start with very simple, visual, 2D-graphical environments.
This is fine for learning a few basic things (though not very good - Scratch's weird programming environment maps poorly onto actual widely-used languages), but there doesn't seem to be anything beyond that taught most of the time - it's considered "too hard" for the students involved, usually, or there just isn't anyone qualified to teach it.
And that basic dragging around of blocks is not hugely useful - it doesn't teach much (*maybe* basic concepts of flow control), and you may have to *un*learn things when moving to actual programming.
I have an alternative list of things to teach which I think might actually be relevant and helpful to people in a way that making a cat dance on screen by blindly following a tutorial is not:
* an introduction to computer hardware (for troubleshooting, etc) and what all the myriad cables do
* basics of networking (what routers do, ISPs and their job, one of those layered network models, HTTP(S), DNS)
* privacy in the digital age (i.e. maybe stop giving Facebook/Google/Amazon all your private information)
* operating systems, what various programs are for, and the fact that ones which *aren't Windows* exist
* what programming involes
* basic shell-or-equivalent scripting (though this may not actually be very useful either, as the OSes people mostly interact with now - iOS, Windows, Android, etc. - disallow this sort of thing or don't make it very useful, sadly)
* fixing basic problems using advanced IT techniques such as "using a search engine to look up your issue" and "blindly tweaking settings until it does something"
This doesn't really sound as fancy as teaching "the new literacy", but it seems like a better place to start for helping people be able to interact with modern computer systems.
## Update (09/02/2020 CE)
Having shown someone this post, they've suggested to me that Scratch is more about teaching some level of computational thinking-type skills - learning how to express intentions in a structured way and being precise/specific - than actually teaching *programming*, regardless of how it's marketed.
This does seem pretty sensible, actually.
I can agree that it is probably useful for this, since most people will enjoy making visual things with direct feedback than writing a bunch of code to print "Hello, World!" or sort a list or something.
Still, it definitely does have limits for this given that it's quite lacking in control flow capability and abstraction compared to regular programming languages.
Also, it's not really marketed this way, and thus probably not taught that way either.

16
blog/on-phones.md Normal file
View File

@ -0,0 +1,16 @@
---
title: On Phones
description: My (probably unpopular in general but... actually likely fairly popular amongst this site's intended audience) opinions on smartphones today.
slug: phones
created: 16/08/2017
updated: 24/01/2020
---
* Why notches? WHY? Just because Apple used them doesn't mean every single manufacturer needs to start making their screens have ugly black bits on them.
* Really, why Apple at all? They sell uncustomisable and locked-down stuff at higher and higher prices with fewer and fewer nice-to-haves (e.g. headphone jacks) each year. And the vendor lock-in (Lightning headphones, iVersionsOfMostOtherSoftware) is also bad.
* It would be nice to *not* have battery life ruined to get slightly slimmer phones.
* The complete lack of updates after a year or so is annoying. Custom ROMs kind of fix this but many aren't available (or even aren't possible due to locked bootloaders) on many devices. This is probably just planned obsolecence.
* Most of the stuff manufacturers preload (their own UI skinning, apps) is just useless bloat. Especially the preloaded, unremovable, probably-spying-on-you Facebook apps which are annoyingly common.
* The lack of SD card slots is, again, probably just planned obsolecence.
* Proper physical QWERTY keyboards would be nice, though as they're such a niche feature that's probably never going to happen except on a few phones.
* The screens don't need to get bigger. People's hands aren't growing every year. And they don't need more pixels to drain increasingly large amounts of power.
* Removable batteries should come back. When I initially wrote this in 2017 or so, they were pretty common, but now barely any new devices let you *swap the battery*, despite lithium-ion batteries degrading within a few years of heavy use. I know you can't economically do highly modular design in a phone, but this is not a complex, technically difficult or expensive thing to want.

View File

@ -0,0 +1,71 @@
---
title: AutoScorer
description: Automatic score keeper, designed for handling Monopoly money.
slug: scorer
---
<div id="app">
<input type="number" v-model.number="startingScore">
<input type="text" v-model="newPlayerName">
<button @click="players.push(newPlayerName)">Add</button>
<ul>
<li
is="player"
v-for="(player, idx) in players"
:key="player"
:title="player"
:name="player"
:start-score="startingScore"
@delete="players.splice(idx, 1)">
</li>
</ul>
</div>
<script src="/assets/js/vue.js"></script>
<script type="text/x-template" id="score-template">
<div class="score">
<input v-model.number="score" type="number">
<button @click="decrement">-</button>
<input v-model.number="change" type="number">
<button @click="increment">+</button>
</div>
</script>
<script>
Vue.component("score", {
props: ["startScore"],
data: function() {
return {
change: 1,
score: this.startScore,
};
},
template: "#score-template",
methods: {
increment: function() {
this.score += this.change;
},
decrement: function() {
this.score -= this.change;
}
}
});
Vue.component("player", {
props: ["startScore", "name"],
template: '<div class="player"><h1 class="player-name">{{name}}</h1><score :startScore="startScore"></score><button @click="$emit(\'delete\')">Delete</button></div>'
});
var vm = new Vue({
el: "#app",
data: {
players: [],
startingScore: 0,
newPlayerName: "Name Here"
}
});
</script>

View File

@ -0,0 +1,106 @@
---
title: Colours of the Alphabet
slug: alphacol
description: Colorizes the Alphabet, using highly advanced colorizational algorithms.
---
<style>
#colOut .charOut {
font-size: 2em;
font-family: Fira Mono, Courier New, Courier, monospace;
}
#chars {
width: 100%;
}
textarea {
font-size: 2em;
}
</style>
<script src="/assets/js/vue.js"></script>
<div id="app">
<div id="colOut">
<span v-for="c in coloredChars" :style="c.style" class="charOut">{{c.char}}</span>
</div>
<hr>
<textarea rows="5" type="text" placeholder="Enter some text" id="chars" v-model="input"></textarea>
<div>Colorization Mode: </div>
<select v-model="method">
<option value="hsl">HSL</option>
<option value="rgb">RGB</option>
</select>
</div>
<script>
String.prototype.forEach = function(callback)
{
for (var i = 0; i < this.length; i++)
callback(this[i]);
}
var beginAlpha = 97;
var endAlpha = 122;
var numChars = endAlpha - beginAlpha + 1
var colMax = 4096;
var alpha = {}
for (var charCode = beginAlpha; charCode <= endAlpha; charCode++)
{
alpha[String.fromCharCode(charCode)] = charCode - beginAlpha;
}
var charOut = document.getElementById("charOut");
var colOut = document.getElementById("colOut");
var pad3 = function(num) {return ("000" + num).substr(-3, 3)}; // Pads out a number so that it is exactly 3 digits long.
function rescaleAlpha(char, max) {
return alpha[char] / numChars * max;
}
function toShortHex(col)
{
var hexCode = Math.round(col).toString(16);
return "#" + pad3(hexCode);
}
var vm = new Vue({
el: "#app",
data: {
input: "",
method: "rgb"
},
computed: {
coloredChars: function() {
var conversionFunction = function() {return "red";}
if (this.method == "rgb") {
conversionFunction = this.charToRGB;
} else if (this.method == "hsl") {
conversionFunction = this.charToHSL;
}
return this.input.split("").map(function(character) {
return {style: {"color": conversionFunction(character.toLowerCase())}, char: character}
});
}
},
methods: {
charToRGB: function(char) {
return toShortHex(rescaleAlpha(char, colMax));
},
charToHSL: function(char) {
return "hsl(" + rescaleAlpha(char, 360) + ", 100%, 50%)"
}
}
})
</script>

View File

@ -0,0 +1,414 @@
---
title: Emu War
description: Survive as long as possible against emus and other wildlife. Contributed by Aidan.
---
<span style="position: fixed">
<span id="bar">
</span>
<span id="text">
</span>
</span>
<div id="screen">
</div>
<div>
<button onclick="lastIns='r';mainLoop()"></button>
<div style="display: inline-block"</div>
<button onclick="lastIns='u';mainLoop()"></button>
<button onclick="lastIns='d';mainLoop()"></button>
</div>
<button onclick="lastIns='l';mainLoop()"></button>
</div>
<script type="text/javascript">
const WIDTH = 30
const HEIGHT = 20
const genTable = (x, y, width, height) => {
let tbody = document.createElement("tbody")
tbody.style = "width:50%;display:block;margin:auto;font-size:0.75rem"
for (let row = 0; row < y; row++) {
let tr = document.createElement("tr")
for (let col = 0; col < x; col++) {
let th = document.createElement("th")
th.innerHTML = " "
th.style = "width:" + width + ";height:" + height
tr.appendChild(th)
}
tbody.appendChild(tr)
}
return tbody
}
const setPixel = (elem, x, y, val) => {
elem.childNodes[1].childNodes[y].childNodes[x].innerHTML = val
}
const fillScreen = (elem, width, height, text) => {
for (let x = 0; x < WIDTH; x++) {
for (let y = 0; y < HEIGHT; y++) {
setPixel(elem, x, y, text)
}
}
}
const writeToScreen = (elem, width, startx, starty, words) => {
let nletter = 0
let x = startx
let y = starty
while(nletter < words.length) {
if (words[nletter] == '\n') {
y++
x=0
nletter++
continue
}
if (x >= width) {
y++
x=0
}
if (words[nletter] == ' ' && x==0) {
nletter++
continue
}
setPixel(elem, x, y, words[nletter])
x++
nletter++
}
}
const say = (elem, text) => {
elem.innerHTML += "<br>" + text
}
const clear = (elem) => {
elem.innerHTML = ""
}
const clamp = (x, max, min) => {
if (x >= max) return max
else if (x <= min) return min
else return x
}
let screen = document.getElementById("screen")
let saybox = document.getElementById("text")
let bar = document.getElementById("bar")
screen.style = "font-size:1rem;font-family:monospace"
let tablescreen = genTable(WIDTH, HEIGHT, "1rem", "1.125rem")
screen.appendChild(tablescreen)
const startDesc = document.createElement("div")
screen.appendChild(startDesc)
startDesc.innerHTML = `Welcome to Aidan's RPG thing!
<br>
You are an intrepid explorer who got lost in a cavernous cavern, infested with all sorts of dangerous critters, from rats to\nmighty ogres.
<br>
You cannot survive, but how many foes will you take with you?
<br>
Use WASD or buttons to move and attack, and 'r' to\nrestart.
<br>
Press W, A, S or D to begin.`
const enemy_icons = ["I", "K", "S", "E", "O", "R"]
const enemy_names = ["ibis", "kestrel", "spider", "emu", "ogre", "rat"]
const enemy_hp = [50, 30, 20, 80, 150, 15]
const enemy_dmg_min = [04, 02, 02, 05, 005, 02]
const enemy_dmg_range = [05, 15, 05, 20, 015, 05]
const enemy_reward = [03, 02, 01, 04, 005, 01]
const START_STR = 10
let hp = 500
let str = 0
let score = 0
let turns = 0
let x = Math.floor(WIDTH / 2)
let y = Math.floor(HEIGHT / 2)
let lastIns = ""
let base_dmg = 10
let enemies = []
let bonuses = []
const restart = () => {
hp = 500
str = 0
score = 0
turns = 0
x = Math.floor(WIDTH / 2)
y = Math.floor(HEIGHT / 2)
lastIns = ""
base_dmg = 10
enemies = []
bonuses = []
clear(bar)
clear(saybox)
fillScreen(screen, WIDTH, HEIGHT, " ")
startDesc.style.display = "block"
tablescreen.style.display = "none"
}
restart()
const BONUS_HP = 128
const BONUS_STR = 8
const MAX_BONUS = 8
const MAX_ENEMY = 24
const BASE_SCALE_FACTOR = 0.5
const gameOverMessage = "GAME OVER!"
let modif = 1
const calcModif = () => {
modif = str / START_STR + 1
}
const encounter = (enemy_id) => {
let enemy_dmg_done = Math.floor(enemy_dmg_min[enemy_id] + Math.random() * enemy_dmg_range[enemy_id] * modif)
say(saybox, "A " + enemy_names[enemy_id] + " attacked and did " + enemy_dmg_done + " damage!")
hp -= enemy_dmg_done
}
const spawnEnemy = (x, y, id) => {
enemies.push({
x: x,
y: y,
id: id,
hp: Math.floor(enemy_hp[id] * modif),
})
}
const spawnBonus = (x, y, hp, str, icon) => {
bonuses.push({
x: x,
y: y,
hp: hp,
str: str,
icon: icon,
})
}
const drawEnemy = (enemy_index) => {
const enemy = enemies[enemy_index]
setPixel(screen, enemy.x, enemy.y, enemy_icons[enemy.id])
}
const drawBonus = (bonus_index) => {
const bonus = bonuses[bonus_index]
setPixel(screen, bonus.x, bonus.y, bonus.icon)
}
const pickupBonus = (bonus_index) => {
const bonus = bonuses[bonus_index]
if (bonus.x == x && bonus.y == y) {
hp += bonus.hp
str += bonus.str
base_dmg += Math.floor(bonus.str * BASE_SCALE_FACTOR)
say(saybox, "Gained " + bonus.hp + "hp and " + bonus.str + "str from pickup!")
return true
}
return false
}
const drawPlayer = () => {
setPixel(screen, x, y, "@")
}
const checkCollision = (enemy_index) => {
let enemy = enemies[enemy_index]
for (let i = 0; i < enemies.length; i++) {
if (i == enemy_index) continue
let other = enemies[i]
if (other.x == enemy.x && other.y == enemy.y) return true
}
return (enemy.x == x && enemy.y == y)
}
const getEnemy = (x, y) => {
for (let i = 0; i < enemies.length; i++) {
let other = enemies[i]
if (other.x == x && other.y == y) return i
}
return -1
}
const canAttackPlayer = (enemy_index) => {
let enemy = enemies[enemy_index]
return enemy.x == x && enemy.y == y
}
const moveEnemy = (enemy_index) => {
let enemy = enemies[enemy_index]
let px = enemy.x
let py = enemy.y
let dx = x - enemy.x
let dy = y - enemy.y
if (Math.random() > 0.75 || dx*dx + dy*dy > 36) {
dx = Math.random() - 0.5
dy = Math.random() - 0.5
}
if (Math.abs(dx) > Math.abs(dy)) {
enemy.x += Math.sign(dx)
} else {
enemy.y += Math.sign(dy)
}
enemy.x = clamp(enemy.x, WIDTH-1, 0)
enemy.y = clamp(enemy.y, HEIGHT-1, 0)
if (canAttackPlayer(enemy_index)) {
encounter(enemies[enemy_index].id)
}
}
const attack = (enemy_index) => {
let done_dmg = base_dmg + Math.floor(Math.random() * (str + START_STR))
enemies[enemy_index].hp -= done_dmg
if (enemies[enemy_index].hp > 0) {
say(saybox, "Attacked " + enemy_names[enemies[enemy_index].id] + " and did " + done_dmg + " damage! It now has " + enemies[enemy_index].hp + "hp!")
}
}
const handleInput = (ins) => {
let lookX = x
let lookY = y
if (ins == "u") {
lookY += -1
} else if (ins == "d") {
lookY += 1
} else if (ins == "l") {
lookX += 1
} else {
lookX += -1
}
lookX = clamp(lookX, WIDTH-1, 0)
lookY = clamp(lookY, WIDTH-1, 0)
let id = getEnemy(lookX, lookY)
if (id == -1) {
x = lookX
y = lookY
} else {
attack(id)
if (enemies[id].hp < 0) {
say(saybox, "Killed a " + enemy_names[enemies[id].id] + " gaining " + enemy_reward[enemies[id].id] + "str!")
str += enemy_reward[enemies[id].id]
base_dmg += Math.floor(enemy_reward[enemies[id].id] * BASE_SCALE_FACTOR)
enemies.splice(id, 1)
x = lookX
y = lookY
score++
}
}
}
const mainLoop = () => {
if (hp <= 0) {
return
}
turns++
fillScreen(screen, WIDTH, HEIGHT, ".")
startDesc.style.display = "none"
tablescreen.style.display = "block"
clear(saybox)
calcModif()
handleInput(lastIns)
for (let i = 0; i < enemies.length; i++) {
let origX = enemies[i].x
let origY = enemies[i].y
moveEnemy(i)
if (checkCollision(i)) {
enemies[i].x = origX
enemies[i].y = origY
}
if (canAttackPlayer(i)) {
encounter(enemies[i].id)
}
drawEnemy(i)
}
let toDel = []
for (let i = 0; i < bonuses.length; i++) {
if (pickupBonus(i)) {
toDel.push(i)
}
drawBonus(i)
}
for (let i = 0; i < toDel.length; i++) {
bonuses.splice(toDel[i], 1)
}
let freqModif = 1 / (0.5*str / START_STR + 1)
if (Math.random() > 0.8 * freqModif && enemies.length <= MAX_ENEMY) {
let randID = Math.floor(Math.random() * enemy_icons.length)
let randX = Math.floor(Math.random() * WIDTH)
let randY = Math.floor(Math.random() * HEIGHT)
spawnEnemy(randX, randY, randID)
}
if (Math.random() > 0.75 && bonuses.length <= MAX_BONUS) {
let randHP = Math.floor(Math.random() * BONUS_HP)
let randStr = Math.floor(Math.random() * BONUS_STR)
let randX = Math.floor(Math.random() * WIDTH)
let randY = Math.floor(Math.random() * HEIGHT)
spawnBonus(randX, randY, randHP, randStr, "?")
}
drawPlayer()
clear(bar)
say(bar, "HP: " + hp + " Str: " + (str + START_STR) + " Base dmg: " + base_dmg)
say(bar, "Vanquished " + score + " foes.")
say(bar, "Turn " + turns)
if (hp <= 0) {
if ("points" in window) {
if (score >= 10) { points.unlockAchievement("emuwar10") }
points.updateMetric("foesVanquished", function(x) { return x + score }, 0)
points.updateMetric("deaths", function(x) { return x + 1 }, 0)
}
clear(saybox)
say(saybox, gameOverMessage + " Press R to restart.")
writeToScreen(screen, WIDTH, Math.floor(WIDTH/2 - gameOverMessage.length/2), Math.floor(HEIGHT/2)-1, gameOverMessage)
}
}
document.addEventListener('keydown', function(event) {
if(event.keyCode == 65) { // A
lastIns = 'r'
} else if(event.keyCode == 87) { // W
lastIns = 'u'
} else if(event.keyCode == 68) { // D
lastIns = 'l'
} else if(event.keyCode == 83) { // S
lastIns = 'd'
} else if(event.keyCode == 82) {
restart()
return
} else {
return
}
mainLoop()
});
function asyncDoLoop(fn) {
setTimeout(() => {
fn()
setTimeout(() => asyncDoLoop(fn), 0)
})
}
</script>

View File

@ -0,0 +1,25 @@
---
title: Game of Life V2
description: Obligatory (John Conway's) Game of Life implementation.
slug: gol
---
<style>
td.on {
background: white;
}
td.off {
background: black;
}
td {
width: 1vw;
height: 1vw;
border: 1px solid gray;
}
table {
border-collapse: collapse;
}
</style>
<div id="app"></div>
<script src="out.js"></script>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,47 @@
---
title: GUIHacker
comments: off
description: <a href="https://github.com/osmarks/guihacker">My fork</a> of GUIHacker. Possibly the only version actually on the web right now since the original website is down.
---
<style>
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 400;
src: local('Source Code Pro'), local('SourceCodePro-Regular'),
}
body {
font-family: 'Source Code Pro', 'Fira Code', 'Inconsolata', 'Courier New', 'Courier', monospace;
background: #000;
color: #00FF00;
margin: 0;
display: block;
}
canvas {
position: absolute;
top: 0;
left: 0;
}
.bars-and-stuff{
left: 66.6%;
}
.output-console {
position: fixed;
overflow: hidden;
}
p{margin:0}
nav {
display: none;
}
.description {
display: none;
}
</style>
<canvas class='hacker-3d-shiz'></canvas>
<canvas class='bars-and-stuff'></canvas>
<div class="output-console"></div>
<script src="/assets/js/h4xx0r.js"></script>

View File

@ -0,0 +1,245 @@
---
title: Idea Generator
slug: ideas
description: Generates ideas. Terribly. Don't do them. These are not good ideas.
---
<noscript>
The Idea Generator requires JavaScript to function.
</noscript>
<div id="app">
<div id="out">ERROR</div>
<button onclick="set()">Randomize</button>
</div>
<script>
// Picks a random element from an array
function pickRandom(l) {
return l[Math.floor(Math.random() * l.length)];
}
function genMany(f, times) {
return Array.apply(null, Array(times)).map(f);
}
// Makes an array by repeating "x" "times" times.
// Uses stackoverflow magic.
function repeat(x, times) {
return genMany(function() { return x; }, times);
}
// Weighted random: takes an array formatted as [[1, "a"], [2, "b"]], interprets first element of each pair as a weight, and then the second as a value
// Weights must be integers and should be small, or they'll eat all memory.
function pickWeightedRandom(arr) {
var longArray = arr.map(function(pair) {
return repeat(pair[1], pair[0]);
}).reduce(function(acc, x) {
return acc.concat(x);
});
return pickRandom(longArray);
}
// Returns thing with given probability, otherwise an empty string
function addMaybe(probability, thing) {
return Math.random() < probability ? thing : "";
}
var vowels = ["a", "e", "i", "o", "u"];
// Correctly discriminates between a/an given the word coming after it
function connectorA(after) {
var firstLetter = after[0];
return vowels.indexOf(firstLetter) > -1 ? "an" : "a";
}
// Fed to reduce in order to evaluate a pattern
function evalPatternReducer(output, current) {
var last = output[output.length - 1]; // Pick the previous output (this will be the one coming afterwards in the actual final output)
return output.concat([current(last)]);
}
function randomize() {
if (Math.random() < 0.02) {
return pickRandom(others);
}
return pickWeightedRandom(patterns).reduceRight(evalPatternReducer, []).reverse().join(" ");
}
function set() {
document.getElementById("out").innerText = randomize();
}
function applyConnector(prev) {
var c = pickRandom(connectors);
if (typeof c == "string") {
return c
} else {
return c(prev);
}
}
function always(x) {
return function() {
return x
}
}
var adverbActionAdjectiveNounPattern = [
function() { return addMaybe(0.3, pickRandom(adverbs)); },
function() { return pickRandom(actions); },
applyConnector,
function() { return addMaybe(0.5, pickRandom(adjectives)); },
function() { return pickRandom(things); }
]
var patterns = [
[4, adverbActionAdjectiveNounPattern],
[1, [always("do not")].concat(adverbActionAdjectiveNounPattern)],
[1, adverbActionAdjectiveNounPattern.concat([always("or else")])]
];
var things = [
"pancake",
"cat",
"app",
"idea generator",
"dog",
"idea",
"problem",
"chair",
"sandwich",
"ice cream",
"town",
"book",
"country",
"computer",
"duct tape",
"apple juice",
"cow",
"lamp",
"politician",
"car",
"chair",
"swivel chair",
"ethernet switch",
"radio",
"watermelon",
"point",
"data",
"spaceship",
"planet",
"moon",
"star",
"black hole",
"decagon",
"crate",
"javascript framework"
];
var adverbableAdjectives = [
"quick",
"slow",
"huge",
"large",
"great",
"awful",
"irritating",
"stupid",
"ideal",
"wonderful",
"brilliant",
"political",
"cool",
"orthogonal",
"strange",
"weird",
"excellent"
]
var otherAdjectives = [
"5-gigabit",
"tall",
"fast",
"small",
"triangular",
"octagonal",
"nonexistent",
"imaginary",
"hyperbolic"
]
var adjectives = adverbableAdjectives.concat(otherAdjectives);
var otherAdverbs = [
]
var adverbs = adverbableAdjectives.map(function(a) {return a + "ly";}).concat(otherAdverbs);
var actions = [
"talk to",
"make",
"find",
"delete",
"meet",
"solve",
"sit on",
"eat",
"enlighten",
"believe in",
"change",
"take",
"study",
"use",
"visit",
"understand",
"read",
"travel to",
"buy",
"sell",
"encourage",
"argue with",
"load",
"fix",
"argue about",
"create"
];
var connectors = [
"your",
"my",
connectorA,
"the",
"someone's",
"another"
]
var optimalConfigurations = [
"Firefox 23 on a Difference Engine",
"manual HTTP over Telnet on a Pentium 3",
"NetPositive on Haiku (<0.6)",
"Vanadium 764 on an AlphaHoloCore P-series (> 150THz recommended)",
"a quantum cheeseputer",
"emulating a CPU on paper",
"a computer outside of the Matrix",
"an iPhone 2 (the Angular 3/PHP 6 version is required on this platform)",
"a computer with an x87 processor",
"a 1048576-bit device supporting the x186 architecture"
]
var others = [
"Protocol Omega has been activated.",
"Error. Out of 1s.",
"Don't believe his lies.",
"Error. You have broken the Internet.",
"They are coming for you. RUN!",
"Help, I'm trapped in an idea generator!",
"*** Prelude.undefined: matrix/src/Physics/SubquantumGravity.hs:1337",
"Please switch to " + pickRandom(optimalConfigurations) + " for an optimal experience.",
"User error. The user will be deleted.",
genMany(function() { return String.fromCharCode(Math.random() * 2048); }, 1024).join("")
]
set();
</script>

View File

@ -0,0 +1,6 @@
---
title: IncDec
slug: incdec
description: The exciting game of incrementing and decrementing!
---
If you're reading this, then this is not linking to actual IncDec as it should due to a server misconfiguration.

View File

@ -0,0 +1,236 @@
---
title: Infipage
description: Outdoing all other websites with <b>INFINITE PAGES!</b>
url: /infipage/0
---
<style>
#prev, #next {
text-decoration: none;
}
#main {
padding-top: 10vh;
font-size: 2em;
display: flex;
justify-content: space-around;
}
#main.mobile {
display: block;
text-align: center;
}
#pagecount {
max-width: 70vw;
overflow-wrap: break-word;
}
#error {
padding-top: 0.5em;
color: red;
text-align: center;
}
</style>
<div id="main">
<a id="prev">Previous Page</a>
<div id="pagecount"></div>
<a id="next">Next Page</a>
</div>
<div id="error"></div>
<script src="https://unpkg.com/big.js@5.2.1/big.js"></script>
<script>
Big.PE = Infinity
Big.DP = 0
// From MDN somewhere
if (!String.prototype.startsWith) {
String.prototype.startsWith = function(search, pos) {
return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
};
}
if (!String.prototype.repeat) {
String.prototype.repeat = function(times) {
return new Array(num + 1).join(this);
};
}
function encodeRLEArray(input) {
var encoding = [];
var prev, count, i;
for (count = 1, prev = input[0], i = 1; i < input.length; i++) {
if (input[i] != prev || count == 35) {
encoding.push([count, prev])
count = 1
prev = input[i]
}
else {
count++
}
}
encoding.push([count, prev])
return encoding
}
function encodeRLEString(rleArr) {
var out = ""
rleArr.forEach(function(pair) {
out += pair[0].toString(36) + pair[1]
})
return out
}
/*function encodeRLEString2(rleArr) {
var out = ""
rleArr.forEach(function(pair) {
var count = pair[0]
var char = pair[1]
if (count !== 1) {
out += "." + count.toString(36) + char
} else {
out += char
}
})
return out
}*/
function decodeRLEArray(arr) {
var out = ""
arr.forEach(function(pair) {
out += pair[1].repeat(pair[0])
})
return out
}
function decodeRLEPair(r) {
return [ parseInt(r[0], 36), r[1] ]
}
function decodeRLEString(str) {
var results = []
var re = /[0-9a-z][0-9A-Za-z_-]/g
var match
while (match = re.exec(str)) {
results.push(decodeRLEPair(match[0]))
}
return results
}
function encodeRLE(str) {
return encodeRLEString(encodeRLEArray(str))
}
function decodeRLE(str) {
return decodeRLEArray(decodeRLEString(str))
}
function b64e(str) {
return btoa(str).replace(/\+/g, "_").replace(/\//g, "-")
}
function b64d(b64) {
return atob(b64.replace(/_/g, "+").replace(/\-/g, "/"))
}
var base = Big(256)
var basediv2 = base.div(2)
function addEncoding(arr, func) {
return arr.concat(arr.map(func))
}
function findShortest(arr) {
return arr.reduce(function(prev, now) {
if (typeof prev === "string") {
return now.length < prev.length ? now : prev
} else {
return now
}
}, null)
}
function encodeBignum(b) {
var out = ""
var curr = b
// Pretend it's a positive int until the end
if (b.s === -1) { curr = b.times(-1) }
var byte = 0
while (!curr.eq(0)) {
var now = curr.mod(base)
out += String.fromCharCode(+now)
// Attempt to emulate an actual bitshift
curr = curr.div(base)
if (now.gte(basediv2)) { curr = curr.minus(1) }
}
var start = b.s === -1 ? "n" : "p"
var b64 = start + b64e(out)
var decimal = b.toString()
var possibilities = [b64, decimal]
possibilities = addEncoding(possibilities, function(x) { return "r" + encodeRLE(x) })
return findShortest(possibilities)
}
function decodeBignum(str) {
if (str.startsWith("r")) {
return decodeBignum(decodeRLE(str.substring(1)))
}
// If string is not tagged with its sign, it's just a regular number
if (!str.startsWith("n") && !str.startsWith("p")) {
return Big(str)
}
var start = str.substring(0, 1)
var bin = b64d(str.substring(1))
var out = Big(0)
// Split string into bytes
var bytes = bin.split("").map(function(x) { return x.charCodeAt(0) })
// Add each byte to string, multiplied by 2 ^ its position in string
bytes.forEach(function(byte, exponent) {
var thisByte = Big(byte).times(base.pow(exponent))
out = out.plus(thisByte)
})
if (start === "n") { out = out.times(-1) }
return out
}
var page
var pageString
var prev = document.querySelector("#prev"), next = document.querySelector("#next"), count = document.querySelector("#pagecount"), main = document.querySelector("#main"), error = document.querySelector("#error")
function loadPage() {
try {
var afterSlash = /infipage\/([A-Za-z0-9_=-]+)/.exec(window.location.pathname)[1]
page = decodeBignum(afterSlash)
} catch(e) {
console.warn("Page Number Decode Failure")
console.warn(e)
error.innerText = "Page number invalid - " + e + ". Defaulting to 0."
page = Big(0)
}
pageString = page.toString()
console.log("Page", pageString)
var canonical = encodeBignum(page)
if (canonical !== afterSlash) {
console.log(canonical, afterSlash, "Mismatch!")
window.location.href = `/infipage/${canonical}`
}
prev.href = encodeBignum(page.minus(1))
next.href = encodeBignum(page.plus(1))
pagecount.innerText = "Page " + page.toString()
}
loadPage()
if ("ontouchstart" in window) { main.classList.add("mobile") }
</script>
<script>
window.addEventListener("load", function() {
if ("points" in window) {
console.log("running update")
points.updateMetric("greatestInfipage", function(current) {
console.log("updated", current, pageString)
if (!current || page.abs().gt(Big(current))) { return pageString }
else { return current }
})
}
})
</script>

View File

@ -0,0 +1,26 @@
---
title: JHLT
description: Tells you how late Joe's homework is.
---
<div id="timer"></div>
<script src="/assets/js/moment.min.js"></script>
<script>
var joe = moment("2017-03-23T09:15:00");
var el = document.getElementById("timer");
function format(dur) {
return "Joe's homework is " +
+ dur.years() + " years "
+ dur.months() + " months "
+ dur.days() + " days "
+ dur.hours() + " hours "
+ dur.minutes() + " minutes "
+ dur.seconds() + " seconds late.";
}
setInterval(function() {
var diff = moment.duration(-joe.diff(moment()));
el.innerText = format(diff);
}, 1000);
</script>

85
experiments/lorem/index.html Executable file
View File

@ -0,0 +1,85 @@
---
title: Lorem Ipsum
slug: lorem
description: Lorem Ipsum (latin-like placeholder text)... FOREVER.
---
<style>
body {
overflow-y: scroll;
overflow-x: hidden;
position: relative;
}
#marker {
width: 1px;
height: 1px;
position: absolute;
bottom: 10vh;
}
#text {
padding-left: 2vw;
padding-right: 2vw;
padding-top: 2vw;
}
</style>
<div id="text"></div>
<script src="/assets/js/lorem.js"></script>
<script src="/assets/js/infiscroll.js"></script>
<script>
var textEl = document.querySelector("#text");
var count = 0;
function pickRandom(l) {
return l[Math.floor(Math.random() * l.length)];
}
var extra = [
"Protocol Omega has been activated.",
"Error. Out of 1s.",
"Don't believe his lies.",
"I have the only antidote.",
"They are coming for you.",
"Help, I'm trapped in an infinite scroll webpage!",
];
function throttle (callback, limit) {
var wait = false;
return function () {
if (!wait) {
callback.call();
wait = true;
setTimeout(function () {
wait = false;
}, limit);
}
}
}
var count = 0
var unaddedCount = 0
var handlePoints = throttle(function() {
if (count >= 400) { points.unlockAchievement("lorem400") }
points.updateMetric("loremParagraphs", function(x) { return x + unaddedCount }, 0).then(function() { unaddedCount = 0 })
}, 300)
window.addEventListener("load", function() {
infiscroll(function() {
if (Math.random() > 0.02) {
textEl.appendChild(document.createTextNode(" " + Lorem.createText(1, Lorem.TYPE.PARAGRAPH)))
} else {
textEl.appendChild(document.createTextNode(" " + pickRandom(extra)))
}
count++
unaddedCount++
console.log("Scrolled down, generating lorem.", count);
if ("points" in window) {
handlePoints()
}
}, "30vh", textEl, 10);
})
</script>

View File

@ -0,0 +1,36 @@
---
title: Arbitrary Points
description: Collect Arbitrary Points and achievements by doing things on this website! See how many you have! Do nothing with them because you can't! This is the final form of gamification.
slug: points
---
<div id="app">
<noscript>You need JS on for this to work. I really don't know what you expected at this point.</noscript>
</div>
<div class="smallinfo">All Arbitrary Points data is stored and processed only on your device.
There is no serverside component whatsoever.
If you don't like this regardless, you can bug me to implement an off switch, attempt to ignore it, or use Internet Explorer 6.
Ideas for features and achievements and whatever else wanted and may be accepted.
This is very easy to meddle with using the browser console, as I haven't tried to prevent that, but if you cheat all the time you may ruin any fun this might have brought.
</div>
<script src="/assets/js/mithril.js"></script>
<script>
if (!("Promise" in window)) {
document.getElementById("app").innerHTML = "Your browser is seemingly too outdated for this to work. Sorry! Try installing/updating Firefox."
}
</script>
<script defer src="./index.js">
</script>
<style>
button {
border: 1px solid black;
background: lightgray;
border-radius: 0;
padding: 0.5em;
}
.metricname {
padding-right: 1em;
}
</style>

110
experiments/points/index.js Normal file
View File

@ -0,0 +1,110 @@
const round = x => Math.round(x * 1e10) / 1e10
const prefixes = ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"]
const siPrefix = (value, unit) => {
let i = 0
let b = value
while (b > 1000) {
b /= 1000
i++
}
return `${round(b).toString()} ${prefixes[i]}${unit}${value !== 1 ? "s" : ""}`
}
const metricDisplayInfo = {
pagesVisited: { name: "Pages visited", units: "page" },
timeSpent: { name: "Time spent", units: "second" },
achievements: { name: "Achievements" },
foesVanquished: { name: "Foes vanquished", units: "foe" },
deaths: { name: "Deaths", units: "death" },
loremParagraphs: { name: "Lorem Ipsum paragraphs seen", units: "paragraph" },
commentsPosted: { name: "Comments posted", units: "comment" },
greatestInfipage: { name: "Largest infipage visited" }
}
const displayMetric = metric => {
let name = metric[0]
let value = metric[1]
const displayInfo = metricDisplayInfo[name]
if (displayInfo) {
name = displayInfo.name
if (displayInfo.units) {
value = siPrefix(value, displayInfo.units)
}
}
return m("tr", m("td.metricname", name), m("td.metricvalue", value))
}
const Metrics = {
metrics: null,
load: async () => {
Metrics.metrics = await points.readAllMetrics()
m.redraw()
},
view: () => m("p", Metrics.metrics === null ? "Loading..." : m("table.metrics", Array.from(Metrics.metrics.entries()).map(displayMetric)))
}
const zfill = (num, z) => num.toString().padStart(z, "0")
const formatDate = x => `${zfill(x.getHours(), 2)}:${zfill(x.getMinutes(), 2)}:${zfill(x.getSeconds(), 2)} ${zfill(x.getDate(), 2)}/${zfill(x.getMonth() + 1, 2)}/${zfill(x.getFullYear(), 4)}`
const renderAchievement = a =>
m(".achievement", { style: `background-color: ${colHash(a.title)}` }, [
a.timestamp && m(".title", { title: a.id }, `Achievement achieved at ${formatDate(new Date(a.timestamp))}`),
m(".title", a.title),
m(".description", a.description),
m(".conditions", `Unlocked by: ${a.conditions}`),
a.points && m(".points", `${a.points} points`)
])
const Achievements = {
achievements: [],
load: async () => {
const raw = await points.getAchievements()
Achievements.achievements = raw.map(ach => {
const info = points.achievementInfo[ach.id]
const out = {
title: ach.id || "???",
description: `Unrecognized achievement ${ach.id}.`,
conditions: "???",
...ach
}
if (info) { Object.assign(out, info) }
m.redraw()
return out
})
Achievements.achievements.sort((a, b) => a.timestamp < b.timestamp)
},
view: () => m(".achievements-listing", Achievements.achievements.map(renderAchievement))
}
const reset = async () => {
if (prompt(`This will reset your points, achievements and metrics. If you are sure, please type "yes I am definitely sure".`) === "yes I am definitely sure") {
if (confirm("Are you really very sure?")) {
await points.reset()
window.location.reload()
}
}
}
let pointsCount = "[loading...]"
const reloadPoints = async () => { pointsCount = await points.getPoints() }
const App = {
view: () => m("div", [
m("h2", `Points: ${pointsCount}`),
m("button", { onclick: reset }, "Reset"),
m(Metrics),
m(Achievements)
])
}
m.mount(document.getElementById("app"), App)
Metrics.load()
reloadPoints()
Achievements.load()
points.unlockAchievement("visitArbitraryPoints")
document.addEventListener("points-update", () => { reloadPoints(); Achievements.load() })

15
experiments/rpncalc-v2/calc.css Executable file
View File

@ -0,0 +1,15 @@
.stack-box {
text-align: center;
border: solid 1px black;
min-width: 30vmin;
max-width: 30vmin; /* will normally be dynamically set */
line-height: 30vmin;
height: 30vmin;
font-size: 7vmin;
margin: -1px; /* make edges join neatly */
}
#input {
width: 100%;
font-size: 2em;
}

157
experiments/rpncalc-v2/calc.js Executable file
View File

@ -0,0 +1,157 @@
// Reads the input box for a RPN expression
// Calculates result
// Outputs it as nicely formatted boxes.
function calculateFromInput() {
var expr = document.getElementById("input").value;
var output = document.getElementById("output")
var result = calculateRPN(expr.split(" "));
output.innerHTML = ""; // Clear the output div
result.stack.forEach(function(num) {
num = num.toString().replace("NaN", "Error");
var box = createBox(num);
box.style["max-width"] = num.length + "em";
output.appendChild(box);
});
if (result.errors.length > 0) { // If errors exist output them separated by line breaks.
result.errors.forEach(error => {
output.appendChild(document.createTextNode(error.toString()))
output.appendChild(document.createElement("br"))
})
}
}
function add(x, y) {
return x + y;
}
function multiply(x, y) {
return x * y;
}
function divide(x, y) {
return x / y;
}
function flip(x, y) {
return [y, x];
}
function subtract(x, y) {
return x - y;
}
function sum(vals) {
var acc = 0;
vals.forEach(function(el) {
acc += el;
});
return acc;
}
function range(low, high) {
var r = [];
for (var i = low; i <= high; i++) {
r.push(i);
}
return r;
}
function createBox(contents) {
var el = document.createElement("div");
el.setAttribute("class", "stack-box");
el.innerText = contents;
return el;
}
// Takes a two-argument function and lifts it to a binary stack op
function binaryOp(fun) {
return function(stack) {
var x = stack.pop();
var y = stack.pop();
stack.push(fun(y, x));
return stack;
}
}
// Takes a function and lifts it to a unary op using a stack. Returns new stack.
function unaryOp(fun) {
return function(stack) {
var x = stack.pop();
stack.push(fun(x));
return stack;
}
}
// Takes a function and lifts it to an op which takes the entire stack and reduces it to one value. Returns new stack.
function greedyOp(fun) {
return function(stack) {
return [fun(stack)];
}
}
// Lifs to an operator which takes two values and adds an array of them to the stack. Returns a new stack.
function binaryMultioutOp(fun) {
return function(stack) {
var x = stack.pop();
var y = stack.pop();
return stack.concat(fun(y, x));
}
}
function calculateRPN(tokens) {
var stack = [];
var errors = [];
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
switch (token) {
case "+":
stack = binaryOp(add)(stack);
break;
case "*":
stack = binaryOp(multiply)(stack);
break;
case "/":
stack = binaryOp(divide)(stack);
break;
case "-":
stack = binaryOp(subtract)(stack);
break;
case "range":
stack = binaryMultioutOp(range)(stack);
break;
case "flip":
stack = binaryMultioutOp(flip)(stack);
break;
case "sum":
stack = greedyOp(sum)(stack);
break;
case "": // This may be entered by accident.
break;
default:
var parsed = parseFloat(token);
if (parsed === parsed) { // check for NaNs from a failed parse
stack.push(parsed);
} else {
errors.push("Token '" + token + "' (#" + (i + 1) + ")" + " invalid");
}
}
}
return {stack: stack, errors: errors};
}

View File

@ -0,0 +1,16 @@
---
title: RPNCalc v2
slug: rpncalc2
description: A Reverse Polish Notation (check wikipedia) calculator, version 2. Buggy and kind of unreliable. This updated version implements subtraction.
---
<link rel="stylesheet" href="calc.css">
<center><div id="output"></div></center>
<hr>
<input type="text" id="input" default="Input RPN expression" oninput="calculateFromInput()">
</div>
<script src="calc.js"></script>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,9 @@
---
title: RPNCalc v3
slug: rpncalc3
description: Reverse Polish Notation calculator, version 3 - with inbuilt docs, arbitrary-size rational numbers, utterly broken float/rational conversion and quite possibly Turing-completeness.
---
<link href="style.css" rel="stylesheet">
<div id="app"></div>
<script src="app.js"></script>

View File

@ -0,0 +1,98 @@
.rpncalc {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.stack {
margin-top: 5vh;
margin-bottom: 5vh;
}
.item {
min-width: 10em;
min-height: 10em;
border: 1px solid black;
margin-top: -1px;
display: flex;
justify-content: center;
align-items: center;
}
.float-slider {
border: 1px solid lightgray;
margin-left: 0.2em;
margin-right: 0.2em;
}
.float-slider-label {
display: flex;
align-items: center;
}
.partial {
text-align: center;
padding: 1em;
}
.horizontal-center {
display: flex;
justify-content: center;
}
.partial-stack {
font-size: 0.8em;
padding: 1em;
}
.formatted-rational {
width: 33%;
}
hr {
width: 100%;
}
.exprinput {
margin-top: 1vh;
width: 100%;
font-size: 1.2em;
}
.config-panel {
background: lightgray;
padding: 1em;
margin-top: 1em;
}
.docs {
text-align: left;
width: 100%;
display: flex;
justify-content: space-around;
margin-top: 3em;
flex-wrap: wrap;
}
.op-docs {
background: #8cb7c6;
color: black;
display: flex;
align-items: center;
margin: 1em;
max-width: 40vw;
}
.op-desc {
padding: 1em;
}
.op-name {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
padding-left: 1em;
padding-right: 1em;
}

View File

@ -0,0 +1,116 @@
---
title: Websocket Terminal
slug: wsterm
description: Type websocket URLs in the top bar and hit enter; type messages in the bottom bar, and also hit enter. Probably useful for some weirdly designed websocket services.
---
<div id="app"></div>
<style>
.messages li {
list-style-type: none;
}
.internal {
color: gray;
}
.user {
color: blue;
}
.user::before {
content: "> ";
}
.remote::before {
content: "< ";
}
#app input {
width: 100%;
}
</style>
<script src="/assets/js/hyperapp.min.js"></script>
<script src="/assets/js/hyperapp-html.min.js"></script>
<script>
const h = hyperappHtml;
const push = (xs, x) => xs.concat([x]);
const state = {
messages: [],
websocket: null
};
let windowVisible = true;
let notify = false;
window.onfocus = () => { windowVisible = true; notify = false; };
window.onblur = () => { windowVisible = false; };
const blinkTime = 1000;
// Blink title a bit by adding then removing ***.
setInterval(() => {
if (notify && !windowVisible) {
let title = document.title;
document.title = "*** " + title;
setTimeout(() => {
document.title = title;
}, blinkTime)
}
}, blinkTime * 2);
const actions = {
connect: value => (state, actions) => {
if (state.websocket != null && state.websocket.close) state.websocket.close();
let ws = new WebSocket(value);
ws.addEventListener("message", ev => {
actions.message([ev.data, "remote"]);
notify = true; // start notifications
});
ws.addEventListener("close", ev => actions.message(["Connection closed.", "internal"]));
ws.addEventListener("open", ev => actions.message(["Connected.", "internal"]));
return {websocket: ws}},
message: value => state => ({messages: push(state.messages, value)}),
send: value => state => {
if (state.websocket !== null && state.websocket.readyState === 1) {
state.websocket.send(value);
} else {
actions.message(["Not connected.", "internal"])
}
},
msgInput: event => (state, actions) => {
if (event.keyCode == 13) { // enter key
let val = event.target.value;
event.target.value = "";
actions.send(val);
actions.message([val, "user"]);
}
},
urlInput: event => (state, actions) => {
if (event.keyCode == 13) { // enter key
let val = event.target.value;
console.log(val);
actions.connect(val);
}
}
};
const cls = x => ({ class: x });
const scrollDown = () => {
let scrollEl = document.scrollingElement;
scrollEl.scrollTop = scrollEl.scrollHeight;
};
const view = (state, actions) => h.div([
h.div([
h.input({ onkeyup: actions.urlInput, placeholder: "URL" })
]),
h.ul({class: "messages", onupdate: (element, old) => scrollDown()}, state.messages.map(msg =>
h.li(cls(msg[1]), msg[0]))),
h.input({ onkeyup: actions.msgInput, placeholder: "Message" })
]);
const main = hyperapp.app(state, actions, view, document.getElementById("app"));
</script>

View File

@ -0,0 +1,8 @@
---
title: Whorl
description: Dice-rolling webapp.
slug: whorl
---
<link rel="stylesheet" href="src.6e636393.css">
<div id="app"></div>
<script src="src.3854b3a8.js"></script>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
#app{font-family:Fira Sans,sans-serif}.previous-rolls{border-collapse:collapse}.previous-rolls tr:first-child{background:#d3d3d3}.previous-rolls td,.previous-rolls th{padding:0 1em}.previous-rolls .raw-dice{font-weight:700;cursor:pointer}.controls{margin-bottom:1em}.controls button{width:10em;height:2em}.controls button,.controls input{border-radius:0;border:1px solid #000}.controls input{width:10em;height:2em;margin-right:1em}.error{color:red} main h1{margin-bottom:1em}

875
package-lock.json generated Normal file
View File

@ -0,0 +1,875 @@
{
"name": "website",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/babel-types": {
"version": "7.0.7",
"resolved": "https://registry.npmjs.org/@types/babel-types/-/babel-types-7.0.7.tgz",
"integrity": "sha512-dBtBbrc+qTHy1WdfHYjBwRln4+LWqASWakLHsWHR2NWHIFkv4W3O070IGoGLEBrJBvct3r0L1BUPuvURi7kYUQ=="
},
"@types/babylon": {
"version": "6.16.5",
"resolved": "https://registry.npmjs.org/@types/babylon/-/babylon-6.16.5.tgz",
"integrity": "sha512-xH2e58elpj1X4ynnKp9qSnWlsRTIs6n3tgLGNfwAGHwePw0mulHQllV34n0T25uYSu1k0hRKkWXF890B1yS47w==",
"requires": {
"@types/babel-types": "*"
}
},
"acorn": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz",
"integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo="
},
"acorn-globals": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-3.1.0.tgz",
"integrity": "sha1-/YJw9x+7SZawBPqIDuXUZXOnMb8=",
"requires": {
"acorn": "^4.0.4"
},
"dependencies": {
"acorn": {
"version": "4.0.13",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz",
"integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c="
}
}
},
"align-text": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz",
"integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=",
"requires": {
"kind-of": "^3.0.2",
"longest": "^1.0.1",
"repeat-string": "^1.5.2"
}
},
"argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"requires": {
"sprintf-js": "~1.0.2"
}
},
"asap": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
"integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY="
},
"atob": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz",
"integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg=="
},
"babel-runtime": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
"integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
"requires": {
"core-js": "^2.4.0",
"regenerator-runtime": "^0.11.0"
}
},
"babel-types": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz",
"integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=",
"requires": {
"babel-runtime": "^6.26.0",
"esutils": "^2.0.2",
"lodash": "^4.17.4",
"to-fast-properties": "^1.0.3"
}
},
"babylon": {
"version": "6.18.0",
"resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz",
"integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ=="
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"camelcase": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
"integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk="
},
"center-align": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz",
"integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=",
"requires": {
"align-text": "^0.1.3",
"lazy-cache": "^1.0.3"
}
},
"character-parser": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/character-parser/-/character-parser-2.2.0.tgz",
"integrity": "sha1-x84o821LzZdE5f/CxfzeHHMmH8A=",
"requires": {
"is-regex": "^1.0.3"
}
},
"clean-css": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.1.tgz",
"integrity": "sha512-4ZxI6dy4lrY6FHzfiy1aEOXgu4LIsW2MhwG0VBKdcoGoH/XLFgaHSdLTGr4O8Be6A8r3MOphEiI8Gc1n0ecf3g==",
"requires": {
"source-map": "~0.6.0"
}
},
"cliui": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz",
"integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=",
"requires": {
"center-align": "^0.1.1",
"right-align": "^0.1.1",
"wordwrap": "0.0.2"
}
},
"commander": {
"version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"optional": true
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
},
"constantinople": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/constantinople/-/constantinople-3.1.2.tgz",
"integrity": "sha512-yePcBqEFhLOqSBtwYOGGS1exHo/s1xjekXiinh4itpNQGCu4KA1euPh1fg07N2wMITZXQkBz75Ntdt1ctGZouw==",
"requires": {
"@types/babel-types": "^7.0.0",
"@types/babylon": "^6.16.2",
"babel-types": "^6.26.0",
"babylon": "^6.18.0"
}
},
"core-js": {
"version": "2.6.11",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz",
"integrity": "sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg=="
},
"css": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz",
"integrity": "sha512-oUnjmWpy0niI3x/mPL8dVEI1l7MnG3+HHyRPHf+YFSbK+svOhXpmSOcDURUh2aOCgl2grzrOPt1nHLuCVFULLw==",
"requires": {
"inherits": "^2.0.3",
"source-map": "^0.6.1",
"source-map-resolve": "^0.5.2",
"urix": "^0.1.0"
}
},
"css-parse": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/css-parse/-/css-parse-2.0.0.tgz",
"integrity": "sha1-pGjuZnwW2BzPBcWMONKpfHgNv9Q=",
"requires": {
"css": "^2.0.0"
}
},
"dayjs": {
"version": "1.8.19",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.19.tgz",
"integrity": "sha512-7kqOoj3oQSmqbvtvGFLU5iYqies+SqUiEGNT0UtUPPxcPYgY1BrkXR0Cq2R9HYSimBXN+xHkEN4Hi399W+Ovlg=="
},
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
},
"decamelize": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA="
},
"decode-uri-component": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
"integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU="
},
"doctypes": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/doctypes/-/doctypes-1.1.0.tgz",
"integrity": "sha1-6oCxBqh1OHdOijpKWv4pPeSJ4Kk="
},
"entities": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-2.0.0.tgz",
"integrity": "sha512-D9f7V0JSRwIxlRI2mjMqufDrRDnx8p+eEOz7aUM9SuvF8gsBzra0/6tbjl1m8eQHrZlYj6PxqE00hZ1SAIKPLw=="
},
"esprima": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
},
"esutils": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g=="
},
"extend-shallow": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
"requires": {
"is-extendable": "^0.1.0"
}
},
"fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
"integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
"requires": {
"graceful-fs": "^4.2.0",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
"glob": {
"version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"graceful-fs": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz",
"integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ=="
},
"gray-matter": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-4.0.2.tgz",
"integrity": "sha512-7hB/+LxrOjq/dd8APlK0r24uL/67w7SkYnfwhNFwg/VDIGWGmduTDYf3WNstLW2fbbmRwrDGCVSJ2isuf2+4Hw==",
"requires": {
"js-yaml": "^3.11.0",
"kind-of": "^6.0.2",
"section-matter": "^1.0.0",
"strip-bom-string": "^1.0.0"
},
"dependencies": {
"kind-of": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
"integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw=="
}
}
},
"handlebars": {
"version": "4.7.2",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.2.tgz",
"integrity": "sha512-4PwqDL2laXtTWZghzzCtunQUTLbo31pcCJrd/B/9JP8XbhVzpS5ZXuKqlOzsd1rtcaLo4KqAn8nl8mkknS4MHw==",
"requires": {
"neo-async": "^2.6.0",
"optimist": "^0.6.1",
"source-map": "^0.6.1",
"uglify-js": "^3.1.4"
},
"dependencies": {
"uglify-js": {
"version": "3.7.6",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.7.6.tgz",
"integrity": "sha512-yYqjArOYSxvqeeiYH2VGjZOqq6SVmhxzaPjJC1W2F9e+bqvFL9QXQ2osQuKUFjM2hGjKG2YclQnRKWQSt/nOTQ==",
"optional": true,
"requires": {
"commander": "~2.20.3",
"source-map": "~0.6.1"
}
}
}
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"requires": {
"function-bind": "^1.1.1"
}
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"requires": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"is-buffer": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
},
"is-expression": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-expression/-/is-expression-3.0.0.tgz",
"integrity": "sha1-Oayqa+f9HzRx3ELHQW5hwkMXrJ8=",
"requires": {
"acorn": "~4.0.2",
"object-assign": "^4.0.1"
},
"dependencies": {
"acorn": {
"version": "4.0.13",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz",
"integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c="
}
}
},
"is-extendable": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
"integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik="
},
"is-promise": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz",
"integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o="
},
"is-regex": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz",
"integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==",
"requires": {
"has": "^1.0.3"
}
},
"js-stringify": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/js-stringify/-/js-stringify-1.0.2.tgz",
"integrity": "sha1-Fzb939lyTyijaCrcYjCufk6Weds="
},
"js-yaml": {
"version": "3.13.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
}
},
"jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"requires": {
"graceful-fs": "^4.1.6"
}
},
"jstransformer": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/jstransformer/-/jstransformer-1.0.0.tgz",
"integrity": "sha1-7Yvwkh4vPx7U1cGkT2hwntJHIsM=",
"requires": {
"is-promise": "^2.0.0",
"promise": "^7.0.1"
}
},
"kind-of": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
"requires": {
"is-buffer": "^1.1.5"
}
},
"lazy-cache": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz",
"integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4="
},
"linkify-it": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz",
"integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==",
"requires": {
"uc.micro": "^1.0.1"
}
},
"lodash": {
"version": "4.17.15",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
},
"longest": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
"integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc="
},
"markdown-it": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-10.0.0.tgz",
"integrity": "sha512-YWOP1j7UbDNz+TumYP1kpwnP0aEa711cJjrAQrzd0UXlbJfc5aAq0F/PZHjiioqDC1NKgvIMX+o+9Bk7yuM2dg==",
"requires": {
"argparse": "^1.0.7",
"entities": "~2.0.0",
"linkify-it": "^2.0.0",
"mdurl": "^1.0.1",
"uc.micro": "^1.0.5"
}
},
"mdurl": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz",
"integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4="
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz",
"integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8="
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"requires": {
"minimist": "0.0.8"
},
"dependencies": {
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
}
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"mustache": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/mustache/-/mustache-4.0.0.tgz",
"integrity": "sha512-FJgjyX/IVkbXBXYUwH+OYwQKqWpFPLaLVESd70yHjSDunwzV2hZOoTBvPf4KLoxesUzzyfTH6F784Uqd7Wm5yA=="
},
"nanoid": {
"version": "2.1.10",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.10.tgz",
"integrity": "sha512-ZPUHBAwrQ+BSwVV2Xh6hBOEStTzAf8LgohOY0kk22lDiDdI32582KjVPYCqgqj7834hTunGzwZOB4me9T6ZcnA=="
},
"neo-async": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz",
"integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw=="
},
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"requires": {
"wrappy": "1"
}
},
"optimist": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz",
"integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=",
"requires": {
"minimist": "~0.0.1",
"wordwrap": "~0.0.2"
}
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
},
"path-parse": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw=="
},
"promise": {
"version": "7.3.1",
"resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz",
"integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==",
"requires": {
"asap": "~2.0.3"
}
},
"pug": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/pug/-/pug-2.0.4.tgz",
"integrity": "sha512-XhoaDlvi6NIzL49nu094R2NA6P37ijtgMDuWE+ofekDChvfKnzFal60bhSdiy8y2PBO6fmz3oMEIcfpBVRUdvw==",
"requires": {
"pug-code-gen": "^2.0.2",
"pug-filters": "^3.1.1",
"pug-lexer": "^4.1.0",
"pug-linker": "^3.0.6",
"pug-load": "^2.0.12",
"pug-parser": "^5.0.1",
"pug-runtime": "^2.0.5",
"pug-strip-comments": "^1.0.4"
}
},
"pug-attrs": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/pug-attrs/-/pug-attrs-2.0.4.tgz",
"integrity": "sha512-TaZ4Z2TWUPDJcV3wjU3RtUXMrd3kM4Wzjbe3EWnSsZPsJ3LDI0F3yCnf2/W7PPFF+edUFQ0HgDL1IoxSz5K8EQ==",
"requires": {
"constantinople": "^3.0.1",
"js-stringify": "^1.0.1",
"pug-runtime": "^2.0.5"
}
},
"pug-code-gen": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/pug-code-gen/-/pug-code-gen-2.0.2.tgz",
"integrity": "sha512-kROFWv/AHx/9CRgoGJeRSm+4mLWchbgpRzTEn8XCiwwOy6Vh0gAClS8Vh5TEJ9DBjaP8wCjS3J6HKsEsYdvaCw==",
"requires": {
"constantinople": "^3.1.2",
"doctypes": "^1.1.0",
"js-stringify": "^1.0.1",
"pug-attrs": "^2.0.4",
"pug-error": "^1.3.3",
"pug-runtime": "^2.0.5",
"void-elements": "^2.0.1",
"with": "^5.0.0"
}
},
"pug-error": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/pug-error/-/pug-error-1.3.3.tgz",
"integrity": "sha512-qE3YhESP2mRAWMFJgKdtT5D7ckThRScXRwkfo+Erqga7dyJdY3ZquspprMCj/9sJ2ijm5hXFWQE/A3l4poMWiQ=="
},
"pug-filters": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/pug-filters/-/pug-filters-3.1.1.tgz",
"integrity": "sha512-lFfjNyGEyVWC4BwX0WyvkoWLapI5xHSM3xZJFUhx4JM4XyyRdO8Aucc6pCygnqV2uSgJFaJWW3Ft1wCWSoQkQg==",
"requires": {
"clean-css": "^4.1.11",
"constantinople": "^3.0.1",
"jstransformer": "1.0.0",
"pug-error": "^1.3.3",
"pug-walk": "^1.1.8",
"resolve": "^1.1.6",
"uglify-js": "^2.6.1"
}
},
"pug-lexer": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/pug-lexer/-/pug-lexer-4.1.0.tgz",
"integrity": "sha512-i55yzEBtjm0mlplW4LoANq7k3S8gDdfC6+LThGEvsK4FuobcKfDAwt6V4jKPH9RtiE3a2Akfg5UpafZ1OksaPA==",
"requires": {
"character-parser": "^2.1.1",
"is-expression": "^3.0.0",
"pug-error": "^1.3.3"
}
},
"pug-linker": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/pug-linker/-/pug-linker-3.0.6.tgz",
"integrity": "sha512-bagfuHttfQOpANGy1Y6NJ+0mNb7dD2MswFG2ZKj22s8g0wVsojpRlqveEQHmgXXcfROB2RT6oqbPYr9EN2ZWzg==",
"requires": {
"pug-error": "^1.3.3",
"pug-walk": "^1.1.8"
}
},
"pug-load": {
"version": "2.0.12",
"resolved": "https://registry.npmjs.org/pug-load/-/pug-load-2.0.12.tgz",
"integrity": "sha512-UqpgGpyyXRYgJs/X60sE6SIf8UBsmcHYKNaOccyVLEuT6OPBIMo6xMPhoJnqtB3Q3BbO4Z3Bjz5qDsUWh4rXsg==",
"requires": {
"object-assign": "^4.1.0",
"pug-walk": "^1.1.8"
}
},
"pug-parser": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/pug-parser/-/pug-parser-5.0.1.tgz",
"integrity": "sha512-nGHqK+w07p5/PsPIyzkTQfzlYfuqoiGjaoqHv1LjOv2ZLXmGX1O+4Vcvps+P4LhxZ3drYSljjq4b+Naid126wA==",
"requires": {
"pug-error": "^1.3.3",
"token-stream": "0.0.1"
}
},
"pug-runtime": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/pug-runtime/-/pug-runtime-2.0.5.tgz",
"integrity": "sha512-P+rXKn9un4fQY77wtpcuFyvFaBww7/91f3jHa154qU26qFAnOe6SW1CbIDcxiG5lLK9HazYrMCCuDvNgDQNptw=="
},
"pug-strip-comments": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/pug-strip-comments/-/pug-strip-comments-1.0.4.tgz",
"integrity": "sha512-i5j/9CS4yFhSxHp5iKPHwigaig/VV9g+FgReLJWWHEHbvKsbqL0oP/K5ubuLco6Wu3Kan5p7u7qk8A4oLLh6vw==",
"requires": {
"pug-error": "^1.3.3"
}
},
"pug-walk": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/pug-walk/-/pug-walk-1.1.8.tgz",
"integrity": "sha512-GMu3M5nUL3fju4/egXwZO0XLi6fW/K3T3VTgFQ14GxNi8btlxgT5qZL//JwZFm/2Fa64J/PNS8AZeys3wiMkVA=="
},
"ramda": {
"version": "0.26.1",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.26.1.tgz",
"integrity": "sha512-hLWjpy7EnsDBb0p+Z3B7rPi3GDeRG5ZtiI33kJhTt+ORCd38AbAIjB/9zRIUoeTbE/AVX5ZkU7m6bznsvrf8eQ=="
},
"regenerator-runtime": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
"integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg=="
},
"repeat-string": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
"integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc="
},
"resolve": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.0.tgz",
"integrity": "sha512-+hTmAldEGE80U2wJJDC1lebb5jWqvTYAfm3YZ1ckk1gBr0MnCqUKlwK1e+anaFljIl+F5tR5IoZcm4ZDA1zMQw==",
"requires": {
"path-parse": "^1.0.6"
}
},
"resolve-url": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz",
"integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo="
},
"right-align": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz",
"integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=",
"requires": {
"align-text": "^0.1.1"
}
},
"safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
},
"section-matter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/section-matter/-/section-matter-1.0.0.tgz",
"integrity": "sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA==",
"requires": {
"extend-shallow": "^2.0.1",
"kind-of": "^6.0.0"
},
"dependencies": {
"kind-of": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
"integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw=="
}
}
},
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
},
"source-map-resolve": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz",
"integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==",
"requires": {
"atob": "^2.1.2",
"decode-uri-component": "^0.2.0",
"resolve-url": "^0.2.1",
"source-map-url": "^0.4.0",
"urix": "^0.1.0"
}
},
"source-map-url": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz",
"integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM="
},
"sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
},
"strip-bom-string": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz",
"integrity": "sha1-5SEekiQ2n7uB1jOi8ABE3IztrZI="
},
"stylus": {
"version": "0.54.7",
"resolved": "https://registry.npmjs.org/stylus/-/stylus-0.54.7.tgz",
"integrity": "sha512-Yw3WMTzVwevT6ZTrLCYNHAFmanMxdylelL3hkWNgPMeTCpMwpV3nXjpOHuBXtFv7aiO2xRuQS6OoAdgkNcSNug==",
"requires": {
"css-parse": "~2.0.0",
"debug": "~3.1.0",
"glob": "^7.1.3",
"mkdirp": "~0.5.x",
"safer-buffer": "^2.1.2",
"sax": "~1.2.4",
"semver": "^6.0.0",
"source-map": "^0.7.3"
},
"dependencies": {
"source-map": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz",
"integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ=="
}
}
},
"to-fast-properties": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz",
"integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc="
},
"token-stream": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/token-stream/-/token-stream-0.0.1.tgz",
"integrity": "sha1-zu78cXp2xDFvEm0LnbqlXX598Bo="
},
"uc.micro": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz",
"integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA=="
},
"uglify-js": {
"version": "2.8.29",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz",
"integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=",
"requires": {
"source-map": "~0.5.1",
"uglify-to-browserify": "~1.0.0",
"yargs": "~3.10.0"
},
"dependencies": {
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
}
}
},
"uglify-to-browserify": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz",
"integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=",
"optional": true
},
"universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
},
"urix": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz",
"integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI="
},
"void-elements": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz",
"integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w="
},
"window-size": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz",
"integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0="
},
"with": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/with/-/with-5.1.1.tgz",
"integrity": "sha1-+k2qktrzLE6pTtRTyB8EaGtXXf4=",
"requires": {
"acorn": "^3.1.0",
"acorn-globals": "^3.0.0"
}
},
"wordwrap": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz",
"integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8="
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
},
"yargs": {
"version": "3.10.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz",
"integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=",
"requires": {
"camelcase": "^1.0.2",
"cliui": "^2.1.0",
"decamelize": "^1.0.0",
"window-size": "0.1.0"
}
}
}
}

19
package.json Normal file
View File

@ -0,0 +1,19 @@
{
"name": "website",
"version": "1.0.0",
"description": "Static site generation code for my website.",
"main": "index.js",
"dependencies": {
"dayjs": "^1.8.19",
"fs-extra": "^8.1.0",
"gray-matter": "^4.0.2",
"handlebars": "^4.7.2",
"markdown-it": "^10.0.0",
"mustache": "^4.0.0",
"nanoid": "^2.1.10",
"pug": "^2.0.4",
"ramda": "^0.26.1",
"stylus": "^0.54.7"
},
"license": "MIT"
}

5
src/global.json Normal file
View File

@ -0,0 +1,5 @@
{
"name": "Oliver's Website",
"domain": "osmarks.tk",
"siteDescription": "Whimsical uselessness available conveniently online."
}

136
src/index.js Normal file
View File

@ -0,0 +1,136 @@
const fs = require("fs")
const fsp = require("fs").promises
const fse = require("fs-extra")
const MarkdownIt = require("markdown-it")
const pug = require("pug")
const path = require("path")
const matter = require('gray-matter')
const mustache = require("mustache")
const globalData = require("./global.json")
const stylus = require("stylus")
const util = require("util")
const R = require("ramda")
const dayjs = require("dayjs")
const customParseFormat = require("dayjs/plugin/customParseFormat")
const nanoid = require("nanoid")
dayjs.extend(customParseFormat)
const stylusRender = util.promisify(stylus.render)
const root = path.join(__dirname, "..")
const templateDir = path.join(root, "templates")
const experimentDir = path.join(root, "experiments")
const blogDir = path.join(root, "blog")
const assetsDir = path.join(root, "assets")
const outDir = path.join(root, "out")
const buildID = nanoid()
globalData.buildID = buildID
const removeExtension = x => x.replace(/\.[^/.]+$/, "")
const readFile = path => fsp.readFile(path, { encoding: "utf8" })
const md = new MarkdownIt()
const renderMarkdown = x => md.render(x)
const parseFrontMatter = content => {
const raw = matter(content)
if (raw.data.updated) {
raw.data.updated = dayjs(raw.data.updated, "DD/MM/YYYY")
}
if (raw.data.created) {
raw.data.created = dayjs(raw.data.created, "DD/MM/YYYY")
}
if (raw.data.created && !raw.data.updated) { raw.data.updated = raw.data.created }
return raw
}
const loadDir = async (dir, func) => {
const files = await fsp.readdir(dir)
const out = {}
await Promise.all(files.map(async file => {
out[removeExtension(file)] = await func(path.join(dir, file), file)
}))
return out
}
const applyTemplate = async (template, input, getOutput, options) => {
const page = parseFrontMatter(await readFile(input))
if (options.processMeta) { options.processMeta(page.data) }
if (options.processContent) { page.content = options.processContent(page.content) }
const rendered = template({ ...globalData, ...page.data, content: page.content })
await fsp.writeFile(await getOutput(page), rendered)
return page.data
}
const processExperiments = templates => {
return loadDir(experimentDir, (subdirectory, basename) => {
return applyTemplate(
templates.experiment,
path.join(subdirectory, "index.html"),
async page => {
const out = path.join(outDir, page.data.slug)
await fse.ensureDir(out)
const allFiles = await fsp.readdir(subdirectory)
await Promise.all(allFiles.map(file => {
if (file !== "index.html") {
return fse.copy(path.join(subdirectory, file), path.join(out, file))
}
}))
return path.join(out, "index.html")
},
{ processMeta: meta => { meta.slug = meta.slug || basename }})
})
}
const processBlog = templates => {
return loadDir(blogDir, async (file, basename) => {
return applyTemplate(templates.blogPost, file, async page => {
const out = path.join(outDir, page.data.slug)
await fse.ensureDir(out)
return path.join(out, "index.html")
}, { processMeta: meta => { meta.slug = meta.slug || removeExtension(basename) }, processContent: renderMarkdown })
})
}
const processAssets = async templates => {
const outAssets = path.join(outDir, "assets")
await fse.ensureDir(outAssets)
applyTemplate(templates.experiment, path.join(assetsDir, "offline.html"), () => path.join(outAssets, "offline.html"), {})
// Write out the web manifest after templating it using somewhat misapplied frontend templating stuff
const manifest = mustache.render(await readFile(path.join(assetsDir, "manifest.webmanifest")), globalData)
await fsp.writeFile(path.join(outAssets, "manifest.webmanifest"), manifest)
const copyAsset = subpath => fse.copy(path.join(assetsDir, subpath), path.join(outAssets, subpath))
// Directly copy images, JS, CSS
await copyAsset("images")
await copyAsset("js")
await copyAsset("css")
const serviceWorker = mustache.render(await readFile(path.join(assetsDir, "sw.js")), globalData)
await fsp.writeFile(path.join(outDir, "sw.js"), serviceWorker)
}
globalData.renderDate = date => date.format("DD/MM/YYYY")
const run = async () => {
const css = await stylusRender(await readFile(path.join(root, "style.styl")), { compress: true })
globalData.css = css
const templates = await loadDir(templateDir, async fullPath => pug.compile(await readFile(fullPath), { filename: fullPath }))
const experimentsList = R.sortBy(x => x.title, R.values(await processExperiments(templates)))
const blogList = R.sortBy(x => x.updated ? -x.updated.valueOf() : 0, R.values(await processBlog(templates)))
await processAssets(templates)
const index = templates.index({ ...globalData, title: "Index", experiments: experimentsList, posts: blogList })
await fsp.writeFile(path.join(outDir, "index.html"), index)
const rssFeed = templates.rss({ ...globalData, items: blogList, lastUpdate: new Date() })
await fsp.writeFile(path.join(outDir, "rss.xml"), rssFeed)
await fsp.writeFile(path.join(outDir, "buildID.txt"), buildID)
}
run()

70
style.styl Normal file
View File

@ -0,0 +1,70 @@
body
margin 0
font-family 'Fira Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif
a
text-decoration none
nav
display flex
align-items center
padding 1em
margin-bottom 0.5em
background black
.logo
width 1.5em
height 1.5em
a, img
margin-right 0.5em
for num in (1..6)
a:nth-child({num})
color hsl(90 + (num * 30), 100%, 80%)
h1, h2, h3, h4, h5, h6
margin 0
font-weight 400
main, .header
margin-left 1em
margin-right 1em
// for easier viewing on big screen devices, narrow the width of text
main.blog-post
max-width 40em
main
margin-top 1em
ul
list-style-type square
padding-left 1em
.isso
padding 1em
.achievements
position fixed
bottom 0
left 0
.achievement
cursor pointer
.achievement
border 1px solid black
margin 0.5em
padding 0.5em
max-width 40em
.title
font-weight 500
.conditions
font-style italic
.smallinfo
font-size 0.8em
margin-top 0.5em
margin-bottom 0.5em

4
templates/blogPost.pug Normal file
View File

@ -0,0 +1,4 @@
extends layout.pug
block content
main.blog-post!= content

4
templates/experiment.pug Normal file
View File

@ -0,0 +1,4 @@
extends layout.pug
block content
main!= content

25
templates/index.pug Normal file
View File

@ -0,0 +1,25 @@
extends layout.pug
block content
main
h2 Blog
p.
Stuff I say, conveniently accessible on the internet.
ul.blog
each post in posts
li
a.title(href=`/${post.slug}/`)= post.title
span= ` `
span.description!= post.description
h2 Experiments
p.
Various random somewhat useless web projects I have put together over many years. Made with at least four different JS frameworks.
ul.experiments
each experiment in experiments
li
a.title(href=`/${experiment.slug}/`)= experiment.title
span= ` `
span.description!= experiment.description
p Get updates to the blog (not experiments) in your favourite RSS reader using the <a href="/rss.xml">RSS feed</a>.

38
templates/layout.pug Normal file
View File

@ -0,0 +1,38 @@
mixin nav-item(url, name)
a(href=url)= name
doctype html
html(lang="en")
head
title= `${title} @ ${name}`
script(src="/assets/js/page.js", defer=true)
meta(charset="UTF-8")
meta(name="viewport", content="width=device-width, initial-scale=1.0")
if description
meta(name="description", content=description)
link(rel="manifest", href="/assets/manifest.webmanifest")
link(rel="shortcut icon", href="/assets/images/icon.png", type="image/png")
style= css
if comments !== "off"
script(src=`https://${domain}/isso/js/embed.min.js`,async=true,data-isso=`https://${domain}/isso/`)
body
nav
a(href="/")
img.logo(src="/assets/images/logo.svg")
+nav-item("/", "Index")
+nav-item(`https://status.${domain}/`, "Status")
+nav-item(`https://i.${domain}/`, "Images")
block nav-items
.header
h1.page-title= title
if updated
h3= `Updated ${renderDate(updated)}`
if created
h3= `Created ${renderDate(created)}`
if description
em.description!= description
block content
if comments !== "off"
.isso
section(id="isso-thread")

16
templates/rss.pug Normal file
View File

@ -0,0 +1,16 @@
doctype xml
rss(version='2.0')
channel
title= name
description= siteDescription
link= `https://${domain}/`
lastBuildDate= new Date().toUTCString()
pubDate= lastUpdate.toUTCString()
each item in items
item
title= item.title
description= item.description
link= `https://${domain}/${item.slug}`
if item.updated
pubDate= item.updated.toDate().toUTCString()