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