summary refs log tree commit diff stats
path: root/ganarchy
diff options
context:
space:
mode:
Diffstat (limited to 'ganarchy')
-rw-r--r--ganarchy/core.py8
-rw-r--r--ganarchy/data.py3
-rw-r--r--ganarchy/templating/templates.py10
3 files changed, 20 insertions, 1 deletions
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():
         </ul>
         <p>Powered by <a href="https://ganarchy.autistic.space/">GAnarchy</a>. AGPLv3-licensed. <a href="https://cybre.tech/SoniEx2/ganarchy">Source Code</a>.</p>
         <p>
+            {% if ganarchy.fedito != 0 -%}
+            <a href="https://fedi-to.net/register?h={{ ganarchy.fedito }}&protocol=web%2Bganarchy">Register web+ganarchy: URI handler (via Fedi-To)</a>
+            {% else -%}
             <a href="{{ ganarchy.base_url|e }}" onclick="event.preventDefault(); navigator.registerProtocolHandler('web+ganarchy', this.href + '?url=%s', 'GAnarchy');">Register web+ganarchy: URI handler</a>
+            {% endif -%}
             (Makes navigating between GAnarchy instances easier).
         </p>
     </body>
@@ -106,7 +110,7 @@ def get_template_loader():
     </head>
     <body>
         <h1>{{ project_title|e }}</h1>
-        <p>Tracking <span id="project_commit"><a href="web+ganarchy:{{ project_commit }}">{{ project_commit }}</a></span></p>
+        <p>Tracking <span id="project_commit"><a href="https://fedi-to.net/go?h={{ ganarchy.fedito }}&target=web%2Bganarchy:{{ project_commit }}">{{ project_commit }}</a></span></p>
         <div id="project_body"><p>{{ project_body|e|replace("\n\n", "</p><p>") }}</p></div>
         <h2>Pinned repos</h2>
         <ul>
@@ -123,7 +127,11 @@ def get_template_loader():
         <p>Powered by <a href="https://ganarchy.autistic.space/">GAnarchy</a>. AGPLv3-licensed. <a href="https://cybre.tech/SoniEx2/ganarchy">Source Code</a>.</p>
         <p>
             <a href="{{ base_url|e }}">Main page</a>.
+            {% if ganarchy.fedito != 0 -%}
+            <a href="https://fedi-to.net/register?h={{ ganarchy.fedito }}&protocol=web%2Bganarchy">Register web+ganarchy: URI handler (via Fedi-To)</a>
+            {% else -%}
             <a href="{{ base_url|e }}" onclick="event.preventDefault(); navigator.registerProtocolHandler('web+ganarchy', this.href + '?url=%s', 'GAnarchy');">Register web+ganarchy: URI handler</a>
+            {% endif -%}
             (Makes navigating between GAnarchy instances easier).
         </p>
     </body>