Compare commits

...

2 Commits

Author SHA1 Message Date
blek ce8737b0f5
load instance url from Env struct 2023-10-01 21:42:48 +10:00
blek 8aeac07cf8
actually include the seo tags to the page 2023-10-01 21:17:07 +10:00
4 changed files with 24 additions and 14 deletions

View File

@ -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()))
} }

View File

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

View File

@ -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="">

View File

@ -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>