mirror of
https://codeberg.org/AutumnSpark1226/nomadForum.git
synced 2025-12-22 11:47:12 +00:00
60 lines
2.2 KiB
Plaintext
Executable File
60 lines
2.2 KiB
Plaintext
Executable File
#!/usr/bin/env python3
|
|
|
|
|
|
# nomadForum - a forum on the NomadNetwork
|
|
# Copyright (C) 2023-2025 AutumnSpark1226
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
import os
|
|
|
|
import main
|
|
|
|
debug = False
|
|
if "DEBUG" in os.environ:
|
|
if os.environ["DEBUG"].lower() == "true":
|
|
debug = True
|
|
import traceback
|
|
|
|
|
|
try:
|
|
link_id, remote_identity = main.handle_ids()
|
|
main.print_header(link_id)
|
|
print(main.main_page_info)
|
|
print('`F222`Bddd')
|
|
print(f"Active posts: `Ff22`_`[List all posts`:{main.page_path}/list.mu]`_`f")
|
|
print("``")
|
|
print()
|
|
posts = main.query_database("SELECT post_id, username, title, datetime(created, 'unixepoch') FROM posts ORDER BY last_action DESC LIMIT 10")
|
|
if len(posts) == 0:
|
|
print("No posts are here. You can write the first one!")
|
|
for post_data in posts:
|
|
post_title = post_data[2].replace("\\`", "\'") # "`" breaks the link
|
|
# "]" breaks the link
|
|
post_title = post_title.replace("[", "(")
|
|
post_title = post_title.replace("]", ")")
|
|
print("-")
|
|
if post_data[1] != "[DELETED]":
|
|
display_name = main.query_database(f"SELECT display_name FROM users WHERE username = '{post_data[1]}'")[0][0]
|
|
username_styled = f"`Ff22`_`[{main.remove_micron(display_name)}`:{main.page_path}/profile.mu`username={post_data[1]}]`f`_"
|
|
else:
|
|
username_styled = "`Ff22[DELETED]`f"
|
|
print(f"{username_styled}: `Ff22`_`[{post_title}`:{main.page_path}/view.mu`post_id={post_data[0]}]`_`f ({post_data[3]} (UTC))")
|
|
print("-")
|
|
main.close_database()
|
|
except:
|
|
print("An error occured")
|
|
if debug:
|
|
traceback.print_exc()
|
|
exit(10) |