feat: rm gift and port about page to tera

This commit is contained in:
Aravinth Manivannan 2023-01-24 23:26:51 +05:30
parent 9f0d38ab07
commit 67d50a3d80
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88
2 changed files with 90 additions and 100 deletions

View File

@ -14,41 +14,68 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use std::cell::RefCell;
use std::str::FromStr;
use actix_web::http::header::ContentType;
use actix_web::{web, HttpResponse, Responder};
use my_codegen::get;
use sailfish::TemplateOnce;
use tera::Context;
use uuid::Uuid;
use crate::errors::*;
use crate::PAGES;
use crate::errors::ServiceError;
use crate::settings::Settings;
use crate::AppData;
#[derive(TemplateOnce)]
#[template(path = "index.html")]
struct Intro<'a> {
uuid: &'a str,
pub use super::*;
pub struct Intro {
ctx: RefCell<Context>,
}
const PAGE: &str = "Survey";
pub const INTRO: TemplateFile = TemplateFile::new("intro", "index.html");
impl<'a> Intro<'a> {
pub fn new(uuid: &'a str) -> Self {
Self { uuid }
impl CtxError for Intro {
fn with_error(&self, e: &ReadableError) -> String {
self.ctx.borrow_mut().insert(ERROR_KEY, e);
self.render()
}
}
#[get(path = "PAGES.panel.campaigns.about")]
pub async fn about(path: web::Path<String>) -> PageResult<impl Responder> {
impl Intro {
pub fn new(settings: &Settings, payload: Option<&str>) -> Self {
let ctx = RefCell::new(context(settings, "Login"));
if let Some(uuid) = payload {
let payload = crate::PAGES.panel.campaigns.get_bench_route(uuid);
ctx.borrow_mut().insert(PAYLOAD_KEY, &payload);
}
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES.render(INTRO.name, &self.ctx.borrow()).unwrap()
}
}
#[actix_web_codegen_const_routes::get(path = "PAGES.panel.campaigns.about")]
pub async fn about(
data: AppData,
path: web::Path<String>,
) -> PageResult<impl Responder, Intro> {
let path = path.into_inner();
match Uuid::from_str(&path) {
Err(_) => Err(PageError::PageDoesntExist),
Err(_) => Err(PageError::new(
Intro::new(&data.settings, None),
ServiceError::CampaignDoesntExist,
)),
Ok(_) => {
let page = Intro::new(&path).render_once().unwrap();
Ok(HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(page))
let about = Intro::new(&data.settings, Some(&path)).render();
let html = ContentType::html();
Ok(HttpResponse::Ok().content_type(html).body(about))
}
}
}
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
cfg.service(about);
}

View File

@ -1,85 +1,48 @@
<. include!("./components/base/top.html"); .>
<body class="survey__body">
<main class="survey__container">
<h1>mCaptcha benchmark survey</h1>
<section>
<h2>Why should I participate</h2>
<p>
<a href="https://mcaptcha.org" target="_blank">mCaptcha</a>
is a cutting edge, privacy respecting CAPTCHA system. We use a
<a href="https://en.wikipedia.org/wiki/Proof_of_work" target="_blank"
>proof of work</a
>
based mechanism to defend against
<a href="https://en.wikipedia.org/wiki/Proof_of_work" target="_blank"
>denial-of-service attacks</a
>
which allows for a non-interactive CAPTCHA experience. We require
performance metrics measured on a wide range of devices to fine-tune the
system for optimal user experience, see for yourself!
</p>
<div class="survey__captcha-widget" style="width: 304px; height: 78px">
<div id="mcaptcha__widget-container" style="width: 304px; height: 78px"></div>
</div>
</section>
<section>
<h2>What do I get?</h2>
<div class="survey__prize-section">
{% extends 'base' %}
{% block body %}
<body class="survey__body">
<main class="survey__container">
<h1>mCaptcha benchmark survey</h1>
<section>
{% include "error_comp" %}
<h2>Why should I participate</h2>
<p>
We are conducting a lucky draw. Two lucky participants, selected at
random, will win a pair of JBL headsets worth over ₹2,500! Also, you
will be helping us make the internet healthier :)
<a href="https://mcaptcha.org" target="_blank">mCaptcha</a>
is a cutting edge, privacy respecting CAPTCHA system. We use a
<a href="https://en.wikipedia.org/wiki/Proof_of_work" target="_blank"
>proof of work</a
>
based mechanism to defend against
<a href="https://en.wikipedia.org/wiki/Proof_of_work" target="_blank"
>denial-of-service attacks</a
>
which allows for a non-interactive CAPTCHA experience. We require
performance metrics measured on a wide range of devices to fine-tune the
system for optimal user experience, see for yourself!
</p>
<a
target="_blank"
class="prize__preview"
href="https://www.amazon.in/JBL-Detachable-Directional-Headphones-Conference/dp/B0948TG7H8"
>
<img
src="<.= crate::assets::HEADSETS.path .>"
alt="<.= crate::assets::HEADSETS.name .>"
class="survey__prize"
/>
<p>
Product details
<img
src="<.= crate::assets::EXTERNAL_LINK.path .>"
alt="<.= crate::assets::EXTERNAL_LINK.name .>"
/>
</p>
</a>
</div>
</section>
<div class="survey__captcha-widget" style="width: 304px; height: 78px">
<div id="mcaptcha__widget-container" style="width: 304px; height: 78px"></div>
</div>
</section>
<section>
<h2>Privacy policy</h2>
<p>This survey collects the following information:</p>
<ul>
<li>Device name</li>
<li>Operating system</li>
<li>Processor information</li>
<li>Benchmark results</li>
</ul>
<b>No Personally identifying information is collected</b>
</section>
<section>
<h2>Privacy policy</h2>
<p>This survey collects the following information:</p>
<ul>
<li>Device name</li>
<li>Operating system</li>
<li>Processor information</li>
<li>Benchmark results</li>
</ul>
<b>No Personally identifying information is collected</b>
</section>
<section>
<h2>Winner Announcement</h2>
<p>
The winners will be announed on the organisation website
<a href="https://mcaptcha.org/blog/survey" target="_blank">here</a> on
December 1, 2021. The winning submission IDs will be published and the
winners expected to provide the submission proof to claim their rewards.
</p>
</section>
<a
class="link__btn"
href="<.= crate::PAGES.panel.campaigns.get_bench_route(uuid) .>"
>Get started</a
>
</main>
<. include!("./components/footer/index.html"); .>
</body>
<script src="<.= &*crate::GLUE .>./dist/bundle.js"></script>
<. include!("./components/base/bottom.html"); .>
<a
class="link__btn"
href="{{ payload }}"
>Get started</a
>
</main>
</body>
<script src="{{ assets.glue }}"></script>
{% endblock body %}