Browse Source

show a no posts message

pull/1/head
wes 8 years ago
parent
commit
cba92cc964
  1. 1
      posts.py
  2. 5
      scripts/tags.js
  3. 9
      tags/post.tag
  4. 7
      templates/index.html
  5. 18
      website.py

1
posts.py

@ -0,0 +1 @@
from functools import total_ordering

5
scripts/tags.js

@ -79,7 +79,7 @@ this.on("mount",
});
riot.tag2('post', '<div class="postnav centered"> <button class="{⁗btn btn-primary ⁗ + (this.pid <= 1 ? ⁗disabled⁗ : ⁗ ⁗) + this.prevloading}" onclick="{prev}">Previous Post</button> <button class="{⁗btn btn-primary ⁗ + (this.nomore ? ⁗disabled⁗ : ⁗ ⁗) + this.nextloading}" onclick="{next}">Next Post</button> </div> <div if="{!loading}" class="post centered"> <h4>{opts.title}</h4> <h5>By {opts.creator}</h5> <p class="post-content centered text-break">{content}</p> <div class="divider"></div> <comments pid="{pid}"> </comments> </div>', '', '', function(opts) {
riot.tag2('post', '<div class="postnav centered"> <button class="{⁗btn btn-primary ⁗ + (this.pid <= 1 ? ⁗disabled⁗ : ⁗ ⁗) + this.prevloading}" onclick="{prev}">Previous Post</button> <button class="{⁗btn btn-primary ⁗ + (this.nomore ? ⁗disabled⁗ : ⁗ ⁗) + this.nextloading}" onclick="{next}">Next Post</button> </div> <h4 class="post centered" if="{nomore}"> No More Posts! </h4> <div if="{!(loading || nomore)}" class="post centered"> <h4>{opts.title}</h4> <h5>By {opts.creator}</h5> <p class="post-content centered text-break">{content}</p> <div class="divider"></div> <comments pid="{pid}"> </comments> </div>', '', '', 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;

9
tags/post.tag

@ -4,7 +4,11 @@
<button class={"btn btn-primary " + (this.nomore ? "disabled" : " ") + this.nextloading} onclick={next}>Next Post</button>
</div>
<div if={!loading} class="post centered">
<h4 class="post centered" if={nomore}>
No More Posts!
</h4>
<div if={!(loading || nomore)} class="post centered">
<h4>{ opts.title }</h4>
<h5>By { opts.creator }</h5>
<p class="post-content centered text-break">{ content }</p>
@ -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;

7
templates/index.html

@ -14,6 +14,8 @@
<posts>
<post></post>
</posts>
<editor>
</editor>
{% endblock %}
@ -28,9 +30,10 @@
{% endblock %}
{% block scripts %}
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.22.1/ramda.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/riot/2.4.1/riot+compiler.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/riot/2.6.7/riot+compiler.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/riot-route/3.0.2/route.min.js"></script>
<script type="text/javascript" src="/scripts/tags.js"></script>
<script type="text/javascript" src="/scripts/blog.js"></script>
{% endblock %}

18
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/<filename>", 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/<filename>", 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/<pid>")
def insert(pid):
print("inserting new post")
@app.route("/<path:path>")
def page_not_found(path):

Loading…
Cancel
Save