From cba92cc964847e3704104c219cce6290bcbd0551 Mon Sep 17 00:00:00 2001 From: wes Date: Sun, 4 Dec 2016 22:48:43 -0500 Subject: [PATCH] show a no posts message --- posts.py | 1 + scripts/tags.js | 5 ++++- tags/post.tag | 9 ++++++++- templates/index.html | 7 +++++-- website.py | 18 ++++++++++-------- 5 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 posts.py diff --git a/posts.py b/posts.py new file mode 100644 index 0000000..088b114 --- /dev/null +++ b/posts.py @@ -0,0 +1 @@ +from functools import total_ordering diff --git a/scripts/tags.js b/scripts/tags.js index 3051e04..27c0de3 100644 --- a/scripts/tags.js +++ b/scripts/tags.js @@ -79,7 +79,7 @@ this.on("mount", }); -riot.tag2('post', '

{opts.title}

By {opts.creator}

{content}

', '', '', function(opts) { +riot.tag2('post', '

No More Posts!

{opts.title}

By {opts.creator}

{content}

', '', '', function(opts) { var self = this; this.loading = false; @@ -131,9 +131,12 @@ this.setPost = function(pid) { function(body) { if (body === "false") { self.nomore = true; + route("/"); + self.update() } else { self.content = R.join(" ")(R.repeat(body, 20)); + route("/"+pid); } self.loading = false; diff --git a/tags/post.tag b/tags/post.tag index 477da1d..3d65a3e 100644 --- a/tags/post.tag +++ b/tags/post.tag @@ -4,7 +4,11 @@ -
+

+ No More Posts! +

+ +

{ opts.title }

By { opts.creator }

{ content }

@@ -66,9 +70,12 @@ this.setPost = function(pid) { function(body) { if (body === "false") { self.nomore = true; + route("/"); + self.update() } else { self.content = R.join(" ")(R.repeat(body, 20)); + route("/"+pid); } self.loading = false; diff --git a/templates/index.html b/templates/index.html index fbb4330..4ebb71e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -14,6 +14,8 @@ + + {% endblock %} @@ -28,9 +30,10 @@ {% endblock %} {% block scripts %} - + - + + {% endblock %} diff --git a/website.py b/website.py index 3a2d149..fa786ba 100755 --- a/website.py +++ b/website.py @@ -1,4 +1,4 @@ -#! /usr/bin/python2 +#! /usr/bin/python3 from functools import partial from flask import abort, Flask, render_template, flash, request, send_from_directory @@ -7,9 +7,8 @@ from flask_appconfig import AppConfig from time import sleep -from urllib import unquote - -from urllib import quote, unquote +from urllib.parse import unquote +from urllib.parse import quote, unquote from json import dumps, loads from comment import testcomments @@ -43,12 +42,12 @@ def NeverWhere(configfile=None): @app.route("/", methods=("GET", "POST")) def index(): - print "matched index" + print("matched index") return render_template("index.html") @app.route("/scripts/", methods=("GET", "POST")) def send_script(filename): - print "matched scripts route" + print("matched scripts route") return send_from_directory("/home/wes/riotblog/scripts/", filename) @app.route("/styles/", methods=("GET", "POST")) @@ -59,7 +58,7 @@ def NeverWhere(configfile=None): def switchPost(pid): posts = { "1" : "Post one is changed! ", - "2" : "Post two here! " + "2" : "Post two here and it's changed! " } return posts.get(pid, "false") @@ -70,9 +69,12 @@ def NeverWhere(configfile=None): try: return testcomments.get(int(pid), dumps([])) except ValueError as e: - print e + print(e) return dumps([]) + @app.route("/insert/") + def insert(pid): + print("inserting new post") @app.route("/") def page_not_found(path):