diff --git a/templates/blog_rss.xml b/templates/blog_rss.xml index d456152..d879ed5 100644 --- a/templates/blog_rss.xml +++ b/templates/blog_rss.xml @@ -12,12 +12,11 @@ {{ blog_description }} {% endif %} fr - {{ last_build_date }} - + {% for post in posts %} {{ post.title }} - {% if post.last_updated %} {{ post.last_updated }} {% else %} {{ post.time }} {% endif %} + {% if post.last_updated %} {{ post.last_updated }} {% else %} {{ post.creation_date }} {% endif %} {{base_url}}/{{ url_for('blog.viewArticle', username=post.author, title_id=post.title_id) }} {{base_url}}/{{ url_for('blog.viewArticle', username=post.author, title_id=post.title_id) }} @@ -26,7 +25,7 @@ - {{ post.content | safe }} + {{ post.content }} {% endfor %} diff --git a/views/blog.py b/views/blog.py index b325f70..20baa59 100644 --- a/views/blog.py +++ b/views/blog.py @@ -11,6 +11,7 @@ import re from shutil import copy from tools.utils import login_required + blog = Blueprint('blog', __name__, template_folder='templates') app = Flask( 'pywallter' ) @@ -262,14 +263,20 @@ def viewauthorrss(author): if list_posts != None: last_build=last_article_date[0] for post in list_posts: - posts=[dict(title_id=post[0], title=post[1], subtitle=post[2], content=markdown(post[3], extensions=MARKDOWN_EXT), creation_date=post[4], + + # Build date to RFC822 format + date_post = time.strptime(post[4], '%d/%m/%Y %H:%M:%S') + posts=[dict(title_id=post[0], title=post[1], subtitle=post[2], content=markdown(post[3], extensions=MARKDOWN_EXT), + creation_date=time.strftime("%a, %d %b %Y %H:%M:%S", date_post) + time.strftime(' %Z'), author=post[5], status=post[6])] + posts - return render_template('blog_rss.xml', + resp = make_response(render_template('blog_rss.xml', base_url=BASE_URL, blog_name=author, last_build_date=last_build, - posts=posts) + posts=posts)) + resp.headers['Content-type'] = 'application/xml; charset=utf-8' + return resp @blog.route('/blog/private_unified//', methods=['GET']) @@ -322,13 +329,17 @@ def viewrss(): if list_posts != None: last_build=last_article_date[0] for post in list_posts: - posts=[dict(title_id=post[0], title=post[1], subtitle=post[2], content=markdown(post[3], extensions=MARKDOWN_EXT), creation_date=post[4], + # Build date to RFC822 format + date_post = time.strptime(post[4], '%d/%m/%Y %H:%M:%S') + posts=[dict(title_id=post[0], title=post[1], subtitle=post[2], content=markdown(post[3], extensions=MARKDOWN_EXT), + creation_date=time.strftime("%a, %d %b %Y %H:%M:%S", date_post) + time.strftime(' %Z'), author=post[5], status=post[6])] + posts - - return render_template('blog_rss.xml', + + resp = make_response(render_template('blog_rss.xml', base_url=BASE_URL, blog_name= TITLE_SERVER, last_build_date=last_build, blog_description=DESC_SERVER, - posts=posts) - + posts=posts)) + resp.headers['Content-type'] = 'application/xml; charset=utf-8' + return resp