dokuwiki fixes

This commit is contained in:
Ville Rantanen
2023-12-01 12:24:00 +02:00
parent 070235c452
commit 71c9cd22bb

View File

@@ -35,7 +35,7 @@ BOLDFINDER = re.compile(r"\*([^\*]+)\*")
CODEFINDER = re.compile(r"\`([^\`]+)\`") CODEFINDER = re.compile(r"\`([^\`]+)\`")
CHECKBOX_DOKUWIKI_TICKED = re.compile(r"<todo #([^>]*)>([^<]+)</todo>") CHECKBOX_DOKUWIKI_TICKED = re.compile(r"<todo #([^>]*)>([^<]+)</todo>")
CHECKBOX_DOKUWIKI_UNTICKED = re.compile(r"<todo>([^<]+)</todo>") CHECKBOX_DOKUWIKI_UNTICKED = re.compile(r"<todo>([^<]+)</todo>")
SHOPNAME_INVALIDCHARS = re.compile("[^A-Za-z0-9_-]+") SHOPNAME_INVALIDCHARS = re.compile("[^A-Za-z0-9_]+")
# create our little application :) # create our little application :)
app = Flask(__name__) app = Flask(__name__)
@@ -121,8 +121,8 @@ def scan_for_new_documents(id):
existing.append(row[1]) existing.append(row[1])
for row in os.listdir(data_dir): for row in os.listdir(data_dir):
if row.endswith(".txt"): if row.endswith(".txt"):
if row[:-3] not in existing: if row[:-4] not in existing:
non_existing.append(row[:-3]) non_existing.append(row[:-4])
for shop in non_existing: for shop in non_existing:
g.db.execute("insert into shops (shop,owner) values (?, ?)", [shop, id]) g.db.execute("insert into shops (shop,owner) values (?, ?)", [shop, id])
g.db.commit() g.db.commit()
@@ -147,7 +147,7 @@ def checkbox_add(item):
if MARKDOWN_STYLE == "markdown": if MARKDOWN_STYLE == "markdown":
return f"[ ] {item}" + "\n" return f"[ ] {item}" + "\n"
if MARKDOWN_STYLE == "dokuwiki": if MARKDOWN_STYLE == "dokuwiki":
return f"<todo>{item}</todo>" + "\n" return f"- <todo>{item}</todo>" + "\n"
def untick(item): def untick(item):
@@ -425,7 +425,7 @@ def add_shop():
import re import re
import string import string
shopname = SHOPNAME_INVALIDCHARS.sub("", request.form["shop"]) shopname = SHOPNAME_INVALIDCHARS.sub("", request.form["shop"].lower())
if shopname == "": if shopname == "":
flash("Shop name empty!") flash("Shop name empty!")