diff --git a/src/pages/panel/campaigns/bench.rs b/src/pages/panel/campaigns/bench.rs index 30e6e00..37cb9c6 100644 --- a/src/pages/panel/campaigns/bench.rs +++ b/src/pages/panel/campaigns/bench.rs @@ -14,46 +14,55 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -use std::str::FromStr; +use std::cell::RefCell; +use actix_web::http::header::ContentType; use actix_web::{web, HttpResponse, Responder}; -use lazy_static::lazy_static; -use my_codegen::get; -use sailfish::TemplateOnce; +use tera::Context; use uuid::Uuid; -use crate::errors::*; -use crate::pages::errors::ErrorPage; +use crate::AppData; use crate::PAGES; -#[derive(TemplateOnce)] -#[template(path = "bench/index.html")] -struct Bench<'a> { - error: Option>, -} -const PAGE: &str = "Survey"; +pub use super::*; -impl<'a> Default for Bench<'a> { - fn default() -> Self { - Bench { error: None } +pub struct Bench { + ctx: RefCell, +} + +pub const BENCH: TemplateFile = TemplateFile::new("new_campaign", "bench/index.html"); + +impl CtxError for Bench { + fn with_error(&self, e: &ReadableError) -> String { + self.ctx.borrow_mut().insert(ERROR_KEY, e); + self.render() } } -lazy_static! { - static ref BENCH: String = Bench::default().render_once().unwrap(); +impl Bench { + pub fn new(settings: &Settings) -> Self { + let ctx = RefCell::new(context(settings, "Login")); + Self { ctx } + } + + pub fn render(&self) -> String { + TEMPLATES.render(BENCH.name, &self.ctx.borrow()).unwrap() + } } -#[get( +#[actix_web_codegen_const_routes::get( path = "PAGES.panel.campaigns.bench", wrap = "crate::api::v1::bench::get_check_login()" )] -pub async fn bench(path: web::Path) -> PageResult { - let path = path.into_inner(); - - match Uuid::from_str(&path) { - Err(_) => Err(PageError::PageDoesntExist), - Ok(_) => Ok(HttpResponse::Ok() - .content_type("text/html; charset=utf-8") - .body(&*BENCH.as_str())), - } +pub async fn bench( + data: AppData, + _path: web::Path, +) -> PageResult { + let bench = Bench::new(&data.settings).render(); + let html = ContentType::html(); + Ok(HttpResponse::Ok().content_type(html).body(bench)) +} + +pub fn services(cfg: &mut actix_web::web::ServiceConfig) { + cfg.service(bench); } diff --git a/templates/bench/index.html b/templates/bench/index.html index eaac574..e7cf292 100644 --- a/templates/bench/index.html +++ b/templates/bench/index.html @@ -1,143 +1,145 @@ -<. include!("../components/base/top.html"); .> - -
- <. include!("../components/error/index.html"); .> -
-

Click to Start Benchmark

-
- +{% extends 'base' %} +{% block body %} + +
+ {% include "error_comp" %} - - - -
+
+

Click to Start Benchmark

+
+ - - -
-

Running benchmark

-
- - -
-

Winner Announcement

-

- The winners will be announed on the organisation website - here on - December 1, 2021. The winning submission IDs will be published and the - winners expected to provide the submission proof to claim their - rewards. -

+ + +
-
-
+ - - - - - - - - -
Difficulty factorDuration(ms)
-
-
- <. include!("../components/footer/index.html"); .> - - - -<. include!("../components/base/bottom.html"); .> + #device-info { + margin: auto; + font-size: 0.8rem; + } + + .advance-log > b, + div { + font-size: 0.8rem; + } + .advance-log { + display: none; + } + #winner-instructions { + display: none; + } + + #submission-proof { + margin: 15px auto; + } + + #submission-proof > div, + b { + font-size: 1.2rem; + font-family: monospace, monospace; + } + + + +{% endblock body %}