diff --git a/src/Controller/BrowserController.php b/src/Controller/BrowserController.php index 8fd8a4be9eabff8d0a859128f42c38dfdf6dee21..086ab92b8175ba28ce7489e817f4cc92bc82e8b6 100644 --- a/src/Controller/BrowserController.php +++ b/src/Controller/BrowserController.php @@ -9,7 +9,6 @@ use Drupal\project_browser\InstallReadiness; use Drupal\project_browser\MaintenanceStatus; use Drupal\project_browser\SecurityStatus; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; // cspell:ignore ctools @@ -51,13 +50,11 @@ class BrowserController extends ControllerBase { * @param string|null $id * If viewing a specific project, the project's local ID (as known to the * source plugin). - * @param \Symfony\Component\HttpFoundation\Request $request - * The current request. * * @return array * A render array. */ - public function browse(?string $source, ?string $id, Request $request): array { + public function browse(?string $source, ?string $id): array { $current_sources = $this->enabledSource->getCurrentSources(); $ui_install_enabled = (bool) $this->config('project_browser.admin_settings')->get('allow_ui_install') && is_object($this->installReadiness); @@ -106,7 +103,6 @@ class BrowserController extends ControllerBase { 'project_browser' => [ 'active_plugins' => $active_plugins, 'module_path' => $this->moduleHandler()->getModule('project_browser')->getPath(), - 'origin_url' => $request->getSchemeAndHttpHost() . $request->getBaseUrl(), 'special_ids' => $this->getSpecialIds(), 'sort_options' => $sort_options, 'maintenance_options' => MaintenanceStatus::asOptions(), diff --git a/sveltejs/public/build/bundle.js b/sveltejs/public/build/bundle.js index 2df11e7f959ed862d08e1fe3f179b25d0224a93d..45fe7eac640958ab74619e3ad8eede5e3da73758 100644 Binary files a/sveltejs/public/build/bundle.js and b/sveltejs/public/build/bundle.js differ diff --git a/sveltejs/public/build/bundle.js.map b/sveltejs/public/build/bundle.js.map index eaba9e4dce5aac7c51e0614d0a96e52744220aa0..98f6940379942eb891ddfd46236c3d3f825a0565 100644 Binary files a/sveltejs/public/build/bundle.js.map and b/sveltejs/public/build/bundle.js.map differ diff --git a/sveltejs/src/App.svelte b/sveltejs/src/App.svelte index 04f69fd202b99b16b363033f0b62be6a2e1e2de6..005f3f6795a29832f0e1ead31620cd9b1323d054 100644 --- a/sveltejs/src/App.svelte +++ b/sveltejs/src/App.svelte @@ -3,12 +3,12 @@ import ModulePage from './ModulePage.svelte'; import Loading from './Loading.svelte'; import { activeTab } from './stores'; - import { ORIGIN_URL } from './constants'; const matches = window.location.pathname.match( /\/admin\/modules\/browse\/(.+)/, ); const projectId = matches ? matches[1] : null; + const { Drupal } = window; let loading = true; let project = []; @@ -35,7 +35,7 @@ {#if !projectId} <ProjectBrowser /> {:else} - {#await load(`${ORIGIN_URL}/drupal-org-proxy/project?id=${projectId}`)} + {#await load(Drupal.url(`drupal-org-proxy/project?id=${projectId}`))} {#if loading} <Loading /> {/if} diff --git a/sveltejs/src/Filter.svelte b/sveltejs/src/Filter.svelte index 90887a67abe904ff1e1397b14094cb66e0afbab3..9ad1d58025f66389f091513dc1dfcd0b2e79e3a3 100644 --- a/sveltejs/src/Filter.svelte +++ b/sveltejs/src/Filter.svelte @@ -7,7 +7,6 @@ } from './stores'; import MediaQuery from './MediaQuery.svelte'; import { normalizeOptions, shallowCompare } from './util'; - import { ORIGIN_URL } from './constants'; const { Drupal } = window; const dispatch = createEventDispatcher(); @@ -29,7 +28,7 @@ } async function fetchAllCategories() { - const response = await fetch(`${ORIGIN_URL}/drupal-org-proxy/categories`); + const response = await fetch(Drupal.url('drupal-org-proxy/categories')); if (response.ok) { return response.json(); } diff --git a/sveltejs/src/ModulePage.svelte b/sveltejs/src/ModulePage.svelte index a70e369b5f0be8ae46f44dad467ae4b2589e675b..f16f242580e5335f58c81485502624dd4575bb2b 100644 --- a/sveltejs/src/ModulePage.svelte +++ b/sveltejs/src/ModulePage.svelte @@ -3,7 +3,6 @@ import ActionButton from './Project/ActionButton.svelte'; import Image from './Project/Image.svelte'; import ImageCarousel from './ImageCarousel.svelte'; - import { ORIGIN_URL } from './constants'; import { moduleCategoryFilter, page } from './stores'; import ProjectIcon from './Project/ProjectIcon.svelte'; import { numberFormatter } from './util'; @@ -15,7 +14,7 @@ function filterByCategory(id) { $moduleCategoryFilter = [id]; $page = 0; - window.location.href = `${ORIGIN_URL}/admin/modules/browse`; + window.location.href = Drupal.url('admin/modules/browse'); } onMount(() => { @@ -28,7 +27,7 @@ }); </script> -<a class="action-link" href="{ORIGIN_URL}/admin/modules/browse"> +<a class="action-link" href={Drupal.url('admin/modules/browse')}> <span aria-hidden="true">〈 </span> {Drupal.t('Back to Browsing')} </a> diff --git a/sveltejs/src/Project/ActionButton.svelte b/sveltejs/src/Project/ActionButton.svelte index 9c509911543baba74ba4850a76ce4f5c801dc212..963f314c0cb4f5b86fd7d03e55191f5251e645a4 100644 --- a/sveltejs/src/Project/ActionButton.svelte +++ b/sveltejs/src/Project/ActionButton.svelte @@ -1,6 +1,6 @@ <script> import { onMount } from 'svelte'; - import { ORIGIN_URL, PACKAGE_MANAGER } from '../constants'; + import { PACKAGE_MANAGER } from '../constants'; import Loading from '../Loading.svelte'; import { openPopup, getCommandsPopupMessage } from '../popup'; import AddInstallButton from './AddInstallButton.svelte'; @@ -32,7 +32,9 @@ * Return is not used, but is a promise due to this being async. */ const showStatus = async (initiate = false) => { - const url = `${ORIGIN_URL}/admin/modules/project_browser/install_in_progress/${project.id}`; + const url = Drupal.url( + `admin/modules/project_browser/install_in_progress/${project.id}`, + ); // /** diff --git a/sveltejs/src/Project/AddInstallButton.svelte b/sveltejs/src/Project/AddInstallButton.svelte index c3b445d4c9cf63859ada11a5772ce54139eb7e56..c5ab0edf1af9d20485a9f1d2ea0616d6502b047d 100644 --- a/sveltejs/src/Project/AddInstallButton.svelte +++ b/sveltejs/src/Project/AddInstallButton.svelte @@ -1,6 +1,6 @@ <script> import { openPopup } from '../popup'; - import { ORIGIN_URL, PACKAGE_MANAGER } from '../constants'; + import { PACKAGE_MANAGER } from '../constants'; import ProjectButtonBase from './ProjectButtonBase.svelte'; export let project; @@ -59,7 +59,9 @@ */ async function activateProject() { loading = true; - const url = `${ORIGIN_URL}/admin/modules/project_browser/activate/${project.id}`; + const url = Drupal.url( + `admin/modules/project_browser/activate/${project.id}`, + ); const installResponse = await fetch(url); if (!installResponse.ok) { handleError(installResponse); @@ -97,7 +99,9 @@ */ async function doRequests() { loading = true; - const beginInstallUrl = `${ORIGIN_URL}/admin/modules/project_browser/install-begin/${project.id}`; + const beginInstallUrl = Drupal.url( + `admin/modules/project_browser/install-begin/${project.id}`, + ); const beginInstallResponse = await fetch(beginInstallUrl); if (!beginInstallResponse.ok) { await handleError(beginInstallResponse); @@ -108,10 +112,12 @@ // with their own endpoint. When one stage completes, the next one is // requested. const installSteps = [ - `${ORIGIN_URL}/admin/modules/project_browser/install-require/${project.id}`, - `${ORIGIN_URL}/admin/modules/project_browser/install-apply`, - `${ORIGIN_URL}/admin/modules/project_browser/install-post_apply`, - `${ORIGIN_URL}/admin/modules/project_browser/install-destroy`, + Drupal.url( + `admin/modules/project_browser/install-require/${project.id}`, + ), + Drupal.url('admin/modules/project_browser/install-apply'), + Drupal.url('admin/modules/project_browser/install-post_apply'), + Drupal.url('admin/modules/project_browser/install-destroy'), ]; // eslint-disable-next-line no-restricted-syntax,guard-for-in diff --git a/sveltejs/src/Project/Project.svelte b/sveltejs/src/Project/Project.svelte index bc0fd76b5b78b5b65b92751c90424cdee9ffcad0..79370b57450bb7dc2bd99f6ec2175eb6d6e12db4 100644 --- a/sveltejs/src/Project/Project.svelte +++ b/sveltejs/src/Project/Project.svelte @@ -7,7 +7,7 @@ import Categories from './Categories.svelte'; import ProjectIcon from './ProjectIcon.svelte'; import { focusedElement, mediaQueryValues } from '../stores'; - import { FULL_MODULE_PATH, ORIGIN_URL } from '../constants'; + import { FULL_MODULE_PATH } from '../constants'; const { Drupal } = window; @@ -33,7 +33,7 @@ <a id="{project.project_machine_name}_title" class="pb-project__link" - href="{ORIGIN_URL}/admin/modules/browse/{project.id}" + href={Drupal.url(`admin/modules/browse/${project.id}`)} rel="noreferrer">{project.title}</a > </h3> diff --git a/sveltejs/src/ProjectBrowser.svelte b/sveltejs/src/ProjectBrowser.svelte index fd78621170728471866b81bf0e221bb39317535b..ed881acb0730070eeb003a24eb89b017bca24712 100644 --- a/sveltejs/src/ProjectBrowser.svelte +++ b/sveltejs/src/ProjectBrowser.svelte @@ -28,7 +28,6 @@ ALL_VALUES_ID, DEFAULT_SOURCE_ID, CURRENT_SOURCES_KEYS, - ORIGIN_URL, FULL_MODULE_PATH, SORT_OPTIONS, ACTIVE_PLUGINS, @@ -103,7 +102,10 @@ JSON.stringify($categoryCheckedTrack), ); } - const url = `${ORIGIN_URL}/drupal-org-proxy/project?${searchParams.toString()}`; + + const url = Drupal.url( + `drupal-org-proxy/project?${searchParams.toString()}`, + ); const res = await fetch(url); if (res.ok) { diff --git a/sveltejs/src/constants.js b/sveltejs/src/constants.js index 67326af8d3cd0994c2e84b4074b089f65a1a2e88..f2aace5f4b59e06c780ba00bef8292f43a06b3fc 100644 --- a/sveltejs/src/constants.js +++ b/sveltejs/src/constants.js @@ -14,8 +14,7 @@ export const DEFAULT_SOURCE_ID = drupalSettings.project_browser.default_plugin_id; export const CURRENT_SOURCES_KEYS = drupalSettings.project_browser.current_sources_keys; -export const ORIGIN_URL = drupalSettings.project_browser.origin_url; -export const FULL_MODULE_PATH = `${ORIGIN_URL}/${drupalSettings.project_browser.module_path}`; +export const FULL_MODULE_PATH = Drupal.url(drupalSettings.project_browser.module_path); export const DARK_COLOR_SCHEME = matchMedia('(forced-colors: active)').matches && matchMedia('(prefers-color-scheme: dark)').matches;