diff --git a/.env.example b/.env.example index 5bc96d6d..84a073f3 100644 --- a/.env.example +++ b/.env.example @@ -37,21 +37,23 @@ MOBILE_APP_ANDROID_PACKAGE=life.doxa.pray # Mapbox (used by the prayer map on /pray) NUXT_PUBLIC_MAPBOX_TOKEN=your-mapbox-public-token -# The plugin-studio branch's two addresses, per deployment. Both are REQUIRED, and both are read by the +# The subdomain branch's two addresses, per deployment. Both are REQUIRED, and both are read by the # server at REQUEST time (server/utils/dx-runtime.ts). They are never baked into a build, so one build # serves any deployment. Changing them needs a restart, not a rebuild. There is no default host: when # one is unset, the pages that need it say which setting is missing. # -# The Research Gallery: the public Plugin Studio on its own subdomain. The menu's Research item, every -# in-page gallery link and the /regions index go here (through this site's /research-gallery). +# The Research Gallery: the research site on its own subdomain, served by the team's dx-maps container. +# The menu's Research item, every in-page gallery link and the /regions index go here (through this +# site's /research-gallery). # VPS: NUXT_PUBLIC_RESEARCH_GALLERY_URL=https://research./ -# laptop: NUXT_PUBLIC_RESEARCH_GALLERY_URL=http://research.localhost:4616/ +# laptop: NUXT_PUBLIC_RESEARCH_GALLERY_URL=http://research.localhost:4615/ NUXT_PUBLIC_RESEARCH_GALLERY_URL= # -# The dx-maps tree this site's maps load from: that subdomain's published /cdn. It must send -# Access-Control-Allow-Origin for the tree (the container does). -# VPS: NUXT_PUBLIC_DX_MAPS_BASE=https://research./cdn/dx-maps -# laptop: NUXT_PUBLIC_DX_MAPS_BASE=http://research.localhost:4616/cdn/dx-maps +# The dx-maps tree this site's maps load from: the container's published tree, which the research +# subdomain serves at /dx-maps. It must send Access-Control-Allow-Origin for the tree (the container +# does). The Studio's own host serves the same tree at /cdn/dx-maps. +# VPS: NUXT_PUBLIC_DX_MAPS_BASE=https://research./dx-maps +# laptop: NUXT_PUBLIC_DX_MAPS_BASE=http://research.localhost:4615/dx-maps NUXT_PUBLIC_DX_MAPS_BASE= # Cloudflare Turnstile diff --git a/DX-MAPS-GALLERY.md b/DX-MAPS-GALLERY.md index 0684a928..f76ff4c5 100644 --- a/DX-MAPS-GALLERY.md +++ b/DX-MAPS-GALLERY.md @@ -43,28 +43,34 @@ bun install bun run dev ``` -Then open (Nuxt prints the port if 3000 is taken). No database -or `.env` is needed for this page. Without `DATABASE_URL`, the dev server only logs -"skipping migrations". +Then open (Nuxt prints the port if 3000 is taken). The maps need +one setting, the published tree they load from: `NUXT_PUBLIC_DX_MAPS_BASE` (see *Deployment method* +below; any published tree works, for example `https://research./dx-maps`). Without it, each map +says which setting is missing. No database is needed for this page: without `DATABASE_URL`, the dev +server only logs "skipping migrations". - Arabic: - Open a specific view: `/research/?tab=prayer-map` (also `research-map-plus-grid`, `regions-dashboard`, `upg-100`, and so on). - Share and embed links in the maps point at this site's own `/dx-maps/` pages. -- To run it against a **local** dx-maps, and to try all three ways a site can take the gallery (drop-in, - CDN, subdomain) with the exact ports and settings: [documentation/LAPTOP-6WAY.md](documentation/LAPTOP-6WAY.md). +- To run it against a **local** dx-maps, and to try both ways a site can take the gallery (drop-in and + subdomain) with the exact ports and settings: [documentation/LAPTOP-6WAY.md](documentation/LAPTOP-6WAY.md). -## Deployment method: the Research Gallery as the public Plugin Studio (this branch, research-gallery-plugin-studio) +## Deployment method: the Research Gallery on its own subdomain (this branch, research-gallery-subdomain) -The research subdomain runs the dx-maps container in its public mode: the **Plugin Studio**, open to -everyone, with every research map, dashboard and list, and its published `/cdn` of production maps. -This site sends readers there and loads its own maps from there. Each deployment sets two addresses, -read by the server at **request time** and never baked into a build: +The research subdomain is the **research site**, served by the team's dx-maps container (the same +container runs the signed-in Plugin Studio and PocketBase, and publishes the maps). It carries every +research map, dashboard and list. This site sends readers there and loads its own maps from the +container's published tree. Each deployment sets two addresses, read by the server at **request +time** and never baked into a build: | Setting | What it is | VPS | Laptop | |---|---|---|---| -| `NUXT_PUBLIC_RESEARCH_GALLERY_URL` | the public Plugin Studio | `https://research./` | `http://research.localhost:4616/` | -| `NUXT_PUBLIC_DX_MAPS_BASE` | its published tree, where this site's maps load from | `https://research./cdn/dx-maps` | `http://research.localhost:4616/cdn/dx-maps` | +| `NUXT_PUBLIC_RESEARCH_GALLERY_URL` | the research site | `https://research./` | `http://research.localhost:4615/` | +| `NUXT_PUBLIC_DX_MAPS_BASE` | the container's published tree, where this site's maps load from | `https://research./dx-maps` | `http://research.localhost:4615/dx-maps` | + +The research subdomain serves the published tree at `/dx-maps`, and the Studio's own host serves the +same tree at `/cdn/dx-maps`. Either works; both send CORS for it. **Why request time.** About 4,000 pages are prerendered, and a prerendered page carries the build's runtime config. An address read there would be baked into the build, which is how the CDN branch diff --git a/app/composables/useDoxaMap.ts b/app/composables/useDoxaMap.ts index 637b366c..6ed4bd8f 100644 --- a/app/composables/useDoxaMap.ts +++ b/app/composables/useDoxaMap.ts @@ -9,7 +9,7 @@ const MAPBOX_JS = 'https://api.mapbox.com/mapbox-gl-js/v3.24.0/mapbox-gl.js' const MAPBOX_GEOCODER_JS = 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.min.js' // Map of bundle keys → bundles in the dx-maps build tree: the deployment's NUXT_PUBLIC_DX_MAPS_BASE (the -// public Plugin Studio's /cdn), asked from this site's server at runtime (loadDxRuntime) because a +// team container's published tree), asked from this site's server at runtime (loadDxRuntime) because a // prerendered page cannot carry it. Each bundle registers its own custom element (, // ). const BUNDLES = { diff --git a/app/composables/useResearchGalleryUrl.ts b/app/composables/useResearchGalleryUrl.ts index c29eae87..caa81c7d 100644 --- a/app/composables/useResearchGalleryUrl.ts +++ b/app/composables/useResearchGalleryUrl.ts @@ -1,8 +1,8 @@ -// The Research Gallery lives on its own subdomain (the public Plugin Studio), so every link that -// went to this site's /research or /regions page goes there instead. The link is this site's own -// /research-gallery, which the server redirects to the deployment's gallery -// (NUXT_PUBLIC_RESEARCH_GALLERY_URL, server/routes/research-gallery.get.ts). A prerendered page -// therefore names no deployment's host. A view opens with ?tab= (for example +// The Research Gallery lives on its own subdomain (the research site, served by the team's dx-maps +// container), so every link that went to this site's /research or /regions page goes there instead. +// The link is this site's own /research-gallery, which the server redirects to the deployment's +// gallery (NUXT_PUBLIC_RESEARCH_GALLERY_URL, server/routes/research-gallery.get.ts). A prerendered +// page therefore names no deployment's host. A view opens with ?tab= (for example // 'regions-dashboard'). The reader's language travels as ?lang=, since the gallery lays // Arabic out right-to-left and an Arabic reader should not land on the English gallery. The // /research and /regions detail pages are kept; nothing links to them any more. diff --git a/app/pages/research/index.vue b/app/pages/research/index.vue index 3fb48668..9c0a7973 100644 --- a/app/pages/research/index.vue +++ b/app/pages/research/index.vue @@ -5,7 +5,7 @@ // SHOW_LEGACY_RESEARCH, so the previous page returns by flipping one constant. // // The gallery is a web component served from the deployment's dx-maps tree (NUXT_PUBLIC_DX_MAPS_BASE, -// the public Plugin Studio's /cdn), asked from this site's server at runtime: this page is prerendered, +// the team container's published tree), asked from this site's server at runtime: this page is prerendered, // and a prerendered page cannot carry a deployment's address. It reads its manifest and every child map // from the same tree. The menu's Research item goes to the gallery's own subdomain instead; this page // is kept, unlinked. See DX-MAPS-GALLERY.md at the repo root. diff --git a/scripts/check-runtime-origins.ts b/scripts/check-runtime-origins.ts index 99619a12..019b2174 100644 --- a/scripts/check-runtime-origins.ts +++ b/scripts/check-runtime-origins.ts @@ -1,8 +1,8 @@ #!/usr/bin/env bun // check-runtime-origins: no deployment's address is baked into this site. // -// The plugin-studio branch sends readers to the Research Gallery and loads its maps from the gallery's -// /cdn. Both addresses differ per deployment, so the server reads them at REQUEST time +// This site sends readers to the Research Gallery and loads its maps from the tree the gallery's +// subdomain publishes. Both addresses differ per deployment, so the server reads them at REQUEST time // (server/utils/dx-runtime.ts), and pages ask /api/dx-runtime or link through /research-gallery. About // 4,000 pages are prerendered, and a prerendered page carries the build's config. An address that // reaches nuxt.config's runtimeConfig, or a page, is baked into the build, which is how the CDN branch diff --git a/server/utils/dx-runtime.ts b/server/utils/dx-runtime.ts index 7644534d..6ff3cfd5 100644 --- a/server/utils/dx-runtime.ts +++ b/server/utils/dx-runtime.ts @@ -1,12 +1,14 @@ /** - * The two per-deployment addresses of the plugin-studio branch, read from the server's environment + * The two per-deployment addresses of the subdomain branch, read from the server's environment * at REQUEST time: * - * NUXT_PUBLIC_RESEARCH_GALLERY_URL the Research Gallery: the public Plugin Studio on its own - * subdomain (https://research./). The Research menu item, - * every in-page gallery link and the /regions index go there. - * NUXT_PUBLIC_DX_MAPS_BASE the dx-maps tree this site's maps load from: that subdomain's - * published /cdn (https://research./cdn/dx-maps). + * NUXT_PUBLIC_RESEARCH_GALLERY_URL the Research Gallery: the research site on its own subdomain, + * served by the team's dx-maps container + * (https://research./). The Research menu item, every + * in-page gallery link and the /regions index go there. + * NUXT_PUBLIC_DX_MAPS_BASE the dx-maps tree this site's maps load from: the container's + * published tree, which that subdomain serves at /dx-maps + * (https://research./dx-maps). * * Why not runtimeConfig.public: about 4,000 pages are PRERENDERED at build time, and a prerendered * page carries the build's runtime config in its payload. An address read there is baked into the