feat: Default index page improvements
- Add project logo to footer and favicon - Display different messages depending on if first-run mode is active
This commit is contained in:
parent
ea3c00da43
commit
01b5dffeee
5 changed files with 43 additions and 18 deletions
|
|
@ -83,3 +83,12 @@ footer {
|
|||
color: transparent;
|
||||
filter: brightness(1.2);
|
||||
}
|
||||
|
||||
b {
|
||||
color: oklch(from var(--c2) var(--name-lightness) c h);
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 100%;
|
||||
height: 64px;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,9 @@ use conduwuit_build_metadata::{GIT_REMOTE_COMMIT_URL, GIT_REMOTE_WEB_URL, versio
|
|||
use conduwuit_service::state;
|
||||
|
||||
pub fn build() -> Router<state::State> {
|
||||
let router = Router::<state::State>::new();
|
||||
router.route("/", get(index_handler))
|
||||
Router::<state::State>::new()
|
||||
.route("/", get(index_handler))
|
||||
.route("/_continuwuity/logo.svg", get(logo_handler))
|
||||
}
|
||||
|
||||
async fn index_handler(
|
||||
|
|
@ -19,22 +20,34 @@ async fn index_handler(
|
|||
) -> Result<impl IntoResponse, WebError> {
|
||||
#[derive(Debug, Template)]
|
||||
#[template(path = "index.html.j2")]
|
||||
struct Tmpl<'a> {
|
||||
struct Index<'a> {
|
||||
nonce: &'a str,
|
||||
server_name: &'a str,
|
||||
first_run: bool,
|
||||
}
|
||||
let nonce = rand::random::<u64>().to_string();
|
||||
|
||||
let template = Tmpl {
|
||||
let template = Index {
|
||||
nonce: &nonce,
|
||||
server_name: services.config.server_name.as_str(),
|
||||
first_run: services.firstrun.is_first_run(),
|
||||
};
|
||||
Ok((
|
||||
[(header::CONTENT_SECURITY_POLICY, format!("default-src 'none' 'nonce-{nonce}';"))],
|
||||
[(
|
||||
header::CONTENT_SECURITY_POLICY,
|
||||
format!("default-src 'nonce-{nonce}'; img-src 'self';"),
|
||||
)],
|
||||
Html(template.render()?),
|
||||
))
|
||||
}
|
||||
|
||||
async fn logo_handler() -> impl IntoResponse {
|
||||
(
|
||||
[(header::CONTENT_TYPE, "image/svg+xml")],
|
||||
include_str!("templates/logo.svg").to_owned(),
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
enum WebError {
|
||||
#[error("Failed to render template: {0}")]
|
||||
|
|
@ -45,7 +58,7 @@ impl IntoResponse for WebError {
|
|||
fn into_response(self) -> Response {
|
||||
#[derive(Debug, Template)]
|
||||
#[template(path = "error.html.j2")]
|
||||
struct Tmpl<'a> {
|
||||
struct Error<'a> {
|
||||
nonce: &'a str,
|
||||
err: WebError,
|
||||
}
|
||||
|
|
@ -55,7 +68,7 @@ impl IntoResponse for WebError {
|
|||
let status = match &self {
|
||||
| Self::Render(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
};
|
||||
let tmpl = Tmpl { nonce: &nonce, err: self };
|
||||
let tmpl = Error { nonce: &nonce, err: self };
|
||||
if let Ok(body) = tmpl.render() {
|
||||
(
|
||||
status,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<title>{% block title %}Continuwuity{% endblock %}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<link rel="icon" href="/_continuwuity/logo.svg">
|
||||
<style type="text/css" nonce="{{ nonce }}">
|
||||
/*<![CDATA[*/
|
||||
{{ include_str !("css/index.css") | safe }}
|
||||
|
|
@ -17,7 +18,8 @@
|
|||
<main>{%~ block content %}{% endblock ~%}</main>
|
||||
{%~ block footer ~%}
|
||||
<footer>
|
||||
<p>Powered by <a href="https://continuwuity.org">Continuwuity</a>
|
||||
<img class="logo" src="/_continuwuity/logo.svg">
|
||||
<p>Powered by <a href="https://continuwuity.org">Continuwuity</a> {{ env!("CARGO_PKG_VERSION") }}
|
||||
{%~ if let Some(version_info) = self::version_tag() ~%}
|
||||
{%~ if let Some(url) = GIT_REMOTE_COMMIT_URL.or(GIT_REMOTE_WEB_URL) ~%}
|
||||
(<a href="{{ url }}">{{ version_info }}</a>)
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
{% extends "_layout.html.j2" %}
|
||||
{%- block content -%}
|
||||
<div class="orb"></div>
|
||||
<div class="panel">
|
||||
<h1>Welcome to <a class="project-name" href="https://continuwuity.org">Continuwuity</a>!</h1>
|
||||
<p>Continuwuity is successfully installed and working. </p>
|
||||
<p>To get started, you can:</p>
|
||||
<ul>
|
||||
<li>Read the <a href="https://continuwuity.org/introduction">documentation</a></li>
|
||||
<li>Join the <a href="https://matrix.to/#/#continuwuity:continuwuity.org?via=continuwuity.org&via=ellis.link&via=explodie.org&via=matrix.org">Continuwuity Matrix room</a> or <a href="https://matrix.to/#/#space:continuwuity.org?via=continuwuity.org&via=ellis.link&via=explodie.org&via=matrix.org">space</a></li>
|
||||
<li>Log in with a <a href="https://matrix.org/ecosystem/clients/">client</a></li>
|
||||
<li>Ensure <a href="https://federationtester.mtrnord.blog/?serverName={{ server_name }}">federation</a> works</li>
|
||||
</ul>
|
||||
<h1>
|
||||
Welcome to <a class="project-name" href="https://continuwuity.org">Continuwuity</a>!
|
||||
</h1>
|
||||
<p>Continuwuity is successfully installed and working.</p>
|
||||
{%- if first_run %}
|
||||
<p>To get started, <b>check the server logs</b> for instructions on how to create the first account.</p>
|
||||
<p>For support, take a look at the <a href="https://continuwuity.org/introduction">documentation</a> or join the <a href="https://matrix.to/#/#continuwuity:continuwuity.org?via=continuwuity.org&via=ellis.link&via=explodie.org&via=matrix.org">Continuwuity Matrix room</a>.</p>
|
||||
{%- else %}
|
||||
<p>To get started, <a href="https://matrix.org/ecosystem/clients">choose a client</a> and connect to <code>{{ server_name }}</code>.</p>
|
||||
{%- endif %}
|
||||
</div>
|
||||
|
||||
{%- endblock content -%}
|
||||
|
|
|
|||
1
src/web/templates/logo.svg
Symbolic link
1
src/web/templates/logo.svg
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../docs/public/assets/logo.svg
|
||||
Loading…
Add table
Reference in a new issue