mirror of
https://github.com/pseXperiments/freedit.git
synced 2026-01-09 19:57:54 -05:00
askama_axum
This commit is contained in:
24
Cargo.lock
generated
24
Cargo.lock
generated
@@ -120,6 +120,17 @@ dependencies = [
|
||||
"askama_escape",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_axum"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a41603f7cdbf5ac4af60760f17253eb6adf6ec5b6f14a7ed830cf687d375f163"
|
||||
dependencies = [
|
||||
"askama",
|
||||
"axum-core",
|
||||
"http",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_derive"
|
||||
version = "0.12.5"
|
||||
@@ -287,9 +298,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.72"
|
||||
version = "0.3.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11"
|
||||
checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cc",
|
||||
@@ -874,6 +885,7 @@ version = "0.7.4-rc.1"
|
||||
dependencies = [
|
||||
"ammonia",
|
||||
"askama",
|
||||
"askama_axum",
|
||||
"atom_syndication",
|
||||
"axum",
|
||||
"axum-extra",
|
||||
@@ -1211,9 +1223,9 @@ checksum = "08a397c49fec283e3d6211adbe480be95aae5f304cfb923e9970e08956d5168a"
|
||||
|
||||
[[package]]
|
||||
name = "httparse"
|
||||
version = "1.9.2"
|
||||
version = "1.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f3935c160d00ac752e09787e6e6bfc26494c2183cc922f1bc678a60d4733bc2"
|
||||
checksum = "d0e7a4dd27b9476dc40cb050d3632d3bba3a70ddbff012285f7f8559a1e7e545"
|
||||
|
||||
[[package]]
|
||||
name = "httpdate"
|
||||
@@ -1905,9 +1917,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.35.0"
|
||||
version = "0.36.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e"
|
||||
checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
@@ -7,6 +7,7 @@ license = "MIT License"
|
||||
[dependencies]
|
||||
ammonia = "4.0.0"
|
||||
askama = { version = "0.12", default-features = false }
|
||||
askama_axum = { version = "0.4.0", default-features = false }
|
||||
atom_syndication = "0.12"
|
||||
axum = { version = "0.7.5", features = ["http1", "http2", "form", "query", "multipart", "tokio"], default-features = false }
|
||||
axum-extra = { version = "0.9", features = ["typed-header"] }
|
||||
|
||||
@@ -2,7 +2,7 @@ use super::{
|
||||
db_utils::{get_range, ivec_to_u32, set_one_with_key, u8_slice_to_u32, IterType},
|
||||
fmt::{clean_html, ts_to_date},
|
||||
inn::ParamsTag,
|
||||
meta_handler::{into_response, PageData, ParamsPage},
|
||||
meta_handler::{PageData, ParamsPage},
|
||||
user::Role,
|
||||
Claim, Feed, FormPost, Item, SiteConfig,
|
||||
};
|
||||
@@ -11,7 +11,7 @@ use crate::{
|
||||
error::AppError,
|
||||
DB,
|
||||
};
|
||||
use askama::Template;
|
||||
use askama_axum::{into_response, Template};
|
||||
use axum::{
|
||||
extract::Query,
|
||||
response::{IntoResponse, Redirect},
|
||||
|
||||
@@ -5,7 +5,7 @@ use super::{
|
||||
},
|
||||
fmt::{clean_html, ts_to_date},
|
||||
inn::inn_add_index,
|
||||
meta_handler::{get_referer, into_response, PageData, ParamsPage},
|
||||
meta_handler::{get_referer, PageData, ParamsPage},
|
||||
Claim, Inn, Post, PostContent, PostStatus, SiteConfig, User,
|
||||
};
|
||||
use crate::{
|
||||
@@ -14,7 +14,7 @@ use crate::{
|
||||
error::AppError,
|
||||
DB,
|
||||
};
|
||||
use askama::Template;
|
||||
use askama_axum::{into_response, Template};
|
||||
use axum::{
|
||||
extract::{Path, Query},
|
||||
response::{IntoResponse, Redirect},
|
||||
|
||||
@@ -20,13 +20,14 @@ use super::{
|
||||
feed::{inn_feed_to_post, update},
|
||||
fmt::{clean_html, md2html, ts_to_date},
|
||||
incr_id,
|
||||
meta_handler::{into_response, PageData, ParamsPage},
|
||||
meta_handler::{PageData, ParamsPage},
|
||||
notification::{add_notification, mark_read, NtType},
|
||||
user::{InnRole, Role},
|
||||
Claim, Comment, Feed, FormPost, Inn, InnType, Post, PostContent, PostStatus, SiteConfig, User,
|
||||
};
|
||||
use crate::{error::AppError, DB};
|
||||
use askama::{filters::escape, Html, Template};
|
||||
use askama_axum::into_response;
|
||||
use atom_syndication::{
|
||||
CategoryBuilder, ContentBuilder, EntryBuilder, FeedBuilder, LinkBuilder, PersonBuilder, Text,
|
||||
WriteConfig,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use askama::Template;
|
||||
use askama_axum::{into_response, Template};
|
||||
use axum::{
|
||||
extract::{Path, Query},
|
||||
response::{IntoResponse, Redirect},
|
||||
@@ -11,7 +11,7 @@ use crate::{controller::fmt::clean_html, error::AppError, DB};
|
||||
|
||||
use super::{
|
||||
db_utils::{get_one, incr_id, u32_to_ivec, u8_slice_to_u32},
|
||||
meta_handler::{into_response, PageData},
|
||||
meta_handler::PageData,
|
||||
notification::{add_notification, mark_read, NtType},
|
||||
Claim, SiteConfig, User,
|
||||
};
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use super::{db_utils::u32_to_ivec, fmt::md2html, Claim, SiteConfig};
|
||||
use crate::{error::AppError, DB};
|
||||
use askama::Template;
|
||||
use askama_axum::{into_response, Template};
|
||||
use axum::{
|
||||
body::Body,
|
||||
http::{HeaderMap, HeaderValue, Uri},
|
||||
response::{IntoResponse, Redirect, Response},
|
||||
};
|
||||
@@ -14,20 +13,6 @@ use http::{HeaderName, StatusCode};
|
||||
use once_cell::sync::Lazy;
|
||||
use tracing::error;
|
||||
|
||||
pub(super) fn into_response<T: Template>(t: &T) -> Response<Body> {
|
||||
match t.render() {
|
||||
Ok(body) => {
|
||||
let headers = [(
|
||||
http::header::CONTENT_TYPE,
|
||||
http::HeaderValue::from_static(T::MIME_TYPE),
|
||||
)];
|
||||
|
||||
(headers, body).into_response()
|
||||
}
|
||||
Err(_) => StatusCode::INTERNAL_SERVER_ERROR.into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "error.html", escape = "none")]
|
||||
struct PageError<'a> {
|
||||
|
||||
@@ -134,7 +134,7 @@ use self::db_utils::{
|
||||
use self::fmt::md2html;
|
||||
use self::tantivy::{ToDoc, FIELDS};
|
||||
use self::user::Role;
|
||||
use crate::{controller::meta_handler::into_response, error::AppError};
|
||||
use crate::error::AppError;
|
||||
use ::tantivy::TantivyDocument;
|
||||
use bincode::config::standard;
|
||||
use bincode::{Decode, Encode};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use super::{
|
||||
get_ids_by_prefix, get_one, incr_id, into_response,
|
||||
get_ids_by_prefix, get_one, incr_id,
|
||||
meta_handler::PageData,
|
||||
u32_to_ivec, u8_slice_to_u32,
|
||||
user::{InnRole, Role},
|
||||
Claim, Comment, Inn, Post, SiteConfig, Solo, User,
|
||||
};
|
||||
use crate::{error::AppError, DB};
|
||||
use askama::Template;
|
||||
use askama_axum::{into_response, Template};
|
||||
use axum::{extract::Query, response::IntoResponse};
|
||||
use axum_extra::{headers::Cookie, TypedHeader};
|
||||
use bincode::config::standard;
|
||||
|
||||
@@ -4,7 +4,7 @@ use super::{
|
||||
IterType,
|
||||
},
|
||||
fmt::{md2html, ts_to_date},
|
||||
get_ids_by_prefix, get_one, incr_id, into_response, ivec_to_u32,
|
||||
get_ids_by_prefix, get_one, incr_id, ivec_to_u32,
|
||||
meta_handler::{get_referer, PageData, ParamsPage},
|
||||
notification::{add_notification, mark_read, NtType},
|
||||
u32_to_ivec, u8_slice_to_u32,
|
||||
@@ -12,7 +12,7 @@ use super::{
|
||||
Claim, SiteConfig, Solo, SoloType, User,
|
||||
};
|
||||
use crate::{error::AppError, DB};
|
||||
use askama::Template;
|
||||
use askama_axum::{into_response, Template};
|
||||
use axum::{
|
||||
extract::{Path, Query},
|
||||
response::{IntoResponse, Redirect},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use askama::Template;
|
||||
use askama_axum::{into_response, Template};
|
||||
use axum::{extract::Query, response::IntoResponse};
|
||||
use axum_extra::{headers::Cookie, TypedHeader};
|
||||
use bincode::config::standard;
|
||||
@@ -35,7 +35,7 @@ use crate::{
|
||||
use super::{
|
||||
db_utils::{get_one, u32_to_ivec, u8_slice_to_u32},
|
||||
fmt::ts_to_date,
|
||||
meta_handler::{into_response, PageData},
|
||||
meta_handler::PageData,
|
||||
Claim, Comment, Item, Post, PostStatus, SiteConfig, Solo, User,
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ use super::{
|
||||
db_utils::{u8_slice_to_u32, IterType},
|
||||
incr_id,
|
||||
inn::ParamsTag,
|
||||
into_response,
|
||||
meta_handler::{get_referer, PageData},
|
||||
notification::{add_notification, NtType},
|
||||
u32_to_ivec,
|
||||
@@ -10,7 +9,7 @@ use super::{
|
||||
Claim, SiteConfig, User,
|
||||
};
|
||||
use crate::{config::CONFIG, error::AppError, DB};
|
||||
use askama::Template;
|
||||
use askama_axum::{into_response, Template};
|
||||
use axum::{
|
||||
extract::{Multipart, Path, Query},
|
||||
response::{IntoResponse, Redirect},
|
||||
|
||||
@@ -6,14 +6,14 @@ use super::{
|
||||
is_valid_name, ivec_to_u32, set_one, set_one_with_key, IterType,
|
||||
},
|
||||
fmt::{clean_html, ts_to_date},
|
||||
get_ids_by_prefix, get_one, incr_id, into_response,
|
||||
get_ids_by_prefix, get_one, incr_id,
|
||||
meta_handler::{PageData, ParamsPage},
|
||||
notification::{add_notification, NtType},
|
||||
u32_to_ivec, u8_slice_to_u32, Claim, Inn, InnType, SiteConfig, User,
|
||||
};
|
||||
use crate::{config::CONFIG, error::AppError, DB};
|
||||
use ::rand::{thread_rng, Rng};
|
||||
use askama::Template;
|
||||
use askama_axum::{into_response, Template};
|
||||
use axum::{
|
||||
extract::{Form, Path, Query},
|
||||
http::{header::SET_COOKIE, HeaderMap},
|
||||
|
||||
@@ -12,12 +12,9 @@ use tokio::net::TcpListener;
|
||||
use tracing::{error, info, warn};
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
use tikv_jemallocator::Jemalloc;
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[global_allocator]
|
||||
static GLOBAL: Jemalloc = Jemalloc;
|
||||
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), AppError> {
|
||||
|
||||
Reference in New Issue
Block a user