mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-06-27 10:14:51 +02:00
feat: HTML default page
This commit is contained in:
parent
0931d77698
commit
d8c03d43f4
10 changed files with 391 additions and 331 deletions
|
@ -3,6 +3,7 @@ concurrency:
|
|||
group: "release-image-${{ github.ref }}"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
paths-ignore:
|
||||
- "*.md"
|
||||
|
@ -78,15 +79,17 @@ jobs:
|
|||
run: echo '${{ toJSON(fromJSON(needs.define-variables.outputs.build_matrix)) }}'
|
||||
- name: Echo matrix
|
||||
run: echo '${{ toJSON(matrix) }}'
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Install rust
|
||||
id: rust-toolchain
|
||||
uses: ./.forgejo/actions/rust-toolchain
|
||||
|
||||
- run: |
|
||||
if ! command -v rustup &> /dev/null ; then
|
||||
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
|
||||
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
|
||||
fi
|
||||
- uses: https://github.com/cargo-bins/cargo-binstall@main
|
||||
- run: cargo binstall timelord-cli@3.0.1
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Set up QEMU
|
||||
|
@ -120,58 +123,18 @@ jobs:
|
|||
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
|
||||
- name: Get Git commit timestamps
|
||||
run: echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
|
||||
|
||||
- uses: ./.forgejo/actions/timelord
|
||||
- name: Set up timelord
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: /timelord/
|
||||
key: timelord-v0 # Cache is already split per runner
|
||||
- name: Run timelord to set timestamps
|
||||
run: timelord sync --source-dir . --cache-dir /timelord/
|
||||
- name: Save timelord
|
||||
uses: actions/cache/save@v3
|
||||
with:
|
||||
path: /timelord/
|
||||
key: timelord-v0
|
||||
path: .
|
||||
|
||||
- name: Cache Rust registry
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
.cargo/git
|
||||
.cargo/git/checkouts
|
||||
.cargo/registry
|
||||
.cargo/registry/src
|
||||
key: rust-registry-image-${{hashFiles('**/Cargo.lock') }}
|
||||
- name: Cache cargo target
|
||||
id: cache-cargo-target
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
cargo-target-${{ matrix.slug }}
|
||||
key: cargo-target-${{ matrix.slug }}-${{hashFiles('**/Cargo.lock') }}-${{steps.rust-toolchain.outputs.rustc_version}}
|
||||
- name: Cache apt cache
|
||||
id: cache-apt
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
var-cache-apt-${{ matrix.slug }}
|
||||
key: var-cache-apt-${{ matrix.slug }}
|
||||
- name: Cache apt lib
|
||||
id: cache-apt-lib
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
var-lib-apt-${{ matrix.slug }}
|
||||
key: var-lib-apt-${{ matrix.slug }}
|
||||
- name: inject cache into docker
|
||||
uses: https://github.com/reproducible-containers/buildkit-cache-dance@v3.1.0
|
||||
with:
|
||||
cache-map: |
|
||||
{
|
||||
".cargo/registry": "/usr/local/cargo/registry",
|
||||
".cargo/git/db": "/usr/local/cargo/git/db",
|
||||
"cargo-target-${{ matrix.slug }}": {
|
||||
"target": "/app/target",
|
||||
"id": "cargo-target-${{ matrix.platform }}"
|
||||
},
|
||||
"var-cache-apt-${{ matrix.slug }}": "/var/cache/apt",
|
||||
"var-lib-apt-${{ matrix.slug }}": "/var/lib/apt"
|
||||
}
|
||||
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
|
||||
|
||||
- name: Build and push Docker image by digest
|
||||
id: build
|
||||
uses: docker/build-push-action@v6
|
||||
|
@ -179,10 +142,10 @@ jobs:
|
|||
context: .
|
||||
file: "docker/Dockerfile"
|
||||
build-args: |
|
||||
GIT_COMMIT_HASH=${{ github.sha }})
|
||||
GIT_COMMIT_HASH_SHORT=${{ env.COMMIT_SHORT_SHA }})
|
||||
GIT_REMOTE_URL=${{github.event.repository.html_url }}
|
||||
GIT_REMOTE_COMMIT_URL=${{github.event.head_commit.url }}
|
||||
CONDUWUIT_VERSION_EXTRA=${{ env.COMMIT_SHORT_SHA }}
|
||||
COMMIT_SHA=${{ github.sha }})
|
||||
REMOTE_URL=${{github.event.repository.html_url }}
|
||||
REMOTE_COMMIT_URL=${{github.event.head_commit.url }}
|
||||
platforms: ${{ matrix.platform }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
annotations: ${{ steps.meta.outputs.annotations }}
|
||||
|
@ -237,7 +200,7 @@ jobs:
|
|||
type=semver,pattern=v{{version}}
|
||||
type=semver,pattern=v{{major}}.{{minor}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.0.') }}
|
||||
type=semver,pattern=v{{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
|
||||
type=ref,event=branch,prefix=${{ format('refs/heads/{0}', github.event.repository.default_branch) != github.ref && 'branch-' || '' }}
|
||||
type=ref,event=branch,prefix=${{ format('refs/heads/{0}', github.event.repository.default_branch) 1= github.ref && 'branch-' || '' }}
|
||||
type=ref,event=pr
|
||||
type=sha,format=long
|
||||
images: ${{needs.define-variables.outputs.images}}
|
||||
|
|
451
Cargo.lock
generated
451
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
15
Cargo.toml
15
Cargo.toml
|
@ -298,7 +298,7 @@ version = "1.15.0"
|
|||
default-features = false
|
||||
features = ["serde"]
|
||||
|
||||
# Used for reading the configuration from continuwuity.toml & environment variables
|
||||
# Used for reading the configuration from conduwuit.toml & environment variables
|
||||
[workspace.dependencies.figment]
|
||||
version = "0.10.19"
|
||||
default-features = false
|
||||
|
@ -631,12 +631,6 @@ package = "conduwuit_web"
|
|||
path = "src/web"
|
||||
default-features = false
|
||||
|
||||
|
||||
[workspace.dependencies.conduwuit-build-metadata]
|
||||
package = "conduwuit_build_metadata"
|
||||
path = "src/build_metadata"
|
||||
default-features = false
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Release profiles
|
||||
|
@ -745,6 +739,7 @@ incremental = true
|
|||
|
||||
[profile.dev.package.conduwuit_core]
|
||||
inherits = "dev"
|
||||
incremental = false
|
||||
#rustflags = [
|
||||
# '--cfg', 'conduwuit_mods',
|
||||
# '-Ztime-passes',
|
||||
|
@ -784,6 +779,7 @@ inherits = "dev"
|
|||
[profile.dev.package.'*']
|
||||
inherits = "dev"
|
||||
debug = 'limited'
|
||||
incremental = false
|
||||
codegen-units = 1
|
||||
opt-level = 'z'
|
||||
#rustflags = [
|
||||
|
@ -805,6 +801,7 @@ inherits = "dev"
|
|||
strip = false
|
||||
opt-level = 0
|
||||
codegen-units = 16
|
||||
incremental = false
|
||||
|
||||
[profile.test.package.'*']
|
||||
inherits = "dev"
|
||||
|
@ -812,6 +809,7 @@ debug = 0
|
|||
strip = false
|
||||
opt-level = 0
|
||||
codegen-units = 16
|
||||
incremental = false
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
|
@ -988,6 +986,3 @@ let_underscore_future = { level = "allow", priority = 1 }
|
|||
|
||||
# rust doesnt understand conduwuit's custom log macros
|
||||
literal_string_with_formatting_args = { level = "allow", priority = 1 }
|
||||
|
||||
|
||||
needless_raw_string_hashes = "allow"
|
||||
|
|
|
@ -18,14 +18,13 @@ ARG LLVM_VERSION=19
|
|||
# Line three: for xx-verify
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
apt-get update && apt-get install -y \
|
||||
apt-get update && apt-get install -y \
|
||||
clang-${LLVM_VERSION} lld-${LLVM_VERSION} pkg-config make jq \
|
||||
curl git \
|
||||
file
|
||||
|
||||
# Create symlinks for LLVM tools
|
||||
RUN <<EOF
|
||||
set -o xtrace
|
||||
# clang
|
||||
ln -s /usr/bin/clang-${LLVM_VERSION} /usr/bin/clang
|
||||
ln -s "/usr/bin/clang++-${LLVM_VERSION}" "/usr/bin/clang++"
|
||||
|
@ -47,7 +46,6 @@ ENV LDDTREE_VERSION=0.3.7
|
|||
|
||||
# Install unpackaged tools
|
||||
RUN <<EOF
|
||||
set -o xtrace
|
||||
curl --retry 5 -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
|
||||
cargo binstall --no-confirm cargo-sbom --version $CARGO_SBOM_VERSION
|
||||
cargo binstall --no-confirm lddtree --version $LDDTREE_VERSION
|
||||
|
@ -61,7 +59,7 @@ ARG TARGETPLATFORM
|
|||
# xx-* are xx-specific meta-packages
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
xx-apt-get install -y \
|
||||
xx-apt-get install -y \
|
||||
xx-c-essentials xx-cxx-essentials pkg-config \
|
||||
liburing-dev
|
||||
|
||||
|
@ -77,7 +75,6 @@ RUN echo "CARGO_INCREMENTAL=0" >> /etc/environment
|
|||
|
||||
# Configure pkg-config
|
||||
RUN <<EOF
|
||||
set -o xtrace
|
||||
echo "PKG_CONFIG_LIBDIR=/usr/lib/$(xx-info)/pkgconfig" >> /etc/environment
|
||||
echo "PKG_CONFIG=/usr/bin/$(xx-info)-pkg-config" >> /etc/environment
|
||||
echo "PKG_CONFIG_ALLOW_CROSS=true" >> /etc/environment
|
||||
|
@ -85,14 +82,12 @@ EOF
|
|||
|
||||
# Configure cc to use clang version
|
||||
RUN <<EOF
|
||||
set -o xtrace
|
||||
echo "CC=clang" >> /etc/environment
|
||||
echo "CXX=clang++" >> /etc/environment
|
||||
EOF
|
||||
|
||||
# Cross-language LTO
|
||||
RUN <<EOF
|
||||
set -o xtrace
|
||||
echo "CFLAGS=-flto" >> /etc/environment
|
||||
echo "CXXFLAGS=-flto" >> /etc/environment
|
||||
# Linker is set to target-compatible clang by xx
|
||||
|
@ -103,7 +98,6 @@ EOF
|
|||
ARG TARGET_CPU=
|
||||
RUN <<EOF
|
||||
set -o allexport
|
||||
set -o xtrace
|
||||
. /etc/environment
|
||||
if [ -n "${TARGET_CPU}" ]; then
|
||||
echo "CFLAGS='${CFLAGS} -march=${TARGET_CPU}'" >> /etc/environment
|
||||
|
@ -121,33 +115,123 @@ FROM toolchain AS builder
|
|||
# Get source
|
||||
COPY . .
|
||||
|
||||
# Conduwuit version info
|
||||
ARG COMMIT_SHA=
|
||||
ARG SHORT_COMMIT_SHA=
|
||||
ARG REMOTE_URL=
|
||||
ARG CONDUWUIT_VERSION_EXTRA=
|
||||
ENV COMMIT_SHA=$COMMIT_SHA
|
||||
ENV SHORT_COMMIT_SHA=$SHORT_COMMIT_SHA
|
||||
ENV REMOTE_URL=$REMOTE_URL
|
||||
ENV CONDUWUIT_VERSION_EXTRA=$CONDUWUIT_VERSION_EXTRA
|
||||
|
||||
# Calculate version info from git if not provided via ARGs
|
||||
# and write all relevant vars to /etc/environment
|
||||
RUN <<'EOF'
|
||||
set -e # Exit on error
|
||||
|
||||
# Use temp variables to store calculated values
|
||||
calculated_commit_sha=""
|
||||
calculated_remote_url=""
|
||||
calculated_version_extra=""
|
||||
|
||||
# --- COMMIT_SHA ---
|
||||
# Calculate COMMIT_SHA if ENV var (from ARG) is empty
|
||||
if [ -z "${COMMIT_SHA}" ]; then
|
||||
# Try to get short commit hash from git
|
||||
calculated_commit_sha=$(git rev-parse HEAD 2>/dev/null || echo "")
|
||||
if [ -n "${calculated_commit_sha}" ]; then
|
||||
echo "COMMIT_SHA='${calculated_commit_sha}'" >> /etc/environment
|
||||
fi
|
||||
else
|
||||
# Ensure ARG-provided value is in /etc/environment
|
||||
echo "COMMIT_SHA='${COMMIT_SHA}'" >> /etc/environment
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "${SHORT_COMMIT_SHA}" ]; then
|
||||
# Try to get short commit hash from git
|
||||
calculated_short_commit_sha=$(git rev-parse --short HEAD 2>/dev/null || echo "")
|
||||
if [ -n "${calculated_short_commit_sha}" ]; then
|
||||
echo "SHORT_COMMIT_SHA='${calculated_short_commit_sha}'" >> /etc/environment
|
||||
fi
|
||||
else
|
||||
# Ensure ARG-provided value is in /etc/environment
|
||||
echo "SHORT_COMMIT_SHA='${SHORT_COMMIT_SHA}'" >> /etc/environment
|
||||
fi
|
||||
|
||||
# --- REMOTE_URL ---
|
||||
# Calculate REMOTE_URL if ENV var (from ARG) is empty
|
||||
if [ -z "${REMOTE_URL}" ]; then
|
||||
# Try to get remote origin URL from git
|
||||
remote_url_raw=$(git config --get remote.origin.url 2>/dev/null || echo "")
|
||||
if [ -n "${remote_url_raw}" ]; then
|
||||
# Transform git URL (SSH or HTTPS) to web URL
|
||||
if [[ $remote_url_raw == "https://"* ]]; then
|
||||
# Already HTTPS, just remove .git suffix
|
||||
calculated_remote_url=$(echo "$remote_url_raw" | sed 's/\.git$//')
|
||||
else
|
||||
# Convert SSH URL to HTTPS URL
|
||||
calculated_remote_url=$(echo "$remote_url_raw" | sed 's/\.git$//' | sed 's/:/\//' | sed 's/^git@/https:\/\//')
|
||||
fi
|
||||
|
||||
# Write calculated web URL if transformation was successful
|
||||
if [ -n "${calculated_remote_url}" ]; then
|
||||
echo "REMOTE_URL='${calculated_remote_url}'" >> /etc/environment
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# Ensure ARG-provided value is in /etc/environment (assume it's a valid web URL)
|
||||
echo "REMOTE_URL='${REMOTE_URL}'" >> /etc/environment
|
||||
# Use provided value for REMOTE_COMMIT_URL calculation below
|
||||
calculated_remote_url="${REMOTE_URL}"
|
||||
fi
|
||||
|
||||
# --- Determine effective values for subsequent calculations ---
|
||||
# Use ENV var value if set (from ARG), otherwise use calculated value
|
||||
effective_commit_sha="${COMMIT_SHA:-$calculated_commit_sha}"
|
||||
effective_short_commit_sha="${SHORT_COMMIT_SHA:-$calculated_short_commit_sha}"
|
||||
effective_remote_url="${REMOTE_URL:-$calculated_remote_url}"
|
||||
|
||||
# --- REMOTE_COMMIT_URL ---
|
||||
# Calculate and write REMOTE_COMMIT_URL if both components are available
|
||||
if [ -z "${REMOTE_COMMIT_URL}" ] && [ -n "${effective_remote_url}" ] && [ -n "${effective_commit_sha}" ]; then
|
||||
echo "REMOTE_COMMIT_URL='${effective_remote_url}/commit/${effective_commit_sha}'" >> /etc/environment
|
||||
else
|
||||
# Ensure ARG-provided value is in /etc/environment
|
||||
echo "REMOTE_COMMIT_URL='${REMOTE_COMMIT_URL}'" >> /etc/environment
|
||||
fi
|
||||
|
||||
# --- CONDUWUIT_VERSION_EXTRA ---
|
||||
# Calculate CONDUWUIT_VERSION_EXTRA if ENV var (from ARG) is empty
|
||||
if [ -z "${CONDUWUIT_VERSION_EXTRA}" ]; then
|
||||
# Use the effective short commit sha, fallback to "unknown revision"
|
||||
calculated_version_extra="${effective_short_commit_sha:-unknown revision}"
|
||||
# Handle case where commit sha calculation failed and ARG wasn't set
|
||||
if [ -z "${calculated_version_extra}" ]; then
|
||||
calculated_version_extra="unknown revision"
|
||||
fi
|
||||
echo "CONDUWUIT_VERSION_EXTRA='${calculated_version_extra}'" >> /etc/environment
|
||||
else
|
||||
# Ensure ARG-provided value is in /etc/environment
|
||||
echo "CONDUWUIT_VERSION_EXTRA='${CONDUWUIT_VERSION_EXTRA}'" >> /etc/environment
|
||||
fi
|
||||
|
||||
EOF
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
# Verify environment configuration
|
||||
RUN cat /etc/environment
|
||||
RUN xx-cargo --print-target-triple
|
||||
|
||||
# Conduwuit version info
|
||||
ARG GIT_COMMIT_HASH=
|
||||
ARG GIT_COMMIT_HASH_SHORT=
|
||||
ARG GIT_REMOTE_URL=
|
||||
ARG GIT_REMOTE_COMMIT_URL=
|
||||
ARG CONDUWUIT_VERSION_EXTRA=
|
||||
ARG CONTINUWUITY_VERSION_EXTRA=
|
||||
ENV GIT_COMMIT_HASH=$GIT_COMMIT_HASH
|
||||
ENV GIT_COMMIT_HASH_SHORT=$GIT_COMMIT_HASH_SHORT
|
||||
ENV GIT_REMOTE_URL=$GIT_REMOTE_URL
|
||||
ENV GIT_REMOTE_COMMIT_URL=$GIT_REMOTE_COMMIT_URL
|
||||
ENV CONDUWUIT_VERSION_EXTRA=$CONDUWUIT_VERSION_EXTRA
|
||||
ENV CONTINUWUITY_VERSION_EXTRA=$CONTINUWUITY_VERSION_EXTRA
|
||||
|
||||
|
||||
# Build the binary
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/usr/local/cargo/git/db \
|
||||
--mount=type=cache,target=/app/target,id=cargo-target-${TARGETPLATFORM} \
|
||||
--mount=type=cache,target=/app/target \
|
||||
bash <<'EOF'
|
||||
set -o allexport
|
||||
set -o xtrace
|
||||
. /etc/environment
|
||||
TARGET_DIR=($(cargo metadata --no-deps --format-version 1 | \
|
||||
jq -r ".target_directory"))
|
||||
|
@ -168,7 +252,6 @@ EOF
|
|||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/usr/local/cargo/git/db \
|
||||
bash <<'EOF'
|
||||
set -o xtrace
|
||||
mkdir /out/sbom
|
||||
typeset -A PACKAGES
|
||||
for BINARY in /out/sbin/*; do
|
||||
|
@ -187,7 +270,6 @@ EOF
|
|||
|
||||
# Extract dynamically linked dependencies
|
||||
RUN <<EOF
|
||||
set -o xtrace
|
||||
mkdir /out/libs
|
||||
mkdir /out/libs-root
|
||||
for BINARY in /out/sbin/*; do
|
||||
|
|
|
@ -130,8 +130,9 @@ buildDepsOnlyEnv =
|
|||
});
|
||||
|
||||
buildPackageEnv = {
|
||||
GIT_COMMIT_HASH = inputs.self.rev or inputs.self.dirtyRev or "";
|
||||
GIT_COMMIT_HASH_SHORT = inputs.self.shortRev or inputs.self.dirtyShortRev or "";
|
||||
COMMIT_SHA = inputs.self.rev or inputs.self.dirtyRev or "";
|
||||
SHORT_COMMIT_SHA = inputs.self.shortRev or inputs.self.dirtyShortRev or "";
|
||||
CONDUWUIT_VERSION_EXTRA = inputs.self.shortRev or inputs.self.dirtyShortRev or "";
|
||||
} // buildDepsOnlyEnv // {
|
||||
# Only needed in static stdenv because these are transitive dependencies of rocksdb
|
||||
CARGO_BUILD_RUSTFLAGS = buildDepsOnlyEnv.CARGO_BUILD_RUSTFLAGS
|
||||
|
|
|
@ -2,7 +2,8 @@ use std::sync::Arc;
|
|||
|
||||
use axum::{Router, response::IntoResponse};
|
||||
use conduwuit::Error;
|
||||
use conduwuit_service::{Services, state, state::Guard};
|
||||
use conduwuit_api::router::{state, state::Guard};
|
||||
use conduwuit_service::Services;
|
||||
use http::{StatusCode, Uri};
|
||||
use ruma::api::client::error::ErrorKind;
|
||||
|
||||
|
@ -10,7 +11,7 @@ pub(crate) fn build(services: &Arc<Services>) -> (Router, Guard) {
|
|||
let router = Router::<state::State>::new();
|
||||
let (state, guard) = state::create(services.clone());
|
||||
let router = conduwuit_api::router::build(router, &services.server)
|
||||
.merge(conduwuit_web::build())
|
||||
.merge(conduwuit_web::build::<state::State>().with_state(()))
|
||||
.fallback(not_found)
|
||||
.with_state(state);
|
||||
|
||||
|
|
|
@ -20,9 +20,6 @@ crate-type = [
|
|||
|
||||
|
||||
[dependencies]
|
||||
conduwuit-build-metadata.workspace = true
|
||||
conduwuit-service.workspace = true
|
||||
|
||||
askama = "0.14.0"
|
||||
|
||||
axum.workspace = true
|
||||
|
|
|
@ -1,34 +1,22 @@
|
|||
use askama::Template;
|
||||
use axum::{
|
||||
Router,
|
||||
extract::State,
|
||||
http::{StatusCode, header},
|
||||
response::{Html, IntoResponse, Response},
|
||||
routing::get,
|
||||
};
|
||||
use conduwuit_build_metadata::{GIT_REMOTE_COMMIT_URL, GIT_REMOTE_WEB_URL, version_tag};
|
||||
use conduwuit_service::state;
|
||||
|
||||
pub fn build() -> Router<state::State> {
|
||||
let router = Router::<state::State>::new();
|
||||
router.route("/", get(index_handler))
|
||||
}
|
||||
pub fn build<S>() -> Router<()> { Router::new().route("/", get(index_handler)) }
|
||||
|
||||
async fn index_handler(
|
||||
State(services): State<state::State>,
|
||||
) -> Result<impl IntoResponse, WebError> {
|
||||
async fn index_handler() -> Result<impl IntoResponse, WebError> {
|
||||
#[derive(Debug, Template)]
|
||||
#[template(path = "index.html.j2")]
|
||||
struct Tmpl<'a> {
|
||||
nonce: &'a str,
|
||||
server_name: &'a str,
|
||||
}
|
||||
let nonce = rand::random::<u64>().to_string();
|
||||
|
||||
let template = Tmpl {
|
||||
nonce: &nonce,
|
||||
server_name: services.config.server_name.as_str(),
|
||||
};
|
||||
let template = Tmpl { nonce: &nonce };
|
||||
Ok((
|
||||
[(header::CONTENT_SECURITY_POLICY, format!("default-src 'none' 'nonce-{nonce}';"))],
|
||||
Html(template.render()?),
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
{%~ block footer ~%}
|
||||
<footer>
|
||||
<p>Powered by <a href="https://continuwuity.org">Continuwuity</a>
|
||||
{%~ if let Some(version_info) = self::version_tag() ~%}
|
||||
{%~ if let Some(url) = GIT_REMOTE_COMMIT_URL.or(GIT_REMOTE_WEB_URL) ~%}
|
||||
{%~ if let Some(version_info) = option_env!("CONDUWUIT_VERSION_EXTRA").or(option_env!("SHORT_COMMIT_SHA")) ~%}
|
||||
{%~ if let Some(url) = option_env!("REMOTE_COMMIT_URL").or(option_env!("REMOTE_URL")) ~%}
|
||||
(<a href="{{ url }}">{{ version_info }}</a>)
|
||||
{%~ else ~%}
|
||||
({{ version_info }})
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
<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">Continuwuity Matrix room</a> or <a href="https://matrix.to/#/#space:continuwuity.org">space</a></li>
|
||||
<li>Join the <a href="https://continuwuity.org/community">community</a></li>
|
||||
<li>Log in with a <a href="https://matrix.org/ecosystem/clients/">client</a></li>
|
||||
<li>Ensure <a href="https://federationtester.matrix.org/#{{ server_name }}">federation</a> works</li>
|
||||
<li>Ensure <a href="https://federationtester.matrix.org/">federation</a> works</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue