Ejemplo n.º 1
0
def ajax_richtext_preview(request, obj_type, obj_ref, obj_revi):
    """
    Ajax view to get an HTML preview of a raw content (in richtext
    syntax).

    GET paramerer:

        ``content``
            raw content to be rendered

    This view returns a JSON response with one key, ``html``, the rendered
    content that can be included in a div element.
    """
    content = request.GET["content"]
    if obj_type in ("create", "object"):
        return {"html": richtext(content, None)}
    obj = get_obj(obj_type, obj_ref, obj_revi, request.user)
    obj.check_readable()
    return {"html": richtext(content, obj)}
Ejemplo n.º 2
0
def richtext_filter(content, obj=None):
    """
    This template filter takes a string value and passes it through the
    function specified by the RICHTEXT_FILTER setting.
    """
    return richtext(content, obj)
Ejemplo n.º 3
0
def richtext_filter(content, obj=None):
    """
    This template filter takes a string value and passes it through the
    function specified by the RICHTEXT_FILTER setting.
    """
    return richtext(content, obj)
Ejemplo n.º 4
0
 def test_richtext_test(self):
     html = richtext("test", self.ctrl)
     self.assertHTMLEqual(html, "TEST")
Ejemplo n.º 5
0
 def test_richtext_disabled(self):
     html = richtext(SIMPLE_TEXT, self.ctrl)
     self.assertHTMLEqual(html, u"<p>%s</p>" % SIMPLE_TEXT)
     self.assertTrue(isinstance(html, SafeData))
Ejemplo n.º 6
0
 def test_richtext_default_settings(self):
     html = richtext(SIMPLE_TEXT, self.ctrl)
     self.assertHTMLEqual(html, u"<p><em>a</em> simple text</p>")
     self.assertTrue(isinstance(html, SafeData))