This commit is contained in:
blek 2023-10-13 23:13:16 +10:00
parent 57c08871be
commit ff7324d089
Signed by: blek
GPG Key ID: 14546221E3595D0C
3 changed files with 55 additions and 1 deletions

View File

@ -61,6 +61,13 @@ pub struct LicensePage {
pub env: Env pub env: Env
} }
#[derive(Template)]
#[template( path = "tos.html" )]
#[allow(dead_code)]
pub struct TOSPage {
pub env: Env
}
pub async fn uploaded(query: HashMap<String, String>, state: SharedState) -> Result<Html<String>, Rejection> { pub async fn uploaded(query: HashMap<String, String>, state: SharedState) -> Result<Html<String>, Rejection> {
if ! query.contains_key("file") { if ! query.contains_key("file") {
@ -138,10 +145,25 @@ pub fn license_f(state: SharedState) -> impl Filter<Extract = impl Reply, Error
.and_then(license) .and_then(license)
} }
pub async fn tos(state: SharedState) -> Result<Html<String>, Rejection> {
let rendered = TOSPage {
env: state.env
};
Ok(warp::reply::html(rendered.render().map_err(|err| warp::reject::custom(HttpReject::AskamaError(err)))?))
}
pub fn tos_f(state: SharedState) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
warp::path!("tos")
.and(warp::path::end())
.map(move || state.clone())
.and_then(tos)
}
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(state.clone()) index_f(state.clone())
.or(uploaded_f(state.clone())) .or(uploaded_f(state.clone()))
.or(passworded_f(state.clone())) .or(passworded_f(state.clone()))
.or(authors_f(state.clone())) .or(authors_f(state.clone()))
.or(license_f(state)) .or(license_f(state.clone()))
.or(tos_f(state))
} }

View File

@ -67,6 +67,18 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<p>
<label>
<input type="checkbox" name="tos_consent">
I agree to the
<a href="/tos">
Terms and Conditions
</a>
<span style='font-size:70%;color:red;transform:translateY(-30%);display:inline-block'>
(required)
</span>
</label>
</p>
<p> <p>
<input type="file" name="file" id="bfile-formupload-file" style="display: none" /> <input type="file" name="file" id="bfile-formupload-file" style="display: none" />
<label for="bfile-formupload-file"> <label for="bfile-formupload-file">

20
filed/templates/tos.html Normal file
View File

@ -0,0 +1,20 @@
{% extends "base.html" %}
{% block body %}
<div style="max-width:95vw;width:fit-content;margin:0 auto">
<h1 style="text-align:center">Terms and conditions</h1>
<ol style="list-style:decimal;padding-left:18px">
<li>
By uploading any file to this website, as a user, you state that the files
you upload are completely legal and take full responsibility for their
distribution via blek! File.
</li>
<li>
Uploading a file with password gives no guarantee that the password will be
stored securely, or that the file will be encrypted or protected at all.
</li>
</ol>
</div>
{% endblock %}