diff options
Diffstat (limited to 'src/public')
-rw-r--r-- | src/public/admin.rs | 10 | ||||
-rw-r--r-- | src/public/console.rs | 33 | ||||
-rw-r--r-- | src/public/docs.rs | 6 | ||||
-rw-r--r-- | src/public/mod.rs | 2 | ||||
-rw-r--r-- | src/public/pages.rs | 6 |
5 files changed, 37 insertions, 20 deletions
diff --git a/src/public/admin.rs b/src/public/admin.rs index 25941f1..bf0a155 100644 --- a/src/public/admin.rs +++ b/src/public/admin.rs @@ -5,7 +5,9 @@ use tokio::sync::Mutex; use crate::{ console::sanatize, - types::{http::ResponseCode, post::Post, session::Session, user::User, comment::Comment, like::Like}, + types::{ + comment::Comment, http::ResponseCode, like::Like, post::Post, session::Session, user::User, + }, }; lazy_static! { @@ -141,7 +143,11 @@ pub fn generate_comments() -> Response { for comment in comments { html.push_str(&format!( "<tr><td>{}</td><td>{}</td><td>{}</td><td>{}</td><td>{}</td></tr>", - comment.comment_id, comment.user_id, comment.post_id, sanatize(&comment.content), comment.date + comment.comment_id, + comment.user_id, + comment.post_id, + sanatize(&comment.content), + comment.date )); } diff --git a/src/public/console.rs b/src/public/console.rs index 16bf4a3..251dbc1 100644 --- a/src/public/console.rs +++ b/src/public/console.rs @@ -84,9 +84,9 @@ impl Formatter for HtmlFormatter { W: ?Sized + io::Write, { let s = if value { - b"<span class='bool'>true</span>" as &[u8] + b"<span class='bool'> true </span>" as &[u8] } else { - b"<span class='bool'>false</span>" as &[u8] + b"<span class='bool'> false </span>" as &[u8] }; writer.write_all(s) } @@ -95,7 +95,7 @@ impl Formatter for HtmlFormatter { where W: ?Sized + io::Write, { - let buff = format!("<span class='number'>{value}</span>"); + let buff = format!("<span class='number'> {value} </span>"); writer.write_all(buff.as_bytes()) } @@ -103,7 +103,7 @@ impl Formatter for HtmlFormatter { where W: ?Sized + io::Write, { - let buff = format!("<span class='number'>{value}</span>"); + let buff = format!("<span class='number'> {value} </span>"); writer.write_all(buff.as_bytes()) } @@ -111,7 +111,7 @@ impl Formatter for HtmlFormatter { where W: ?Sized + io::Write, { - let buff = format!("<span class='number'>{value}</span>"); + let buff = format!("<span class='number'> {value} </span>"); writer.write_all(buff.as_bytes()) } @@ -119,7 +119,7 @@ impl Formatter for HtmlFormatter { where W: ?Sized + io::Write, { - let buff = format!("<span class='number'>{value}</span>"); + let buff = format!("<span class='number'> {value} </span>"); writer.write_all(buff.as_bytes()) } @@ -127,7 +127,7 @@ impl Formatter for HtmlFormatter { where W: ?Sized + io::Write, { - let buff = format!("<span class='number'>{value}</span>"); + let buff = format!("<span class='number'> {value} </span>"); writer.write_all(buff.as_bytes()) } @@ -135,7 +135,7 @@ impl Formatter for HtmlFormatter { where W: ?Sized + io::Write, { - let buff = format!("<span class='number'>{value}</span>"); + let buff = format!("<span class='number'> {value} </span>"); writer.write_all(buff.as_bytes()) } @@ -143,7 +143,7 @@ impl Formatter for HtmlFormatter { where W: ?Sized + io::Write, { - let buff = format!("<span class='number'>{value}</span>"); + let buff = format!("<span class='number'> {value} </span>"); writer.write_all(buff.as_bytes()) } @@ -151,7 +151,7 @@ impl Formatter for HtmlFormatter { where W: ?Sized + io::Write, { - let buff = format!("<span class='number'>{value}</span>"); + let buff = format!("<span class='number'> {value} </span>"); writer.write_all(buff.as_bytes()) } @@ -159,7 +159,7 @@ impl Formatter for HtmlFormatter { where W: ?Sized + io::Write, { - let buff = format!("<span class='number'>{value}</span>"); + let buff = format!("<span class='number'> {value} </span>"); writer.write_all(buff.as_bytes()) } @@ -167,7 +167,7 @@ impl Formatter for HtmlFormatter { where W: ?Sized + io::Write, { - let buff = format!("<span class='number'>{value}</span>"); + let buff = format!("<span class='number'> {value} </span>"); writer.write_all(buff.as_bytes()) } @@ -192,7 +192,7 @@ impl Formatter for HtmlFormatter { if first { writer.write_all(b"<span class='key'>") } else { - writer.write_all(b"<span class='key'>,") + writer.write_all(b",<span class='key'>") } } @@ -202,6 +202,13 @@ impl Formatter for HtmlFormatter { { writer.write_all(b"</span>") } + + fn begin_object_value<W>(&mut self, writer: &mut W) -> io::Result<()> + where + W: ?Sized + io::Write, + { + writer.write_all(b" : ") + } } pub fn sanatize(input: &str) -> String { diff --git a/src/public/docs.rs b/src/public/docs.rs index f4e26be..397e696 100644 --- a/src/public/docs.rs +++ b/src/public/docs.rs @@ -49,6 +49,7 @@ fn generate_body(body: Option<&'static str>) -> String { </div> "# .to_string(); + let body = body.trim(); if body.starts_with('{') { return html.replace( @@ -135,13 +136,16 @@ pub async fn init() { users::USERS_SELF, users::USERS_AVATAR, users::USERS_BANNER, + users::USERS_FOLLOW, + users::USERS_FOLLOW_STATUS, + users::USERS_FRIENDS, admin::ADMIN_AUTH, admin::ADMIN_QUERY, admin::ADMIN_POSTS, admin::ADMIN_USERS, admin::ADMIN_SESSIONS, admin::ADMIN_COMMENTS, - admin::ADMIN_LIKES + admin::ADMIN_LIKES, ]; let mut endpoints = ENDPOINTS.lock().await; for doc in docs { diff --git a/src/public/mod.rs b/src/public/mod.rs index 76796ea..bb75ef0 100644 --- a/src/public/mod.rs +++ b/src/public/mod.rs @@ -25,7 +25,7 @@ pub mod pages; pub fn router() -> Router { let governor_conf = Box::new( GovernorConfigBuilder::default() - .burst_size(20) + .burst_size(30) .per_second(1) .key_extractor(SmartIpKeyExtractor) .finish() diff --git a/src/public/pages.rs b/src/public/pages.rs index 6d5c0de..426727e 100644 --- a/src/public/pages.rs +++ b/src/public/pages.rs @@ -1,6 +1,7 @@ use axum::{ response::{IntoResponse, Redirect, Response}, - routing::get, Router + routing::get, + Router, }; use crate::{ @@ -58,9 +59,8 @@ async fn wordpress(_: Log) -> Response { } async fn forgot(UserAgent(agent): UserAgent, _: Log) -> Response { - if agent.starts_with("curl") { - return super::serve("/404.html").await + return super::serve("/404.html").await; } Redirect::to("https://www.youtube.com/watch?v=dQw4w9WgXcQ").into_response() |