load instance url from Env struct
This commit is contained in:
parent
8aeac07cf8
commit
ce8737b0f5
|
@ -13,18 +13,22 @@ use super::{state::SharedState, rejection::HttpReject};
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template( path = "index.html" )]
|
#[template( path = "index.html" )]
|
||||||
pub struct Index {}
|
pub struct Index {
|
||||||
|
env: Env
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template( path = "bad_action_req.html" )]
|
#[template( path = "bad_action_req.html" )]
|
||||||
pub struct BadActionReq {}
|
pub struct BadActionReq {
|
||||||
|
env: Env
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template( path = "uploaded.html" )]
|
#[template( path = "uploaded.html" )]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub struct Uploaded {
|
pub struct Uploaded {
|
||||||
file: String,
|
file: String,
|
||||||
instance_url: String
|
env: Env
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,7 +40,7 @@ pub async fn uploaded(query: HashMap<String, String>, state: SharedState) -> Res
|
||||||
|
|
||||||
let rendered = Uploaded {
|
let rendered = Uploaded {
|
||||||
file: query.get("file").unwrap().clone(),
|
file: query.get("file").unwrap().clone(),
|
||||||
instance_url: state.env.instanceurl.clone()
|
env: state.env.clone()
|
||||||
};
|
};
|
||||||
Ok(warp::reply::html(rendered.render().map_err(|err| warp::reject::custom(HttpReject::AskamaError(err)))?))
|
Ok(warp::reply::html(rendered.render().map_err(|err| warp::reject::custom(HttpReject::AskamaError(err)))?))
|
||||||
}
|
}
|
||||||
|
@ -50,16 +54,20 @@ pub fn uploaded_f(state: SharedState) -> impl Filter<Extract = impl Reply, Error
|
||||||
.and_then(uploaded)
|
.and_then(uploaded)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn index() -> Result<Html<String>, Rejection> {
|
pub async fn index(state: SharedState) -> Result<Html<String>, Rejection> {
|
||||||
let rendered = Index {};
|
let rendered = Index {
|
||||||
|
env: state.env.clone()
|
||||||
|
};
|
||||||
Ok(warp::reply::html(rendered.render().map_err(|err| warp::reject::custom(HttpReject::AskamaError(err)))?))
|
Ok(warp::reply::html(rendered.render().map_err(|err| warp::reject::custom(HttpReject::AskamaError(err)))?))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn index_f() -> impl Filter<Extract = impl Reply, Error = warp::Rejection> + Clone {
|
pub fn index_f(state: SharedState) -> impl Filter<Extract = impl Reply, Error = warp::Rejection> + Clone {
|
||||||
warp::path::end().and_then(index)
|
warp::path::end()
|
||||||
|
.map(move || state.clone())
|
||||||
|
.and_then(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_routes(state: SharedState) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
|
pub fn get_routes(state: SharedState) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
|
||||||
index_f()
|
index_f(state.clone())
|
||||||
.or(uploaded_f(state))
|
.or(uploaded_f(state.clone()))
|
||||||
}
|
}
|
|
@ -11,8 +11,9 @@
|
||||||
|
|
||||||
<meta property="og:title" content="🛸 blek! File">
|
<meta property="og:title" content="🛸 blek! File">
|
||||||
<meta property="og:description" content="A minute file hosting service">
|
<meta property="og:description" content="A minute file hosting service">
|
||||||
<meta property="og:url" content="https://file.blek.codes">
|
|
||||||
<meta property="og:site_name" content="file.blek.codes">
|
<meta property="og:url" content='{{ env.instanceurl }}'>
|
||||||
|
<meta property="og:site_name" content="blek! File">
|
||||||
<meta property="og:type" content="website">
|
<meta property="og:type" content="website">
|
||||||
<meta property="og:image" content="">
|
<meta property="og:image" content="">
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
<div class="card-text">
|
<div class="card-text">
|
||||||
<p>
|
<p>
|
||||||
The file is accessible via this link:
|
The file is accessible via this link:
|
||||||
<a href='{{ instance_url }}/file/{{ file }}'>{{ instance_url }}/file/{{ file }}</a>
|
<a href='{{ env.instanceurl }}/file/{{ file }}'>{{ env.instanceurl }}/file/{{ file }}</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class="js-only">
|
<p class="js-only">
|
||||||
<button class="btn btn-fill" style="cursor:pointer" id="copylink" data-clipboard-text="{{ instance_url }}/file/{{ file }}">
|
<button class="btn btn-fill" style="cursor:pointer" id="copylink" data-clipboard-text="{{ env.instanceurl }}/file/{{ file }}">
|
||||||
Copy link
|
Copy link
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Reference in New Issue