Basic Email Protection
This commit is contained in:
parent
a4da8a4f52
commit
1a9d3d0b39
1 changed files with 86 additions and 54 deletions
|
@ -38,10 +38,11 @@ def headers(server, code):
|
||||||
|
|
||||||
server.end_headers()
|
server.end_headers()
|
||||||
|
|
||||||
def head(title="", description="", image="", config={}):
|
def head(title="", description="", image="", config={}, author=""):
|
||||||
|
|
||||||
if image.startswith("/"): image = config.get("url","")+image
|
if image.startswith("/"): image = config.get("url","")+image
|
||||||
|
|
||||||
|
|
||||||
favicon = config.get("favicon", "/icon/internet")
|
favicon = config.get("favicon", "/icon/internet")
|
||||||
|
|
||||||
html = """
|
html = """
|
||||||
|
@ -65,6 +66,32 @@ def head(title="", description="", image="", config={}):
|
||||||
<meta property="og:description" content=\""""+Simplify(description, False)+"""">
|
<meta property="og:description" content=\""""+Simplify(description, False)+"""">
|
||||||
<meta property="og:image" content=\""""+image+"""">
|
<meta property="og:image" content=\""""+image+"""">
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Author tags.
|
||||||
|
|
||||||
|
if author:
|
||||||
|
account = accounts().get(author, {})
|
||||||
|
name = account.get("title", account)
|
||||||
|
mastodon = account.get("mastodon", "")
|
||||||
|
|
||||||
|
try:
|
||||||
|
if "/" in mastodon:
|
||||||
|
mastodon = mastodon.replace("https://", "").replace("http://", "")
|
||||||
|
mastodon = mastodon.split("/")[1]+"@"+mastodon.split("/")[0]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if mastodon:
|
||||||
|
|
||||||
|
html = html + """
|
||||||
|
<meta name=article:author content=\""""+name+"""">
|
||||||
|
<meta name=fediverse:creator content=\""""+mastodon+"""">
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
html = html + """
|
||||||
|
|
||||||
<!-- This meta tag is needed for pretty rendering on phones -->
|
<!-- This meta tag is needed for pretty rendering on phones -->
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
|
||||||
|
@ -406,7 +433,9 @@ def ArticlePage(server, url):
|
||||||
# Generating <head>
|
# Generating <head>
|
||||||
html = head(title = Articles.get(article, {}).get("title", article),
|
html = head(title = Articles.get(article, {}).get("title", article),
|
||||||
description = Articles.get(article, {}).get("description", ""),
|
description = Articles.get(article, {}).get("description", ""),
|
||||||
config = config
|
image = Articles.get(article, {}).get("thumbnail", ""),
|
||||||
|
config = config,
|
||||||
|
author = Articles.get(article, {}).get("author")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -550,68 +579,71 @@ def AccountPage(server, account):
|
||||||
|
|
||||||
|
|
||||||
html = html + '</center>'
|
html = html + '</center>'
|
||||||
|
|
||||||
|
# Protecting emails and stuff from scrubbers
|
||||||
|
if len(str(server.cookie)) == 50:
|
||||||
|
|
||||||
# Website
|
# Website
|
||||||
|
|
||||||
website = Safe(Accounts.get(account, {}).get("website" , ""))
|
|
||||||
if website:
|
|
||||||
|
|
||||||
webtitle = website.replace("https://", "").replace("http://", "")
|
website = Safe(Accounts.get(account, {}).get("website" , ""))
|
||||||
if not website.startswith("http"): website = "http://"+website
|
if website:
|
||||||
|
|
||||||
html = html + '<center>'
|
|
||||||
html = html + '<img style="vertical-align: middle" src="/icon/internet">'
|
|
||||||
html = html + '<a href="'+website+'"> '+webtitle+'</a>'
|
|
||||||
html = html + '</center>'
|
|
||||||
|
|
||||||
# Email
|
webtitle = website.replace("https://", "").replace("http://", "")
|
||||||
|
if not website.startswith("http"): website = "http://"+website
|
||||||
email = Safe(Accounts.get(account, {}).get("email" , ""))
|
|
||||||
if email:
|
|
||||||
|
|
||||||
html = html + '<center>'
|
|
||||||
html = html + '<img style="vertical-align: middle" src="/icon/frase">'
|
|
||||||
html = html + '<a href="mailto:'+email+'"> '+email+'</a>'
|
|
||||||
html = html + '</center>'
|
|
||||||
|
|
||||||
# Mastodon
|
|
||||||
|
|
||||||
mastodon = Safe(Accounts.get(account, {}).get("mastodon" , ""))
|
|
||||||
if mastodon:
|
|
||||||
|
|
||||||
# It could be mastodon url and not handle.
|
|
||||||
try:
|
|
||||||
if "/" in mastodon:
|
|
||||||
mastodon = mastodon.replace("https://", "").replace("http://", "")
|
|
||||||
mastodon = mastodon.split("/")[1]+"@"+mastodon.split("/")[0]
|
|
||||||
|
|
||||||
mastolink = "https://"+mastodon[1:].split("@")[1]+"/@"+mastodon[1:].split("@")[0]
|
|
||||||
|
|
||||||
html = html + '<center>'
|
html = html + '<center>'
|
||||||
html = html + '<img style="vertical-align: middle" src="/icon/mastodon">'
|
html = html + '<img style="vertical-align: middle" src="/icon/internet">'
|
||||||
html = html + '<a href="'+mastolink+'"> '+mastodon+'</a>'
|
html = html + '<a href="'+website+'"> '+webtitle+'</a>'
|
||||||
html = html + '</center>'
|
html = html + '</center>'
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Matrix
|
# Email
|
||||||
|
|
||||||
matrix = Safe(Accounts.get(account, {}).get("matrix" , ""))
|
email = Safe(Accounts.get(account, {}).get("email" , ""))
|
||||||
if matrix:
|
if email:
|
||||||
|
|
||||||
# Matrix could be the matrix.to link
|
html = html + '<center>'
|
||||||
if "/" in matrix:
|
html = html + '<img style="vertical-align: middle" src="/icon/frase">'
|
||||||
matrix = matrix[matrix.rfind("/")+1:]
|
html = html + '<a href="mailto:'+email+'"> '+email+'</a>'
|
||||||
|
html = html + '</center>'
|
||||||
matrixlink = "https://matrix.to/#/"+matrix
|
|
||||||
|
|
||||||
html = html + '<center>'
|
|
||||||
html = html + '<img style="vertical-align: middle" src="/icon/element">'
|
|
||||||
html = html + '<a href="'+matrixlink+'"> '+matrix+'</a>'
|
|
||||||
html = html + '</center>'
|
|
||||||
|
|
||||||
if any((website, email, mastodon, matrix)):
|
# Mastodon
|
||||||
html = html + '<br>'
|
|
||||||
|
mastodon = Safe(Accounts.get(account, {}).get("mastodon" , ""))
|
||||||
|
if mastodon:
|
||||||
|
|
||||||
|
# It could be mastodon url and not handle.
|
||||||
|
try:
|
||||||
|
if "/" in mastodon:
|
||||||
|
mastodon = mastodon.replace("https://", "").replace("http://", "")
|
||||||
|
mastodon = mastodon.split("/")[1]+"@"+mastodon.split("/")[0]
|
||||||
|
|
||||||
|
mastolink = "https://"+mastodon[1:].split("@")[1]+"/@"+mastodon[1:].split("@")[0]
|
||||||
|
|
||||||
|
html = html + '<center>'
|
||||||
|
html = html + '<img style="vertical-align: middle" src="/icon/mastodon">'
|
||||||
|
html = html + '<a href="'+mastolink+'"> '+mastodon+'</a>'
|
||||||
|
html = html + '</center>'
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Matrix
|
||||||
|
|
||||||
|
matrix = Safe(Accounts.get(account, {}).get("matrix" , ""))
|
||||||
|
if matrix:
|
||||||
|
|
||||||
|
# Matrix could be the matrix.to link
|
||||||
|
if "/" in matrix:
|
||||||
|
matrix = matrix[matrix.rfind("/")+1:]
|
||||||
|
|
||||||
|
matrixlink = "https://matrix.to/#/"+matrix
|
||||||
|
|
||||||
|
html = html + '<center>'
|
||||||
|
html = html + '<img style="vertical-align: middle" src="/icon/element">'
|
||||||
|
html = html + '<a href="'+matrixlink+'"> '+matrix+'</a>'
|
||||||
|
html = html + '</center>'
|
||||||
|
|
||||||
|
if any((website, email, mastodon, matrix)):
|
||||||
|
html = html + '<br>'
|
||||||
|
|
||||||
html = html + '</div>'
|
html = html + '</div>'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue