ui: Fix base url mess

This commit is contained in:
nemunaire 2021-09-01 11:20:41 +02:00
parent 74d77dce9f
commit 17839474e1
23 changed files with 66 additions and 43 deletions

View File

@ -10,15 +10,22 @@ run() {
if [ -d "${FILE}" ] if [ -d "${FILE}" ]
then then
for f in "${FILE}/"*.html "${FILE}/"*.js for f in "${FILE}/"*.html "${FILE}/"*.js "${FILE}/"*.css
do do
run "${NEWBASE}" "${f}" run "${NEWBASE}" "${f}"
done done
[ -d "${FILE}/js/" ] && run "${NEWBASE}" "${FILE}/js" [ -d "${FILE}/js/" ] && run "${NEWBASE}" "${FILE}/js"
[ -d "${FILE}/views/" ] && run "${NEWBASE}" "${FILE}/views" [ -d "${FILE}/views/" ] && run "${NEWBASE}" "${FILE}/views"
[ -d "${FILE}/_app/" ] && run "${NEWBASE}" "${FILE}/_app"
[ -d "${FILE}/_app/assets/pages/" ] && run "${NEWBASE}" "${FILE}/_app/assets/pages"
elif [ -f "${FILE}" ] elif [ -f "${FILE}" ]
then then
sed -ri "s@(href|src)=\"${CURRENT_BASE}@\1=\"${NEWBASE}@g;s@\\\$http.get\(\"${CURRENT_BASE}@\$http.get\(\"${NEWBASE}@g;s@\\\$http\((.*)\"${CURRENT_BASE}@\$http(\1\"${NEWBASE}@g" ${FILE} if [ "${FILE##*.}" == "css" ]
then
sed -ri "s@${CURRENT_BASE}_app/@${NEWBASE}_app/@g" ${FILE}
else
sed -ri "s@(href|src)=\"${CURRENT_BASE}@\1=\"${NEWBASE}@g;s@\\\$http.get\(\"${CURRENT_BASE}@\$http.get\(\"${NEWBASE}@g;s@\\\$http\((.*)\"${CURRENT_BASE}@\$http(\1\"${NEWBASE}@g;s@from \"${CURRENT_BASE}_app@from \"${NEWBASE}_app@g;s@\`${CURRENT_BASE}_app/\\\$@\`${NEWBASE}_app/\\\$@g;s@paths: \{\"base\":\"${CURRENT_BASE%/}\",\"assets\":\"${CURRENT_BASE%/}\"\},@paths: {\"base\":\"${NEWBASE%/}\",\"assets\":\"${NEWBASE%/}\"},@" ${FILE}
fi
fi fi
} }

View File

@ -4,9 +4,10 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<meta name="author" content="EPITA Laboratoire SRS"> <meta name="author" content="EPITA Laboratoire SRS">
<meta name="robots" content="all"> <meta name="robots" content="all">
<base href="/">
%svelte.head% %svelte.head%
</head> </head>
<body> <body>

View File

