fixed implementation of UGC content uploader
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CommonConfig(AppConfig):
|
||||
name = 'common'
|
||||
@@ -0,0 +1,14 @@
|
||||
from markdown_it import MarkdownIt
|
||||
|
||||
_markdown = MarkdownIt('js-default', {'html': False, 'breaks': True})
|
||||
|
||||
|
||||
def render_markdown(text):
|
||||
"""Render markdown text to safe HTML.
|
||||
|
||||
Raw HTML is escaped and dangerous link schemes (javascript:, data:,
|
||||
vbscript:) are rejected by markdown-it with html=False.
|
||||
"""
|
||||
if not text:
|
||||
return ''
|
||||
return _markdown.render(text).rstrip('\n')
|
||||
@@ -38,6 +38,7 @@ INSTALLED_APPS = [
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'common',
|
||||
'api',
|
||||
'landing',
|
||||
'library',
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
from django import template
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from common.markdown import render_markdown
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter
|
||||
def markdown(text):
|
||||
return mark_safe(render_markdown(text))
|
||||
@@ -7,6 +7,6 @@ from django.urls import include, path
|
||||
urlpatterns = [
|
||||
path('', include('landing.urls')),
|
||||
path('', include('profiles.urls')),
|
||||
path('api/', include('library.urls')),
|
||||
path('', include('library.urls')),
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user