Add optional footer blurb

This commit is contained in:
asonix 2022-11-21 11:16:21 -06:00
parent a0195d94aa
commit 9133dd7688
4 changed files with 22 additions and 0 deletions

1
.env
View file

@ -2,4 +2,5 @@ HOSTNAME=localhost:8079
PORT=8079
RESTRICTED_MODE=true
API_TOKEN=somesecretpassword
FOOTER_BLURB="Contact <a href=\"https://masto.asonix.dog/@asonix\">@asonix</a> for inquiries"
# OPENTELEMETRY_URL=http://localhost:4317

View file

@ -100,6 +100,7 @@ TELEGRAM_TOKEN=secret
TELEGRAM_ADMIN_HANDLE=your_handle
TLS_KEY=/path/to/key
TLS_CERT=/path/to/cert
FOOTER_BLURB="Contact <a href=\"https://masto.asonix.dog/@asonix\">@asonix</a>
```
#### Descriptions
@ -137,6 +138,8 @@ The handle of the telegram user allowed to administer the relay. There is no def
Optional - This is specified if you are running the relay directly on the internet and have a TLS key to provide HTTPS for your relay
##### `TLS_CERT`
Optional - This is specified if you are running the relay directly on the internet and have a TLS certificate chain to provide HTTPS for your relay
##### `FOOTER_BLURB`
Optional - Add custom notes in the footer of the page
### Subscribing
Mastodon admins can subscribe to this relay by adding the `/inbox` route to their relay settings.

View file

@ -37,6 +37,7 @@ pub(crate) struct ParsedConfig {
api_token: Option<String>,
tls_key: Option<PathBuf>,
tls_cert: Option<PathBuf>,
footer_blurb: Option<String>,
}
#[derive(Clone)]
@ -56,6 +57,7 @@ pub struct Config {
telegram_admin_handle: Option<String>,
api_token: Option<String>,
tls: Option<TlsConfig>,
footer_blurb: Option<String>,
}
#[derive(Clone)]
@ -112,6 +114,7 @@ impl std::fmt::Debug for Config {
.field("api_token", &"[redacted]")
.field("tls_key", &"[redacted]")
.field("tls_cert", &"[redacted]")
.field("footer_blurb", &self.footer_blurb)
.finish()
}
}
@ -135,6 +138,7 @@ impl Config {
.set_default("api_token", None as Option<&str>)?
.set_default("tls_key", None as Option<&str>)?
.set_default("tls_cert", None as Option<&str>)?
.set_default("footer_blurb", None as Option<&str>)?
.add_source(Environment::default())
.build()?;
@ -172,6 +176,7 @@ impl Config {
telegram_admin_handle: config.telegram_admin_handle,
api_token: config.api_token,
tls,
footer_blurb: config.footer_blurb,
})
}
@ -214,6 +219,16 @@ impl Config {
Ok(Some((certs, key)))
}
pub(crate) fn footer_blurb(&self) -> Option<crate::templates::Html<&str>> {
if let Some(blurb) = &self.footer_blurb {
if !blurb.is_empty() {
return Some(crate::templates::Html(blurb));
}
}
None
}
pub(crate) fn sled_path(&self) -> &PathBuf {
&self.sled_path
}

View file

@ -84,6 +84,9 @@ templates::{info, instance, statics::index_css},
</section>
</main>
<footer>
@if let Some(blurb) = config.footer_blurb() {
<div>@blurb</div>
}
<p>
The source code for this project can be found at
<a href="@config.source_code()">@config.source_code()</a>