diff --git a/anonkun.py b/anonkun.py
index 411acd7..e60eeb5 100644
--- a/anonkun.py
+++ b/anonkun.py
@@ -57,7 +57,6 @@ app.wsgi_app = ProxyFix(app.wsgi_app)
app.register_blueprint(views)
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024
app.config['SESSION_TYPE'] = 'filesystem'
-app.url_map.strict_slashes = False
app.jinja_env.trim_blocks = True
app.jinja_env.lstrip_blocks = True
#app.jinja_env.undefined = "StrictUndefined"
diff --git a/anonkun.sql b/anonkun.sql
index d109125..4e96a1b 100644
--- a/anonkun.sql
+++ b/anonkun.sql
@@ -27,6 +27,7 @@ CREATE TABLE `quest_meta` (
CREATE TABLE `quest_data` (
`post_id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
`quest_id` SMALLINT UNSIGNED NOT NULL,
+ `page_num` TINYINT UNSIGNED NOT NULL,
`post_type` ENUM('text', 'dice', 'poll') NOT NULL,
`post` MEDIUMTEXT NOT NULL,
`timestamp` INT UNSIGNED NOT NULL,
diff --git a/database.py b/database.py
index 9952d1c..cf3c356 100644
--- a/database.py
+++ b/database.py
@@ -130,12 +130,13 @@ def insert_quest(canon_title, owner_id):
return quest_id
-def insert_quest_post(quest_id, post_type, post, timestamp):
+def insert_quest_post(quest_id, page_num, post_type, post, timestamp):
"""Insers a new quest post."""
_DB.execute(
"INSERT INTO `quest_data`" \
- + "(`quest_id`, `post_type`, `post`, `timestamp`) " \
- + "VALUES (%s, %s, %s, %s)", (quest_id, post_type, post, timestamp))
+ + "(`quest_id`, `page_num`, `post_type`, `post`, `timestamp`) " \
+ + "VALUES (%s, %s, %s, %s, %s)",
+ (quest_id, page_num, post_type, post, timestamp))
post_id = _DB.execute(
"SELECT `post_id` FROM `quest_data` WHERE `quest_id` = %s " \
+ "ORDER BY `post_id` DESC", (quest_id,)).fetchone()[0]
diff --git a/events.py b/events.py
index 22bb3e9..0ff3fd6 100644
--- a/events.py
+++ b/events.py
@@ -28,17 +28,16 @@ def qm_only(msg=""):
def _nop(*args, **kwargs):
data = args[0]
room = data.get("room")
- res = db.get_quest_meta(quest_id=room)
+ res = db.get_quest_meta(room)
if not res:
return msg
- if session.get("user_id") != res[3]:
+ if session.get("user_id") != res[2]:
return msg
return func(*args, **kwargs)
return _nop
return actual_decorator
-
@socketio.on('joined')
def joined(data):
"""
@@ -167,12 +166,14 @@ def new_post(data, internal=False):
"""
room = data.get("room")
post = data.get("post")
+ page_num = data.get("page_num")
+
post = bleach.clean(post.strip())
post = post.replace("\n", "
")
post = tools.handle_img(post)
date = int(time.time())
- post_id = db.insert_quest_post(room, "text", post, date)
+ post_id = db.insert_quest_post(room, page_num, "text", post, date)
db.set_post_closed(room)
data = {}
@@ -229,6 +230,7 @@ def dice_post(data):
except (ValueError, AssertionError):
return
diceStrict = bool(data.get("diceStrict"))
+ page_num = data.get("page_num")
dice_roll = f"{data['diceNum']}d{data['diceSides']}"
if diceMod:
@@ -241,7 +243,7 @@ def dice_post(data):
post += " vs DC" + str(diceChal)
date = int(time.time())
- post_id = db.insert_quest_post(room, "dice", post, date)
+ post_id = db.insert_quest_post(room, page_num, "dice", post, date)
new_call = (dice_roll, diceStrict, diceChal, diceRollsTaken)
db.insert_dice_call(post_id, room, new_call)
db.set_post_open(post_id, room)
@@ -295,6 +297,7 @@ def poll_post(data):
room = data.pop("room", None)
multi_choice = bool(data.pop("pollAllowMultipleChoices", None))
allow_writein = bool(data.pop("pollAllowUserOptions", None))
+ page_num = data.get("page_num")
options = []
for key, value in data.items():
if not value or not key.startswith("pollOption-"):
@@ -307,7 +310,7 @@ def poll_post(data):
post = "Poll"
date = int(time.time())
- post_id = db.insert_quest_post(room, "poll", post, date)
+ post_id = db.insert_quest_post(room, page_num, "poll", post, date)
db.insert_poll(post_id, room, multi_choice, allow_writein)
new_options = []
for option in options:
diff --git a/static/anonkunQM.js b/static/anonkunQM.js
index 146a717..be34a39 100644
--- a/static/anonkunQM.js
+++ b/static/anonkunQM.js
@@ -5,7 +5,7 @@ var tid = setInterval( function () {
clearInterval( tid );
document.getElementById('chatWindow').scrollTop = document.getElementById('chatWindow').scrollHeight;
- socket = io.connect('https://' + document.domain + ':' + location.port);
+ socket = io.connect('https://' + document.domain + location.port);
socket.on('connect', function() {
socket.emit('joined', {room: room_id});
});
@@ -223,7 +223,7 @@ function makePost() {
let text = qparea.value.trim();
qparea.value = '';
if (text == '') { return; }
- socket.emit('new_post', {post: text, room: room_id});
+ socket.emit('new_post', {post: text, page_num: page_num, room: room_id});
}
function edit_post(post_id) {
document.getElementById('questPostData-' + post_id).contentEditable = 'true';
@@ -247,6 +247,7 @@ function form_post(form_id, emit_msg) {
obj[key] = value;
});
obj.room = room_id;
+ obj.page_num = page_num;
socket.emit(emit_msg, obj);
document.getElementById(form_id).reset();
}
diff --git a/templates/quest.html b/templates/quest.html
index 90bcd67..f453ee1 100644
--- a/templates/quest.html
+++ b/templates/quest.html
@@ -2,7 +2,7 @@
{% block title %}{{ quest_title }}{% endblock %}
{% block head %}
-
+
{% if session.get("user_id") == owner_id %}
{% else %}
@@ -11,7 +11,14 @@
{% endblock %}
{% block header %}
{% if session.get("user_id") == owner_id %}
-