diff --git a/.gitignore b/.gitignore
index 2149892..643c2da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,4 @@
wiki-pages/*
-webroot/*
venv/
__pycache__/
data/*
diff --git a/config.py b/config.py
index cdc9672..1056ee7 100644
--- a/config.py
+++ b/config.py
@@ -3,3 +3,7 @@ port=8080
domain='example.com'
debug=True
allow_signup=False
+locale='en'
+
+name='This Awesome Wiki!'
+description='This is about all things awesome'
diff --git a/data_management.py b/data_management.py
index 8b722d3..00543ea 100644
--- a/data_management.py
+++ b/data_management.py
@@ -1,13 +1,24 @@
import config
import json
-def get_data(data_type, key, value):
- if data_type == 'users':
- users_json_string = open('data/users.json', 'r').read()
- json_data = json.loads(users_json_string)
+def get_data(data_type, key='', value=''):
+ json_string = ''
+ match data_type:
+ case 'users':
+ json_string = open('data/users.json','r').read()
+ case 'menu':
+ json_string = open('data/menu.json','r').read()
+ case _:
+ json_string = ''
+ print('Error, invalid data type (data_management.get_data)')
+
+ json_data = json.loads(json_string)
+ if key != '':
for json_object in json_data:
if json_object[key] == value:
return json_object
+ else:
+ return json_data
return -1
diff --git a/functions.py b/functions.py
index d33bcbe..558f5fb 100644
--- a/functions.py
+++ b/functions.py
@@ -3,3 +3,24 @@ import hashlib
def sha512_hash(Password):
HashedPassword = hashlib.sha512(Password.encode('utf-8')).hexdigest()
return HashedPassword
+
+
+def dropdown_menu(object_input):
+ html = ''
+ def loop(x, count):
+ html = ''
+ for key,value in x.items():
+ print(' ' * count * 5, key)
+ if type(value) == dict:
+ html += f''
+ html += f'{key}
'
+ html += loop(x[key], count+1)
+ html += f' '
+ else:
+ html += f'{key}
'
+ return html
+
+ count = 0
+ html += loop(object_input, count)
+ print(html)
+ return html
diff --git a/main.py b/main.py
index 6776a63..3628fb7 100644
--- a/main.py
+++ b/main.py
@@ -11,19 +11,23 @@ app = Flask(__name__)
@app.route('/')
def index():
- pages = os.listdir('./wiki-pages')
- pages_string = ''
- for page in pages:
- if page[-3:] == '.md':
- pages_string += f'{page[:-3]}
'
- return render_template('index.html', pages=pages_string)
+ menu = data_management.get_data('menu')
+ return render_template(
+ 'index.html',
+ config=config,
+ menu=menu,
+ functions=functions
+ )
@app.route('/wiki/')
def wiki_page(page):
if os.path.isfile(f'./wiki-pages/{page}.md'):
file_contents = md.render(open(f'./wiki-pages/{page}.md', 'r').read())
+ menu = data_management.get_data('menu')
return render_template(
'wiki-page.html',
+ functions=functions,
+ menu=menu,
content=file_contents,
page_title=page
)
@@ -32,19 +36,25 @@ def wiki_page(page):
@app.route('/create_page')
def create_page():
- return render_template('forms/create_page.html')
-@app.route('/submit_create_page', methods=['POST'])
-def submit_create_page():
- page_name = request.form['page_name']
- return redirect(f'/edit/{page_name}', 302)
+ menu = data_management.get_data('menu')
+ return render_template(
+ 'forms/create_page.html',
+ functions=functions,
+ menu=menu,
+ config=config
+
+ )
@app.route('/edit/')
def edit_page(page):
+ menu = data_management.get_data('menu')
if os.path.isfile(f'./wiki-pages/{page}.md'):
file_contents = open(f'./wiki-pages/{page}.md', 'r').read()
return render_template(
'forms/edit-page.html',
content=file_contents,
+ functions=functions,
+ menu=menu,
page_title=page
)
else:
@@ -55,6 +65,10 @@ def edit_page(page):
)
# Forms
+@app.route('/submit_create_page', methods=['POST'])
+def submit_create_page():
+ page_name = request.form['page_name']
+ return redirect(f'/edit/{page_name}', 302)
@app.route('/submit-edit', methods=['POST'])
def submit_edit_page():
page = request.form['page']
diff --git a/static/custom.css b/static/custom.css
new file mode 100644
index 0000000..86420a3
--- /dev/null
+++ b/static/custom.css
@@ -0,0 +1,15 @@
+* {
+ font: Sans-Serif;
+}
+body {
+ background: #fbf1d7;
+}
+a {
+ background: #83c5b8;
+ text-decoration: none;
+}
+a:hover {
+ background: #fe8019;
+ text-decoration: underline;
+}
+
diff --git a/static/robots.txt b/static/robots.txt
new file mode 100644
index 0000000..c6742d8
--- /dev/null
+++ b/static/robots.txt
@@ -0,0 +1,2 @@
+User-Agent: *
+Disallow: /
diff --git a/templates/forms/create_page.html b/templates/forms/create_page.html
index faa242d..f7b8f6e 100644
--- a/templates/forms/create_page.html
+++ b/templates/forms/create_page.html
@@ -1,3 +1,8 @@
+
+