Bug fix + lepší náhledy gifů
Tento commit je obsažen v:
rodič
842efae4fc
revize
4faa8e94cd
43
Cargo.lock
vygenerováno
43
Cargo.lock
vygenerováno
@ -436,21 +436,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bit-set"
|
|
||||||
version = "0.5.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
|
|
||||||
dependencies = [
|
|
||||||
"bit-vec",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bit-vec"
|
|
||||||
version = "0.6.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bit_field"
|
name = "bit_field"
|
||||||
version = "0.10.2"
|
version = "0.10.2"
|
||||||
@ -1078,16 +1063,6 @@ dependencies = [
|
|||||||
"hashbrown 0.13.2",
|
"hashbrown 0.13.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fancy-regex"
|
|
||||||
version = "0.12.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7493d4c459da9f84325ad297371a6b2b8a162800873a22e3b6b6512e61d18c05"
|
|
||||||
dependencies = [
|
|
||||||
"bit-set",
|
|
||||||
"regex",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
@ -1728,9 +1703,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.5.0"
|
version = "2.6.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memoffset"
|
name = "memoffset"
|
||||||
@ -1815,7 +1790,6 @@ dependencies = [
|
|||||||
"encoding",
|
"encoding",
|
||||||
"enumflags2",
|
"enumflags2",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"fancy-regex",
|
|
||||||
"fs_extra",
|
"fs_extra",
|
||||||
"glob",
|
"glob",
|
||||||
"html-minifier",
|
"html-minifier",
|
||||||
@ -1828,6 +1802,7 @@ dependencies = [
|
|||||||
"pwhash",
|
"pwhash",
|
||||||
"rand",
|
"rand",
|
||||||
"redis",
|
"redis",
|
||||||
|
"regex",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_qs",
|
"serde_qs",
|
||||||
@ -2221,9 +2196,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.9.4"
|
version = "1.10.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29"
|
checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
@ -2233,9 +2208,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-automata"
|
name = "regex-automata"
|
||||||
version = "0.3.7"
|
version = "0.4.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629"
|
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
@ -2244,9 +2219,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
version = "0.7.5"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
|
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rgb"
|
name = "rgb"
|
||||||
|
@ -15,7 +15,6 @@ dotenv = "0.15.0"
|
|||||||
enumflags2 = "0.7.7"
|
enumflags2 = "0.7.7"
|
||||||
encoding = "0.2.33"
|
encoding = "0.2.33"
|
||||||
env_logger = "0.10.0"
|
env_logger = "0.10.0"
|
||||||
fancy-regex = "0.12.0"
|
|
||||||
glob = "0.3.1"
|
glob = "0.3.1"
|
||||||
image = "0.24.7"
|
image = "0.24.7"
|
||||||
ipnetwork = "0.20.0"
|
ipnetwork = "0.20.0"
|
||||||
@ -26,6 +25,7 @@ num-traits = "0.2.16"
|
|||||||
pwhash = "1.0.0"
|
pwhash = "1.0.0"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
redis = { version = "0.24.0", features = ["aio", "json", "tokio-comp"] }
|
redis = { version = "0.24.0", features = ["aio", "json", "tokio-comp"] }
|
||||||
|
regex = "1.10.2"
|
||||||
serde = "1.0.166"
|
serde = "1.0.166"
|
||||||
serde_json = "1.0.100"
|
serde_json = "1.0.100"
|
||||||
serde_qs = "0.12.0"
|
serde_qs = "0.12.0"
|
||||||
|
@ -116,8 +116,8 @@ impl From<pwhash::error::Error> for NekrochanError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<fancy_regex::Error> for NekrochanError {
|
impl From<regex::Error> for NekrochanError {
|
||||||
fn from(e: fancy_regex::Error) -> Self {
|
fn from(e: regex::Error) -> Self {
|
||||||
error!("Internal server error: {e:#?}");
|
error!("Internal server error: {e:#?}");
|
||||||
|
|
||||||
Self::InternalError
|
Self::InternalError
|
||||||
|
@ -91,7 +91,7 @@ impl File {
|
|||||||
process_image(cfg, original_name.clone(), new_name.clone(), thumb_name).await?
|
process_image(cfg, original_name.clone(), new_name.clone(), thumb_name).await?
|
||||||
};
|
};
|
||||||
|
|
||||||
rename(format!("/tmp/{new_name}"), format!("uploads/{new_name}")).await?;
|
rename(format!("/tmp/{new_name}"), format!("./uploads/{new_name}")).await?;
|
||||||
|
|
||||||
let file = File {
|
let file = File {
|
||||||
original_name,
|
original_name,
|
||||||
@ -188,6 +188,7 @@ async fn process_image(
|
|||||||
let output = spawn_blocking(move || {
|
let output = spawn_blocking(move || {
|
||||||
Command::new("convert")
|
Command::new("convert")
|
||||||
.arg(&format!("/tmp/{new_name}"))
|
.arg(&format!("/tmp/{new_name}"))
|
||||||
|
.arg("-coalesce")
|
||||||
.arg("-thumbnail")
|
.arg("-thumbnail")
|
||||||
.arg(&format!("{thumb_size}x{thumb_size}>"))
|
.arg(&format!("{thumb_size}x{thumb_size}>"))
|
||||||
.arg(&format!("./uploads/thumb/{thumb_name}"))
|
.arg(&format!("./uploads/thumb/{thumb_name}"))
|
||||||
@ -335,7 +336,7 @@ pub async fn cleanup_files(ctx: &Ctx) -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for file in glob("uploads/*.*")? {
|
for file in glob("./uploads/*.*")? {
|
||||||
let file = file?;
|
let file = file?;
|
||||||
let file_name = file.file_name();
|
let file_name = file.file_name();
|
||||||
|
|
||||||
@ -348,7 +349,7 @@ pub async fn cleanup_files(ctx: &Ctx) -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for file in glob("uploads/thumb/*.*")? {
|
for file in glob("./uploads/thumb/*.*")? {
|
||||||
let file = file?;
|
let file = file?;
|
||||||
let file_name = file.file_name();
|
let file_name = file.file_name();
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use chrono::{DateTime, Locale, Utc};
|
use chrono::{DateTime, Locale, Utc};
|
||||||
use fancy_regex::{Captures, Regex};
|
use regex::{Captures, Regex};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use std::{collections::HashSet, fmt::Display};
|
use std::{collections::HashSet, fmt::Display};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use fancy_regex::{Captures, Regex};
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
use regex::{Captures, Regex};
|
||||||
use sqlx::query_as;
|
use sqlx::query_as;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
@ -15,15 +15,13 @@ lazy_static! {
|
|||||||
pub static ref NAME_REGEX: Regex =
|
pub static ref NAME_REGEX: Regex =
|
||||||
Regex::new(r"^([^#].*?)?(?:(##([^ ].*?)|#([^#].*?)))?(##( .*?)?)?$").unwrap();
|
Regex::new(r"^([^#].*?)?(?:(##([^ ].*?)|#([^#].*?)))?(##( .*?)?)?$").unwrap();
|
||||||
pub static ref QUOTE_REGEX: Regex = Regex::new(r">>(\d+)").unwrap();
|
pub static ref QUOTE_REGEX: Regex = Regex::new(r">>(\d+)").unwrap();
|
||||||
pub static ref GREENTEXT_REGEX: Regex =
|
pub static ref GREENTEXT_REGEX: Regex = Regex::new(r"(?mR)^>(.*)$").unwrap();
|
||||||
Regex::new(r"(?m)^>((?!>\d+|>>/\w+(/\d*)?|>>#/).*)")
|
pub static ref ORANGETEXT_REGEX: Regex = Regex::new(r"(?mR)^<(.*)$").unwrap();
|
||||||
.unwrap();
|
pub static ref REDTEXT_REGEX: Regex = Regex::new(r"==(.+?)==").unwrap();
|
||||||
pub static ref ORANGETEXT_REGEX: Regex = Regex::new(r"(?m)^<(.+)").unwrap();
|
pub static ref BLUETEXT_REGEX: Regex = Regex::new(r"--(.+?)--").unwrap();
|
||||||
pub static ref REDTEXT_REGEX: Regex = Regex::new(r"(?m)==(.+?)==").unwrap();
|
pub static ref GLOWTEXT_REGEX: Regex = Regex::new(r"\%\%(.+?)\%\%").unwrap();
|
||||||
pub static ref BLUETEXT_REGEX: Regex = Regex::new(r"(?m)--(.+?)--").unwrap();
|
pub static ref UH_OH_TEXT_REGEX: Regex = Regex::new(r"\(\(\((.+?)\)\)\)").unwrap();
|
||||||
pub static ref GLOWTEXT_REGEX: Regex = Regex::new(r"(?m)\%\%(.+?)\%\%").unwrap();
|
pub static ref SPOILER_REGEX: Regex = Regex::new(r"\|\|([\s\S]+?)\|\|").unwrap();
|
||||||
pub static ref UH_OH_TEXT_REGEX: Regex = Regex::new(r"(?m)\(\(\((.+?)\)\)\)").unwrap();
|
|
||||||
pub static ref SPOILER_REGEX: Regex = Regex::new(r"(?m)\|\|([\s\S]+?)\|\|").unwrap();
|
|
||||||
pub static ref URL_REGEX: Regex =
|
pub static ref URL_REGEX: Regex =
|
||||||
Regex::new(r"https?\://[^\s<>\[\]{}|\\^]+").unwrap();
|
Regex::new(r"https?\://[^\s<>\[\]{}|\\^]+").unwrap();
|
||||||
}
|
}
|
||||||
@ -34,7 +32,7 @@ pub fn parse_name(
|
|||||||
anon_name: &str,
|
anon_name: &str,
|
||||||
name: &str,
|
name: &str,
|
||||||
) -> Result<(String, Option<String>, Option<String>), NekrochanError> {
|
) -> Result<(String, Option<String>, Option<String>), NekrochanError> {
|
||||||
let Some(captures) = NAME_REGEX.captures(name)? else {
|
let Some(captures) = NAME_REGEX.captures(name) else {
|
||||||
return Ok((anon_name.to_owned(), None, None));
|
return Ok((anon_name.to_owned(), None, None));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -112,7 +110,8 @@ pub async fn markup(
|
|||||||
op: Option<i32>,
|
op: Option<i32>,
|
||||||
text: &str,
|
text: &str,
|
||||||
) -> Result<String, NekrochanError> {
|
) -> Result<String, NekrochanError> {
|
||||||
let text = escape_html(text);
|
let text = escape_html(&text);
|
||||||
|
|
||||||
let quoted_posts = get_quoted_posts(ctx, board, &text).await?;
|
let quoted_posts = get_quoted_posts(ctx, board, &text).await?;
|
||||||
|
|
||||||
let text = QUOTE_REGEX.replace_all(&text, |captures: &Captures| {
|
let text = QUOTE_REGEX.replace_all(&text, |captures: &Captures| {
|
||||||
@ -182,7 +181,7 @@ async fn get_quoted_posts(
|
|||||||
let mut quoted_ids: Vec<i32> = Vec::new();
|
let mut quoted_ids: Vec<i32> = Vec::new();
|
||||||
|
|
||||||
for quote in QUOTE_REGEX.captures_iter(text) {
|
for quote in QUOTE_REGEX.captures_iter(text) {
|
||||||
let id_raw = "e.unwrap()[1];
|
let id_raw = "e[1];
|
||||||
let Ok(id) = id_raw.parse() else { continue };
|
let Ok(id) = id_raw.parse() else { continue };
|
||||||
|
|
||||||
quoted_ids.push(id);
|
quoted_ids.push(id);
|
||||||
|
@ -221,6 +221,7 @@ summary {
|
|||||||
|
|
||||||
.banner {
|
.banner {
|
||||||
display: block;
|
display: block;
|
||||||
|
width: 100%;
|
||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
margin: 8px auto;
|
margin: 8px auto;
|
||||||
border: 1px solid var(--box-border);
|
border: 1px solid var(--box-border);
|
||||||
|
Načítá se…
Odkázat v novém úkolu
Zablokovat Uživatele