Add legacy URL handling and update environment configurations
This commit is contained in:
parent
19f0d65896
commit
9f56dfba1d
11 changed files with 79 additions and 28 deletions
|
|
@ -1,10 +1,16 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { legacyAsset } from '../legacyAssets.js';
|
||||
import { legacyUrl } from '../legacyUrls.js';
|
||||
|
||||
const logoUrl = legacyAsset('/images/layout/regalami-un-sorriso-ets-640.png');
|
||||
const facebookUrl = legacyAsset('/images/FB-f-Logo__blue_29.png');
|
||||
const donateUrl = legacyAsset('/images/btn_donateCC_LG.gif');
|
||||
const legacyHomeUrl = legacyUrl('/');
|
||||
const associationUrl = legacyUrl('/associazione.jsp');
|
||||
const photoUrl = legacyUrl('/gallery2.php');
|
||||
const archiveUrl = legacyUrl('/gallery2.php');
|
||||
const donatePageUrl = legacyUrl('/dettaglio_clienti-it.html');
|
||||
const isMenuOpen = ref(false);
|
||||
|
||||
function toggleMenu() {
|
||||
|
|
@ -21,7 +27,7 @@ function closeMenu() {
|
|||
<a id="top"></a>
|
||||
<nav class="navbar fixed-top navbar-expand-lg navbar-light bg-white fixed-top">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="http://localhost:8080/faceai_simulator.php?raceId=101&lang=it">
|
||||
<a class="navbar-brand" :href="legacyHomeUrl">
|
||||
<img :src="logoUrl" alt="Regalami Un Sorriso ETS" width="100" />
|
||||
</a>
|
||||
<button
|
||||
|
|
@ -37,19 +43,19 @@ function closeMenu() {
|
|||
<div :class="['collapse', 'navbar-collapse', { show: isMenuOpen }]" id="navbarResponsive">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="http://localhost:8080/index.jsp" @click="closeMenu">Home</a>
|
||||
<a class="nav-link" :href="legacyHomeUrl" @click="closeMenu">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="http://localhost:8080/associazione.jsp" @click="closeMenu">Associazione</a>
|
||||
<a class="nav-link" :href="associationUrl" @click="closeMenu">Associazione</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="http://localhost:8080/faceai_simulator.php?raceId=101&lang=it" @click="closeMenu">Foto</a>
|
||||
<a class="nav-link active" :href="photoUrl" @click="closeMenu">Foto</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link btn btn-sm btn-warning" href="http://localhost:8080/gallery2.php" @click="closeMenu">Archivio</a>
|
||||
<a class="nav-link btn btn-sm btn-warning" :href="archiveUrl" @click="closeMenu">Archivio</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="http://localhost:8080/dettaglio_clienti-it.html" @click="closeMenu">
|
||||
<a :href="donatePageUrl" @click="closeMenu">
|
||||
<img :src="donateUrl" border="0" alt="PayPal" />
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { legacyUrl } from '../legacyUrls.js';
|
||||
|
||||
const copy = {
|
||||
it: {
|
||||
|
|
@ -114,8 +115,8 @@ const knownServerMessages = {
|
|||
'Choose a selfie before starting the search.': 'chooseSelfie'
|
||||
};
|
||||
|
||||
const simulatorUrl = 'http://localhost:8080/faceai_simulator.php?raceId=101&lang=it';
|
||||
const legacyHomeUrl = 'http://localhost:8080/index.jsp';
|
||||
const simulatorUrl = legacyUrl('/faceai_simulator.php?raceId=101&lang=it');
|
||||
const legacyHomeUrl = legacyUrl('/');
|
||||
|
||||
function isInvalidRaceAvailability(availability) {
|
||||
return availability?.reasonCode === 'RACE_DIRECTORY_NOT_FOUND' || availability?.reasonCode === 'MISSING_RACE_STORAGE';
|
||||
|
|
|
|||
29
faceai/apps/frontend/src/legacyUrls.js
Normal file
29
faceai/apps/frontend/src/legacyUrls.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
const localHostnames = new Set(['localhost', '127.0.0.1', '::1']);
|
||||
|
||||
function trimTrailingSlash(value) {
|
||||
return String(value || '').replace(/\/$/, '');
|
||||
}
|
||||
|
||||
function currentHostname() {
|
||||
if (typeof window === 'undefined' || !window.location || !window.location.hostname) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return window.location.hostname.toLowerCase();
|
||||
}
|
||||
|
||||
export function getLegacyBaseUrl() {
|
||||
const configuredBaseUrl = trimTrailingSlash(import.meta.env.VITE_LEGACY_BASE_URL || '');
|
||||
if (configuredBaseUrl) {
|
||||
return configuredBaseUrl;
|
||||
}
|
||||
|
||||
return localHostnames.has(currentHostname())
|
||||
? 'http://localhost:8080'
|
||||
: 'https://www.regalamiunsorriso.it';
|
||||
}
|
||||
|
||||
export function legacyUrl(path = '/') {
|
||||
const normalizedPath = path.startsWith('/') ? path : `/${path}`;
|
||||
return `${getLegacyBaseUrl()}${normalizedPath}`;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue