mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-03-14 13:08:27 +03:00
static pages are rendered and cached
This commit is contained in:
parent
f817f49182
commit
fe02c43c2c
7 changed files with 49 additions and 65 deletions
|
@ -16,29 +16,27 @@
|
|||
*/
|
||||
|
||||
use actix_web::{HttpResponse, Responder};
|
||||
use lazy_static::lazy_static;
|
||||
use sailfish::TemplateOnce;
|
||||
|
||||
use crate::pages::TITLE;
|
||||
|
||||
#[derive(Clone, TemplateOnce)]
|
||||
#[template(path = "auth/login/index.html")]
|
||||
struct IndexPage<'a> {
|
||||
name: &'a str,
|
||||
title: &'a str,
|
||||
}
|
||||
struct IndexPage;
|
||||
|
||||
impl<'a> Default for IndexPage<'a> {
|
||||
const PAGE: &str = "Login";
|
||||
|
||||
impl Default for IndexPage {
|
||||
fn default() -> Self {
|
||||
IndexPage {
|
||||
name: TITLE,
|
||||
title: "Login",
|
||||
}
|
||||
IndexPage
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref INDEX: String = IndexPage::default().render_once().unwrap();
|
||||
}
|
||||
|
||||
pub async fn login() -> impl Responder {
|
||||
let body = IndexPage::default().render_once().unwrap();
|
||||
HttpResponse::Ok()
|
||||
.content_type("text/html; charset=utf-8")
|
||||
.body(body)
|
||||
.body(&*INDEX)
|
||||
}
|
||||
|
|
|
@ -16,29 +16,27 @@
|
|||
*/
|
||||
|
||||
use actix_web::{HttpResponse, Responder};
|
||||
use lazy_static::lazy_static;
|
||||
use sailfish::TemplateOnce;
|
||||
|
||||
use crate::pages::TITLE;
|
||||
|
||||
#[derive(TemplateOnce, Clone)]
|
||||
#[derive(Clone, TemplateOnce)]
|
||||
#[template(path = "auth/register/index.html")]
|
||||
struct IndexPage<'a> {
|
||||
name: &'a str,
|
||||
title: &'a str,
|
||||
}
|
||||
struct IndexPage;
|
||||
|
||||
impl<'a> Default for IndexPage<'a> {
|
||||
const PAGE: &str = "Join";
|
||||
|
||||
impl Default for IndexPage {
|
||||
fn default() -> Self {
|
||||
IndexPage {
|
||||
name: TITLE,
|
||||
title: "Join",
|
||||
}
|
||||
IndexPage
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref INDEX: String = IndexPage::default().render_once().unwrap();
|
||||
}
|
||||
|
||||
pub async fn join() -> impl Responder {
|
||||
let body = IndexPage::default().render_once().unwrap();
|
||||
HttpResponse::Ok()
|
||||
.content_type("text/html; charset=utf-8")
|
||||
.body(body)
|
||||
.body(&*INDEX)
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ mod auth;
|
|||
mod panel;
|
||||
pub mod routes;
|
||||
|
||||
pub const TITLE: &str = "mCaptcha";
|
||||
pub const NAME: &str = "mCaptcha";
|
||||
|
||||
pub fn services(cfg: &mut ServiceConfig) {
|
||||
auth::services(cfg);
|
||||
|
|
|
@ -16,28 +16,25 @@
|
|||
*/
|
||||
|
||||
use actix_web::{HttpResponse, Responder};
|
||||
use lazy_static::lazy_static;
|
||||
use sailfish::TemplateOnce;
|
||||
|
||||
use crate::pages::TITLE;
|
||||
|
||||
pub mod sitekey;
|
||||
|
||||
#[derive(TemplateOnce, Clone)]
|
||||
#[template(path = "panel/index.html")]
|
||||
pub struct IndexPage<'a> {
|
||||
pub name: &'a str,
|
||||
pub title: &'a str,
|
||||
pub struct IndexPage;
|
||||
|
||||
const PAGE: &str = "Dashboard";
|
||||
|
||||
impl Default for IndexPage {
|
||||
fn default() -> Self {
|
||||
IndexPage
|
||||
}
|
||||
}
|
||||
|
||||
const COMPONENT: &str = "Dashboard";
|
||||
|
||||
impl<'a> Default for IndexPage<'a> {
|
||||
fn default() -> Self {
|
||||
IndexPage {
|
||||
name: TITLE,
|
||||
title: COMPONENT,
|
||||
}
|
||||
}
|
||||
lazy_static! {
|
||||
static ref INDEX: String = IndexPage::default().render_once().unwrap();
|
||||
}
|
||||
|
||||
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
|
||||
|
@ -49,10 +46,9 @@ pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
|
|||
}
|
||||
|
||||
async fn panel() -> impl Responder {
|
||||
let body = IndexPage::default().render_once().unwrap();
|
||||
HttpResponse::Ok()
|
||||
.content_type("text/html; charset=utf-8")
|
||||
.body(body)
|
||||
.body(&*INDEX)
|
||||
}
|
||||
|
||||
pub mod routes {
|
||||
|
|
|
@ -16,39 +16,37 @@
|
|||
*/
|
||||
|
||||
use actix_web::{HttpResponse, Responder};
|
||||
use lazy_static::lazy_static;
|
||||
use sailfish::TemplateOnce;
|
||||
|
||||
use crate::pages::TITLE;
|
||||
const PAGE: &str = "Add Sitekey";
|
||||
|
||||
lazy_static! {
|
||||
static ref INDEX: String = IndexPage::default().render_once().unwrap();
|
||||
}
|
||||
|
||||
#[derive(TemplateOnce, Clone)]
|
||||
#[template(path = "panel/add-site-key/index.html")]
|
||||
pub struct IndexPage<'a> {
|
||||
pub name: &'a str,
|
||||
pub title: &'a str,
|
||||
pub levels: usize,
|
||||
pub form_title: &'a str,
|
||||
pub form_description: &'a str,
|
||||
pub form_duration: usize,
|
||||
}
|
||||
|
||||
const COMPONENT: &str = "Add Site Key";
|
||||
|
||||
impl<'a> Default for IndexPage<'a> {
|
||||
fn default() -> Self {
|
||||
IndexPage {
|
||||
name: TITLE,
|
||||
title: COMPONENT,
|
||||
levels: 1,
|
||||
form_description: "",
|
||||
form_title: "Add Site Key",
|
||||
form_title: PAGE,
|
||||
form_duration: 30,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn add_sitekey() -> impl Responder {
|
||||
let body = IndexPage::default().render_once().unwrap();
|
||||
HttpResponse::Ok()
|
||||
.content_type("text/html; charset=utf-8")
|
||||
.body(body)
|
||||
.body(&*INDEX)
|
||||
}
|
||||
|
|
|
@ -20,19 +20,13 @@ use sailfish::TemplateOnce;
|
|||
|
||||
#[derive(TemplateOnce, Clone)]
|
||||
#[template(path = "panel/site-keys/index.html")]
|
||||
pub struct IndexPage<'a> {
|
||||
pub name: &'a str,
|
||||
pub title: &'a str,
|
||||
}
|
||||
pub struct IndexPage;
|
||||
|
||||
const TITLE: &str = "Add Site Key";
|
||||
const PAGE: &str = "SiteKeys";
|
||||
|
||||
impl<'a> Default for IndexPage<'a> {
|
||||
impl Default for IndexPage {
|
||||
fn default() -> Self {
|
||||
IndexPage {
|
||||
name: "mCaptcha",
|
||||
title: TITLE,
|
||||
}
|
||||
IndexPage
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title><.= title .> | <.= name .></title>
|
||||
<title><.= PAGE .> | <.= crate::pages::NAME .></title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
Loading…
Add table
Reference in a new issue