Allow using custom source URLs #421

Open
Oneric wants to merge 1 commit from Oneric/akkoma-fe:custom-source into develop
Member

Some instances carry a few patches, most often frontend patches, which atm results in broken source links which makes it hard to determine what the patches are and potentially adopting them (and technically may also violate the AGPL licence)
With a convenient way to point to the correct repo such broken links will hopefully become rarer

To avoid having to specify the default URLs twice values are only set if fetched configs actually defined it

Some instances carry a few patches, most often frontend patches, which atm results in broken source links which makes it hard to determine what the patches are and potentially adopting them *(and technically may also violate the AGPL licence)* With a convenient way to point to the correct repo such broken links will hopefully become rarer To avoid having to specify the default URLs twice values are only set if fetched configs actually defined it
Oneric force-pushed custom-source from 9c0b9999d9 to c4301ae802 2024-10-03 18:11:26 +00:00 Compare
Author
Member

I tried teaching admin-fe about this with this backend diff:

diff --git a/config/description.exs b/config/description.exs
index b69478fdb..63113439a 100644
--- a/config/description.exs
+++ b/config/description.exs
@@ -1194,7 +1194,9 @@
             showInstanceSpecificPanel: false,
             subjectLineBehavior: "email",
             theme: "pleroma-dark",
-            webPushNotifications: false
+            webPushNotifications: false,
+            backendCommitUrl: nil,
+            frontendCommitUrl: nil
           }
         ],
         children: [
@@ -1398,6 +1400,18 @@
             label: "Stop Gifs",
             type: :boolean,
             description: "Whether to pause animated images until they're hovered on"
+          },
+          %{
+            key: :backendCommitUrl,
+            label: "Backend Commit URL",
+            type: :string,
+            description: "URL prefix for backend commit hashes"
+          },
+          %{
+            key: :frontendCommitUrl,
+            label: "Frontend Commit URL",
+            type: :string,
+            description: "URL prefix for frontend commit hashes"
           }
         ]
       },

, however this causes admin-fe to set those fields to an empty string instead of leaving it undefined, or at least null. Not sure if there’s a better way to deal with this than adding checks for those here in the frontend code.
For regular options admin-fe has the option to completely remove it from settings, but this doesn't seem to work for the frontend config map entries; only the entire map can be deleted

I tried teaching admin-fe about this with this backend diff: ```diff diff --git a/config/description.exs b/config/description.exs index b69478fdb..63113439a 100644 --- a/config/description.exs +++ b/config/description.exs @@ -1194,7 +1194,9 @@ showInstanceSpecificPanel: false, subjectLineBehavior: "email", theme: "pleroma-dark", - webPushNotifications: false + webPushNotifications: false, + backendCommitUrl: nil, + frontendCommitUrl: nil } ], children: [ @@ -1398,6 +1400,18 @@ label: "Stop Gifs", type: :boolean, description: "Whether to pause animated images until they're hovered on" + }, + %{ + key: :backendCommitUrl, + label: "Backend Commit URL", + type: :string, + description: "URL prefix for backend commit hashes" + }, + %{ + key: :frontendCommitUrl, + label: "Frontend Commit URL", + type: :string, + description: "URL prefix for frontend commit hashes" } ] }, ``` , however this causes admin-fe to set those fields to an empty string instead of leaving it undefined, or at least `null`. Not sure if there’s a better way to deal with this than adding checks for those here in the frontend code. For regular options admin-fe has the option to completely remove it from settings, but this doesn't seem to work for the frontend config map entries; only the entire map can be deleted
Oneric force-pushed custom-source from c4301ae802 to ad3ac7a292 2024-10-17 22:42:39 +00:00 Compare
Author
Member

Empty string, null and undefined all are falsy values in JS, so the check is actually quite simple. The NSFW censor image also relies on this using an empty string to invoke the default fallback, so it seems there’s no cleaner way with admin-fe. Changed check accordingly to let admin-fe work with these new settings

Empty string, `null` and `undefined` all are falsy values in JS, so the check is actually quite simple. The NSFW censor image also relies on this using an empty string to invoke the default fallback, so it seems there’s no cleaner way with admin-fe. Changed check accordingly to let admin-fe work with these new settings
floatingghost reviewed 2024-10-26 03:45:18 +00:00
@ -13,4 +12,3 @@
},
computed: {
frontendVersionLink () {
return pleromaFeCommitUrl + this.frontendVersion

we might want to consider using some for of urljoin function, because this makes it 100% mandatory to have the trailing slash in the config

we might want to consider using some for of `urljoin` function, because this makes it 100% mandatory to have the trailing slash in the config
Author
Member

done with URL.parse() which won't throw exceptions itself, and since i wasn’t sure if a null might lead to exceptions later it gets stubbed out for an invalid config

done with `URL.parse()` which won't throw exceptions itself, and since i wasn’t sure if a `null` might lead to exceptions later it gets stubbed out for an invalid config
Oneric marked this conversation as resolved
Oneric force-pushed custom-source from ad3ac7a292 to 42ba77ebf4 2024-10-26 14:33:52 +00:00 Compare
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u custom-source:Oneric-custom-source
git checkout Oneric-custom-source
Sign in to join this conversation.
No description provided.