a bunch of updates CHECK CONFIG
This commit is contained in:
20
README.md
20
README.md
@@ -10,6 +10,26 @@ the blinkies and stamps stuff is literally just because i want an easy way to up
|
||||
|
||||
make sure blinkies are actually blinkie-sized, and stamps are likewise stamp-sized. too much variation in size will make the layout weird. there's not validation because its designed just to make uploading the images not require ftp + manual code as i had been doing before.
|
||||
|
||||
# Config
|
||||
|
||||
this is how your config should look at the latest update
|
||||
|
||||
```
|
||||
REGISTRATION = True # Make sure to disable in production
|
||||
ICON_UPLOAD_FOLDER = 'myriad/static/icons' # where member icons will be stored
|
||||
BLINKIES_UPLOAD_FOLDER = 'myriad/static/blinkies' # where blinkies will be stored
|
||||
STAMPS_UPLOAD_FOLDER = 'myriad/static/stamps' # where stamps will be stored
|
||||
MISC_UPLOAD_FOLDER = 'myriad/static/misc' # where misc image uploads will be stored
|
||||
THEMES_FOLDER = 'myriad/static/themes' # all the theme css files are here
|
||||
TMP_FOLDER = 'myriad/static/tmp' # required for exports
|
||||
SYSTEM_NAME = 'Myriad' # will be shown in the title bar
|
||||
PAGES_NAME = 'Read More...' # will be shown in the nav bar if using custom pages
|
||||
SECRET_KEY = "dev" # CHANGE THIS - see wiki for details
|
||||
|
||||
```
|
||||
|
||||
most likely if you get an error after updating, you need to make sure your config has all the fields as sampled above. we may have added something that you now need.
|
||||
|
||||
# A note on data export/import
|
||||
|
||||
there are currently various ways to export and import data for use within myriad. individual member exports and imports deal only with the fields (though icons, stamps, and blinkies can be exported to a zip folder). they're designed to be used with an active database for whatever purpose the user requires.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import os, datetime
|
||||
|
||||
from flask import Flask
|
||||
from myriad.utilities import server_time, get_datetime_str, remove_html
|
||||
from myriad.utilities import server_time, get_datetime_str, remove_html, get_pages
|
||||
from myriad.db import get_db
|
||||
|
||||
|
||||
@@ -43,8 +43,12 @@ def create_app():
|
||||
db = get_db()
|
||||
member = db.execute("SELECT * FROM member WHERE id=(?)",(mid,)).fetchone()
|
||||
return member
|
||||
def get_system_name():
|
||||
return app.config["SYSTEM_NAME"]
|
||||
def get_pages_name():
|
||||
return app.config["PAGES_NAME"]
|
||||
|
||||
|
||||
return dict(get_themes=get_themes, server_time=w_server_time, get_datetime_str=w_get_datetime_str, get_member=get_member, remove_html=remove_html)
|
||||
return dict(get_themes=get_themes, server_time=w_server_time, get_datetime_str=w_get_datetime_str, get_member=get_member, remove_html=remove_html, get_pages=get_pages, get_system_name=get_system_name, get_pages_name=get_pages_name)
|
||||
|
||||
return app
|
||||
|
||||
@@ -93,4 +93,10 @@ def groups():
|
||||
else:
|
||||
group_members[gid]=[member]
|
||||
|
||||
return render_template("groups.html", groups=groups, group_members=group_members)
|
||||
return render_template("groups.html", groups=groups, group_members=group_members)
|
||||
|
||||
@bp.route("/page/<pid>")
|
||||
def custom_page(pid):
|
||||
db = get_db()
|
||||
page = db.execute("SELECT * FROM pages WHERE id=(?)",(pid,)).fetchone()
|
||||
return render_template('custom_page.html', page=page)
|
||||
@@ -462,10 +462,18 @@ def admin():
|
||||
|
||||
return "<a href='/'>go home</a>"
|
||||
|
||||
elif "new_page" in request.form:
|
||||
page_title = request.form["page_title"]
|
||||
page_content = request.form["page_content"]
|
||||
|
||||
db.execute("INSERT INTO pages (title, content) VALUES (?, ?)", (page_title, page_content))
|
||||
db.commit()
|
||||
|
||||
users = db.execute("SELECT * FROM user").fetchall()
|
||||
front_log = db.execute("SELECT * FROM front_log ORDER BY start_time DESC").fetchall()
|
||||
pages = db.execute("SELECT * FROM pages").fetchall()
|
||||
|
||||
return render_template("manage/admin.html", users=users, front_log=front_log)
|
||||
return render_template("manage/admin.html", users=users, front_log=front_log, pages=pages)
|
||||
|
||||
|
||||
|
||||
@@ -892,7 +900,30 @@ def group_delete(gid):
|
||||
|
||||
return redirect(url_for("manage.groups"))
|
||||
|
||||
|
||||
|
||||
@bp.route("/edit_page/<pid>", methods=("GET", "POST"))
|
||||
@login_required
|
||||
def edit_page(pid):
|
||||
db = get_db()
|
||||
|
||||
if request.method == "POST":
|
||||
content = request.form["content"]
|
||||
title = request.form["title"]
|
||||
|
||||
db.execute("UPDATE pages SET content=(?), title=(?)",(content, title))
|
||||
db.commit()
|
||||
|
||||
page = db.execute("SELECT * FROM pages WHERE id=(?)",(pid,)).fetchone()
|
||||
|
||||
return render_template("manage/edit_custom_page.html", page=page)
|
||||
|
||||
@bp.route("/delete_page/<pid>")
|
||||
@login_required
|
||||
def delete_page(pid):
|
||||
db = get_db()
|
||||
|
||||
db.execute("DELETE FROM pages WHERE id=(?)",(pid,))
|
||||
db.commit()
|
||||
|
||||
return redirect(url_for("manage.admin"))
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ a:hover{
|
||||
|
||||
form{
|
||||
margin:20px;
|
||||
max-width:800px;
|
||||
}
|
||||
label,input{
|
||||
margin:10px;
|
||||
@@ -41,8 +42,6 @@ form textarea{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.profile{
|
||||
margin:15px;
|
||||
border-style:solid;
|
||||
@@ -283,6 +282,13 @@ form textarea{
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.mobile{
|
||||
display:none;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>{% block title %}{% endblock %} - Myriad</title>
|
||||
<title>{% block title %}{% endblock %} - {{ get_system_name() }}</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
|
||||
{% set themes = get_themes() %}
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<div class="container" id="nav">
|
||||
<div class="navitem">{{ server_time() }}</div>
|
||||
<div class="heading">Myriad</div>
|
||||
<div class="heading">{{ get_system_name() }}</div>
|
||||
<div class="navitem">> <a href="{{ url_for('home.index') }}">Home</a></div>
|
||||
<div class="navitem">> <a href="{{ url_for('home.full_list') }}">Full List</a></div>
|
||||
<div class="navitem">> <a href="{{ url_for('home.groups') }}">Groups</a></div>
|
||||
@@ -30,6 +30,15 @@
|
||||
<div class="navitem">> <a href="{{ url_for('manage.admin') }}">Site Administration</a></div>
|
||||
{% endif %}
|
||||
|
||||
{% set pages = get_pages() %}
|
||||
{% if pages %}
|
||||
<div class="heading">{{ get_pages_name() }}</div>
|
||||
{% endif %}
|
||||
{% for page in pages %}
|
||||
<div class="navitem">> <a href="{{ url_for('home.custom_page', pid=page[0]) }}">{{page[1]|safe}}</a></div>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
<div class="heading">Blog</div>
|
||||
{% if g.user %}<div class="navitem">> <a href="{{ url_for('blog.new') }}">New Post</a></div>{% endif %}
|
||||
<div class="navitem">> <a href="{{ url_for('blog.blog') }}">View All Posts</a></div>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<img src="{{ url_for('static', filename='any.jpg') }}" class="icon">
|
||||
{% endif %}
|
||||
<div class="title">{{post[3]|safe}}</div>
|
||||
<div class="timestamp">{{ get_datetime_str(post[2]) }} - <a href="{{ url_for('home.page', mid=post[1]) }}">{{op[3]}}</a> {% if g.user %}{% if op[9]==0 %}(Private){% else %}(Public)</b>{% endif %}{% endif %}</div>
|
||||
<div class="timestamp">{{ get_datetime_str(post[2]) }} - <a href="{{ url_for('home.page', mid=post[1]) }}">{{op[3]|safe}}</a> {% if g.user %}{% if op[9]==0 %}(Private){% else %}(Public)</b>{% endif %}{% endif %}</div>
|
||||
<div class="content">
|
||||
{{post[4].replace('\n', '<br>')|safe}}
|
||||
</div>
|
||||
|
||||
14
myriad/templates/custom_page.html
Normal file
14
myriad/templates/custom_page.html
Normal file
@@ -0,0 +1,14 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block title %}{{ remove_html(page[1]) }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="container">
|
||||
|
||||
{% if g.user %}<a href="{{ url_for('manage.edit_page', pid=page[0]) }}">Edit Page</a>{% endif %}
|
||||
|
||||
{{ page[2]|safe }}
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -21,6 +21,21 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="heading">Custom Pages</div>
|
||||
<form method="post" id="pages">
|
||||
<label for="page_title">Page Title</label>
|
||||
<input name="page_title" id="page_title"><br>
|
||||
<label for="page_content">Page Content</label>
|
||||
<textarea name="page_content" id="page_content">Hello World!</textarea><br><br>
|
||||
<input type="submit" name="new_page" value="Create New Page">
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
|
||||
{% for page in pages %}
|
||||
<p>{{page[1]}} - <a href="{{ url_for('manage.edit_page', pid=page[0]) }}">Edit Page</a> ☆ <a href="{{ url_for('manage.delete_page', pid=page[0]) }}">Delete Page</a></p>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
<div class="heading">Backup</div>
|
||||
<a href="{{ url_for('manage.export_system') }}">Export entire system as JSON</a> (without images)<br>
|
||||
|
||||
30
myriad/templates/manage/edit_custom_page.html
Normal file
30
myriad/templates/manage/edit_custom_page.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<head>
|
||||
<!--1. Import highlighter-->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.30/themes/prism.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.30/components/prism-core.min.js" data-manual></script><!--Remove data-manual if also using Prism normally-->
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.30/plugins/autoloader/prism-autoloader.min.js"></script>
|
||||
<!--2. Import code-input-js-->
|
||||
<script src="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@2.8/code-input.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@2.8/code-input.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@2.8/plugins/indent.min.js"></script>
|
||||
<!--3. Join code-input-js to highlighter-->
|
||||
<script>codeInput.registerTemplate("syntax-highlighted", new codeInput.templates.Prism(Prism, [new codeInput.plugins.Indent()]));</script>
|
||||
</head>
|
||||
|
||||
{% extends 'base.html' %}
|
||||
{% block title %}{{ remove_html(page[1]) }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="container">
|
||||
|
||||
<form method="post">
|
||||
<label for="title">Page Title</label>
|
||||
<input name="title" id="title" value="{{page[1]}}"><br>
|
||||
<code-input language="HTML"><textarea data-code-input-fallback name="content">{{ page[2] }}</textarea></code-input>
|
||||
<input type="submit" name="update_page" value="Save Page">
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -1,4 +1,5 @@
|
||||
import datetime, re
|
||||
from myriad.db import get_db
|
||||
|
||||
def server_time():
|
||||
raw = datetime.datetime.now()
|
||||
@@ -22,4 +23,9 @@ def get_datetime_str(dt_obj):
|
||||
|
||||
def remove_html(mystring):
|
||||
newstring = re.sub('<[^<]+?>', '', mystring)
|
||||
return newstring
|
||||
return newstring
|
||||
|
||||
def get_pages():
|
||||
db = get_db()
|
||||
pages = db.execute("SELECT * FROM pages ORDER BY position").fetchall()
|
||||
return pages
|
||||
Reference in New Issue
Block a user