mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of gitlab.com:bashrc2/epicyon
commit
c5cc5528ce
|
@ -1,23 +1,28 @@
|
||||||
# Caddy configuration file for running epicyon on example.com
|
# Example configuration file for running Caddy2 in front of Epicyon
|
||||||
|
|
||||||
example.com {
|
YOUR_DOMAIN {
|
||||||
tls {
|
tls USER@YOUR_DOMAIN
|
||||||
# Valid values are rsa2048, rsa4096, rsa8192, p256, and p384.
|
|
||||||
# Default is currently p256.
|
|
||||||
key_type p384
|
|
||||||
}
|
|
||||||
header / Strict-Transport-Security "max-age=31556925"
|
|
||||||
header / X-Content-Type-Options "nosniff"
|
|
||||||
header / X-Download-Options "noopen"
|
|
||||||
header / X-Frame-Options "DENY"
|
|
||||||
header / X-Permitted-Cross-Domain-Policies "none"
|
|
||||||
header / X-Robots-Tag "noindex"
|
|
||||||
header / X-XSS-Protection "1; mode=block"
|
|
||||||
|
|
||||||
proxy / http://localhost:7156 {
|
header {
|
||||||
transparent
|
Strict-Transport-Security "max-age=31556925"
|
||||||
timeout 10800s
|
Content-Security-Policy "default-src https:; script-src https: 'unsafe-inline'; style-src https: 'unsafe-inline'"
|
||||||
|
X-Content-Type-Options "nosniff"
|
||||||
|
X-Download-Options "noopen"
|
||||||
|
X-Frame-Options "DENY"
|
||||||
|
X-Permitted-Cross-Domain-Policies "none"
|
||||||
|
X-XSS-Protection "1; mode=block"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
route /newsmirror/* {
|
||||||
|
root * /var/www/YOUR_DOMAIN
|
||||||
|
file_server
|
||||||
|
}
|
||||||
|
|
||||||
|
route /* {
|
||||||
|
reverse_proxy http://127.0.0.1:7156
|
||||||
|
}
|
||||||
|
|
||||||
|
encode zstd gzip
|
||||||
}
|
}
|
||||||
|
|
||||||
# eof
|
# eof
|
32
content.py
32
content.py
|
@ -529,9 +529,41 @@ def _add_music_tag(content: str, tag: str) -> str:
|
||||||
return ':music: ' + content + ' ' + tag + ' '
|
return ':music: ' + content + ' ' + tag + ' '
|
||||||
|
|
||||||
|
|
||||||
|
def _shorten_linked_urls(content: str) -> str:
|
||||||
|
"""If content comes with a web link included then make sure
|
||||||
|
that it is short enough
|
||||||
|
"""
|
||||||
|
if 'href=' not in content:
|
||||||
|
return content
|
||||||
|
if '>' not in content:
|
||||||
|
return content
|
||||||
|
if '<' not in content:
|
||||||
|
return content
|
||||||
|
sections = content.split('>')
|
||||||
|
ctr = 0
|
||||||
|
for section_text in sections:
|
||||||
|
if ctr == 0:
|
||||||
|
ctr += 1
|
||||||
|
continue
|
||||||
|
if '<' not in section_text:
|
||||||
|
ctr += 1
|
||||||
|
continue
|
||||||
|
section_text = section_text.split('<')[0]
|
||||||
|
if ' ' in section_text:
|
||||||
|
continue
|
||||||
|
if len(section_text) > MAX_LINK_LENGTH:
|
||||||
|
content = content.replace('>' + section_text + '<',
|
||||||
|
'>' +
|
||||||
|
section_text[:MAX_LINK_LENGTH-1] + '<')
|
||||||
|
ctr += 1
|
||||||
|
return content
|
||||||
|
|
||||||
|
|
||||||
def add_web_links(content: str) -> str:
|
def add_web_links(content: str) -> str:
|
||||||
"""Adds markup for web links
|
"""Adds markup for web links
|
||||||
"""
|
"""
|
||||||
|
content = _shorten_linked_urls(content)
|
||||||
|
|
||||||
if ':' not in content:
|
if ':' not in content:
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
12
tests.py
12
tests.py
|
@ -3523,6 +3523,18 @@ def _test_actor_parsing():
|
||||||
def _test_web_links():
|
def _test_web_links():
|
||||||
print('test_web_links')
|
print('test_web_links')
|
||||||
|
|
||||||
|
example_text = \
|
||||||
|
'<p>Some text!</p><p><a href=\"https://videosite.whatever/video' + \
|
||||||
|
'/A3JpZMovL25kci1kZS32MGE0NCg4YB1lMLQwLTRkMGEtYkYxMS5kNmQ1MjJqY' + \
|
||||||
|
'WZjKzd\">https://videosite.whatever/video/A3JpZMovL25kci1kZS32' + \
|
||||||
|
'MGE0NCg4YB1lMLQwLTRkMGEtYkYxMS5kNmQ1MjJqYWZjKzd</a></p>'
|
||||||
|
linked_text = add_web_links(example_text)
|
||||||
|
expected_text = \
|
||||||
|
'<p>Some text!</p><p><a href="https://videosite.whatever/video/' + \
|
||||||
|
'A3JpZMovL25kci1kZS32MGE0NCg4YB1lMLQwLTRkMGEtYkYxMS5kNmQ1MjJqYW' + \
|
||||||
|
'ZjKzd">https://videosite.whatever/video/A3JpZM</a></p>'
|
||||||
|
assert linked_text == expected_text
|
||||||
|
|
||||||
example_text = \
|
example_text = \
|
||||||
"<p>Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + \
|
"<p>Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + \
|
||||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + \
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + \
|
||||||
|
|
Loading…
Reference in New Issue