Example #1
0
def _diff_post(revision,last_revision,use_default=False,render_mode=False,is_answer=False):
    title_diff = None
    body_diff = None
    tags_diff = None
    descs = []

    if use_default:
        title_diff = revision.title
        body_diff = revision.html        
        tags_diff = mark_safe(tags_html(revision.tagname_list()))

    if last_revision is not None:
        if not is_answer and last_revision.title != revision.title:
            title_diff = mark_safe(htmldiff(revision.title,last_revision.title ))
            descs.append( _("edited title"))

        if revision.html != last_revision.html:
            if not render_mode:#markdown diff
                body_diff = mark_safe(htmldiff(revision.body,last_revision.body ))
            else:#render html diff
                revision_html = static_content(revision.html,"markdown")
                last_revision_html = static_content(last_revision.html,"markdown")
                body_diff = htmldiff(revision_html,last_revision_html,render_mode=True )
            descs.append(_("edited body"))

        current_tags = " ".join(revision.tagname_list())
        last_tags = " ".join(last_revision.tagname_list())
        if last_tags != current_tags:
            tags_diff = tagsdiff(current_tags,last_tags)
            tags_diff = mark_safe(tags_html(tags_diff))
            descs.append(_("edited tags"))
            
    return (title_diff,body_diff,tags_diff,",".join(descs))
Example #2
0
def _diff_tag_post(revision,last_revision,use_default=False,render_mode=False):
    about_diff = None
    detail_diff = None
    descs = []

    if use_default:
        about_diff = revision.about
        detail_diff = revision.detail

    if last_revision is not None:
        if revision.about != last_revision.about:
            about_diff = mark_safe(htmldiff(revision.about,last_revision.about ))
            descs.append(_("edited about"))

        if revision.detail != last_revision.detail:
            if not render_mode:
                detail_diff = mark_safe(htmldiff(revision.detail,last_revision.detail )) 
            else:
                revision_detail = static_content(revision.detail,"markdown")
                last_revision_detail = static_content(last_revision.detail,"markdown")
                detail_diff = htmldiff(revision_detail,last_revision_detail,render_mode=True )
            descs.append(_("edited detail"))

    return (about_diff,detail_diff,",".join(descs))