Slon/Static/html/about: Add about page

You can set the content for this page using the "about_page_content" key
in database settings.
This commit is contained in:
Alec Murphy 2025-03-21 08:28:51 -04:00
parent d64fbfdea8
commit 5c8839db20
3 changed files with 38 additions and 3 deletions

View file

@ -4,13 +4,22 @@ if (String.EndsWith(".css", session->path())) {
return;
}
if (!StrICmp("/json/about.json", session->path())) {
JsonArray* about = Json.CreateArray(session->mem_task);
about->append(Json.CreateObject(session->mem_task), JSON_OBJECT);
about->o(0)->set("url", "_About this instance", JSON_STRING);
about->o(0)->set("content", db->o("settings")->@("about_page_content"), JSON_STRING);
session->send(about);
return;
}
if (!StrICmp("/js/header.js", session->path())) {
session->content_type("text/javascript");
@slon_http_send_file(session, "M:/Slon/Static/js/header.js");
return;
}
if (String.EndsWith(".js", session->path())) {
if (!StrICmp("/js/statuses.js", session->path())) {
session->content_type("text/javascript");
@slon_http_send_file(session, "M:/Slon/Static/js/statuses.js");
return;
@ -20,3 +29,16 @@ if (String.BeginsWith("/@", session->path())) {
@slon_web_user_get(session);
return;
}
if (!StrICmp("/about", session->path())) {
@slon_http_send_file(session, "M:/Slon/Static/html/about.html");
return;
}
if (!StrICmp("/", session->path()) || !StrICmp("/index.html", session->path())) {
session->header("Location", "/about");
session->status(302);
return;
}
// <script>);

View file

@ -7,6 +7,10 @@ function updateStatusContainers() {
let horizontal_fill_count = ((pc.offsetWidth - 32) / 16);
let url = pc.getElementsByTagName('url')[0].textContent;
let marqueeHref = url == "Unnamed Task" ? window.location : url;
if (url.substring(0,1) == '_') {
url = url.substring(1);
marqueeHref = window.location;
}
post_html += "<b>\u2554";
for (var i = 0; i < (horizontal_fill_count / 2) - ((240 / 16) / 2); i++) {
@ -47,6 +51,7 @@ function updateStatuses(user, statuses) {
let container = document.createElement('div');
container.className = "status-container";
// Render user profile
if (user != "")
{
let content = document.createElement('div');
content.className = "status-content";
@ -97,7 +102,9 @@ function updateStatuses(user, statuses) {
}
}
content_html += "</div>";
content_html += "<span class=status-counts>&#128172; " + status["replies_count"] + " &#128640; " + status["reblogs_count"] + " &#11088; " + status["favourites_count"] + "</span>";
if (user != "") {
content_html += "<span class=status-counts>&#128172; " + status["replies_count"] + " &#128640; " + status["reblogs_count"] + " &#11088; " + status["favourites_count"] + "</span>";
}
if (status["application"] && status["application"]["website"]) {
content_html += "<div class=status-footer>via <a href=" + status["application"]["website"] + ">" + status["application"]["name"] + "</a></div>";
}

View file

@ -154,7 +154,7 @@ def generate_iso_c_file():
tlse_hc_fixup('TLS_WRITE', 'tls_write', tlse_bin_path, tlse_hc_path)
tlse_hc_fixup('TLS_ESTABLISHED', 'tls_established', tlse_bin_path, tlse_hc_path)
# Update css/js timestamps for user.html
# Update css/js timestamps for user.html, about.html
user_html_file = redsea_path + '/Slon/Static/html/user.html'
user_html_timestamp = str(time.time())
@ -162,6 +162,12 @@ def generate_iso_c_file():
if res:
raise ValueError(step_error_message + str(res))
about_html_file = redsea_path + '/Slon/Static/html/about.html'
about_html_timestamp = str(time.time())
res = os.system('cat ' + about_html_file + ' | sed \'s/timestamp=/timestamp=' + about_html_timestamp + '/g\' | sponge ' + about_html_file)
if res:
raise ValueError(step_error_message + str(res))
time.sleep(0.25)
res = os.system('sync && fusermount -u ' + redsea_path)