forked from MarseyWorld/MarseyWorld
fds
parent
c5a8a69278
commit
8064ffead1
|
@ -11,6 +11,10 @@ def create_comment(text, autojanny=False):
|
|||
else: author_id = NOTIFICATIONS_ID
|
||||
|
||||
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,
|
||||
parent_submission=None,
|
||||
distinguish_level=6,
|
||||
|
|
|
@ -13,52 +13,25 @@ class UserMention(SpanToken):
|
|||
def __init__(self, match_obj):
|
||||
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):
|
||||
|
||||
pattern = re.compile("(^|\s|\n)r/(\w{3,25})")
|
||||
pattern = re.compile("(^|\s|\n)(r/|/r/)(\w{3,25})")
|
||||
parse_inner = False
|
||||
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):
|
||||
|
||||
pattern = re.compile("(^|\s|\n)u/((\w|-){3,25})")
|
||||
pattern = re.compile("(^|\s|\n)(u/|/u/)((\w|-){3,25})")
|
||||
parse_inner = False
|
||||
def __init__(self, match_obj):
|
||||
self.target = (match_obj.group(1), match_obj.group(2))
|
||||
|
||||
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))
|
||||
self.target = (match_obj.group(2), match_obj.group(3))
|
||||
|
||||
class CustomRenderer(HTMLRenderer):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(UserMention,
|
||||
SubMention,
|
||||
RedditorMention,
|
||||
SubMention2,
|
||||
RedditorMention2,
|
||||
)
|
||||
|
||||
for i in kwargs:
|
||||
self.__dict__[i] = kwargs[i]
|
||||
super().__init__(UserMention, SubMention, RedditorMention)
|
||||
for i in kwargs: self.__dict__[i] = kwargs[i]
|
||||
|
||||
def render_user_mention(self, token):
|
||||
space = token.target[0]
|
||||
|
@ -85,15 +58,8 @@ class CustomRenderer(HTMLRenderer):
|
|||
class Renderer(HTMLRenderer):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(UserMention,
|
||||
SubMention,
|
||||
RedditorMention,
|
||||
SubMention2,
|
||||
RedditorMention2,
|
||||
)
|
||||
|
||||
for i in kwargs:
|
||||
self.__dict__[i] = kwargs[i]
|
||||
super().__init__(UserMention, SubMention, RedditorMention)
|
||||
for i in kwargs: self.__dict__[i] = kwargs[i]
|
||||
|
||||
def render_user_mention(self, token):
|
||||
space = token.target[0]
|
||||
|
@ -118,17 +84,9 @@ class Renderer(HTMLRenderer):
|
|||
class Renderer2(HTMLRenderer):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(UserMention2,
|
||||
UserMention,
|
||||
SubMention,
|
||||
RedditorMention,
|
||||
SubMention2,
|
||||
RedditorMention2)
|
||||
super().__init__(UserMention, SubMention, RedditorMention)
|
||||
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):
|
||||
space = token.target[0]
|
||||
target = token.target[1]
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
{% if v %}
|
||||
<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 %}
|
||||
<style>
|
||||
html {
|
||||
|
@ -39,7 +39,7 @@
|
|||
{% endif %}
|
||||
{% else %}
|
||||
<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 %}
|
||||
|
||||
</head>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<script src="/static/assets/js/bootstrap.js?a=3"></script>
|
||||
{% if v %}
|
||||
<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">
|
||||
{% if v.agendaposter %}
|
||||
<style>
|
||||
|
@ -32,7 +32,7 @@
|
|||
{% endif %}
|
||||
{% else %}
|
||||
<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 %}
|
||||
|
||||
<link href="/static/assets/css/fa.css?a=3" rel="stylesheet">
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
{% block content %}
|
||||
{% if v %}
|
||||
<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 %}
|
||||
<style>
|
||||
html {
|
||||
|
@ -30,7 +30,7 @@
|
|||
{% endif %}
|
||||
{% else %}
|
||||
<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 %}
|
||||
|
||||
<div class="row justify-content-around">
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
{% endblock %}
|
||||
|
||||
<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 href="/static/assets/css/fa.css?a=3" rel="stylesheet">
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<title>2-Step Login - {{'SITE_NAME' | app_config}}</title>
|
||||
|
||||
<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>
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
|
||||
<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 %}
|
||||
<style>
|
||||
html {
|
||||
|
|
|
@ -39,10 +39,10 @@
|
|||
|
||||
{% if v %}
|
||||
<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 %}
|
||||
<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 %}
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
||||
<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>
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
{% block stylesheets %}
|
||||
{% if v %}
|
||||
<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 %}
|
||||
<style>
|
||||
html {
|
||||
|
@ -50,7 +50,7 @@
|
|||
{% endif %}
|
||||
{% else %}
|
||||
<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">
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue