add rss content to post history and generate it when creating or editing a post
This commit is contained in:
@@ -43,6 +43,7 @@ MIGRATIONS = [
|
||||
add_signature_format,
|
||||
create_default_bookmark_collections,
|
||||
add_display_name,
|
||||
'ALTER TABLE "post_history" ADD COLUMN "content_rss" STRING DEFAULT NULL'
|
||||
]
|
||||
|
||||
def run_migrations():
|
||||
|
||||
@@ -2,7 +2,7 @@ from flask import (
|
||||
Blueprint, redirect, url_for, flash, render_template, request
|
||||
)
|
||||
from .users import login_required, get_active_user
|
||||
from ..lib.babycode import babycode_to_html, BABYCODE_VERSION
|
||||
from ..lib.babycode import babycode_to_html, babycode_to_rssxml, BABYCODE_VERSION
|
||||
from ..constants import InfoboxKind
|
||||
from ..db import db
|
||||
from ..models import Posts, PostHistory, Threads, Topics, Mentions
|
||||
@@ -12,6 +12,7 @@ bp = Blueprint("posts", __name__, url_prefix = "/post")
|
||||
|
||||
def create_post(thread_id, user_id, content, markup_language="babycode"):
|
||||
parsed_content = babycode_to_html(content)
|
||||
parsed_rss = babycode_to_rssxml(content)
|
||||
with db.transaction():
|
||||
post = Posts.create({
|
||||
"thread_id": thread_id,
|
||||
@@ -22,6 +23,7 @@ def create_post(thread_id, user_id, content, markup_language="babycode"):
|
||||
revision = PostHistory.create({
|
||||
"post_id": post.id,
|
||||
"content": parsed_content.result,
|
||||
"content_rss": parsed_rss,
|
||||
"is_initial_revision": True,
|
||||
"original_markup": content,
|
||||
"markup_language": markup_language,
|
||||
@@ -43,11 +45,13 @@ def create_post(thread_id, user_id, content, markup_language="babycode"):
|
||||
|
||||
def update_post(post_id, new_content, markup_language='babycode'):
|
||||
parsed_content = babycode_to_html(new_content)
|
||||
parsed_rss = babycode_to_rssxml(new_content)
|
||||
with db.transaction():
|
||||
post = Posts.find({'id': post_id})
|
||||
new_revision = PostHistory.create({
|
||||
'post_id': post.id,
|
||||
'content': parsed_content.result,
|
||||
"content_rss": parsed_rss,
|
||||
'is_initial_revision': False,
|
||||
'original_markup': new_content,
|
||||
'markup_language': markup_language,
|
||||
|
||||
Reference in New Issue
Block a user