Fixed it up i think
parent
9f6e779b00
commit
808fe128fc
|
@ -34,7 +34,7 @@ services:
|
|||
postgres:
|
||||
container_name: "postgres"
|
||||
image: postgres
|
||||
command: ["postgres", "-c", "log_statement=all"]
|
||||
command: ["postgres"] #, "-c", "log_statement=all"]
|
||||
volumes:
|
||||
- "./schema.sql:/docker-entrypoint-initdb.d/00-schema.sql"
|
||||
- "./seed-users.sql:/docker-entrypoint-initdb.d/01-seed-users.sql"
|
||||
|
|
|
@ -59,13 +59,14 @@ DELETE_EDIT_RATELIMIT = "10/minute;50/day"
|
|||
|
||||
PUSH_NOTIF_LIMIT = 1000
|
||||
|
||||
IS_LOCALHOST = SITE.startswith("localhost:") or SITE.startswith("127.0.0.1") or SITE.startswith("192.168.") or SITE.endswith(".local")
|
||||
IS_LOCALHOST = SITE.startswith("localhost") or SITE.startswith("127.0.0.1") or SITE.startswith("192.168.") or SITE.endswith(".local")
|
||||
print(f"IS_LOCALHOST: {IS_LOCALHOST}")
|
||||
|
||||
if IS_LOCALHOST:
|
||||
SITE_FULL = 'http://' + SITE
|
||||
SITE_IMAGES = SITE
|
||||
SITE_FULL_IMAGES = f'http://{SITE_IMAGES}'
|
||||
print("here")
|
||||
else:
|
||||
SITE_FULL = 'https://' + SITE
|
||||
SITE_IMAGES = 'i.' + SITE
|
||||
|
@ -1089,3 +1090,5 @@ if not IS_LOCALHOST:
|
|||
|
||||
with open("includes/content-security-policy", "w") as f:
|
||||
f.write(f'add_header Content-Security-Policy "{csp}";')
|
||||
|
||||
print(f"SITE_FULL_IMAGES: {SITE_FULL_IMAGES}")
|
|
@ -36,6 +36,9 @@ def heavy(fn):
|
|||
slf = args[0]
|
||||
slf.heavy_count += 1
|
||||
return fn(*args, **kwargs)
|
||||
|
||||
wrapper.heavy_count = 1
|
||||
|
||||
return wrapper
|
||||
|
||||
class ModifierContextFrame:
|
||||
|
@ -213,7 +216,6 @@ class Modified:
|
|||
|
||||
self.add_style(f'transform: {transformstyle.value};')
|
||||
|
||||
@heavy
|
||||
@modifier
|
||||
def enraged(self):
|
||||
self.underlay(self.soup.new_tag(
|
||||
|
@ -306,10 +308,12 @@ class Modified:
|
|||
|
||||
self.container.append(other)
|
||||
|
||||
""" Coming Soon (TM)
|
||||
@heavy
|
||||
@modifier
|
||||
def bulge(self, strength: NumberLiteralToken = None):
|
||||
self.child = self.child.wrap(self.soup.new_tag('svg', attrs={'class': 'marseyfx-modifier-bulge-container'}))
|
||||
"""
|
||||
|
||||
@modifier
|
||||
def prohibition(self):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import numbers
|
||||
import random
|
||||
from tokenize import Token
|
||||
|
||||
|
@ -47,6 +48,16 @@ class Emoji:
|
|||
if random.random() < 0.004:
|
||||
self.is_golden = True
|
||||
|
||||
def heavy_count(self):
|
||||
count = 0
|
||||
for modifier in self.modifiers:
|
||||
if hasattr(Modified, modifier.name):
|
||||
fn = getattr(Modified, modifier.name)
|
||||
if hasattr(fn, 'heavy_count') and isinstance(fn.heavy_count, numbers.Number) :
|
||||
count += fn.heavy_count
|
||||
|
||||
return count
|
||||
|
||||
def create_el(self, tokenizer: Tokenizer):
|
||||
soup = BeautifulSoup()
|
||||
el = None
|
||||
|
@ -106,7 +117,7 @@ class Emoji:
|
|||
if (self.is_flipped):
|
||||
container['class'].append(' marseyfx-flipped')
|
||||
|
||||
return mod.container.wrap(container), mod.heavy_count
|
||||
return mod.container.wrap(container)
|
||||
|
||||
def parse_emoji(tokenizer: Tokenizer):
|
||||
token = tokenizer.parse_next_tokens()
|
||||
|
|
|
@ -219,7 +219,7 @@ protocols = ('http', 'https')
|
|||
|
||||
sanitize_url_regex = re.compile(
|
||||
r"""\(*# Match any opening parentheses.
|
||||
\b(?<![@.])(?:(?:{0}):/{{0,3}}(?:(?:\w+:)?\w+@)?)?# http://
|
||||
\b(?<![@.:#!])(?:(?:{0}):/{{0,3}}(?:(?:\w+:)?\w+@)?)?# http://
|
||||
([\w-]+\.)+(?:{1})(?:\:[0-9]+)?(?!\.\w)\b# xx.yy.tld(:##)?
|
||||
(?:[/?][^#\s\{{\}}\|\\\^\[\]`<>"]*)?
|
||||
# /path/zz (excluding "unsafe" chars from RFC 1738,
|
||||
|
|
|
@ -18,7 +18,7 @@ from sqlalchemy.sql import func
|
|||
import bleach
|
||||
from bleach.css_sanitizer import CSSSanitizer
|
||||
from bleach.linkifier import LinkifyFilter
|
||||
from bs4 import BeautifulSoup
|
||||
from bs4 import BeautifulSoup, Tag
|
||||
from mistletoe import markdown
|
||||
|
||||
from files.classes.domains import BannedDomain
|
||||
|
@ -246,6 +246,12 @@ class RenderEmojisResult:
|
|||
emoji.count += 1
|
||||
g.db.add(emoji)
|
||||
|
||||
def is_nsfw(self):
|
||||
for emoji in self.emojis_used:
|
||||
if emoji in OVER_18_EMOJIS:
|
||||
return True
|
||||
return False
|
||||
|
||||
def render_emojis_tag(tag: Tag, **kwargs):
|
||||
result = RenderEmojisResult()
|
||||
tag = copy.copy(tag)
|
||||
|
@ -289,9 +295,9 @@ def render_emojis(markup: Union[str, Tag], **kwargs):
|
|||
if not permit_golden:
|
||||
emoji.is_golden = False
|
||||
|
||||
emoji_html, heavy_count = emoji.create_el(tokenizer)
|
||||
emoji_html = emoji.create_el(tokenizer)
|
||||
result.tags.append(emoji_html)
|
||||
result.heavy_count += heavy_count
|
||||
result.heavy_count += emoji.heavy_count()
|
||||
|
||||
if len(tokenizer.errors) > 0:
|
||||
soup = BeautifulSoup()
|
||||
|
@ -584,17 +590,6 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis
|
|||
sanitized = video_sub_regex.sub(r'<p class="resizable"><video controls preload="none" src="\1"></video></p>', sanitized)
|
||||
sanitized = audio_sub_regex.sub(r'<audio controls preload="none" src="\1"></audio>', sanitized)
|
||||
|
||||
if count_emojis:
|
||||
for emoji in g.db.query(Emoji).filter(Emoji.submitter_id==None, Emoji.name.in_(emojis_used)):
|
||||
emoji.count += 1
|
||||
g.db.add(emoji)
|
||||
|
||||
if obj:
|
||||
for emoji in emojis_used:
|
||||
if emoji in OVER_18_EMOJIS:
|
||||
obj.nsfw = True
|
||||
break
|
||||
|
||||
sanitized = sanitized.replace('<p></p>', '')
|
||||
|
||||
allowed_css_properties = allowed_styles.copy()
|
||||
|
@ -626,6 +621,9 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis
|
|||
if count_emojis:
|
||||
emoji_render.db_update_count()
|
||||
|
||||
if obj and emoji_render.is_nsfw():
|
||||
obj.nsfw = True
|
||||
|
||||
# -- @ MENTIONS --
|
||||
ping_count = 0
|
||||
names = set(m.group(1) for m in mention_regex.finditer(sanitized))
|
||||
|
@ -806,20 +804,10 @@ def filter_emojis_only(title, golden=True, count_emojis=False, obj=None, author=
|
|||
if obj.sharpened:
|
||||
title = sharpen(title)
|
||||
|
||||
emojis_used = set()
|
||||
result = render_emojis(title, permit_golden=golden, permit_big=False)
|
||||
|
||||
title = render_emoji(title, emoji_regex2, golden, emojis_used, is_title=True)
|
||||
|
||||
if count_emojis:
|
||||
for emoji in g.db.query(Emoji).filter(Emoji.submitter_id==None, Emoji.name.in_(emojis_used)):
|
||||
emoji.count += 1
|
||||
g.db.add(emoji)
|
||||
|
||||
if obj:
|
||||
for emoji in emojis_used:
|
||||
if emoji in OVER_18_EMOJIS:
|
||||
obj.nsfw = True
|
||||
break
|
||||
if obj and result.is_nsfw():
|
||||
obj.nsfw = True
|
||||
|
||||
title = strikethrough_regex.sub(r'\1<del>\2</del>', title)
|
||||
|
||||
|
|
Loading…
Reference in New Issue