Allow using custom source URLs #421

Merged
floatingghost merged 1 commit from Oneric/akkoma-fe:custom-source into develop 2025-01-05 15:52:16 +00:00
Owner

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
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
to c4301ae802
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2024-10-03 18:11:26 +00:00
Compare
Author
Owner

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
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
to ad3ac7a292
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2024-10-17 22:42:39 +00:00
Compare
Author
Owner

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
@ -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
Owner

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
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
to 42ba77ebf4
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
2024-10-26 14:33:52 +00:00
Compare
floatingghost deleted branch custom-source 2025-01-05 15:52:16 +00:00
Sign in to join this conversation.
No description provided.