mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-28 00:07:57 -05:00
wiki: Move wikimarkdown calls into templates.
This commit is contained in:
@@ -26,7 +26,7 @@ from utils import to36, tup, iters
|
||||
from wrapped import Wrapped, StringTemplate, CacheStub, CachedVariable, Templated
|
||||
from mako.template import Template
|
||||
from r2.config.extensions import get_api_subtype
|
||||
from r2.lib.filters import spaceCompress, safemarkdown
|
||||
from r2.lib.filters import spaceCompress, safemarkdown, wikimarkdown
|
||||
from r2.models.subreddit import SubSR
|
||||
import time, pytz
|
||||
from pylons import c, g
|
||||
@@ -590,7 +590,7 @@ class WikiViewJsonTemplate(ThingJsonTemplate):
|
||||
def render(self, thing, *a, **kw):
|
||||
edit_date = time.mktime(thing.edit_date.timetuple())
|
||||
return ObjectTemplate(dict(content_md=thing.page_content_md,
|
||||
content_html=thing.page_content,
|
||||
content_html=wikimarkdown(thing.page_content_md),
|
||||
revision_by=thing.edit_by,
|
||||
revision_date=edit_date,
|
||||
may_revise=thing.may_revise))
|
||||
|
||||
@@ -3,12 +3,10 @@ from pylons import c
|
||||
from r2.lib.wrapped import Templated
|
||||
from r2.lib.menus import PageNameNav
|
||||
from r2.controllers.validator.wiki import this_may_revise
|
||||
from r2.lib.filters import wikimarkdown
|
||||
from pylons.i18n import _
|
||||
|
||||
class WikiView(Templated):
|
||||
def __init__(self, content, edit_by, edit_date, diff=None):
|
||||
self.page_content = wikimarkdown(content) if content else ''
|
||||
self.page_content_md = content
|
||||
self.diff = diff
|
||||
self.edit_by = edit_by
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
|
||||
<%namespace file="utils.html" import="timestamp"/>
|
||||
|
||||
<%!
|
||||
from r2.lib.filters import wikimarkdown
|
||||
%>
|
||||
|
||||
%if thing.diff:
|
||||
<p>
|
||||
@@ -29,10 +32,10 @@
|
||||
</p>
|
||||
%endif
|
||||
<p>
|
||||
%if not thing.page_content:
|
||||
%if not thing.page_content_md:
|
||||
<em>${_("this page is empty")}</em>
|
||||
%else:
|
||||
${unsafe(thing.page_content)}
|
||||
${unsafe(wikimarkdown(thing.page_content_md))}
|
||||
%endif
|
||||
</p>
|
||||
%if thing.edit_date:
|
||||
|
||||
Reference in New Issue
Block a user