From 454c3337b5fcd2f98b40dac0714d303cdd9fc1f6 Mon Sep 17 00:00:00 2001
From: SoniEx2
Date: Sat, 24 Dec 2022 22:32:49 -0300
Subject: Add Fedi-To integration
---
ganarchy/core.py | 8 ++++++++
ganarchy/data.py | 3 +++
ganarchy/templating/templates.py | 10 +++++++++-
3 files changed, 20 insertions(+), 1 deletion(-)
(limited to 'ganarchy')
diff --git a/ganarchy/core.py b/ganarchy/core.py
index d162dff..d882a57 100644
--- a/ganarchy/core.py
+++ b/ganarchy/core.py
@@ -275,8 +275,16 @@ class GAnarchy:
except LookupError:
title = "GAnarchy on " + parse.urlparse(base_url).hostname
+ try:
+ fedito = self._config.get_property_value(
+ ganarchy.data.DataProperty.INSTANCE_FEDITO
+ )
+ except LookupError:
+ fedito = 0
+
self.title = title
self.base_url = base_url
+ self.fedito = fedito
def load_projects(self):
"""Loads the projects into this GAnarchy instance.
diff --git a/ganarchy/data.py b/ganarchy/data.py
index b497176..a69186f 100644
--- a/ganarchy/data.py
+++ b/ganarchy/data.py
@@ -109,6 +109,7 @@ _MATCHER_REPO_LIST_SRCS = abdl.compile("""->'repo_list_srcs':$dict
_MATCHER_TITLE = abdl.compile("""->title'title':$str""", dict(str=str))
_MATCHER_BASE_URL = abdl.compile("""->base_url'base_url':$str:$uri""", dict(str=str, uri=URIPredicate()))
+_MATCHER_FEDITO = abdl.compile("""->fedito'fedi-to':$int""", dict(int=int))
class OverridableProperty(abc.ABC):
"""An overridable property, with options.
@@ -187,6 +188,7 @@ class DataProperty(Enum):
INSTANCE_BASE_URL = (2, str)
VCS_REPOS = (3, PCTP)
REPO_LIST_SOURCES = (4, RepoListSource)
+ INSTANCE_FEDITO = (5, int)
def get_type(self):
"""Returns the expected type for values from this DataProperty.
@@ -278,6 +280,7 @@ class ObjectDataSource(DataSource):
_SUPPORTED_PROPERTIES = {
DataProperty.INSTANCE_TITLE: lambda obj: (d['title'][1] for d in _MATCHER_TITLE.match(obj)),
DataProperty.INSTANCE_BASE_URL: lambda obj: (d['base_url'][1] for d in _MATCHER_BASE_URL.match(obj)),
+ DataProperty.INSTANCE_FEDITO: lambda obj: (d['fedito'][1] for d in _MATCHER_FEDITO.match(obj)),
DataProperty.VCS_REPOS: lambda obj: (PCTP(r['commit'][0], r['url'][0], r['branch'][0], {k: v[1] for k, v in r.items() if k in {'active', 'federate', 'pinned'}}) for r in _MATCHER_REPOS.match(obj)),
DataProperty.REPO_LIST_SOURCES: lambda obj: (RepoListSource(d['src'][0], d['src'][1]) for d in _MATCHER_REPO_LIST_SRCS.match(obj)),
}
diff --git a/ganarchy/templating/templates.py b/ganarchy/templating/templates.py
index 1574d7c..af9bf2e 100644
--- a/ganarchy/templating/templates.py
+++ b/ganarchy/templating/templates.py
@@ -59,7 +59,11 @@ def get_template_loader():
Powered by GAnarchy. AGPLv3-licensed. Source Code.
+ {% if ganarchy.fedito != 0 -%}
+ Register web+ganarchy: URI handler (via Fedi-To)
+ {% else -%}
Register web+ganarchy: URI handler
+ {% endif -%}
(Makes navigating between GAnarchy instances easier).
{{ project_title|e }}
- Tracking {{ project_commit }}
+ Tracking {{ project_commit }}
{{ project_body|e|replace("\n\n", "
") }}
Pinned repos