@ -40,7 +40,7 @@
message = ""; message = "";
const response = await fetch( const response = await fetch(
"/submit/" + exercice.id, "submit/" + exercice.id,
{ {
method: "POST", method: "POST",
body: JSON.stringify(responses), body: JSON.stringify(responses),

View File

@ -44,7 +44,7 @@
hinterror = ""; hinterror = "";
const response = await fetch( const response = await fetch(
"/openhint/" + exercice.id, "openhint/" + exercice.id,
{ {
method: "POST", method: "POST",
body: JSON.stringify({ id: hint.id }), body: JSON.stringify({ id: hint.id }),

View File

@ -38,7 +38,7 @@
wcsubmitted = true; wcsubmitted = true;
const response = await fetch( const response = await fetch(
"/wantchoices/" + exercice_id, "wantchoices/" + exercice_id,
{ {
method: "POST", method: "POST",
body: JSON.stringify({ id: Number(flag.id) }), body: JSON.stringify({ id: Number(flag.id) }),

View File

@ -45,8 +45,8 @@
</Container> </Container>
</div> </div>
<Container class="d-flex justify-content-between p-1" style="max-height: inherit"> <Container class="d-flex justify-content-between p-1" style="max-height: inherit">
<a href="/"> <a href=".">
<img src="/img/fic.png" alt="Forum International de la Cybersécurité" class="h-100"> <img src="img/fic.png" alt="Forum International de la Cybersécurité" class="h-100">
</a> </a>
<HeaderPartners /> <HeaderPartners />
</Container> </Container>
@ -57,7 +57,7 @@
<Collapse {isOpen} navbar expand="md" on:update={handleUpdate}> <Collapse {isOpen} navbar expand="md" on:update={handleUpdate}>
<Nav navbar> <Nav navbar>
<NavItem> <NavItem>
<NavLink href="/"> <NavLink href=".">
<Icon name="box-seam" /> <Icon name="box-seam" />
Accueil Accueil
</NavLink> </NavLink>
@ -66,7 +66,7 @@
<NavTags /> <NavTags />
{#if $settings && $settings.end - $settings.start >= 0} {#if $settings && $settings.end - $settings.start >= 0}
<NavItem> <NavItem>
<NavLink href="/rank"> <NavLink href="rank">
<Icon name="sort-down" /> <Icon name="sort-down" />
Classement Classement
</NavLink> </NavLink>
@ -74,7 +74,7 @@
{/if} {/if}
<HeaderIssues /> <HeaderIssues />
<NavItem> <NavItem>
<NavLink href="/rules"> <NavLink href="rules">
<Icon name="signpost-split" /> <Icon name="signpost-split" />
Aide Aide
</NavLink> </NavLink>
@ -91,11 +91,11 @@
{/if} {/if}
<NavItem class="ms-2"> <NavItem class="ms-2">
{#if !$my} {#if !$my}
<Badge href="/register" color="warning"> <Badge href="register" color="warning">
Inscription Inscription
</Badge> </Badge>
{:else if $my.team_id && $teams} {:else if $my.team_id && $teams}
<Badge href="/edit" style="background-color: {$teams[$my.team_id].color} !important; color: {$teams[$my.team_id].color};"> <Badge href="edit" style="background-color: {$teams[$my.team_id].color} !important; color: {$teams[$my.team_id].color};">
<span class="teamname">{$my.name}</span> <span class="teamname">{$my.name}</span>
</Badge> </Badge>
{/if} {/if}

View File

@ -39,14 +39,14 @@
<div class="d-flex h-100 justify-content-center align-items-center"> <div class="d-flex h-100 justify-content-center align-items-center">
<ButtonGroup size="lg"> <ButtonGroup size="lg">
<a <a
href="/" href="."
class="btn btn-light" class="btn btn-light"
> >
<Icon name="ui-checks-grid" /> <Icon name="ui-checks-grid" />
Accueil Accueil
</a> </a>
<a <a
href="/rank" href="rank"
class="btn btn-light" class="btn btn-light"
> >
<Icon name="sort-down" /> <Icon name="sort-down" />

View File

@ -25,7 +25,7 @@
{#if $issues.length} {#if $issues.length}
<NavItem> <NavItem>
<NavLink href="/issues"> <NavLink href="issues">
<Icon name="bug" /> <Icon name="bug" />
Problèmes Problèmes
<Badge color={badge_color}>{$issues_nb_responses}</Badge> <Badge color={badge_color}>{$issues_nb_responses}</Badge>

View File

@ -6,17 +6,17 @@
let partners = [ let partners = [
{ {
img: '/img/epita.png', img: 'img/epita.png',
alt: 'Epita', alt: 'Epita',
href: 'https://www.epita.fr/', href: 'https://www.epita.fr/',
}, },
{ {
img: '/img/srs.png', img: 'img/srs.png',
alt: 'Laboratoire SRS Épita', alt: 'Laboratoire SRS Épita',
href: 'https://srs.epita.fr/', href: 'https://srs.epita.fr/',
}, },
{ {
img: '/img/comcyber.png', img: 'img/comcyber.png',
alt: 'Réserves de cyberdéfense', alt: 'Réserves de cyberdéfense',
}, },
]; ];

View File

@ -29,7 +29,7 @@
<div> <div>
{#each Object.keys($tags).sort() as itag, index} {#each Object.keys($tags).sort() as itag, index}
{#if filter === "" || itag.toLowerCase().indexOf(filter.toLowerCase()) >= 0} {#if filter === "" || itag.toLowerCase().indexOf(filter.toLowerCase()) >= 0}
<DropdownItem href="/tags/{itag}"> <DropdownItem href="tags/{itag}">
#{itag} #{itag}
<Badge> <Badge>
{#if $my && $my.team_id}{$tags[itag].solved}/{/if}{$tags[itag].count} {#if $my && $my.team_id}{$tags[itag].solved}/{/if}{$tags[itag].count}

View File

@ -21,7 +21,7 @@
<DropdownMenu class="niceborder" end> <DropdownMenu class="niceborder" end>
<div> <div>
{#each Object.keys($themes) as th, index} {#each Object.keys($themes) as th, index}
<DropdownItem href="/{$themes[th].urlid}"> <DropdownItem href="{$themes[th].urlid}">
{$themes[th].name} {$themes[th].name}
{#if $max_solved > 1 && $themes[th].solved == $max_solved} {#if $max_solved > 1 && $themes[th].solved == $max_solved}
<Badge color="danger"> <Badge color="danger">

View File

@ -46,7 +46,7 @@
return false; return false;
} }
const response = await fetch('/chname', { const response = await fetch('chname', {
method: "POST", method: "POST",
body: JSON.stringify({newName: newTeamName}), body: JSON.stringify({newName: newTeamName}),
}); });

View File

@ -26,7 +26,7 @@
{/if} {/if}
</strong> </strong>
{:else if $my && $my.exercices[k]} {:else if $my && $my.exercices[k]}
<a href="/{theme.urlid}/{theme.exercices[k].urlid}" class:text-success={$my.exercices[k].solved}> <a href="{theme.urlid}/{theme.exercices[k].urlid}" class:text-success={$my.exercices[k].solved}>
{theme.exercices[k].title} {theme.exercices[k].title}
{#if theme.exercices[k].curcoeff > 1.0} {#if theme.exercices[k].curcoeff > 1.0}
<Icon name="gift" aria-hidden="true" /> <Icon name="gift" aria-hidden="true" />

View File

@ -72,7 +72,7 @@
<h3 class="display-4">{exercice.title}</h3> <h3 class="display-4">{exercice.title}</h3>
<div> <div>
{#each exercice.tags as tag, index} {#each exercice.tags as tag, index}
<Badge href="/tags/{tag}" pill color="secondary" class="mx-1 mb-2" >#{tag}</Badge> <Badge href="tags/{tag}" pill color="secondary" class="mx-1 mb-2" >#{tag}</Badge>
{/each} {/each}
</div> </div>
{#if !$my || !$my.exercices[exercice.id]} {#if !$my || !$my.exercices[exercice.id]}
@ -105,7 +105,7 @@
aucune équipe aucune équipe
{:else} {:else}
{exercice.tried} {exercice.tried == 1?"équipe":"équipes"} {exercice.tried} {exercice.tried == 1?"équipe":"équipes"}
{#if $my && $my.exercices[exercice.id].total_tries} {#if $my && $my.exercices[exercice.id] && $my.exercices[exercice.id].total_tries}
(cumulant {$my.exercices[exercice.id].total_tries} {$my.exercices[exercice.id].total_tries == 1?"tentative":"tentatives"}) (cumulant {$my.exercices[exercice.id].total_tries} {$my.exercices[exercice.id].total_tries == 1?"tentative":"tentatives"})
{/if} {/if}
{/if} {/if}
@ -123,13 +123,13 @@
{#if $my && $my.team_id} {#if $my && $my.team_id}
<Col> <Col>
{#if $settings.acceptNewIssue} {#if $settings.acceptNewIssue}
<a href="/issues/?eid={exercice.id}" class="float-end btn btn-sm btn-warning"> <a href="issues/?eid={exercice.id}" class="float-end btn btn-sm btn-warning">
<Icon name="bug" /> <Icon name="bug" />
Rapporter une anomalie sur ce défi Rapporter une anomalie sur ce défi
</a> </a>
{/if} {/if}
{#if $settings.QAenabled} {#if $settings.QAenabled}
<a href="/qa/exercices/{exercice.id}" class="float-end btn btn-sm btn-info" target="_self"> <a href="qa/exercices/{exercice.id}" class="float-end btn btn-sm btn-info" target="_self">
<Icon name="bug" /> <Icon name="bug" />
Voir les éléments QA sur ce défi Voir les éléments QA sur ce défi
</a> </a>

View File

@ -43,7 +43,7 @@
<div style="background-image: url({theme.image})" class="page-header"> <div style="background-image: url({theme.image})" class="page-header">
<Container class="text-primary"> <Container class="text-primary">
<h1 class="display-2"> <h1 class="display-2">
<a href="/{theme.urlid}">{theme.name}</a> <a href="{theme.urlid}">{theme.name}</a>
</h1> </h1>
<h2>{@html theme.authors}</h2> <h2>{@html theme.authors}</h2>
</Container> </Container>

View File

@ -66,7 +66,7 @@
<li <li
class="list-group-item" class="list-group-item"
class:list-group-item-action={$my && $my.exercices[k]} class:list-group-item-action={$my && $my.exercices[k]}
on:click={goto(`/${theme.urlid}/${theme.exercices[k].urlid}`)} on:click={goto(`${theme.urlid}/${theme.exercices[k].urlid}`)}
> >
<div class="row"> <div class="row">
<div class="col-1" style="margin-top: -0.5rem; margin-bottom: -0.5rem; text-align: right; border-right: 5px solid #{$my && $my.exercices[k] && $my.exercices[k].solved_rank ? '62c462' : 'bbb'}"> <div class="col-1" style="margin-top: -0.5rem; margin-bottom: -0.5rem; text-align: right; border-right: 5px solid #{$my && $my.exercices[k] && $my.exercices[k].solved_rank ? '62c462' : 'bbb'}">
@ -86,7 +86,7 @@
</svg> </svg>
</div> </div>
{#each theme.exercices[k].tags as tag, idx} {#each theme.exercices[k].tags as tag, idx}
<Badge href="/tags/{tag}" pill color="secondary" class="mx-1 float-end">#{tag}</Badge> <Badge href="tags/{tag}" pill color="secondary" class="mx-1 float-end">#{tag}</Badge>
{/each} {/each}
<h5 class="fw-bold"> <h5 class="fw-bold">
{#if $my && $my.exercices[k]} {#if $my && $my.exercices[k]}

View File

@ -0,0 +1,15 @@
<script context="module">
export function load({ error, status }) {
return {
props: {
title: `${status}: ${error.message}`
}
};
}
</script>
<script>
export let title;
</script>
<h1>{title}</h1>

View File

@ -33,7 +33,7 @@
}; };
} }
settings.update(await fetch('/settings.json'), cb); settings.update(await fetch('settings.json'), cb);
} }
let refresh_interval_teams = null; let refresh_interval_teams = null;
@ -45,7 +45,7 @@
} }
refresh_interval_teams = setInterval(refresh_teams, interval); refresh_interval_teams = setInterval(refresh_teams, interval);
teamsStore.update(await fetch('/teams.json'), cb); teamsStore.update(await fetch('teams.json'), cb);
} }
let refresh_interval_themes = null; let refresh_interval_themes = null;
@ -57,7 +57,7 @@
} }
refresh_interval_themes = setInterval(refresh_themes, interval); refresh_interval_themes = setInterval(refresh_themes, interval);
await themesStore.update(await fetch('/themes.json'), cb); await themesStore.update(await fetch('themes.json'), cb);
} }
let refresh_interval_my = null; let refresh_interval_my = null;
@ -69,7 +69,7 @@
} }
refresh_interval_my = setInterval(refresh_my, interval); refresh_interval_my = setInterval(refresh_my, interval);
my.update(await fetch('/my.json'), cb); my.update(await fetch('my.json'), cb);
} }
let refresh_interval_issues = null; let refresh_interval_issues = null;
@ -81,7 +81,7 @@
} }
refresh_interval_issues = setInterval(refresh_issues, interval); refresh_interval_issues = setInterval(refresh_issues, interval);
issuesStore.update(await fetch('/issues.json'), cb); issuesStore.update(await fetch('issues.json'), cb);
} }
export async function load({ page, fetch, session, context }) { export async function load({ page, fetch, session, context }) {

View File

@ -51,7 +51,7 @@
{:else} {:else}
<Alert color="danger"> <Alert color="danger">
<strong>Vous n'avez pas encore d'équipe&nbsp;!</strong> <strong>Vous n'avez pas encore d'équipe&nbsp;!</strong>
Rendez-vous sur <a href="/register">la page d'inscription</a> pour plus d'information. Rendez-vous sur <a href="register">la page d'inscription</a> pour plus d'information.
</Alert> </Alert>
{/if} {/if}
</Container> </Container>

View File

@ -24,7 +24,7 @@
{#if !$my} {#if !$my}
{#if $settings.allowRegistration} {#if $settings.allowRegistration}
<Alert color="warning" class="text-justify" fade={false}> <Alert color="warning" class="text-justify" fade={false}>
<strong>Votre équipe n'est pas encore enregistrée.</strong> Rendez-vous sur <a href="/register">cette page</a> pour procéder à votre inscription. <strong>Votre équipe n'est pas encore enregistrée.</strong> Rendez-vous sur <a href="register">cette page</a> pour procéder à votre inscription.
</Alert> </Alert>
{:else} {:else}
<Alert color="danger" class="text-justify" fade={false}> <Alert color="danger" class="text-justify" fade={false}>
@ -53,7 +53,7 @@
<CardTheme <CardTheme
class="{$my && $my.team_id && $myThemes[$themes[th].id].exercice_solved > 0?'border-success ':''}{$themes[th].exercice_coeff_max > 1?'border-warning ':''}" class="{$my && $my.team_id && $myThemes[$themes[th].id].exercice_solved > 0?'border-success ':''}{$themes[th].exercice_coeff_max > 1?'border-warning ':''}"
theme={$themes[th]} theme={$themes[th]}
on:click={goto(`/${$themes[th].urlid}`)} on:click={goto(`${$themes[th].urlid}`)}
/> />
</Col> </Col>
{/each} {/each}

View File

@ -64,7 +64,7 @@
return false; return false;
} }
const response = await fetch('/issue', { const response = await fetch('issue', {
method: "POST", method: "POST",
body: JSON.stringify(issue), body: JSON.stringify(issue),
}); });
@ -151,7 +151,7 @@
<tr> <tr>
<td> <td>
{issue.subject} {issue.subject}
{#if issue.exercice} (défi <a href="/{issue.url}">{issue.exercice}</a>){/if} {#if issue.exercice} (défi <a href="{issue.url}">{issue.exercice}</a>){/if}
</td> </td>
<td>{issue.state} / {issue.priority}</td> <td>{issue.state} / {issue.priority}</td>
<td>{#if issue.assignee}{issue.assignee}{:else}En attente d'attribution{/if}</td> <td>{#if issue.assignee}{issue.assignee}{:else}En attente d'attribution{/if}</td>

View File

@ -38,7 +38,7 @@
function gotoHomeOnDiff(i) { function gotoHomeOnDiff(i) {
refresh_my((my) => { refresh_my((my) => {
if (my && my.team_id) { if (my && my.team_id) {
goto('/'); goto('.');
} else if (i > 0) { } else if (i > 0) {
setTimeout(gotoHomeOnDiff, 650, i-1); setTimeout(gotoHomeOnDiff, 650, i-1);
} }
@ -66,7 +66,7 @@
return; return;
} }
const response = await fetch('/registration', { const response = await fetch('registration', {
method: "POST", method: "POST",
body: JSON.stringify(form), body: JSON.stringify(form),
}) })

View File

@ -56,7 +56,7 @@
<CardTheme <CardTheme
theme={theme} theme={theme}
exercice={exercice} exercice={exercice}
on:click={goto(`/${theme.urlid}/${exercice.urlid}`)} on:click={goto(`${theme.urlid}/${exercice.urlid}`)}
/> />
</Col> </Col>
{/each} {/each}