Ensure web_base does not end in /
This commit is contained in:
parent
18e35184a5
commit
30ddf1e9b2
4 changed files with 23 additions and 19 deletions
|
|
@ -146,14 +146,11 @@ impl ConfigFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn web_base(&self) -> String {
|
fn web_base(&self) -> String {
|
||||||
let mut base = self.web.base.clone();
|
self.web
|
||||||
if !base.starts_with('/') {
|
.base
|
||||||
base.insert(0, '/');
|
.strip_suffix('/')
|
||||||
}
|
.unwrap_or(&self.web.base)
|
||||||
if !base.ends_with('/') {
|
.to_string()
|
||||||
base.push('/');
|
|
||||||
}
|
|
||||||
base
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn web_worker_token(&self) -> String {
|
fn web_worker_token(&self) -> String {
|
||||||
|
|
@ -210,14 +207,21 @@ impl ConfigFile {
|
||||||
// TODO Url functions
|
// TODO Url functions
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct WorkerServerConfig {
|
pub struct WorkerServerConfig {
|
||||||
/// Never ends with a `/`.
|
/// Always ends without a `/`.
|
||||||
|
///
|
||||||
|
/// This means that you can prefix the url onto an absolute path and get a
|
||||||
|
/// correct url.
|
||||||
pub url: String,
|
pub url: String,
|
||||||
pub token: String,
|
pub token: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
/// Always starts and ends with a `/`.
|
/// Always ends without a `/` (prioritizing the latter).
|
||||||
|
///
|
||||||
|
/// This means that you can prefix the base onto an absolute path and get
|
||||||
|
/// another absolute path. You could also use an url here if you have a
|
||||||
|
/// weird reason to do so.
|
||||||
pub web_base: String,
|
pub web_base: String,
|
||||||
pub web_address: SocketAddr,
|
pub web_address: SocketAddr,
|
||||||
pub web_worker_token: String,
|
pub web_worker_token: String,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use super::Base;
|
||||||
ext = "html",
|
ext = "html",
|
||||||
source = "\
|
source = "\
|
||||||
{% import \"util.html\" as util %}
|
{% import \"util.html\" as util %}
|
||||||
<a href=\"{{ root }}commit/{{ hash }}\"
|
<a href=\"{{ root }}/commit/{{ hash }}\"
|
||||||
class=\"{% call util::commit_class(reachable) %}\"
|
class=\"{% call util::commit_class(reachable) %}\"
|
||||||
title=\"{% call util::commit_title(reachable) %}\">
|
title=\"{% call util::commit_title(reachable) %}\">
|
||||||
{{ short }}
|
{{ short }}
|
||||||
|
|
@ -38,7 +38,7 @@ impl CommitLink {
|
||||||
#[template(
|
#[template(
|
||||||
ext = "html",
|
ext = "html",
|
||||||
source = "\
|
source = "\
|
||||||
<a href=\"{{ root }}run/{{ id }}\">
|
<a href=\"{{ root }}/run/{{ id }}\">
|
||||||
Run of {{ short }}
|
Run of {{ short }}
|
||||||
</a>
|
</a>
|
||||||
"
|
"
|
||||||
|
|
@ -62,7 +62,7 @@ impl RunLink {
|
||||||
#[template(
|
#[template(
|
||||||
ext = "html",
|
ext = "html",
|
||||||
source = "\
|
source = "\
|
||||||
<a href=\"{{ root }}worker/{{ name }}\">
|
<a href=\"{{ root }}/worker/{{ name }}\">
|
||||||
{{ name }}
|
{{ name }}
|
||||||
</a>
|
</a>
|
||||||
"
|
"
|
||||||
|
|
|
||||||
|
|
@ -5,17 +5,17 @@
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width" />
|
<meta name="viewport" content="width=device-width" />
|
||||||
<title>{% block title %}{% endblock %} - {{ base.repo_name }}</title>
|
<title>{% block title %}{% endblock %} - {{ base.repo_name }}</title>
|
||||||
<link rel="icon" href="{{ base.root }}logo.svg">
|
<link rel="icon" href="{{ base.root }}/logo.svg">
|
||||||
<link rel="stylesheet" href="{{ base.root }}base.css" />
|
<link rel="stylesheet" href="{{ base.root }}/base.css" />
|
||||||
{% block head %}{% endblock %}
|
{% block head %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<nav>
|
<nav>
|
||||||
<a href="{{ base.root }}" {% if base.current=="index" %} class="current" {% endif %}>
|
<a href="{{ base.root }}/" {% if base.current=="index" %} class="current" {% endif %}>
|
||||||
<img src="{{ base.root }}logo.svg" alt="">{{ base.repo_name }}
|
<img src="{{ base.root }}/logo.svg" alt="">{{ base.repo_name }}
|
||||||
</a>
|
</a>
|
||||||
<a href="{{ base.root }}queue/" {% if base.current=="queue" %} class="current" {% endif %}>
|
<a href="{{ base.root }}/queue/" {% if base.current=="queue" %} class="current" {% endif %}>
|
||||||
queue
|
queue
|
||||||
</a>
|
</a>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
{% block title %}queue ({{ inner.tasks.len() }}){% endblock %}
|
{% block title %}queue ({{ inner.tasks.len() }}){% endblock %}
|
||||||
|
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<script type="module" src="{{ base.root }}queue.js"></script>
|
<script type="module" src="{{ base.root }}/queue.js"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue