2026.01.04 19:09:25 (cachyos.cmoser.eu)
This commit is contained in:
@@ -3,47 +3,48 @@ from . import formatters
|
|||||||
from ... import settings
|
from ... import settings
|
||||||
PARSER = bbcode.Parser(newline="\n",escape_html=True,replace_links=False)
|
PARSER = bbcode.Parser(newline="\n",escape_html=True,replace_links=False)
|
||||||
|
|
||||||
|
|
||||||
|
def add_simple_formatters(simple_formatters):
|
||||||
|
|
||||||
|
for i in simple_formatters:
|
||||||
|
if len(i) == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if len(i) == 1:
|
||||||
|
kwargs = {}
|
||||||
|
else:
|
||||||
|
kwargs = i[1]
|
||||||
|
PARSER.add_simple_formatter(*i[0], **kwargs)
|
||||||
|
|
||||||
|
def add_formatters(formatters):
|
||||||
|
for i in formatters:
|
||||||
|
if len(i) == 0:
|
||||||
|
continue
|
||||||
|
if isinstance(i[0][1], str):
|
||||||
|
if len(i[0]) < 2:
|
||||||
|
continue
|
||||||
|
elif len(i[0]) == 2:
|
||||||
|
args = (i[0][0], import_string(i[0][1]))
|
||||||
|
else:
|
||||||
|
args = (i[0][0], import_string(i[0][1]), *i[2:])
|
||||||
|
else:
|
||||||
|
args = i[0]
|
||||||
|
|
||||||
|
if len(i) == 1:
|
||||||
|
kwargs = {}
|
||||||
|
else:
|
||||||
|
kwargs = i[1]
|
||||||
|
|
||||||
|
PARSER.add_formatter(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def _():
|
def _():
|
||||||
from django.utils.module_loading import import_string
|
from django.utils.module_loading import import_string
|
||||||
|
|
||||||
def add_simple_formatters(simple_formatters):
|
|
||||||
for i in simple_formatters:
|
|
||||||
if len(i) == 0:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if len(i) == 1:
|
|
||||||
kwargs = {}
|
|
||||||
else:
|
|
||||||
kwargs = i[1]
|
|
||||||
PARSER.add_simple_formatter(*i[0], **kwargs)
|
|
||||||
|
|
||||||
def add_formatters(formatters):
|
|
||||||
for i in formatters:
|
|
||||||
|
|
||||||
if len(i) == 0:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if isinstance(i[0][1], str):
|
|
||||||
if len(i[0]) < 2:
|
|
||||||
continue
|
|
||||||
elif len(i[0]) == 2:
|
|
||||||
args = (i[0][0], import_string(i[0][1]))
|
|
||||||
else:
|
|
||||||
args = (i[0][0], import_string(i[0][1]), *i[2:])
|
|
||||||
else:
|
|
||||||
args = i[0]
|
|
||||||
|
|
||||||
if len(i) == 1:
|
|
||||||
kwargs = {}
|
|
||||||
else:
|
|
||||||
kwargs = i[1]
|
|
||||||
|
|
||||||
PARSER.add_formatter(*args, **kwargs)
|
|
||||||
|
|
||||||
add_simple_formatters(formatters.SIMPLE_FORMATTERS)
|
add_simple_formatters(formatters.SIMPLE_FORMATTERS)
|
||||||
add_formatters(formatters.FORMATTERS)
|
add_formatters(formatters.FORMATTERS)
|
||||||
if settings.TINYWIKI_BBCODE_EXTR_SIMPLE_FORMATTERS:
|
if settings.TINYWIKI_BBCODE_EXTRA_SIMPLE_FORMATTERS:
|
||||||
add_simple_formatters(settings.TINYWIKI_BBCODE_EXTR_SIMPLE_FORMATTERS)
|
add_simple_formatters(settings.TINYWIKI_BBCODE_EXTRA_SIMPLE_FORMATTERS)
|
||||||
if settings.TINYWIKI_BBCODE_EXTRA_FORMATTERS:
|
if settings.TINYWIKI_BBCODE_EXTRA_FORMATTERS:
|
||||||
add_formatters(settings.TINYWIKI_BBCODE_EXTRA_FORMATTERS)
|
add_formatters(settings.TINYWIKI_BBCODE_EXTRA_FORMATTERS)
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ TINYWIKI_BASE_TEMPLATE = getattr(
|
|||||||
|
|
||||||
TINYWIKI_HOME = getattr(settings, "TINYWIKI_HOME", "tw-home")
|
TINYWIKI_HOME = getattr(settings, "TINYWIKI_HOME", "tw-home")
|
||||||
TINYWIKI_BBCODE_EXTRA_FORMATTERS = getattr(settings, 'TINYWIKI_BBCODE_EXTRA_FORMATTERS', None)
|
TINYWIKI_BBCODE_EXTRA_FORMATTERS = getattr(settings, 'TINYWIKI_BBCODE_EXTRA_FORMATTERS', None)
|
||||||
TINYWIKI_BBCODE_EXTR_SIMPLE_FORMATTERS = getattr(settings, 'TINYWIKI_BBCODE_EXTR_SIMPLE_FORMATTERS', None)
|
TINYWIKI_BBCODE_EXTRA_SIMPLE_FORMATTERS = getattr(settings,
|
||||||
|
'TINYWIKI_BBCODE_EXTRA_SIMPLE_FORMATTERS',
|
||||||
|
None)
|
||||||
|
|
||||||
USE_BOOTSTRAP = getattr(settings, "USE_BOOTSTRAP", False)
|
USE_BOOTSTRAP = getattr(settings, "USE_BOOTSTRAP", False)
|
||||||
|
|||||||
@@ -12,8 +12,10 @@ from ..models import Page
|
|||||||
from ..enums import WikiPageStatus
|
from ..enums import WikiPageStatus
|
||||||
from django.utils.translation import ngettext, gettext as _
|
from django.utils.translation import ngettext, gettext as _
|
||||||
from ..import settings
|
from ..import settings
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
|
||||||
class HomeView(View):
|
class HomeView(View):
|
||||||
template_name = "tinywiki/home/home.html"
|
template_name = "tinywiki/home/home.html"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user