Compare commits

..

2 Commits

Author SHA1 Message Date
40db35cf7f added support for custom config file paths 2025-04-12 14:36:40 +01:00
66efd0c696 added support for custom config file paths 2025-04-12 14:36:12 +01:00
5 changed files with 20 additions and 13 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
config.py
htmlconfig.py
__pycache__
*.swp
log

View File

@ -1,10 +1,8 @@
import users
import posts
import rebuild
import click
def editpost(userID, datetime):
def editpost(userID, datetime, config, posts, users):
post_counter = 0
user_posts = []
print("Which post do you want to edit?")

View File

@ -1,4 +1,17 @@
import sys # Command line arguments
from importlib.machinery import SourceFileLoader
from datetime import datetime
import newpost
import editpost
import rebuild
import initialise
config_file_path = "config.py"
if len(sys.argv) > 1:
for argument in sys.argv:
if argument[:9] == "--config=":
config_file_path = argument[9:]
try:
import posts
except:
@ -10,19 +23,13 @@ except:
print("No users database")
initialise.initialise()
try:
import config
config = SourceFileLoader("config", config_file_path).load_module()
if config.autogenerated == True:
print("Error: autogenerated = True")
exit()
except:
print("Please move example.config.py to config.py and edit the options to your case and then set autogenerated=False")
exit()
import newpost
import editpost
import rebuild
import sys # Command line arguments
from datetime import datetime
if len(sys.argv) > 1:
for argument in sys.argv:
@ -53,8 +60,8 @@ if user_present == True:
answer = input()
if answer == 'N' or answer == '0':
newpost.newpost(userID, username, datetime)
newpost.newpost(userID, username, datetime, config, posts, users)
if answer == 'E' or answer == '1':
editpost.editpost(userID, datetime)
editpost.editpost(userID, datetime, config, posts, users)
else:
print('Sorry, that account does not exist, If it should, please ask the webadmin to add this account')

View File

@ -15,7 +15,7 @@ except:
print("No users database")
import output
def newpost(userID, username, datetime):
def newpost(userID, username, datetime, config, posts, users):
title = input("Title: ")
content = click.edit()
content = content.replace("'", "\'")

View File

@ -11,6 +11,7 @@ def parse_post_format(post, post_index, username):
post = post.replace("%C", post_data["content"])
post = post.replace("%L", f"{config.site_url}/post/{post_index}.{config.file_extension}")
post = post.replace("%U", f"{config.site_url}/user/{username}.{config.file_extension}")
post = post.replace("%H", f"{config.site_url}/")
post = post.replace("%N", username)
return post