|
@ -40,7 +40,8 @@ def cacheit(key, thunk): |
|
|
def get_posts(): |
|
|
def get_posts(): |
|
|
posts = getattr(g, "posts", None) |
|
|
posts = getattr(g, "posts", None) |
|
|
if posts is None: |
|
|
if posts is None: |
|
|
posts = g._posts = Posts(app.config["COUCHDB_USER"], app.config["COUCHDB_PASSWORD"]) |
|
|
posts = g._posts = Posts(app.config["COUCHDB_USER"], |
|
|
|
|
|
app.config["COUCHDB_PASSWORD"]) |
|
|
return posts |
|
|
return posts |
|
|
|
|
|
|
|
|
def get_initial(): |
|
|
def get_initial(): |
|
@ -64,11 +65,13 @@ def NeverWhere(configfile=None): |
|
|
# Set template variables to be injected |
|
|
# Set template variables to be injected |
|
|
@app.context_processor |
|
|
@app.context_processor |
|
|
def inject_variables(): |
|
|
def inject_variables(): |
|
|
return dict( |
|
|
return { |
|
|
quote=quote, |
|
|
"quote" : quote, |
|
|
postid=initial_post["_id"], |
|
|
"postid" : initial_post["_id"], |
|
|
postcontent=defaultdict(str) |
|
|
"postcontent" : defaultdict(str), |
|
|
) |
|
|
"links" : dumps([]), |
|
|
|
|
|
"projects" : dumps([]) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@login_manager.user_loader |
|
|
@login_manager.user_loader |
|
|
def load_user(user_id): |
|
|
def load_user(user_id): |
|
@ -86,10 +89,6 @@ def NeverWhere(configfile=None): |
|
|
print("did not log in successfully") |
|
|
print("did not log in successfully") |
|
|
return render_template("login.html", success=success) |
|
|
return render_template("login.html", success=success) |
|
|
|
|
|
|
|
|
@app.route("/blog/ghprojects", methods=("GET",)) |
|
|
|
|
|
def projects(): |
|
|
|
|
|
return jsonify(loads(cacheit("projects", getProjects))) |
|
|
|
|
|
|
|
|
|
|
|
# page routes |
|
|
# page routes |
|
|
@cache.cached(timeout=50) |
|
|
@cache.cached(timeout=50) |
|
|
@app.route("/blog/posts/", methods=("GET",)) |
|
|
@app.route("/blog/posts/", methods=("GET",)) |
|
@ -107,7 +106,12 @@ def NeverWhere(configfile=None): |
|
|
@cache.cached(timeout=50) |
|
|
@cache.cached(timeout=50) |
|
|
@app.route("/blog/links", methods=("GET",)) |
|
|
@app.route("/blog/links", methods=("GET",)) |
|
|
def showLinks(): |
|
|
def showLinks(): |
|
|
return render_template("index.html", page="links") |
|
|
return render_template("index.html", |
|
|
|
|
|
links=dumps( |
|
|
|
|
|
list( |
|
|
|
|
|
posts.links(json=False))), |
|
|
|
|
|
page="links" |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
@cache.cached(timeout=50) |
|
|
@cache.cached(timeout=50) |
|
|
@app.route("/blog/about", methods=("GET",)) |
|
|
@app.route("/blog/about", methods=("GET",)) |
|
@ -127,7 +131,9 @@ def NeverWhere(configfile=None): |
|
|
lambda: dumps(posts.getpost(_id, json=False))) |
|
|
lambda: dumps(posts.getpost(_id, json=False))) |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
return render_template("index.html", page="posts", postcontent=dict(post_content)) |
|
|
return render_template("index.html", |
|
|
|
|
|
page="posts", |
|
|
|
|
|
postcontent=dict(post_content)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@cache.cached(timeout=50) |
|
|
@cache.cached(timeout=50) |
|
@ -201,6 +207,10 @@ def NeverWhere(configfile=None): |
|
|
""" |
|
|
""" |
|
|
return posts.links() |
|
|
return posts.links() |
|
|
|
|
|
|
|
|
|
|
|
@app.route("/blog/ghprojects", methods=("GET",)) |
|
|
|
|
|
def projects(): |
|
|
|
|
|
return jsonify(loads(cacheit("projects", getProjects))) |
|
|
|
|
|
|
|
|
return app |
|
|
return app |
|
|
|
|
|
|
|
|
app = NeverWhere() |
|
|
app = NeverWhere() |
|
|