Compare commits

..

3 Commits

Author SHA1 Message Date
veclav talica
f0fafb33bd track listing generator and its integration 2023-05-23 22:26:23 +05:00
veclav talica
9086b7e38c jsxm package 2023-05-23 19:33:29 +05:00
veclav talica
94af318b89 note that time is UTC 2023-05-23 00:03:16 +05:00
6 changed files with 1437 additions and 3 deletions

View File

@ -13,3 +13,5 @@ for d in ./articles/*; do
done done
./tools/feed_generator.py ./articles/ https://mjestecko.neocities.org/ > ./html/feed.xml ./tools/feed_generator.py ./articles/ https://mjestecko.neocities.org/ > ./html/feed.xml
./tools/track_listing_generator.py html/tracks > html/tracks.html

1351
html/xm.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -27,13 +27,13 @@ if not brief is None:
date = metadata.get("Date") date = metadata.get("Date")
if not date is None: if not date is None:
article_head += f"-- Created: *{MONTHS[date.tm_mon]} {date.tm_mday}, {date.tm_year}*\n\n" article_head += f"-- Created: *{MONTHS[date.tm_mon]} {date.tm_mday}, {date.tm_year} UTC*\n\n"
last_edit = metadata.get("Last Edit") last_edit = metadata.get("Last Edit")
if not last_edit is None: if not last_edit is None:
if date is None or last_edit.tm_mon != date.tm_mon or \ if date is None or last_edit.tm_mon != date.tm_mon or \
last_edit.tm_mday != date.tm_mday or last_edit.tm_year != date.tm_year: last_edit.tm_mday != date.tm_mday or last_edit.tm_year != date.tm_year:
article_head += f"-- Edited: *{MONTHS[last_edit.tm_mon]} {last_edit.tm_mday}, {last_edit.tm_year}*\n\n" article_head += f"-- Edited: *{MONTHS[last_edit.tm_mon]} {last_edit.tm_mday}, {last_edit.tm_year} UTC*\n\n"
# todo: Hyperlinks to appropriate tag pages. # todo: Hyperlinks to appropriate tag pages.
tags = metadata.get("Tags") tags = metadata.get("Tags")

View File

@ -40,6 +40,6 @@ for root, dirs, _ in walk(argv[1]):
page += f""">*{','.join(metadata["Tags"])}*\n---\n""" page += f""">*{','.join(metadata["Tags"])}*\n---\n"""
curtime = time.gmtime(int(time.time())) curtime = time.gmtime(int(time.time()))
page += f"Last compiled: *{MONTHS[curtime.tm_mon]} {curtime.tm_mday}, {curtime.tm_year} {curtime.tm_hour}:{curtime.tm_min:02d}*\n\n" page += f"Last compiled: *{MONTHS[curtime.tm_mon]} {curtime.tm_mday}, {curtime.tm_year} {curtime.tm_hour}:{curtime.tm_min:02d} UTC*\n\n"
print(page_metadata + wrap_page(page)) print(page_metadata + wrap_page(page))

View File

@ -9,6 +9,7 @@ HEAD_EMBED = """
<ul class="nav"> <ul class="nav">
<li><a href="/">main page</a></li> <li><a href="/">main page</a></li>
<li><a href="https://git.poto.cafe/veclavtalica/mjestecko">source</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="/feed.xml">rss</a></li>
<li><a href="/articles/mjestečko.html">about</a></li> <li><a href="/articles/mjestečko.html">about</a></li>
</ul> </ul>

View File

@ -0,0 +1,80 @@
#!/usr/bin/python3
from sys import argv, exit
from os import walk, path
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;
window.loadAndPlayTrack = function(url) {
var request = new XMLHttpRequest();
request.responseType = "arraybuffer";
request.open('GET', url);
request.send();
request.onload = (_) => {
if (request.readyState === 4 && request.status === 200) {
XMPlayer.stop();
XMPlayer.load(request.response);
XMPlayer.play();
}
}
}
window.onload = function() {
XMPlayer.init();
}
})(window, document)
</script>
</head>
<body>
<div style="display: flex;">
<div>
<h2 id="mjestečko">mjestečko</h2>
<ul class="nav">
<li><a href="/">main page</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>
</div>
<div class="container">
<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:
if not f.endswith('.xm'):
continue
page += (
f""" <div><p style="display: inline;">{f}</p><button style="float: right;" onclick="window.loadAndPlayTrack('/tracks/{f}')">play</button></div>\n"""
" <hr/>\n"
)
page += """ </div>
</div>
</body>
</html>
"""
print(page)