purge xm track player page, it was never good
This commit is contained in:
parent
1098e6551d
commit
67ce1832a4
@ -24,5 +24,3 @@ for d in ./articles/*/; do
|
||||
done
|
||||
|
||||
./tools/feed_generator.py ./articles/ https://mjestecko.neocities.org/ > ./html/feed.xml
|
||||
|
||||
./tools/track_listing_generator.py html/tracks > html/tracks.html
|
||||
|
@ -7,7 +7,6 @@ HEAD_EMBED = """
|
||||
<ul>
|
||||
<li><a href="/"><strong>mjestečko</strong></a></li>
|
||||
<li><a href="https://git.poto.cafe/veclavtalica/mjestecko">source</a></li>
|
||||
<li><a href="/tracks.html">tracks</a></li>
|
||||
<li><a href="/feed.xml">rss</a></li>
|
||||
<li><a href="/articles/mjestečko.html">about</a></li>
|
||||
</ul>
|
||||
|
@ -1,92 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
from sys import argv, exit
|
||||
from os import walk, path
|
||||
|
||||
from page_shares import HEAD_EMBED, TAIL_EMBED
|
||||
|
||||
if len(argv) <= 1:
|
||||
print("No directory was supplied")
|
||||
exit(-1)
|
||||
|
||||
page = """<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Tracks</title>
|
||||
<link type="text/css" rel="stylesheet" href="/style.css"/>
|
||||
<script type="text/javascript" src="/xm.js"></script>
|
||||
<script type="text/javascript">
|
||||
(function (window, document) {
|
||||
if (!window.XMPlayer)
|
||||
window.XMPlayer = {};
|
||||
|
||||
var XMPlayer = window.XMPlayer;
|
||||
var was_init = false
|
||||
|
||||
// https://stackoverflow.com/questions/16245767/creating-a-blob-from-a-base64-string-in-javascript
|
||||
function b64toBlob(base64) {
|
||||
const decoded = atob(base64);
|
||||
const uInt8Array = new Uint8Array(decoded.length);
|
||||
for (let i = 0; i < decoded.length; ++i)
|
||||
uInt8Array[i] = decoded.charCodeAt(i);
|
||||
return new Blob([uInt8Array]);
|
||||
}
|
||||
|
||||
async function decompressGzippedBase64(str) {
|
||||
const ds = new DecompressionStream(`gzip`);
|
||||
const decompressedStream = b64toBlob(str).stream().pipeThrough(ds);
|
||||
return new Response(decompressedStream).blob();
|
||||
}
|
||||
|
||||
window.loadAndPlayTrack = function(url) {
|
||||
if (!was_init) {
|
||||
XMPlayer.init();
|
||||
was_init = true;
|
||||
}
|
||||
var request = new XMLHttpRequest();
|
||||
request.responseType = `text`;
|
||||
request.open('GET', url);
|
||||
request.send();
|
||||
request.onload = async(_) => {
|
||||
if (request.readyState === 4 && request.status === 200) {
|
||||
XMPlayer.stop();
|
||||
XMPlayer.load(await (await decompressGzippedBase64(request.response)).arrayBuffer());
|
||||
XMPlayer.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
})(window, document)
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
"""
|
||||
page += HEAD_EMBED
|
||||
|
||||
page += """
|
||||
<h3 id="articles">Tracks</h3>
|
||||
<p>.xm module tracks of my own. Btw, they're playable in browser :3</p>
|
||||
<p>Note that some files are rendered incorrectly.</p>
|
||||
<hr/>
|
||||
"""
|
||||
|
||||
for _, _, files in walk(argv[1]):
|
||||
files.sort()
|
||||
for f in files:
|
||||
# note: Base64 gzip encoded data is expected.
|
||||
if not f.endswith('.xm.txt'):
|
||||
continue
|
||||
page += (
|
||||
f""" <div><p style="display: inline;">{f[:-4]}</p><button style="float: right;" onclick="window.loadAndPlayTrack('/tracks/{f}')">play</button></div>\n"""
|
||||
" <hr/>\n"
|
||||
)
|
||||
break
|
||||
|
||||
page += TAIL_EMBED
|
||||
|
||||
page += """</div>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
print(page)
|
Loading…
Reference in New Issue
Block a user