This commit is contained in:
deadvey 2025-03-29 21:08:46 +00:00
parent f9a9166bb6
commit 9d2e163624
4 changed files with 15 additions and 12 deletions

Binary file not shown.

Binary file not shown.

View File

@ -11,3 +11,6 @@ USE glogger;
CREATE TABLE users ( userID INT PRIMARY KEY AUTO_INCREMENT NOT NULL, username VARCHAR(255) ); CREATE TABLE users ( userID INT PRIMARY KEY AUTO_INCREMENT NOT NULL, username VARCHAR(255) );
CREATE TABLE posts ( postID INT PRIMARY KEY AUTO_INCREMENT NOT NULL, userID INT, FOREIGN KEY(userID) REFERENCES users(userID), title VARCHAR(255), content TEXT, pubDate VARCHAR(255), editDate VARCHAR(255) ); CREATE TABLE posts ( postID INT PRIMARY KEY AUTO_INCREMENT NOT NULL, userID INT, FOREIGN KEY(userID) REFERENCES users(userID), title VARCHAR(255), content TEXT, pubDate VARCHAR(255), editDate VARCHAR(255) );
``` ```
# TO DO
* Add RSS and/or ATOM support
* Make it more reliable?

View File

@ -39,15 +39,15 @@ def create_post_page(post, db):
def create_timeline(db): def create_timeline(db):
with open(f"{config.webroot}/index.gmi", "w") as timeline_file: with open(f"{config.webroot}/index.gmi", "w") as timeline_file:
output.log("Writing posts to timeline") output.log("Writing posts to timeline")
users = [] users = []
cursor = db.cursor() cursor = db.cursor()
cursor.execute(f"SELECT userName FROM users") cursor.execute(f"SELECT userName FROM users")
for x in cursor: for x in cursor:
users += x users += x
cursor.execute(f"SELECT * FROM posts ORDER BY postID Desc LIMIT {config.posts_in_timeline}") cursor.execute(f"SELECT * FROM posts ORDER BY postID Desc LIMIT {config.posts_in_timeline}")
for x in cursor: for x in cursor:
username = users[x[1]-1] username = users[x[1]-1]
post = config.timeline_post_format post = config.timeline_post_format
post = parse_post.parse_post_format(post, x, username) post = parse_post.parse_post_format(post, x, username)
timeline_file.write(post) timeline_file.write(post)