mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of gitlab.com:bashrc2/epicyon
commit
a70eb1e629
|
@ -16,7 +16,7 @@ from blocking import update_blocked_cache
|
|||
from blocking import is_blocked_domain
|
||||
|
||||
default_user_agent_blocks = [
|
||||
'fedilist'
|
||||
'fedilist', 'ncsc scan'
|
||||
]
|
||||
|
||||
|
||||
|
|
21
daemon.py
21
daemon.py
|
@ -58,6 +58,8 @@ from donate import get_donation_url
|
|||
from donate import set_donation_url
|
||||
from donate import get_website
|
||||
from donate import set_website
|
||||
from donate import get_gemini_link
|
||||
from donate import set_gemini_link
|
||||
from person import clear_person_qrcodes
|
||||
from person import add_alternate_domains
|
||||
from person import add_actor_update_timestamp
|
||||
|
@ -6452,6 +6454,21 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
set_website(actor_json, '', self.server.translate)
|
||||
actor_changed = True
|
||||
|
||||
# change gemini link
|
||||
current_gemini_link = \
|
||||
get_gemini_link(actor_json, self.server.translate)
|
||||
if fields.get('geminiLink'):
|
||||
if fields['geminiLink'] != current_gemini_link:
|
||||
set_gemini_link(actor_json,
|
||||
fields['geminiLink'],
|
||||
self.server.translate)
|
||||
actor_changed = True
|
||||
else:
|
||||
if current_gemini_link:
|
||||
set_gemini_link(actor_json, '',
|
||||
self.server.translate)
|
||||
actor_changed = True
|
||||
|
||||
# account moved to new address
|
||||
moved_to = ''
|
||||
if actor_json.get('movedTo'):
|
||||
|
@ -8035,6 +8052,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
is_group = False
|
||||
donate_url = None
|
||||
website_url = None
|
||||
gemini_link = None
|
||||
enigma_pub_key = None
|
||||
pgp_pub_key = None
|
||||
pgp_fingerprint = None
|
||||
|
@ -8064,6 +8082,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
locked_account = get_locked_account(actor_json)
|
||||
donate_url = get_donation_url(actor_json)
|
||||
website_url = get_website(actor_json, self.server.translate)
|
||||
gemini_link = get_gemini_link(actor_json,
|
||||
self.server.translate)
|
||||
xmpp_address = get_xmpp_address(actor_json)
|
||||
matrix_address = get_matrix_address(actor_json)
|
||||
ssb_address = get_ssb_address(actor_json)
|
||||
|
@ -8116,6 +8136,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
options_profile_url,
|
||||
options_link,
|
||||
page_number, donate_url, website_url,
|
||||
gemini_link,
|
||||
xmpp_address, matrix_address,
|
||||
ssb_address, blog_address,
|
||||
tox_address, briar_address,
|
||||
|
|
75
donate.py
75
donate.py
|
@ -21,6 +21,10 @@ def _get_website_strings() -> []:
|
|||
return ['www', 'website', 'web', 'homepage']
|
||||
|
||||
|
||||
def _get_gemini_strings() -> []:
|
||||
return ['gemini', 'capsule', 'gemlog']
|
||||
|
||||
|
||||
def get_donation_url(actor_json: {}) -> str:
|
||||
"""Returns a link used for donations
|
||||
"""
|
||||
|
@ -82,6 +86,34 @@ def get_website(actor_json: {}, translate: {}) -> str:
|
|||
return ''
|
||||
|
||||
|
||||
def get_gemini_link(actor_json: {}, translate: {}) -> str:
|
||||
"""Returns a gemini link
|
||||
"""
|
||||
if not actor_json.get('attachment'):
|
||||
return ''
|
||||
match_strings = _get_gemini_strings()
|
||||
for property_value in actor_json['attachment']:
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if name_value.lower() not in match_strings:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
continue
|
||||
prop_value_name, _ = \
|
||||
get_attachment_property_value(property_value)
|
||||
if not prop_value_name:
|
||||
continue
|
||||
if not property_value['type'].endswith('PropertyValue'):
|
||||
continue
|
||||
return property_value[prop_value_name]
|
||||
return ''
|
||||
|
||||
|
||||
def set_donation_url(actor_json: {}, donate_url: str) -> None:
|
||||
"""Sets a link used for donations
|
||||
"""
|
||||
|
@ -203,3 +235,46 @@ def set_website(actor_json: {}, website_url: str, translate: {}) -> None:
|
|||
"value": website_url
|
||||
}
|
||||
actor_json['attachment'].append(new_entry)
|
||||
|
||||
|
||||
def set_gemini_link(actor_json: {}, gemini_link: str, translate: {}) -> None:
|
||||
"""Sets a gemini link
|
||||
"""
|
||||
gemini_link = gemini_link.strip()
|
||||
not_link = False
|
||||
if '.' not in gemini_link:
|
||||
not_link = True
|
||||
if '://' not in gemini_link:
|
||||
not_link = True
|
||||
if ' ' in gemini_link:
|
||||
not_link = True
|
||||
if '<' in gemini_link:
|
||||
not_link = True
|
||||
|
||||
if not actor_json.get('attachment'):
|
||||
actor_json['attachment'] = []
|
||||
|
||||
match_strings = _get_gemini_strings()
|
||||
|
||||
# remove any existing value
|
||||
property_found = None
|
||||
for property_value in actor_json['attachment']:
|
||||
if not property_value.get('name'):
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
continue
|
||||
if property_value['name'].lower() not in match_strings:
|
||||
continue
|
||||
property_found = property_value
|
||||
break
|
||||
if property_found:
|
||||
actor_json['attachment'].remove(property_found)
|
||||
if not_link:
|
||||
return
|
||||
|
||||
new_entry = {
|
||||
"name": 'Gemini',
|
||||
"type": "PropertyValue",
|
||||
"value": gemini_link
|
||||
}
|
||||
actor_json['attachment'].append(new_entry)
|
||||
|
|
Binary file not shown.
|
@ -277,6 +277,21 @@ server</a> then see <a
|
|||
href="https://code.libreserver.org/bashrc/epicyon/raw/main/caddy.example.conf">caddy.example.conf</a>.</p>
|
||||
<p>Now you can navigate to your domain and register an account. The
|
||||
first account becomes the administrator.</p>
|
||||
<h2 id="configuring-notifications">Configuring notifications</h2>
|
||||
<p>Since Epicyon does not use javascript there are no notifications in
|
||||
the browser. However, you can receive notifications via email, XMPP, <a
|
||||
href="https://matrix.org">Matrix</a> or <a
|
||||
href="https://ntfy.sh">ntfy</a>.</p>
|
||||
<p>Copy the notifications script:</p>
|
||||
<div class="sourceCode" id="cb13"><pre
|
||||
class="sourceCode bash"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cp</span> /opt/epicyon/scripts/epicyon-notification /usr/local/bin/epicyon-notification</span>
|
||||
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="fu">chmod</span> +x /usr/local/bin/epicyon-notification</span></code></pre></div>
|
||||
<p>If you are using email for notifications and it is a single user
|
||||
instance then you might want to edit <em>MY_EMAIL_ADDRESS</em> within
|
||||
<em>/usr/local/bin/epicyon-notification</em>.</p>
|
||||
<p>Then add the following to <em>/etc/crontab</em>.</p>
|
||||
<div class="sourceCode" id="cb14"><pre
|
||||
class="sourceCode bash"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="co"># */1 * * * * root /usr/local/bin/epicyon-notification</span></span></code></pre></div>
|
||||
<h2 id="installing-on-onion-or-i2p-domains">Installing on Onion or i2p
|
||||
domains</h2>
|
||||
<p>If you don’t have access to the clearnet, or prefer to avoid it, then
|
||||
|
@ -294,24 +309,24 @@ instances.</p>
|
|||
<p>Unlike some other instance types, Epicyon is really easy to upgrade.
|
||||
It only requires a git pull to obtain the changes from the upstream
|
||||
repo, then set permissions and restart the daemon.</p>
|
||||
<div class="sourceCode" id="cb13"><pre
|
||||
class="sourceCode bash"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="bu">cd</span> /opt/epicyon</span>
|
||||
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> pull</span>
|
||||
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a><span class="fu">chown</span> <span class="at">-R</span> epicyon:epicyon <span class="pp">*</span></span>
|
||||
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a><span class="ex">systemctl</span> restart epicyon</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb15"><pre
|
||||
class="sourceCode bash"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="bu">cd</span> /opt/epicyon</span>
|
||||
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="fu">git</span> pull</span>
|
||||
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a><span class="fu">chown</span> <span class="at">-R</span> epicyon:epicyon <span class="pp">*</span></span>
|
||||
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a><span class="ex">systemctl</span> restart epicyon</span></code></pre></div>
|
||||
<h1 id="housekeeping">Housekeeping</h1>
|
||||
<p>To avoid running out of disk space you will want to clear down old
|
||||
inbox posts. Posts from your instance outboxes will be unaffected.</p>
|
||||
<p>Create an archive script
|
||||
<strong>/usr/bin/epicyon-archive</strong>:</p>
|
||||
<div class="sourceCode" id="cb14"><pre
|
||||
class="sourceCode bash"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="co">#!/bin/bash</span></span>
|
||||
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="bu">cd</span> /opt/epicyon <span class="kw">||</span> <span class="bu">exit</span> 0</span>
|
||||
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a><span class="ex">/usr/bin/python3</span> epicyon.py <span class="at">--archive</span> none <span class="at">--archiveweeks</span> 4 <span class="at">--maxposts</span> 32000</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb16"><pre
|
||||
class="sourceCode bash"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="co">#!/bin/bash</span></span>
|
||||
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a><span class="bu">cd</span> /opt/epicyon <span class="kw">||</span> <span class="bu">exit</span> 0</span>
|
||||
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a><span class="ex">/usr/bin/python3</span> epicyon.py <span class="at">--archive</span> none <span class="at">--archiveweeks</span> 4 <span class="at">--maxposts</span> 32000</span></code></pre></div>
|
||||
<p>You can adjust the maximum number of weeks and the maximum number of
|
||||
inbox posts as needed. Then add it as a cron entry.</p>
|
||||
<div class="sourceCode" id="cb15"><pre
|
||||
class="sourceCode bash"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">"*/60 * * * * root /usr/bin/epicyon-archive"</span> <span class="op">>></span> /etc/crontab</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb17"><pre
|
||||
class="sourceCode bash"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">"*/60 * * * * root /usr/bin/epicyon-archive"</span> <span class="op">>></span> /etc/crontab</span></code></pre></div>
|
||||
<h1 id="registering-accounts">Registering accounts</h1>
|
||||
<p>You will notice that within the systemd daemon the
|
||||
<em>registration</em> option is set to <em>open</em>. In a browser if
|
||||
|
|
|
@ -245,6 +245,24 @@ If you are using the [Caddy web server](https://caddyserver.com) then see [caddy
|
|||
|
||||
Now you can navigate to your domain and register an account. The first account becomes the administrator.
|
||||
|
||||
## Configuring notifications
|
||||
Since Epicyon does not use javascript there are no notifications in the browser. However, you can receive notifications via email, XMPP, [Matrix](https://matrix.org) or [ntfy](https://ntfy.sh).
|
||||
|
||||
Copy the notifications script:
|
||||
|
||||
``` bash
|
||||
cp /opt/epicyon/scripts/epicyon-notification /usr/local/bin/epicyon-notification
|
||||
chmod +x /usr/local/bin/epicyon-notification
|
||||
```
|
||||
|
||||
If you are using email for notifications and it is a single user instance then you might want to edit *MY_EMAIL_ADDRESS* within */usr/local/bin/epicyon-notification*.
|
||||
|
||||
Then add the following to */etc/crontab*.
|
||||
|
||||
``` bash
|
||||
# */1 * * * * root /usr/local/bin/epicyon-notification
|
||||
```
|
||||
|
||||
## Installing on Onion or i2p domains
|
||||
If you don't have access to the clearnet, or prefer to avoid it, then it's possible to run an Epicyon instance easily from your laptop. There are scripts within the *deploy* directory which can be used to install an instance on a Debian or Arch/Parabola operating system. With some modification of package names they could be also used with other distros.
|
||||
|
||||
|
|
|
@ -140,6 +140,7 @@ def html_person_options(default_timeline: str,
|
|||
page_number: int,
|
||||
donate_url: str,
|
||||
web_address: str,
|
||||
gemini_link: str,
|
||||
xmpp_address: str,
|
||||
matrix_address: str,
|
||||
ssb_address: str,
|
||||
|
@ -340,6 +341,13 @@ def html_person_options(default_timeline: str,
|
|||
options_str += \
|
||||
'<p class="imText">🌐 <a href="' + web_str + '">' + \
|
||||
web_address + '</a></p>\n'
|
||||
if gemini_link:
|
||||
gemini_str = remove_html(gemini_link)
|
||||
if '://' not in gemini_str:
|
||||
gemini_str = 'gemini://' + gemini_str
|
||||
options_str += \
|
||||
'<p class="imText">♊ <a href="' + gemini_str + '">' + \
|
||||
gemini_link + '</a></p>\n'
|
||||
if xmpp_address:
|
||||
options_str += \
|
||||
'<p class="imText">' + translate['XMPP'] + \
|
||||
|
|
|
@ -46,6 +46,7 @@ from posts import parse_user_feed
|
|||
from posts import is_create_inside_announce
|
||||
from donate import get_donation_url
|
||||
from donate import get_website
|
||||
from donate import get_gemini_link
|
||||
from xmpp import get_xmpp_address
|
||||
from matrix import get_matrix_address
|
||||
from ssb import get_ssb_address
|
||||
|
@ -699,6 +700,7 @@ def html_profile(signing_priv_key_pem: str,
|
|||
donate_section = ''
|
||||
donate_url = get_donation_url(profile_json)
|
||||
website_url = get_website(profile_json, translate)
|
||||
gemini_link = get_gemini_link(profile_json, translate)
|
||||
blog_address = get_blog_address(profile_json)
|
||||
enigma_pub_key = get_enigma_pub_key(profile_json)
|
||||
pgp_pub_key = get_pgp_pub_key(profile_json)
|
||||
|
@ -725,6 +727,10 @@ def html_profile(signing_priv_key_pem: str,
|
|||
donate_section += \
|
||||
'<p>' + translate['Website'] + ': <a href="' + \
|
||||
website_url + '" tabindex="1">' + website_url + '</a></p>\n'
|
||||
if gemini_link:
|
||||
donate_section += \
|
||||
'<p>' + 'Gemini' + ': <a href="' + \
|
||||
gemini_link + '" tabindex="1">' + gemini_link + '</a></p>\n'
|
||||
if email_address:
|
||||
donate_section += \
|
||||
'<p>' + translate['Email'] + ': <a href="mailto:' + \
|
||||
|
@ -2168,8 +2174,8 @@ def _get_supported_languagesSorted(base_dir: str) -> str:
|
|||
|
||||
def _html_edit_profile_main(base_dir: str, display_nickname: str, bio_str: str,
|
||||
moved_to: str, donate_url: str, website_url: str,
|
||||
blog_address: str, actor_json: {},
|
||||
translate: {},
|
||||
gemini_link: str, blog_address: str,
|
||||
actor_json: {}, translate: {},
|
||||
nickname: str, domain: str) -> str:
|
||||
"""main info on edit profile screen
|
||||
"""
|
||||
|
@ -2225,6 +2231,10 @@ def _html_edit_profile_main(base_dir: str, display_nickname: str, bio_str: str,
|
|||
edit_text_field(translate['Website'], 'websiteUrl',
|
||||
website_url, 'https://...')
|
||||
|
||||
edit_profile_form += \
|
||||
edit_text_field('Gemini', 'geminiLink',
|
||||
gemini_link, 'gemini://...')
|
||||
|
||||
edit_profile_form += \
|
||||
edit_text_field('Blog', 'blogAddress', blog_address, 'https://...')
|
||||
|
||||
|
@ -2330,7 +2340,7 @@ def html_edit_profile(server, translate: {},
|
|||
notify_likes = notify_reactions = ''
|
||||
hide_like_button = hide_reaction_button = media_instance_str = ''
|
||||
blogs_instance_str = news_instance_str = moved_to = twitter_str = ''
|
||||
bio_str = donate_url = website_url = email_address = ''
|
||||
bio_str = donate_url = website_url = gemini_link = email_address = ''
|
||||
pgp_pub_key = enigma_pub_key = ''
|
||||
pgp_fingerprint = xmpp_address = matrix_address = ''
|
||||
ssb_address = blog_address = tox_address = ''
|
||||
|
@ -2343,6 +2353,7 @@ def html_edit_profile(server, translate: {},
|
|||
moved_to = actor_json['movedTo']
|
||||
donate_url = get_donation_url(actor_json)
|
||||
website_url = get_website(actor_json, translate)
|
||||
gemini_link = get_gemini_link(actor_json, translate)
|
||||
xmpp_address = get_xmpp_address(actor_json)
|
||||
matrix_address = get_matrix_address(actor_json)
|
||||
ssb_address = get_ssb_address(actor_json)
|
||||
|
@ -2484,6 +2495,7 @@ def html_edit_profile(server, translate: {},
|
|||
edit_profile_form += \
|
||||
_html_edit_profile_main(base_dir, display_nickname, bio_str,
|
||||
moved_to, donate_url, website_url,
|
||||
gemini_link,
|
||||
blog_address, actor_json, translate,
|
||||
nickname, domain)
|
||||
|
||||
|
|
Loading…
Reference in New Issue