Add <snip> feature to blog for hiding bulk of post body
This commit is contained in:
parent
413d527a3e
commit
72b9c60595
|
@ -6,6 +6,7 @@ from __future__ import unicode_literals
|
||||||
from flask import Blueprint, g, request, redirect, url_for, flash, make_response
|
from flask import Blueprint, g, request, redirect, url_for, flash, make_response
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
import time
|
||||||
|
import re
|
||||||
from xml.dom.minidom import Document
|
from xml.dom.minidom import Document
|
||||||
|
|
||||||
import rophako.model.user as User
|
import rophako.model.user as User
|
||||||
|
@ -89,6 +90,10 @@ def entry(fid):
|
||||||
post = Blog.get_entry(post_id)
|
post = Blog.get_entry(post_id)
|
||||||
post["post_id"] = 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.
|
# Render the body.
|
||||||
if post["format"] == "markdown":
|
if post["format"] == "markdown":
|
||||||
post["rendered_body"] = render_markdown(post["body"])
|
post["rendered_body"] = render_markdown(post["body"])
|
||||||
|
@ -456,6 +461,11 @@ def partial_index():
|
||||||
|
|
||||||
post["post_id"] = post_id
|
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.
|
# Render the body.
|
||||||
if post["format"] == "markdown":
|
if post["format"] == "markdown":
|
||||||
post["rendered_body"] = render_markdown(post["body"])
|
post["rendered_body"] = render_markdown(post["body"])
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ post["rendered_body"] | safe }}
|
{{ post["rendered_body"] | safe }}
|
||||||
|
{% if post["snipped"] %}
|
||||||
|
<p>
|
||||||
|
<a href="{{ url_for('blog.entry', fid=post['fid']) }}">Read more...</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<div class="clear">
|
<div class="clear">
|
||||||
|
|
|
@ -33,7 +33,10 @@
|
||||||
<input type="radio" name="format" value="html"{% if format == "html" %} checked{% endif %}> HTML
|
<input type="radio" name="format" value="html"{% if format == "html" %} checked{% endif %}> HTML
|
||||||
</label><br>
|
</label><br>
|
||||||
<textarea class="form-control input-lg" cols="80" rows="12" name="body">{{ body }}</textarea><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><snip></code>
|
||||||
|
where you want the division to appear.<p>
|
||||||
|
|
||||||
<strong>Avatar:</strong><br>
|
<strong>Avatar:</strong><br>
|
||||||
<span id="avatar-preview"></span>
|
<span id="avatar-preview"></span>
|
||||||
|
@ -155,4 +158,4 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user