From 8390458c2f5473135c5019e9c09d4eff7189848c Mon Sep 17 00:00:00 2001 From: Mayel de Borniol Date: Thu, 3 Oct 2024 12:54:19 +0100 Subject: [PATCH] https://github.com/bonfire-networks/bonfire-app/issues/126 and https://github.com/bonfire-networks/bonfire-app/issues/1031 --- flavours/classic/config/activity_pub.exs | 8 +++- flavours/classic/config/bonfire_search.exs | 2 +- ...re.UI.Common.OpenExternalLinkLive.hooks.js | 38 +++++++++++++++++++ .../config/flavour_assets/hooks/index.js | 30 ++++++++------- flavours/classic/config/test.exs | 6 ++- justfile | 6 ++- 6 files changed, 70 insertions(+), 20 deletions(-) create mode 100644 flavours/classic/config/flavour_assets/hooks/Bonfire.UI.Common.OpenExternalLinkLive.hooks.js diff --git a/flavours/classic/config/activity_pub.exs b/flavours/classic/config/activity_pub.exs index ffc170c6fb1..28dde1b9a5f 100644 --- a/flavours/classic/config/activity_pub.exs +++ b/flavours/classic/config/activity_pub.exs @@ -35,7 +35,13 @@ config :activity_pub, :mrf_simple, config :http_signatures, adapter: ActivityPub.Safety.Signatures # config :tesla, adapter: Tesla.Adapter.Hackney -config :tesla, :adapter, {Tesla.Adapter.Finch, name: Bonfire.Finch} +config :tesla, + :adapter, + {Tesla.Adapter.Finch, + name: Bonfire.Finch, + pools: %{ + :default => [conn_opts: [case_sensitive_headers: true]] + }} config :activity_pub, :http, proxy_url: nil, diff --git a/flavours/classic/config/bonfire_search.exs b/flavours/classic/config/bonfire_search.exs index b4fad2f74ab..d27ff76f173 100644 --- a/flavours/classic/config/bonfire_search.exs +++ b/flavours/classic/config/bonfire_search.exs @@ -5,7 +5,7 @@ config :bonfire_search, adapter: Bonfire.Search.Meili # for use by API client -config :tesla, :adapter, {Tesla.Adapter.Finch, name: Bonfire.Finch} +# config :tesla, :adapter, {Tesla.Adapter.Finch, name: Bonfire.Finch} # config :tesla, adapter: Tesla.Adapter.Hackney config :phoenix, :format_encoders, json: Jason config :phoenix, :json_library, Jason diff --git a/flavours/classic/config/flavour_assets/hooks/Bonfire.UI.Common.OpenExternalLinkLive.hooks.js b/flavours/classic/config/flavour_assets/hooks/Bonfire.UI.Common.OpenExternalLinkLive.hooks.js new file mode 100644 index 00000000000..40b2e3f330b --- /dev/null +++ b/flavours/classic/config/flavour_assets/hooks/Bonfire.UI.Common.OpenExternalLinkLive.hooks.js @@ -0,0 +1,38 @@ +/* +This file was generated by the Surface compiler. +*/ + + +let LinksClickPrompt = { + mounted() { + this.el.addEventListener("click", e => { + const link = e.target.closest('a'); + if (!link) return; + + e.preventDefault(); + const url = window.prompt("Confirm or edit URL to follow:", link.href); + + if (url) { + window.location.href = url; + } + }); + } +}; + +let LinksDangerModal = { + mounted() { + this.el.addEventListener("click", e => { + const link = e.target.closest('a'); + if (!link) return; + + const url = link.href; + + if (url && url.indexOf("/") != 0) { + e.preventDefault(); + this.pushEvent("Bonfire.UI.Common.ReusableModalLive:prompt_external_link", { url: url }) + } + }); + } +}; + +export { LinksClickPrompt, LinksDangerModal }; diff --git a/flavours/classic/config/flavour_assets/hooks/index.js b/flavours/classic/config/flavour_assets/hooks/index.js index 287625429c7..db828fd4863 100644 --- a/flavours/classic/config/flavour_assets/hooks/index.js +++ b/flavours/classic/config/flavour_assets/hooks/index.js @@ -13,25 +13,27 @@ function ns(hooks, nameSpace) { import * as c1 from "./Bonfire.Editor.Milkdown.hooks.js" import * as c2 from "./Bonfire.UI.Common.ViewCodeLive.hooks.js" import * as c3 from "./Bonfire.UI.Common.LazyImage.hooks.js" -import * as c4 from "./Bonfire.UI.Common.PreviewContentLive.hooks.js" -import * as c5 from "./Bonfire.UI.Common.NotificationLive.hooks.js" -import * as c6 from "./Bonfire.UI.Common.LoadMoreLive.hooks.js" -import * as c7 from "./Bonfire.UI.Common.ChangeLocaleLive.hooks.js" -import * as c8 from "./Bonfire.UI.Common.ChangeThemesLive.hooks.js" -import * as c9 from "./Bonfire.UI.Common.ComposerLive.hooks.js" -import * as c10 from "./Bonfire.UI.Social.Activity.DateAgoLive.hooks.js" +import * as c4 from "./Bonfire.UI.Common.OpenExternalLinkLive.hooks.js" +import * as c5 from "./Bonfire.UI.Common.PreviewContentLive.hooks.js" +import * as c6 from "./Bonfire.UI.Common.NotificationLive.hooks.js" +import * as c7 from "./Bonfire.UI.Common.LoadMoreLive.hooks.js" +import * as c8 from "./Bonfire.UI.Common.ChangeLocaleLive.hooks.js" +import * as c9 from "./Bonfire.UI.Common.ChangeThemesLive.hooks.js" +import * as c10 from "./Bonfire.UI.Common.ComposerLive.hooks.js" +import * as c11 from "./Bonfire.UI.Social.Activity.DateAgoLive.hooks.js" let hooks = Object.assign( ns(c1, "Bonfire.Editor.Milkdown"), ns(c2, "Bonfire.UI.Common.ViewCodeLive"), ns(c3, "Bonfire.UI.Common.LazyImage"), - ns(c4, "Bonfire.UI.Common.PreviewContentLive"), - ns(c5, "Bonfire.UI.Common.NotificationLive"), - ns(c6, "Bonfire.UI.Common.LoadMoreLive"), - ns(c7, "Bonfire.UI.Common.ChangeLocaleLive"), - ns(c8, "Bonfire.UI.Common.ChangeThemesLive"), - ns(c9, "Bonfire.UI.Common.ComposerLive"), - ns(c10, "Bonfire.UI.Social.Activity.DateAgoLive") + ns(c4, "Bonfire.UI.Common.OpenExternalLinkLive"), + ns(c5, "Bonfire.UI.Common.PreviewContentLive"), + ns(c6, "Bonfire.UI.Common.NotificationLive"), + ns(c7, "Bonfire.UI.Common.LoadMoreLive"), + ns(c8, "Bonfire.UI.Common.ChangeLocaleLive"), + ns(c9, "Bonfire.UI.Common.ChangeThemesLive"), + ns(c10, "Bonfire.UI.Common.ComposerLive"), + ns(c11, "Bonfire.UI.Social.Activity.DateAgoLive") ) export default hooks diff --git a/flavours/classic/config/test.exs b/flavours/classic/config/test.exs index 7e5b5e08b23..14cad7c80c3 100644 --- a/flavours/classic/config/test.exs +++ b/flavours/classic/config/test.exs @@ -66,8 +66,10 @@ config :bonfire_umbrella, Bonfire.Common.Repo, log: false, stacktrace: true -config :tesla, - adapter: if(federate?, do: {Tesla.Adapter.Finch, name: Bonfire.Finch}, else: Tesla.Mock) +if !federate? do + config :tesla, + adapter: Tesla.Mock +end #  enable federation in tests, since we're either using mocks or integration testing with TEST_INSTANCE config :activity_pub, :instance, federating: true diff --git a/justfile b/justfile index 306d6f5febf..7f908d1ebdf 100644 --- a/justfile +++ b/justfile @@ -611,11 +611,11 @@ test-federation-in-extensions *args=ap_ext: test-federation-dance-positions just test-watch $@ test-federation-dance *args='': test-federation-dance-positions - TEST_INSTANCE=yes just test --only test_instance $@ + TEST_INSTANCE=yes HOSTNAME=localhost just test --only test_instance $@ just test-federation-dance-positions test-federation-dance-unsigned *args='': test-federation-dance-positions - ACCEPT_UNSIGNED_ACTIVITIES=1 TEST_INSTANCE=yes just test --only test_instance $@ + ACCEPT_UNSIGNED_ACTIVITIES=1 TEST_INSTANCE=yes HOSTNAME=localhost just test --only test_instance $@ just test-federation-dance-positions test-federation-dance-positions: @@ -633,6 +633,7 @@ load_testing: # Create or reset the test DB test-db-reset: init db-pre-migrations {{ if WITH_DOCKER == "total" { "just docker-compose run -e MIX_ENV=test web mix ecto.drop --force" } else { "MIX_ENV=test just mix ecto.drop --force" } }} + {{ if WITH_DOCKER == "total" { "just docker-compose run -e MIX_ENV=test web mix ecto.drop --force -r Bonfire.Common.TestInstanceRepo" } else { "MIX_ENV=test just mix ecto.drop --force -r Bonfire.Common.TestInstanceRepo" } }} #### RELEASE RELATED COMMANDS (Docker-specific for now) #### @@ -970,6 +971,7 @@ nix-db-init: (nix-db "start") tunnel: tunnel-localhost-run @tunnel-localhost-run: + echo "NOTE: you'll need to copy the generated domain name that will be printed below into HOSTNAME in your .env" ssh -R 80:localhost:4000 localhost.run # this requires `cargo install tunnelto` (the homebrew version of tunnelto doesn't work)