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}" ]
then
for f in "${FILE}/"*.html "${FILE}/"*.js
for f in "${FILE}/"*.html "${FILE}/"*.js "${FILE}/"*.css
do
run "${NEWBASE}" "${f}"
done
[ -d "${FILE}/js/" ] && run "${NEWBASE}" "${FILE}/js"
[ -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}" ]
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
}

View File

@ -4,9 +4,10 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<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="robots" content="all">
<base href="/">
%svelte.head%
</head>
<body>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,7 +26,7 @@
{/if}
</strong>
{: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}
{#if theme.exercices[k].curcoeff > 1.0}
<Icon name="gift" aria-hidden="true" />

View File

@ -72,7 +72,7 @@
<h3 class="display-4">{exercice.title}</h3>
<div>
{#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}
</div>
{#if !$my || !$my.exercices[exercice.id]}
@ -105,7 +105,7 @@
aucune équipe
{:else}
{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"})
{/if}
{/if}
@ -123,13 +123,13 @@
{#if $my && $my.team_id}
<Col>
{#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" />
Rapporter une anomalie sur ce défi
</a>
{/if}
{#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" />
Voir les éléments QA sur ce défi
</a>

View File

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

View File

@ -66,7 +66,7 @@
<li
class="list-group-item"
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="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>
</div>
{#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}
<h5 class="fw-bold">
{#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;
@ -45,7 +45,7 @@
}
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;
@ -57,7 +57,7 @@
}
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;
@ -69,7 +69,7 @@
}
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;
@ -81,7 +81,7 @@
}
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 }) {

View File

@ -51,7 +51,7 @@
{:else}
<Alert color="danger">
<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>
{/if}
</Container>

View File

@ -24,7 +24,7 @@
{#if !$my}
{#if $settings.allowRegistration}
<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>
{:else}
<Alert color="danger" class="text-justify" fade={false}>
@ -53,7 +53,7 @@
<CardTheme
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]}
on:click={goto(`/${$themes[th].urlid}`)}
on:click={goto(`${$themes[th].urlid}`)}
/>
</Col>
{/each}

View File

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

View File

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

View File

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