forked from rDrama/rDrama
fds
parent
c5a8a69278
commit
8064ffead1
|
@ -11,6 +11,10 @@ def create_comment(text, autojanny=False):
|
||||||
else: author_id = NOTIFICATIONS_ID
|
else: author_id = NOTIFICATIONS_ID
|
||||||
|
|
||||||
text_html = sanitize(Renderer2().render(mistletoe.Document(text)))
|
text_html = sanitize(Renderer2().render(mistletoe.Document(text)))
|
||||||
|
|
||||||
|
for i in re.finditer("^@((\w|-){1,25})", text_html):
|
||||||
|
text_html = text_html.replace(i.group(1), f'<a href="/@{i.group(1)}"><img loading="lazy" src="/@{i.group(1)}/pic" class="pp20">@{i.group(1)}</a>')
|
||||||
|
|
||||||
new_comment = Comment(author_id=author_id,
|
new_comment = Comment(author_id=author_id,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
|
|
|
@ -13,52 +13,25 @@ class UserMention(SpanToken):
|
||||||
def __init__(self, match_obj):
|
def __init__(self, match_obj):
|
||||||
self.target = (match_obj.group(1), match_obj.group(2))
|
self.target = (match_obj.group(1), match_obj.group(2))
|
||||||
|
|
||||||
class UserMention2(SpanToken):
|
|
||||||
pattern = re.compile("^@((\w|-){1,25})")
|
|
||||||
parse_inner = False
|
|
||||||
def __init__(self, match_obj):
|
|
||||||
self.target = (match_obj.group(1))
|
|
||||||
|
|
||||||
class SubMention(SpanToken):
|
class SubMention(SpanToken):
|
||||||
|
|
||||||
pattern = re.compile("(^|\s|\n)r/(\w{3,25})")
|
pattern = re.compile("(^|\s|\n)(r/|/r/)(\w{3,25})")
|
||||||
parse_inner = False
|
parse_inner = False
|
||||||
def __init__(self, match_obj):
|
def __init__(self, match_obj):
|
||||||
self.target = (match_obj.group(1), match_obj.group(2))
|
self.target = (match_obj.group(2), match_obj.group(3))
|
||||||
|
|
||||||
class RedditorMention(SpanToken):
|
class RedditorMention(SpanToken):
|
||||||
|
|
||||||
pattern = re.compile("(^|\s|\n)u/((\w|-){3,25})")
|
pattern = re.compile("(^|\s|\n)(u/|/u/)((\w|-){3,25})")
|
||||||
parse_inner = False
|
parse_inner = False
|
||||||
def __init__(self, match_obj):
|
def __init__(self, match_obj):
|
||||||
self.target = (match_obj.group(1), match_obj.group(2))
|
self.target = (match_obj.group(2), match_obj.group(3))
|
||||||
|
|
||||||
class SubMention2(SpanToken):
|
|
||||||
|
|
||||||
pattern = re.compile("(^|\s|\n)/r/(\w{3,25})")
|
|
||||||
parse_inner = False
|
|
||||||
def __init__(self, match_obj):
|
|
||||||
self.target = (match_obj.group(1), match_obj.group(2))
|
|
||||||
|
|
||||||
class RedditorMention2(SpanToken):
|
|
||||||
|
|
||||||
pattern = re.compile("(^|\s|\n)/u/((\w|-){3,25})")
|
|
||||||
parse_inner = False
|
|
||||||
def __init__(self, match_obj):
|
|
||||||
self.target = (match_obj.group(1), match_obj.group(2))
|
|
||||||
|
|
||||||
class CustomRenderer(HTMLRenderer):
|
class CustomRenderer(HTMLRenderer):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super().__init__(UserMention,
|
super().__init__(UserMention, SubMention, RedditorMention)
|
||||||
SubMention,
|
for i in kwargs: self.__dict__[i] = kwargs[i]
|
||||||
RedditorMention,
|
|
||||||
SubMention2,
|
|
||||||
RedditorMention2,
|
|
||||||
)
|
|
||||||
|
|
||||||
for i in kwargs:
|
|
||||||
self.__dict__[i] = kwargs[i]
|
|
||||||
|
|
||||||
def render_user_mention(self, token):
|
def render_user_mention(self, token):
|
||||||
space = token.target[0]
|
space = token.target[0]
|
||||||
|
@ -85,15 +58,8 @@ class CustomRenderer(HTMLRenderer):
|
||||||
class Renderer(HTMLRenderer):
|
class Renderer(HTMLRenderer):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super().__init__(UserMention,
|
super().__init__(UserMention, SubMention, RedditorMention)
|
||||||
SubMention,
|
for i in kwargs: self.__dict__[i] = kwargs[i]
|
||||||
RedditorMention,
|
|
||||||
SubMention2,
|
|
||||||
RedditorMention2,
|
|
||||||
)
|
|
||||||
|
|
||||||
for i in kwargs:
|
|
||||||
self.__dict__[i] = kwargs[i]
|
|
||||||
|
|
||||||
def render_user_mention(self, token):
|
def render_user_mention(self, token):
|
||||||
space = token.target[0]
|
space = token.target[0]
|
||||||
|
@ -118,17 +84,9 @@ class Renderer(HTMLRenderer):
|
||||||
class Renderer2(HTMLRenderer):
|
class Renderer2(HTMLRenderer):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super().__init__(UserMention2,
|
super().__init__(UserMention, SubMention, RedditorMention)
|
||||||
UserMention,
|
|
||||||
SubMention,
|
|
||||||
RedditorMention,
|
|
||||||
SubMention2,
|
|
||||||
RedditorMention2)
|
|
||||||
for i in kwargs: self.__dict__[i] = kwargs[i]
|
for i in kwargs: self.__dict__[i] = kwargs[i]
|
||||||
|
|
||||||
def render_user_mention2(self, token):
|
|
||||||
return f'<a href="/@{token.target}"><img loading="lazy" src="/@{token.target}/pic" class="pp20">@{token.target}</a>'
|
|
||||||
|
|
||||||
def render_user_mention(self, token):
|
def render_user_mention(self, token):
|
||||||
space = token.target[0]
|
space = token.target[0]
|
||||||
target = token.target[1]
|
target = token.target[1]
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?a=34"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
|
<link rel="stylesheet" href="/static/assets/css/main.css?a=35"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
|
||||||
{% if v.agendaposter %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?a=34"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
<link rel="stylesheet" href="/static/assets/css/main.css?a=35"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<script src="/static/assets/js/bootstrap.js?a=3"></script>
|
<script src="/static/assets/js/bootstrap.js?a=3"></script>
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?a=34">
|
<link rel="stylesheet" href="/static/assets/css/main.css?a=35">
|
||||||
<link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
|
<link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
|
||||||
{% if v.agendaposter %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?a=34"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
<link rel="stylesheet" href="/static/assets/css/main.css?a=35"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">
|
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?a=34"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
|
<link rel="stylesheet" href="/static/assets/css/main.css?a=35"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
|
||||||
{% if v.agendaposter %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?a=34"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
<link rel="stylesheet" href="/static/assets/css/main.css?a=35"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="row justify-content-around">
|
<div class="row justify-content-around">
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?a=34">
|
<link rel="stylesheet" href="/static/assets/css/main.css?a=35">
|
||||||
<link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
<link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
||||||
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">
|
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<title>2-Step Login - {{'SITE_NAME' | app_config}}</title>
|
<title>2-Step Login - {{'SITE_NAME' | app_config}}</title>
|
||||||
|
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?a=34"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
<link rel="stylesheet" href="/static/assets/css/main.css?a=35"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
|
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?a=34"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
|
<link rel="stylesheet" href="/static/assets/css/main.css?a=35"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
|
||||||
{% if v.agendaposter %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
|
|
@ -39,10 +39,10 @@
|
||||||
|
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?a=34"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
|
<link rel="stylesheet" href="/static/assets/css/main.css?a=35"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?a=34"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
<link rel="stylesheet" href="/static/assets/css/main.css?a=35"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">
|
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<title>{% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}Sign up - {{'SITE_NAME' | app_config}}{% endif %}</title>
|
<title>{% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}Sign up - {{'SITE_NAME' | app_config}}{% endif %}</title>
|
||||||
|
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?a=34"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
<link rel="stylesheet" href="/static/assets/css/main.css?a=35"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<title>{% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}{{'SITE_NAME' | app_config}}{% endif %}</title>
|
<title>{% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}{{'SITE_NAME' | app_config}}{% endif %}</title>
|
||||||
|
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?a=34"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
<link rel="stylesheet" href="/static/assets/css/main.css?a=35"><link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
{% block stylesheets %}
|
{% block stylesheets %}
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?a=34"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
|
<link rel="stylesheet" href="/static/assets/css/main.css?a=35"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?a=3">
|
||||||
{% if v.agendaposter %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
|
||||||
<link rel="stylesheet" href="/static/assets/css/main.css?a=34">
|
<link rel="stylesheet" href="/static/assets/css/main.css?a=35">
|
||||||
<link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
<link rel="stylesheet" href="/static/assets/css/{{'DEFAULT_THEME' | app_config}}.css?a=3">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue