copy text and other small changes
This commit is contained in:
520
Cargo.lock
generated
520
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@ random-string = "1.1.0"
|
|||||||
reqwest = { version = "0.13.2", features = ["stream"] }
|
reqwest = { version = "0.13.2", features = ["stream"] }
|
||||||
tracing = "0.1.44"
|
tracing = "0.1.44"
|
||||||
wasm-bindgen = "0.2.114"
|
wasm-bindgen = "0.2.114"
|
||||||
web-sys = { version = "0.3.91", features = ["XmlHttpRequest", "XmlHttpRequestUpload", "ProgressEvent" ] }
|
web-sys = { version = "0.3.91", features = [ "Navigator", "Clipboard" ] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["web"]
|
default = ["web"]
|
||||||
|
|||||||
@ -4,13 +4,6 @@ pkgs.mkShell {
|
|||||||
rustup
|
rustup
|
||||||
];
|
];
|
||||||
nativeBuildInputs = with pkgs;[
|
nativeBuildInputs = with pkgs;[
|
||||||
openssl
|
|
||||||
glib
|
|
||||||
gdk-pixbuf
|
|
||||||
pango
|
|
||||||
atk
|
|
||||||
xdo
|
|
||||||
lld
|
|
||||||
];
|
];
|
||||||
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
|
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
use views::{Blog, Home, Navbar, Upload};
|
use views::{Upload};
|
||||||
use tracing::Level;
|
use tracing::Level;
|
||||||
|
|
||||||
mod components;
|
mod components;
|
||||||
@ -11,15 +11,9 @@ mod views;
|
|||||||
enum Route {
|
enum Route {
|
||||||
#[route("/upload")]
|
#[route("/upload")]
|
||||||
Upload {},
|
Upload {},
|
||||||
#[layout(Navbar)]
|
|
||||||
#[route("/")]
|
|
||||||
Home {},
|
|
||||||
#[route("/blog/:id")]
|
|
||||||
Blog { id: i32 },
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const FAVICON: Asset = asset!("/assets/favicon.ico");
|
const FAVICON: Asset = asset!("/assets/favicon.ico");
|
||||||
//const MAIN_CSS: Asset = asset!("/assets/styling/main.css");
|
|
||||||
const TAILWIND_CSS: Asset = asset!("/assets/tailwind.css");
|
const TAILWIND_CSS: Asset = asset!("/assets/tailwind.css");
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|||||||
@ -1,30 +0,0 @@
|
|||||||
use crate::Route;
|
|
||||||
use dioxus::prelude::*;
|
|
||||||
use crate::components::{Hero};
|
|
||||||
|
|
||||||
//const BLOG_CSS: Asset = asset!("/assets/styling/blog.css");
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn Blog(id: i32) -> Element {
|
|
||||||
rsx! {
|
|
||||||
// document::Link { rel: "stylesheet", href: BLOG_CSS }
|
|
||||||
|
|
||||||
div {
|
|
||||||
id: "blog",
|
|
||||||
|
|
||||||
h1 { "This is blog #{id}!" }
|
|
||||||
p { "In blog #{id}, we show how the Dioxus router works and how URL parameters can be passed as props to our route components." }
|
|
||||||
|
|
||||||
Link {
|
|
||||||
to: Route::Blog { id: id - 1 },
|
|
||||||
"Previous"
|
|
||||||
}
|
|
||||||
span { " <---> " }
|
|
||||||
Link {
|
|
||||||
to: Route::Blog { id: id + 1 },
|
|
||||||
"Next"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Hero{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
use dioxus::prelude::*;
|
|
||||||
use crate::components::{Hero, Echo};
|
|
||||||
|
|
||||||
/// The Home page component that will be rendered when the current route is `[Route::Home]`
|
|
||||||
#[component]
|
|
||||||
pub fn Home() -> Element {
|
|
||||||
rsx! {
|
|
||||||
Hero {}
|
|
||||||
Echo {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +1,2 @@
|
|||||||
mod home;
|
|
||||||
pub use home::Home;
|
|
||||||
|
|
||||||
mod blog;
|
|
||||||
pub use blog::Blog;
|
|
||||||
|
|
||||||
mod navbar;
|
|
||||||
pub use navbar::Navbar;
|
|
||||||
|
|
||||||
mod upload;
|
mod upload;
|
||||||
pub use upload::Upload;
|
pub use upload::Upload;
|
||||||
|
|||||||
@ -1,25 +0,0 @@
|
|||||||
use crate::Route;
|
|
||||||
use dioxus::prelude::*;
|
|
||||||
|
|
||||||
//const NAVBAR_CSS: Asset = asset!("/assets/styling/navbar.css");
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn Navbar() -> Element {
|
|
||||||
rsx! {
|
|
||||||
// document::Link { rel: "stylesheet", href: NAVBAR_CSS }
|
|
||||||
|
|
||||||
div {
|
|
||||||
id: "navbar",
|
|
||||||
Link {
|
|
||||||
to: Route::Home {},
|
|
||||||
"Home"
|
|
||||||
}
|
|
||||||
Link {
|
|
||||||
to: Route::Blog { id: 1 },
|
|
||||||
"Blog"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Outlet::<Route> {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -45,8 +45,10 @@ async fn upload_file(mut upload: FileStream) -> Result<String, HttpError> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if upload.size().unwrap() > UPLOAD_SIZE_LIMIT {
|
if let Some(size) = upload.size() {
|
||||||
return HttpError::payload_too_large("this file is too large");
|
if size > UPLOAD_SIZE_LIMIT {
|
||||||
|
return HttpError::payload_too_large("this file is too large");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -60,7 +62,7 @@ async fn upload_file(mut upload: FileStream) -> Result<String, HttpError> {
|
|||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
total_len += bytes.len() as u64;
|
total_len += bytes.len() as u64;
|
||||||
if total_len > UPLOAD_SIZE_LIMIT {
|
if total_len > UPLOAD_SIZE_LIMIT {
|
||||||
error = Some("Uploaded file to large");
|
error = Some("Uploaded file too large");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +99,11 @@ pub fn build_table(files: Vec<(String, String, Option<Result<String, HttpError>>
|
|||||||
td { class: "px-2",
|
td { class: "px-2",
|
||||||
match &file.2 {
|
match &file.2 {
|
||||||
Some(res) => { match res {
|
Some(res) => { match res {
|
||||||
Ok(file_id) => { rsx! { input { type:"button" , "/upload/dl/{file_id}"} } },
|
Ok(file_url) => {let url = file_url.clone(); rsx! { input {
|
||||||
|
type:"button",
|
||||||
|
onclick: move |_| { web_sys::window().unwrap().navigator().clipboard().write_text(&url); },
|
||||||
|
value: "{file_url}"
|
||||||
|
} } },
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let msg = e.message.clone().unwrap();
|
let msg = e.message.clone().unwrap();
|
||||||
rsx! { p { "Upload failed, reason : {msg}" } }
|
rsx! { p { "Upload failed, reason : {msg}" } }
|
||||||
@ -144,7 +150,13 @@ pub fn Upload() -> Element {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = upload_file(file.clone().into()).await;
|
let res = match upload_file(file.clone().into()).await {
|
||||||
|
Ok(file_id) => {
|
||||||
|
let host = web_sys::window().unwrap().location().host().expect("unknown_host");
|
||||||
|
Ok(host + "/upload/" + &file_id)
|
||||||
|
},
|
||||||
|
Err(err) => { Err(err) }
|
||||||
|
};
|
||||||
selected.with_mut(|files| { files[idx].2 = Some(res) });
|
selected.with_mut(|files| { files[idx].2 = Some(res) });
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user