- Restored broken download tooltips that showed raw template placeholders instead of rendered values - Simplified `autobuild.py` by removing unnecessary fallback/parsing complexity and reducing helper overhead - Audited non-ASCII characters and get rid of Unicode “gremlins” that are not supported by WebView - Converted hardcoded external template links to protocol-relative `//...` URLs so they follow the current site scheme Reviewed-on: #14 Reviewed-by: Gleb Zaharov <risdeveau@lair.moe> Co-authored-by: Burer <burer@kolibrios.org> Co-committed-by: Burer <burer@kolibrios.org>
This commit was merged in pull request #14.
This commit is contained in:
@@ -45,15 +45,22 @@ def before_request():
|
||||
|
||||
@app.context_processor
|
||||
def _inject_autobuild_vers():
|
||||
return {"autobuild_vers": autobuild.autobuild_vers}
|
||||
return {
|
||||
"autobuild_vers": autobuild.autobuild_vers,
|
||||
"autobuild_sizes": autobuild.autobuild_sizes,
|
||||
}
|
||||
|
||||
|
||||
@app.context_processor
|
||||
def _inject_autobuild_date():
|
||||
return {
|
||||
"autobuild_date": g.translations.get("downloads", {})
|
||||
.get("date-format", "{DD}.{MM}.{YYYY}")
|
||||
.format(**autobuild.autobuild_date)
|
||||
"autobuild_date": autobuild.autobuild_date.strftime(
|
||||
g.translations.get("downloads", {})
|
||||
.get("date-format", "{DD}.{MM}.{YYYY}")
|
||||
.replace("{YYYY}", "%Y")
|
||||
.replace("{MM}", "%m")
|
||||
.replace("{DD}", "%d")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
+38
-43
@@ -1,22 +1,50 @@
|
||||
from datetime import date
|
||||
import re
|
||||
import threading
|
||||
import time
|
||||
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
|
||||
STATUS_URL = "http://builds.kolibrios.org/status.html"
|
||||
STATUS_SEC = 300 # refetch each 5 minutes
|
||||
DOWNLOAD_LANGS = ("en_US", "ru_RU", "es_ES")
|
||||
DOWNLOAD_EXTS = ("img", "iso", "distr", "raw")
|
||||
|
||||
autobuild_date = {"YYYY": "YYYY", "MM": "MM", "DD": "DD"}
|
||||
VER_RE = re.compile(r"\b(\d+\.\d+\.\d+\.\d+\+\d{3,8}-[0-9a-fA-F]{7,40})\b")
|
||||
DATE_RE = re.compile(r"\b(\d{4})\.(\d{2})\.(\d{2})\s+\d{2}:\d{2}:\d{2}\b")
|
||||
ROW_RE = re.compile(r"(<tr\b[^>]*>.*?</tr>)", flags=re.I | re.S)
|
||||
|
||||
autobuild_date = date.today()
|
||||
autobuild_vers = "0.0.0.0+0000-0000000"
|
||||
autobuild_sizes = {
|
||||
lang: {ext: "?" for ext in DOWNLOAD_EXTS}
|
||||
for lang in DOWNLOAD_LANGS
|
||||
}
|
||||
|
||||
_started = False
|
||||
_updater_lock = threading.Lock()
|
||||
|
||||
|
||||
def _refresh_build_date_once():
|
||||
def _refresh_build_sizes():
|
||||
for lang in DOWNLOAD_LANGS:
|
||||
for ext in DOWNLOAD_EXTS:
|
||||
url = f"http://builds.kolibrios.org/{lang}/latest-{ext}.7z"
|
||||
req = Request(
|
||||
url,
|
||||
method="HEAD",
|
||||
headers={"User-Agent": "Mozilla/5.0"},
|
||||
)
|
||||
with urlopen(req, timeout=10) as r:
|
||||
content_length = r.headers.get("Content-Length")
|
||||
if not content_length:
|
||||
continue
|
||||
autobuild_sizes[lang][ext] = f"{int(content_length) / 1048576:.1f} MB"
|
||||
|
||||
|
||||
def _refresh_autobuild_once():
|
||||
global autobuild_date, autobuild_vers
|
||||
try:
|
||||
from urllib.request import Request, urlopen
|
||||
req = Request(
|
||||
STATUS_URL,
|
||||
headers={
|
||||
@@ -29,67 +57,34 @@ def _refresh_build_date_once():
|
||||
r.headers.get_content_charset() or "utf-8", "replace"
|
||||
)
|
||||
|
||||
ver_re = re.compile(
|
||||
r"\b(\d+\.\d+\.\d+\.\d+\+\d{3,8}-[0-9a-fA-F]{7,40})\b"
|
||||
)
|
||||
last_ver = None
|
||||
|
||||
rows = re.findall(r"(<tr\b[^>]*>.*?</tr>)", html, flags=re.I | re.S)
|
||||
for row in rows:
|
||||
for row in ROW_RE.findall(html):
|
||||
cls = re.search(r'class\s*=\s*"([^"]*)"', row, flags=re.I)
|
||||
classes = cls.group(1).lower() if cls else ""
|
||||
if "commit" in classes:
|
||||
mver = ver_re.search(row)
|
||||
mver = VER_RE.search(row)
|
||||
if mver:
|
||||
last_ver = mver.group(1)
|
||||
continue
|
||||
if "success" not in classes:
|
||||
continue
|
||||
text = re.sub(r"<[^>]+>", " ", row)
|
||||
mts = re.search(
|
||||
r"\b(\d{4})\.(\d{2})\.(\d{2})\s+\d{2}:\d{2}:\d{2}\b", text
|
||||
)
|
||||
mts = DATE_RE.search(text)
|
||||
if mts:
|
||||
autobuild_date["YYYY"], autobuild_date["MM"], autobuild_date["DD"] = mts.groups()
|
||||
else:
|
||||
mds = re.search(r"\b(\d{2})\.(\d{2})\.(\d{4})\b", text)
|
||||
if not mds:
|
||||
return
|
||||
autobuild_date["YYYY"], autobuild_date["MM"], autobuild_date["DD"] = (
|
||||
mds.group(3),
|
||||
mds.group(2),
|
||||
mds.group(1),
|
||||
)
|
||||
autobuild_date = date(*map(int, mts.groups()))
|
||||
if last_ver:
|
||||
autobuild_vers = last_ver
|
||||
_refresh_build_sizes()
|
||||
return
|
||||
|
||||
# Fallback for plain-text log format (no HTML table)
|
||||
# Example: 2025.09.20 20:45:10 user 💚 Build processing completed successfully. Thank you.
|
||||
log_line_re = re.compile(
|
||||
r"^(\d{4})\.(\d{2})\.(\d{2})\s+\d{2}:\d{2}:\d{2}\s+(.*)$"
|
||||
)
|
||||
for raw in html.splitlines():
|
||||
mline = log_line_re.match(raw.strip())
|
||||
if not mline:
|
||||
continue
|
||||
yyyy, mm, dd, rest = mline.groups()
|
||||
mver = ver_re.search(rest)
|
||||
if mver:
|
||||
last_ver = mver.group(1)
|
||||
if "Build processing completed successfully" in rest:
|
||||
autobuild_date["YYYY"], autobuild_date["MM"], autobuild_date["DD"] = yyyy, mm, dd
|
||||
if last_ver:
|
||||
autobuild_vers = last_ver
|
||||
return
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def _updater_loop():
|
||||
while True:
|
||||
_refresh_build_date_once()
|
||||
_refresh_autobuild_once()
|
||||
time.sleep(STATUS_SEC)
|
||||
|
||||
|
||||
@@ -102,4 +97,4 @@ def ensure_started():
|
||||
_started = True
|
||||
|
||||
|
||||
_refresh_build_date_once()
|
||||
_refresh_autobuild_once()
|
||||
|
||||
+1
-1
@@ -19,5 +19,5 @@ def render_localized_template(lang, template_name):
|
||||
template_name,
|
||||
year=date.today().year,
|
||||
),
|
||||
remove_empty_space=True,
|
||||
remove_empty_space=False,
|
||||
)
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
('es_ES', 'Español')
|
||||
) %}
|
||||
<a href="//builds.kolibrios.org/{{ l }}/latest-{{ ext }}.7z"
|
||||
title="ver. $autobuild_cmtid_{{ l }}, $autobuild_size_{{ l }}_{{ ext }}"
|
||||
title="{{ autobuild_vers }}, {{ autobuild_sizes[l][ext] }}"
|
||||
class="button">
|
||||
{{ lang }}
|
||||
{% if l == 'en_US' %}
|
||||
@@ -100,9 +100,9 @@
|
||||
{{ _(
|
||||
'downloads:download_description',
|
||||
kolibrios="<b>{0}</b>".format(_('title:index')),
|
||||
zip="<a href='http://www.7-zip.org' target='_blank'>7zip</a>",
|
||||
gpl="<a href='http://www.gnu.org/licenses/gpl-2.0.html' target='_blank'>GPLv2</a>",
|
||||
git="<a href='https://git.kolibrios.org'>{0}</a>".format(_('downloads:git-server'))
|
||||
zip="<a href='https://7-zip.org' target='_blank'>7zip</a>",
|
||||
gpl="<a href='//www.gnu.org/licenses/gpl-2.0.html' target='_blank'>GPLv2</a>",
|
||||
git="<a href='//git.kolibrios.org'>{0}</a>".format(_('downloads:git-server'))
|
||||
) | safe }}
|
||||
</p>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
'article:p1',
|
||||
kolibrios="<b>{0}</b>"
|
||||
.format(_('menu:kolibrios')),
|
||||
drivers="<a href='http://wiki.kolibrios.org/wiki/Hardware_Support'>{0}</a>"
|
||||
drivers="<a href='//wiki.kolibrios.org/wiki/Hardware_Support'>{0}</a>"
|
||||
.format(_('article:drivers'))
|
||||
) | safe }}
|
||||
</p>
|
||||
@@ -19,7 +19,7 @@
|
||||
'article:p2',
|
||||
kolibrios="<b>{0}</b>"
|
||||
.format(_('menu:kolibrios')),
|
||||
fasm="<a href='http://www.flatassembler.net' target='_blank'>FASM</a>"
|
||||
fasm="<a href='//flatassembler.net' target='_blank'>FASM</a>"
|
||||
) | safe }}
|
||||
</p>
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
'article:p3',
|
||||
kolibrios="<b>{0}</b>"
|
||||
.format(_('menu:kolibrios')),
|
||||
feedback="<a href='http://board.kolibrios.org'>{0}</a>"
|
||||
feedback="<a href='//board.kolibrios.org'>{0}</a>"
|
||||
.format(_('article:feedback')),
|
||||
help="<a href='https://git.kolibrios.org/KolibriOS/kolibrios'>{0}</a>"
|
||||
help="<a href='//git.kolibrios.org/KolibriOS/kolibrios'>{0}</a>"
|
||||
.format(_('article:help'))
|
||||
) | safe }}
|
||||
</p>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div id="footer">
|
||||
<img src="{{ url_for('static', filename='img/logo.png') }}" alt="KolibriOS">
|
||||
<p>
|
||||
© 2004 – {{ year }} <br />
|
||||
© 2004 - {{ year }} <br />
|
||||
{{ _('footer:team') }}
|
||||
</p>
|
||||
</div>
|
||||
@@ -4,7 +4,7 @@
|
||||
<link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||
<meta name="description" content="{{ _('header:%s' % request.url_rule.endpoint) }}">
|
||||
<meta name="keywords"
|
||||
content="kolibri, kolibrios, колибри, колибриос, colibri, operating system, assembler, калибри, fasm, alternate, open source">
|
||||
content="kolibri, kolibrios, colibri, colibrios, колибри, колибриос, калибри, калибриос, operating system, assembler, fasm, alternate, open source">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
|
||||
<script src="{{ url_for('static', filename='script.min.js') }}"></script>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<nav id="menu">
|
||||
<a href="{{ url_for('index', lang=g.locale) }}" class="{% if request.endpoint == 'index' %}a-sel{% endif %}">
|
||||
<a href="{{ url_for('index', lang=g.locale) }}"{% if request.endpoint == 'index' %} class="a-sel"{% endif %}>
|
||||
{% if current == 'index' %}
|
||||
<font bg="lightblue">{{ _('menu:kolibrios') }}</font>
|
||||
{% else %}
|
||||
{{ _('menu:kolibrios') }}
|
||||
{% endif %}
|
||||
</a>
|
||||
|
||||
<a href="{{ url_for('download', lang=g.locale) }}" class="{% if request.endpoint == 'download' %}a-sel{% endif %}">
|
||||
|
||||
<a href="{{ url_for('download', lang=g.locale) }}"{% if request.endpoint == 'download' %} class="a-sel"{% endif %}>
|
||||
{% if current == 'download' %}
|
||||
<font bg="lightblue">{{ _('menu:download') }}</font>
|
||||
{% else %}
|
||||
@@ -15,10 +15,12 @@
|
||||
{% endif %}
|
||||
</a>
|
||||
|
||||
<a href="https://board.kolibrios.org">{{ _('menu:forum') }}</a>
|
||||
<a href="https://wiki.kolibrios.org/wiki/Main_Page/{{ g.locale }}">{{ _('menu:wiki') }}</a>
|
||||
<a href="https://git.kolibrios.org">Git</a>
|
||||
|
||||
<a href="//board.kolibrios.org">{{ _('menu:forum') }}</a>
|
||||
|
||||
<a href="//wiki.kolibrios.org/wiki/Main_Page/{{ g.locale }}">{{ _('menu:wiki') }}</a>
|
||||
|
||||
<a href="//git.kolibrios.org">Git</a>
|
||||
|
||||
<button onclick="dropdown_show(this)" id="lang-butt">
|
||||
<img src="{{ url_for('static', filename='img/flags/%s.png' % g.locale) }}" alt="{{ g.locale }}">
|
||||
</button>
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
<img src="{{ url_for('static', filename='img/icons/i_discord.png') }}" alt="Discord">Discord
|
||||
</a>
|
||||
<br />
|
||||
<a href="https://www.facebook.com/groups/kolibrios/" target="_blank">
|
||||
<a href="https://facebook.com/groups/kolibrios/" target="_blank">
|
||||
<img src="{{ url_for('static', filename='img/icons/i_facebook.png') }}" alt="Facebook">Facebook
|
||||
</a>
|
||||
<br />
|
||||
<a href="https://www.reddit.com/r/KolibriOS/" target="_blank">
|
||||
<a href="https://reddit.com/r/KolibriOS/" target="_blank">
|
||||
<img src="{{ url_for('static', filename='img/icons/i_reddit.png') }}" alt="Reddit">Reddit
|
||||
</a>
|
||||
</p>
|
||||
@@ -24,4 +24,4 @@
|
||||
<a href="irc://kolibrios.org" target="_blank">
|
||||
<img src="{{ url_for('static', filename='img/icons/i_irc.png') }}" alt="IRC">IRC
|
||||
</a>
|
||||
</p>
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user