mirror of
https://codeberg.org/demostf/frontend.git
synced 2026-06-03 18:24:12 +02:00
upload page
This commit is contained in:
parent
b0b3c0f3ed
commit
a8f0d8e299
8 changed files with 171 additions and 18 deletions
11
src/main.rs
11
src/main.rs
|
|
@ -221,9 +221,16 @@ async fn logout(
|
|||
)
|
||||
}
|
||||
|
||||
async fn upload(State(_app): State<Arc<App>>, session: SessionData) -> impl IntoResponse {
|
||||
async fn upload(State(app): State<Arc<App>>, session: SessionData) -> impl IntoResponse {
|
||||
if let Some(token) = session.token() {
|
||||
render(UploadPage { key: token }, session).into_response()
|
||||
render(
|
||||
UploadPage {
|
||||
key: token.as_str(),
|
||||
api: app.api.as_str(),
|
||||
},
|
||||
session,
|
||||
)
|
||||
.into_response()
|
||||
} else {
|
||||
(
|
||||
StatusCode::FOUND,
|
||||
|
|
|
|||
|
|
@ -4,19 +4,20 @@ use crate::pages::Page;
|
|||
use maud::{html, Markup};
|
||||
use std::borrow::Cow;
|
||||
|
||||
pub struct UploadPage {
|
||||
pub key: String,
|
||||
pub struct UploadPage<'a> {
|
||||
pub key: &'a str,
|
||||
pub api: &'a str,
|
||||
}
|
||||
|
||||
impl UploadPage {
|
||||
pub fn plugin_section(&self) -> PluginSection {
|
||||
impl<'a> UploadPage<'a> {
|
||||
pub fn plugin_section(&self) -> PluginSection<'a> {
|
||||
PluginSection {
|
||||
key: Some(self.key.as_str()),
|
||||
key: Some(self.key),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Page for UploadPage {
|
||||
impl Page for UploadPage<'_> {
|
||||
fn title(&self) -> Cow<'static, str> {
|
||||
"Upload - demos.tf".into()
|
||||
}
|
||||
|
|
@ -39,20 +40,26 @@ impl Page for UploadPage {
|
|||
noscript {
|
||||
"Javascript is required for demo upload."
|
||||
}
|
||||
"Drop files or click to upload"
|
||||
span.text { "Drop files or click to upload" }
|
||||
input type = "file" {}
|
||||
}
|
||||
.demo-info {
|
||||
span.map {}
|
||||
span.time {}
|
||||
}
|
||||
input type = "hidden" name = "api" value = (self.api) {}
|
||||
button.button.button-primary disabled { "Upload" }
|
||||
}
|
||||
section {
|
||||
.title {
|
||||
h3 { "API Key" }
|
||||
}
|
||||
pre { (self.key) }
|
||||
pre.key { (self.key) }
|
||||
p { "This key is used by the plugin to authenticate you as the uploader and link the uploaded demo to your account." }
|
||||
}
|
||||
(self.plugin_section())
|
||||
}
|
||||
script src = (script) type = "text/javascript" {}
|
||||
script defer src = (script) type = "text/javascript" {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue