1
0
Derivar 0

Add <snip> feature to blog for hiding bulk of post body

pull/2/head
Noah 2015-05-14 16:46:47 -07:00
ascendente 413d527a3e
cometimento 72b9c60595
3 ficheiros modificados com 19 adições e 2 eliminações

Ver ficheiro

@ -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 "<snip>" in post["body"]:
post["body"] = re.sub(r'\s*<snip>\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 "<snip>" in post["body"]:
post["body"] = post["body"].split("<snip>")[0]
post["snipped"] = True
# Render the body.
if post["format"] == "markdown":
post["rendered_body"] = render_markdown(post["body"])

Ver ficheiro

@ -30,6 +30,10 @@
</div>
{{ post["rendered_body"] | safe }}
{% if post["snipped"] %}
<p>
<a href="{{ url_for('blog.entry', fid=post['fid']) }}">Read more...</a>
{% endif %}
<p>
<div class="clear">

Ver ficheiro

@ -33,7 +33,10 @@
<input type="radio" name="format" value="html"{% if format == "html" %} checked{% endif %}> HTML
</label><br>
<textarea class="form-control input-lg" cols="80" rows="12" name="body">{{ body }}</textarea><br>
<a href="{{ url_for('emoticons.index') }}" target="_blank">Emoticon reference</a> (opens in new window)<p>
<a href="/markdown" target="_blank">Markdown cheatsheet</a> /
<a href="{{ url_for('emoticons.index') }}" target="_blank">Emoticon reference</a> (opens in new window)<br>
Optional: separate your summary from the rest of the post by typing <code>&lt;snip&gt;</code>
where you want the division to appear.<p>
<strong>Avatar:</strong><br>
<span id="avatar-preview"></span>
@ -155,4 +158,4 @@
}
}
</script>
{% endblock %}
{% endblock %}