Compare commits

..

No commits in common. "ce8737b0f571b44b3aaa250ef7cf26e4b328c9d1" and "e73afde9bc5e7f8e50f0efcd95316ebb309bad89" have entirely different histories.

4 changed files with 14 additions and 24 deletions

View File

@ -13,22 +13,18 @@ use super::{state::SharedState, rejection::HttpReject};
#[derive(Template)]
#[template( path = "index.html" )]
pub struct Index {
env: Env
}
pub struct Index {}
#[derive(Template)]
#[template( path = "bad_action_req.html" )]
pub struct BadActionReq {
env: Env
}
pub struct BadActionReq {}
#[derive(Template)]
#[template( path = "uploaded.html" )]
#[allow(dead_code)]
pub struct Uploaded {
file: String,
env: Env
instance_url: String
}
@ -40,7 +36,7 @@ pub async fn uploaded(query: HashMap<String, String>, state: SharedState) -> Res
let rendered = Uploaded {
file: query.get("file").unwrap().clone(),
env: state.env.clone()
instance_url: state.env.instanceurl.clone()
};
Ok(warp::reply::html(rendered.render().map_err(|err| warp::reject::custom(HttpReject::AskamaError(err)))?))
}
@ -54,20 +50,16 @@ pub fn uploaded_f(state: SharedState) -> impl Filter<Extract = impl Reply, Error
.and_then(uploaded)
}
pub async fn index(state: SharedState) -> Result<Html<String>, Rejection> {
let rendered = Index {
env: state.env.clone()
};
pub async fn index() -> Result<Html<String>, Rejection> {
let rendered = Index {};
Ok(warp::reply::html(rendered.render().map_err(|err| warp::reject::custom(HttpReject::AskamaError(err)))?))
}
pub fn index_f(state: SharedState) -> impl Filter<Extract = impl Reply, Error = warp::Rejection> + Clone {
warp::path::end()
.map(move || state.clone())
.and_then(index)
pub fn index_f() -> impl Filter<Extract = impl Reply, Error = warp::Rejection> + Clone {
warp::path::end().and_then(index)
}
pub fn get_routes(state: SharedState) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
index_f(state.clone())
.or(uploaded_f(state.clone()))
index_f()
.or(uploaded_f(state))
}

View File

@ -14,7 +14,6 @@
<link rel="stylesheet" href="/js-only.css" />
<script src="/delay.js"></script>
<title>blek! File</title>
{% include "seotags.html" %}
{% block head %}{% endblock %}
</head>

View File

@ -11,9 +11,8 @@
<meta property="og:title" content="🛸 blek! File">
<meta property="og:description" content="A minute file hosting service">
<meta property="og:url" content='{{ env.instanceurl }}'>
<meta property="og:site_name" content="blek! File">
<meta property="og:url" content="https://file.blek.codes">
<meta property="og:site_name" content="file.blek.codes">
<meta property="og:type" content="website">
<meta property="og:image" content="">

View File

@ -10,11 +10,11 @@
<div class="card-text">
<p>
The file is accessible via this link:
<a href='{{ env.instanceurl }}/file/{{ file }}'>{{ env.instanceurl }}/file/{{ file }}</a>
<a href='{{ instance_url }}/file/{{ file }}'>{{ instance_url }}/file/{{ file }}</a>
</p>
<p class="js-only">
<button class="btn btn-fill" style="cursor:pointer" id="copylink" data-clipboard-text="{{ env.instanceurl }}/file/{{ file }}">
<button class="btn btn-fill" style="cursor:pointer" id="copylink" data-clipboard-text="{{ instance_url }}/file/{{ file }}">
Copy link
</button>
</p>