From d2d755d7f6a87ea3d23964e2d11bba95533e80fc Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 6 Apr 2024 11:53:31 -0400 Subject: [PATCH] allow alternative hostnames --- README.md | 2 +- boofilsic/settings.py | 11 +- catalog/search/views.py | 2 +- catalog/sites/fedi.py | 5 +- catalog/templates/_item_card.html | 2 +- catalog/templates/item_base.html | 4 +- catalog/templates/podcastepisode.html | 4 +- common/templates/_footer.html | 3 + common/templates/_sidebar.html | 5 +- common/templates/common_libs.html | 5 + common/templatetags/duration.py | 6 + compose.yml | 2 + doc/configuration.md | 17 ++- doc/install.md | 154 +------------------------- mastodon/api.py | 39 +++---- users/templates/users/login.html | 8 +- 16 files changed, 73 insertions(+), 196 deletions(-) diff --git a/README.md b/README.md index efaa332b..fc5579f6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # 🧩 NeoDB -_mark the things you love._ +_mark the things you love_ ![](https://github.com/neodb-social/neodb/actions/workflows/check.yml/badge.svg?branch=main) ![](https://github.com/neodb-social/neodb/actions/workflows/tests.yml/badge.svg?branch=main) diff --git a/boofilsic/settings.py b/boofilsic/settings.py index 23a73e58..4b051871 100644 --- a/boofilsic/settings.py +++ b/boofilsic/settings.py @@ -41,6 +41,8 @@ env = environ.FileAwareEnv( ), # Links in site footer NEODB_SITE_LINKS=(dict, {}), + # Alternative domains + NEODB_ALTERNATIVE_DOMAINS=(list, []), # Default language NEODB_LANGUAGE=(str, "zh-hans"), # Invite only mode @@ -200,12 +202,9 @@ ALLOW_EMAIL_ONLY_ACCOUNT = env.bool( # Allow user to login via any Mastodon/Pleroma sites MASTODON_ALLOW_ANY_SITE = len(MASTODON_ALLOWED_SITES) == 0 -REDIRECT_URIS = env( - "NEODB_LOGIN_MASTODON_REDIRECT_URI", - default=SITE_INFO["site_url"] + "/account/login/oauth", -) -# for sites migrated from previous version, either wipe mastodon client ids or use: -# REDIRECT_URIS = f'{SITE_INFO["site_url"]}/users/OAuth2_login/' +ALTERNATIVE_DOMAINS = env("NEODB_ALTERNATIVE_DOMAINS", default=[]) # type: ignore + +SITE_DOMAINS = [SITE_DOMAIN] + ALTERNATIVE_DOMAINS ENABLE_LOCAL_ONLY = env("NEODB_ENABLE_LOCAL_ONLY") diff --git a/catalog/search/views.py b/catalog/search/views.py index b98b94eb..b9d95404 100644 --- a/catalog/search/views.py +++ b/catalog/search/views.py @@ -126,7 +126,7 @@ def search(request): if keywords.find("://") > 0: host = keywords.split("://")[1].split("/")[0] - if host == settings.SITE_INFO["site_domain"]: + if host in settings.SITE_DOMAINS: return redirect(keywords) site = SiteManager.get_site_by_url(keywords) if site: diff --git a/catalog/sites/fedi.py b/catalog/sites/fedi.py index 95a47ba1..55f222b6 100644 --- a/catalog/sites/fedi.py +++ b/catalog/sites/fedi.py @@ -51,10 +51,7 @@ class FediverseInstance(AbstractSite): val = URLValidator() try: val(url) - if ( - url.split("://", 1)[1].split("/", 1)[0].lower() - == settings.SITE_INFO["site_domain"] - ): + if url.split("://", 1)[1].split("/", 1)[0].lower() in settings.SITE_DOMAINS: # disallow local instance URLs return False return cls.get_json_from_url(url) is not None diff --git a/catalog/templates/_item_card.html b/catalog/templates/_item_card.html index 2e24c059..3d35e244 100644 --- a/catalog/templates/_item_card.html +++ b/catalog/templates/_item_card.html @@ -23,7 +23,7 @@
diff --git a/catalog/templates/item_base.html b/catalog/templates/item_base.html index 7146fe9e..ac11a861 100644 --- a/catalog/templates/item_base.html +++ b/catalog/templates/item_base.html @@ -18,7 +18,7 @@ - + {% if item.has_cover %}{% endif %} @@ -48,7 +48,7 @@
- {{ item.title }}
{% if request.user.is_authenticated and not mark.shelf_type %} diff --git a/catalog/templates/podcastepisode.html b/catalog/templates/podcastepisode.html index efe6a894..ebf6a3fa 100644 --- a/catalog/templates/podcastepisode.html +++ b/catalog/templates/podcastepisode.html @@ -15,9 +15,9 @@ content="0;url={{ item.parent_item.url }}?focus={{ item.uuid }}{% if request.GET.position %}&position={{ request.GET.position }}{% endif %}" /> {% endif %} + content="{{ item.cover_url|default:item.program.cover_image_url }}"> + content="{{ item.cover_url|default:item.program.cover_image_url }}"> {% if item.media_url and item.parent_item %} 源代码
+
+ 这是{{ site_name }}的临时镜像,请尽可能使用原始站点。 +