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