fixed implementation of UGC content uploader

This commit is contained in:
JakeBreath
2026-08-03 18:57:39 -05:00
parent 39e31d3980
commit 473b3c811b
40 changed files with 4137 additions and 87 deletions
+5
View File
@@ -0,0 +1,5 @@
from django.apps import AppConfig
class CommonConfig(AppConfig):
name = 'common'
+14
View File
@@ -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')
+1
View File
@@ -38,6 +38,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'common',
'api',
'landing',
'library',
+11
View File
@@ -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))
+1 -1
View File
@@ -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),
]