2025.12.22 18:39:25 (cachyos.cmoser.eu)
This commit is contained in:
BIN
static/icons/favicon.ico
Normal file
BIN
static/icons/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -17,15 +17,44 @@ from .text_formatters import (
|
|||||||
render_youtube_video,
|
render_youtube_video,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .simple_formatters import SIMPLE_FORMATTERS
|
from .simple_formatters import SIMPLE_FORMATTERS # noqa: F401
|
||||||
# a list of tuples containig an tuple args and a dict of kwargs
|
# a list of tuples containig an tuple args and a dict of kwargs
|
||||||
|
|
||||||
# a list of tuples containing an tuple of args and a dict of kwargs
|
# a list of tuples containing an tuple of args and a dict of kwargs
|
||||||
FORMATTERS=[
|
FORMATTERS=[
|
||||||
(('url',render_url),{'strip':True,'swallow_trailing_newline':True,'same_tag_closes':True}),
|
(
|
||||||
(('wiki-url',render_wiki_url),{'strip':True,'swallow_trailing_newline':True,'same_tag_closes':True}),
|
('url', render_url),
|
||||||
(('wiki',render_wiki_link),{'strip':True,'swallow_tailin_newline':True,'standalone':True}),
|
{
|
||||||
(('codeblock',render_codeblock),{'strip':True,'swallow_trailing_newline':False,'same_tag_closes':False,"render_embedded":False}),
|
'strip': True,
|
||||||
|
'swallow_trailing_newline': True,
|
||||||
|
'same_tag_closes': True
|
||||||
|
}
|
||||||
|
),
|
||||||
|
(
|
||||||
|
('wiki-url', render_wiki_url),
|
||||||
|
{
|
||||||
|
'strip': True,
|
||||||
|
'swallow_trailing_newline': True,
|
||||||
|
'same_tag_closes': True
|
||||||
|
}
|
||||||
|
),
|
||||||
|
(
|
||||||
|
('wiki', render_wiki_link),
|
||||||
|
{
|
||||||
|
'strip': True,
|
||||||
|
'swallow_tailin_newline': True,
|
||||||
|
'standalone': True
|
||||||
|
}
|
||||||
|
),
|
||||||
|
(
|
||||||
|
('codeblock', render_codeblock),
|
||||||
|
{
|
||||||
|
'strip': True,
|
||||||
|
'swallow_trailing_newline': False,
|
||||||
|
'same_tag_closes': False,
|
||||||
|
'render_embedded': False
|
||||||
|
}
|
||||||
|
),
|
||||||
(('ol', render_ordered_list), {}),
|
(('ol', render_ordered_list), {}),
|
||||||
(('ul', render_unordered_list), {}),
|
(('ul', render_unordered_list), {}),
|
||||||
(('li', render_list_item), {}),
|
(('li', render_list_item), {}),
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from ... import settings
|
|||||||
from ... import models
|
from ... import models
|
||||||
import bbcode
|
import bbcode
|
||||||
|
|
||||||
|
|
||||||
def render_url(tag_name:str,value,options,parent,context):
|
def render_url(tag_name:str,value,options,parent,context):
|
||||||
try:
|
try:
|
||||||
url = options['url']
|
url = options['url']
|
||||||
@@ -22,6 +23,7 @@ def render_url(tag_name:str,value,options,parent,context):
|
|||||||
return f"<a href=\"{url}\" class=\"icon-link icon-link-hover\" referrer-policy=\"no-referrer\" rel=\"noreferrer noopener\">{value}<svg class=\"bi\"><use xlink:href=\"{settings.settings.STATIC_URL + "tinywiki/icons/bootstrap-icons.svg"}#box-arrow-up-right\"></use></svg></a>"
|
return f"<a href=\"{url}\" class=\"icon-link icon-link-hover\" referrer-policy=\"no-referrer\" rel=\"noreferrer noopener\">{value}<svg class=\"bi\"><use xlink:href=\"{settings.settings.STATIC_URL + "tinywiki/icons/bootstrap-icons.svg"}#box-arrow-up-right\"></use></svg></a>"
|
||||||
return f"<a href=\"{url}\" referrer-policy=\"no-referrer\" rel=\"noreferrer noopener\">{value}</a>"
|
return f"<a href=\"{url}\" referrer-policy=\"no-referrer\" rel=\"noreferrer noopener\">{value}</a>"
|
||||||
|
|
||||||
|
|
||||||
def render_wiki_url(tag_name,value,options,parent,context):
|
def render_wiki_url(tag_name,value,options,parent,context):
|
||||||
if tag_name in options:
|
if tag_name in options:
|
||||||
url = reverse("tinywiki:page",kwargs={'slug':options[tag_name]})
|
url = reverse("tinywiki:page",kwargs={'slug':options[tag_name]})
|
||||||
@@ -75,17 +77,21 @@ def render_wiki_link(tag_name,value,options,parent,context):
|
|||||||
return f"<a href=\"{url}\" class=\"icon-link icon-link-hover\">{title}<svg class=\"bi\"><use xlink:href=\"{href}#{svg}\"></use></svg></a>"
|
return f"<a href=\"{url}\" class=\"icon-link icon-link-hover\">{title}<svg class=\"bi\"><use xlink:href=\"{href}#{svg}\"></use></svg></a>"
|
||||||
return f"<a href=\"{url}\">{value}</a>"
|
return f"<a href=\"{url}\">{value}</a>"
|
||||||
|
|
||||||
|
|
||||||
def render_codeblock(tag_name:str,value,options,parent,context)->str:
|
def render_codeblock(tag_name:str,value,options,parent,context)->str:
|
||||||
if tag_name in options:
|
if tag_name in options:
|
||||||
return f"<pre style=\"overflow-x:auto;\"><code class=\"language-{options[tag_name]}\">{value}</pre></code>"
|
return f"<pre style=\"overflow-x:auto;\"><code class=\"language-{options[tag_name]}\">{value}</pre></code>"
|
||||||
return f"<pre style=\"overflow-x:auto;\"><code>{value}</pre></code>"
|
return f"<pre style=\"overflow-x:auto;\"><code>{value}</pre></code>"
|
||||||
|
|
||||||
|
|
||||||
def render_ordered_list(tag_name:str,value,options,parent,context)->str:
|
def render_ordered_list(tag_name:str,value,options,parent,context)->str:
|
||||||
return f"<ol>{value}</ol>"
|
return f"<ol>{value}</ol>"
|
||||||
|
|
||||||
|
|
||||||
def render_unordered_list(tag_name:str,value,options,parent,context)->str:
|
def render_unordered_list(tag_name:str,value,options,parent,context)->str:
|
||||||
return f"<ul>{value}</ul>"
|
return f"<ul>{value}</ul>"
|
||||||
|
|
||||||
|
|
||||||
def render_list_item(tag_name:str,value,options,parent,context)->str:
|
def render_list_item(tag_name:str,value,options,parent,context)->str:
|
||||||
return f"<li>{value}</li>"
|
return f"<li>{value}</li>"
|
||||||
|
|
||||||
@@ -95,6 +101,7 @@ def render_paragraph(tag_name:str,value,options,parent,context):
|
|||||||
return f"<p style=\"text-align:justify;\">{value}</p>"
|
return f"<p style=\"text-align:justify;\">{value}</p>"
|
||||||
return f"<p>{value}</p>"
|
return f"<p>{value}</p>"
|
||||||
|
|
||||||
|
|
||||||
def render_image(tag_name: str, value, options, parent, context):
|
def render_image(tag_name: str, value, options, parent, context):
|
||||||
if tag_name not in options:
|
if tag_name not in options:
|
||||||
return ""
|
return ""
|
||||||
@@ -184,6 +191,7 @@ def render_image(tag_name:str,value,options,parent,context):
|
|||||||
else:
|
else:
|
||||||
return f'<figure {fig_style}><img src="{options[tag_name]}" {style}><figcaption>{value}</figcaption></figure>'
|
return f'<figure {fig_style}><img src="{options[tag_name]}" {style}><figcaption>{value}</figcaption></figure>'
|
||||||
|
|
||||||
|
|
||||||
def render_wiki_image(tag_name: str, value, options, parent, context):
|
def render_wiki_image(tag_name: str, value, options, parent, context):
|
||||||
if tag_name not in options:
|
if tag_name not in options:
|
||||||
return ""
|
return ""
|
||||||
@@ -271,6 +279,7 @@ def render_wiki_image(tag_name:str,value,options,parent,context):
|
|||||||
else:
|
else:
|
||||||
return f'<figure {fig_style}><img src="{image.image.url}" alt="{image.alt}" {style}><figcaption>{image.description}</figcaption></figure>'
|
return f'<figure {fig_style}><img src="{image.image.url}" alt="{image.alt}" {style}><figcaption>{image.description}</figcaption></figure>'
|
||||||
|
|
||||||
|
|
||||||
def render_table(tag_name:str,value,options,parent,context):
|
def render_table(tag_name:str,value,options,parent,context):
|
||||||
if settings.USE_BOOTSTRAP:
|
if settings.USE_BOOTSTRAP:
|
||||||
classes=["table"]
|
classes=["table"]
|
||||||
|
|||||||
Reference in New Issue
Block a user