From 0ce0832a2855d1bad52898a585e5f416b9dfd9c4 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Fri, 19 May 2023 10:57:43 -0600 Subject: [PATCH] Add support for BreezeWiki Includes nightly build support for automatically pulling the most up to date instance list. Closes #104 --- .github/workflows/update-instances.yml | 11 +++++++++++ lib/farside.ex | 19 +++++++++++++++---- services-full.json | 15 +++++++++++++++ services.json | 15 +++++++++++++++ 4 files changed, 56 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update-instances.yml b/.github/workflows/update-instances.yml index 0cb2ade..b152420 100644 --- a/.github/workflows/update-instances.yml +++ b/.github/workflows/update-instances.yml @@ -205,6 +205,17 @@ jobs: apply_update + # ============================================================== + # BreezeWiki update + # ============================================================== + curl -s https://docs.breezewiki.com/files/instances.json | \ + jq '[.[] | .instance]' > bw-tmp.json + jq --slurpfile breezewiki breezewiki-tmp.json \ + '(.[] | select(.type == "breezewiki") ) + .instances |= $breezewiki[0]' services-full.json > services-tmp.json + + apply_update + # ============================================================== # TODO: Update instances for other services # ============================================================== diff --git a/lib/farside.ex b/lib/farside.ex index f31920a..aeec6d8 100644 --- a/lib/farside.ex +++ b/lib/farside.ex @@ -1,7 +1,7 @@ defmodule Farside do - @service_prefix Application.fetch_env!(:farside, :service_prefix) - @fallback_suffix Application.fetch_env!(:farside, :fallback_suffix) - @previous_suffix Application.fetch_env!(:farside, :previous_suffix) + @service_prefix Application.compile_env!(:farside, :service_prefix) + @fallback_suffix Application.compile_env!(:farside, :fallback_suffix) + @previous_suffix Application.compile_env!(:farside, :previous_suffix) # Define relation between available services and their parent service. # This enables Farside to redirect with links such as: @@ -19,6 +19,7 @@ defmodule Farside do @imdb_regex ~r/imdb.com|libremdb/ @quora_regex ~r/quora.com|quetre/ @gsearch_regex ~r/google.com\/search|whoogle/ + @fandom_regex ~r/fandom.com|breezewiki/ @parent_services %{ @youtube_regex => ["invidious", "piped"], @@ -33,7 +34,8 @@ defmodule Farside do @tiktok_regex => ["proxitok"], @imdb_regex => ["libremdb"], @quora_regex => ["quetre"], - @gsearch_regex => ["whoogle"] + @gsearch_regex => ["whoogle"], + @fandom_regex => ["breezewiki"] } def get_services_map do @@ -127,6 +129,15 @@ defmodule Farside do else instance end + String.match?(service, @fandom_regex) -> + # Fandom links require the subdomain to be preserved, otherwise the + # requested path won't work. + if String.contains?(service, ".fandom.com") do + wiki = String.replace(service, ".fandom.com", "") + "#{instance}/#{wiki}" + else + instance + end true -> instance end diff --git a/services-full.json b/services-full.json index 9cee4cb..82c108d 100644 --- a/services-full.json +++ b/services-full.json @@ -544,5 +544,20 @@ "https://dumb.lunar.icu", "https://dumb.esmailelbob.xyz" ] + }, + { + "type": "breezewiki", + "test_url": "/undertale/wiki/Hot_Dog...%3F", + "fallback": "https://breezewiki.com", + "instances": [ + "https://breezewiki.com", + "https://antifandom.com", + "https://breezewiki.pussthecat.org", + "https://bw.projectsegfau.lt", + "https://breeze.hostux.net", + "https://bw.artemislena.eu", + "https://breeze.777.tf", + "https://breezewiki.esmailelbob.xyz" + ] } ] diff --git a/services.json b/services.json index 49c8fb3..a3c3fcf 100644 --- a/services.json +++ b/services.json @@ -501,5 +501,20 @@ "https://dumb.lunar.icu", "https://dumb.esmailelbob.xyz" ] + }, + { + "type": "breezewiki", + "test_url": "/undertale/wiki/Hot_Dog...%3F", + "fallback": "https://breezewiki.com", + "instances": [ + "https://breezewiki.com", + "https://antifandom.com", + "https://breezewiki.pussthecat.org", + "https://bw.projectsegfau.lt", + "https://breeze.hostux.net", + "https://bw.artemislena.eu", + "https://breeze.777.tf", + "https://breezewiki.esmailelbob.xyz" + ] } ]