From 72b9c6059540880bb9f95558f00806c0286572ac Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Thu, 14 May 2015 16:46:47 -0700 Subject: [PATCH] Add feature to blog for hiding bulk of post body --- rophako/modules/blog/__init__.py | 10 ++++++++++ rophako/modules/blog/templates/blog/entry.inc.html | 4 ++++ rophako/modules/blog/templates/blog/update.html | 7 +++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/rophako/modules/blog/__init__.py b/rophako/modules/blog/__init__.py index 953b124..ff413f1 100644 --- a/rophako/modules/blog/__init__.py +++ b/rophako/modules/blog/__init__.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals from flask import Blueprint, g, request, redirect, url_for, flash, make_response import datetime import time +import re from xml.dom.minidom import Document import rophako.model.user as User @@ -89,6 +90,10 @@ def entry(fid): post = Blog.get_entry(post_id) post["post_id"] = post_id + # Body has a snipped section? + if "" in post["body"]: + post["body"] = re.sub(r'\s*\s*', '\n\n', post["body"]) + # Render the body. if post["format"] == "markdown": post["rendered_body"] = render_markdown(post["body"]) @@ -456,6 +461,11 @@ def partial_index(): post["post_id"] = post_id + # Body has a snipped section? + if "" in post["body"]: + post["body"] = post["body"].split("")[0] + post["snipped"] = True + # Render the body. if post["format"] == "markdown": post["rendered_body"] = render_markdown(post["body"]) diff --git a/rophako/modules/blog/templates/blog/entry.inc.html b/rophako/modules/blog/templates/blog/entry.inc.html index 6f2dc04..dadc942 100644 --- a/rophako/modules/blog/templates/blog/entry.inc.html +++ b/rophako/modules/blog/templates/blog/entry.inc.html @@ -30,6 +30,10 @@ {{ post["rendered_body"] | safe }} + {% if post["snipped"] %} +

+ Read more... + {% endif %}

diff --git a/rophako/modules/blog/templates/blog/update.html b/rophako/modules/blog/templates/blog/update.html index c1d5527..3de9f53 100644 --- a/rophako/modules/blog/templates/blog/update.html +++ b/rophako/modules/blog/templates/blog/update.html @@ -33,7 +33,10 @@ HTML

- Emoticon reference (opens in new window)

+ Markdown cheatsheet / + Emoticon reference (opens in new window)
+ Optional: separate your summary from the rest of the post by typing <snip> + where you want the division to appear.

Avatar:
@@ -155,4 +158,4 @@ } } -{% endblock %} \ No newline at end of file +{% endblock %}