mirror of
https://codeberg.org/demostf/frontend.git
synced 2026-06-03 18:24:12 +02:00
load map images from remote
This commit is contained in:
parent
6dcb4493a1
commit
8325c0c57d
4 changed files with 18 additions and 5 deletions
|
|
@ -16,9 +16,11 @@ export interface MapRenderProps {
|
||||||
scale: number;
|
scale: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const map_root = document.querySelector('[data-maps]').getAttribute('data-maps');
|
||||||
|
|
||||||
export function MapRender(props: MapRenderProps) {
|
export function MapRender(props: MapRenderProps) {
|
||||||
const mapAlias = findMapAlias(props.header.map);
|
const mapAlias = findMapAlias(props.header.map);
|
||||||
const image = `/images/leveloverview/dist/${mapAlias}.webp`;
|
const image = `${map_root}images/${mapAlias}.webp`;
|
||||||
const background = `url(${image})`;
|
const background = `url(${image})`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -52,4 +52,5 @@ pub enum Listen {
|
||||||
pub struct SiteConfig {
|
pub struct SiteConfig {
|
||||||
pub url: String,
|
pub url: String,
|
||||||
pub api: String,
|
pub api: String,
|
||||||
|
pub maps: String,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
src/main.rs
10
src/main.rs
|
|
@ -55,6 +55,7 @@ struct App {
|
||||||
connection: PgPool,
|
connection: PgPool,
|
||||||
openid: SteamOpenId,
|
openid: SteamOpenId,
|
||||||
api: String,
|
api: String,
|
||||||
|
maps: String,
|
||||||
pub session_store: MemoryStore,
|
pub session_store: MemoryStore,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,6 +86,7 @@ async fn main() -> Result<()> {
|
||||||
openid: SteamOpenId::new(&config.site.url, "/login/callback")
|
openid: SteamOpenId::new(&config.site.url, "/login/callback")
|
||||||
.expect("invalid steam login url"),
|
.expect("invalid steam login url"),
|
||||||
api: config.site.api,
|
api: config.site.api,
|
||||||
|
maps: config.site.maps,
|
||||||
session_store: session_store.clone(),
|
session_store: session_store.clone(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -373,7 +375,13 @@ async fn viewer(
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
Ok(render(ViewerPage { demo }, session))
|
Ok(render(
|
||||||
|
ViewerPage {
|
||||||
|
demo,
|
||||||
|
maps: &app.maps,
|
||||||
|
},
|
||||||
|
session,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
async fn handler_404() -> impl IntoResponse {
|
async fn handler_404() -> impl IntoResponse {
|
||||||
Error::NotFound
|
Error::NotFound
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ use demostf_build::Asset;
|
||||||
use maud::{html, Markup};
|
use maud::{html, Markup};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
pub struct ViewerPage {
|
pub struct ViewerPage<'a> {
|
||||||
pub demo: Option<Demo>,
|
pub demo: Option<Demo>,
|
||||||
|
pub maps: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Asset)]
|
#[derive(Asset)]
|
||||||
|
|
@ -30,7 +31,7 @@ pub struct ViewerStyle;
|
||||||
)]
|
)]
|
||||||
pub struct ParserWasm;
|
pub struct ParserWasm;
|
||||||
|
|
||||||
impl Page for ViewerPage {
|
impl Page for ViewerPage<'_> {
|
||||||
fn title(&self) -> Cow<'static, str> {
|
fn title(&self) -> Cow<'static, str> {
|
||||||
format!(
|
format!(
|
||||||
"{} - demos.tf",
|
"{} - demos.tf",
|
||||||
|
|
@ -45,8 +46,9 @@ impl Page for ViewerPage {
|
||||||
fn render(&self) -> Markup {
|
fn render(&self) -> Markup {
|
||||||
let script = ViewerScript::url();
|
let script = ViewerScript::url();
|
||||||
let style_url = ViewerStyle::url();
|
let style_url = ViewerStyle::url();
|
||||||
|
let maps = self.maps;
|
||||||
html! {
|
html! {
|
||||||
.viewer-page {
|
.viewer-page data-maps = (maps) {
|
||||||
@if let Some(demo) = self.demo.as_ref() {
|
@if let Some(demo) = self.demo.as_ref() {
|
||||||
input type = "hidden" name = "url" value = (demo.url) {}
|
input type = "hidden" name = "url" value = (demo.url) {}
|
||||||
progress.download min = "0" max = "100" value = "0" {}
|
progress.download min = "0" max = "100" value = "0" {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue