Browse Source

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

pull/2/head
Noah Petherbridge 5 years ago
parent
commit
72b9c60595
3 changed files with 19 additions and 2 deletions
  1. +10
    -0
      rophako/modules/blog/__init__.py
  2. +4
    -0
      rophako/modules/blog/templates/blog/entry.inc.html
  3. +5
    -2
      rophako/modules/blog/templates/blog/update.html

+ 10
- 0
rophako/modules/blog/__init__.py View File

@@ -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"])


+ 4
- 0
rophako/modules/blog/templates/blog/entry.inc.html View File

@@ -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">


+ 5
- 2
rophako/modules/blog/templates/blog/update.html View File

@@ -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 %}

Loading…
Cancel
Save