Compare commits

..

No commits in common. "40db35cf7f846914634916b5c804c3e8c610f4f2" and "d54da0ac66e5bccf8b636c4a7a2fdddef1868caf" have entirely different histories.

5 changed files with 13 additions and 20 deletions

1
.gitignore vendored
View File

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

View File

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

View File

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

View File

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