Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 34 additions & 29 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,47 @@ repository = "https://github.com/QuartzLibrary/glowpub"
readme = "README.md"
edition = "2024"

[features]
default = ["binary"]
binary = ["epub", "dep:clap", "dep:simple_logger", "dep:slug"]
epub = ["gen", "api", "dep:epub-builder", "dep:uuid"]
api = ["dep:serde_json", "dep:tokio", "dep:glob", "dep:rpassword"]
gen = ["dep:fontdb", "dep:resvg", "dep:textwrap", "dep:tiny-skia", "dep:usvg", "dep:ammonia", "dep:cssparser", "dep:html-escape", "dep:html5ever", "dep:lightningcss", "dep:lol_html", "dep:markup5ever", "dep:markup5ever_rcdom", "dep:xml5ever"]

[dependencies]
chrono = { version = "0.4", features = ["serde"] }
glob = "0.3"
log = "0.4"
mime = "0.3"
rand = "0.8"
regex = "1"
chrono = { version = "0.4", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
mime = "0.3"
sha2 = "0.10"
uuid = { version = "1", features = ["v4"] }

reqwest = { version = "0.12", features = ["json"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio = { version = "1", features = ["full"] }
image = { version = "0.25", default-features = false, features = ["bmp", "gif", "jpeg", "png", "webp"] }

fontdb = "0.16"
resvg = "0.41"
textwrap = "0.16"
tiny-skia = "0.11"
usvg = "0.41"
serde_json = { version ="1", optional = true }
tokio = { version = "1", features = ["full"], optional = true }
glob = { version = "0.3", optional = true }
rpassword = { version = "7.3.1", optional = true }

epub-builder = { version = "0.7", default-features = false, features = ["libzip"] }
fontdb = { version = "0.16", optional = true }
resvg = { version = "0.41", optional = true }
textwrap = { version = "0.16", optional = true }
tiny-skia = { version = "0.11", optional = true }
usvg = { version = "0.41", optional = true }

ammonia = "4"
cssparser = "0.33"
html-escape = "0.2"
html5ever = "0.27"
lightningcss = "1.0.0-alpha.55"
lol_html = "1"
markup5ever = "0.12"
markup5ever_rcdom = "0.3"
xml5ever = "0.18"
ammonia = { version = "4", optional = true }
cssparser = { version = "0.33", optional = true }
html-escape = { version = "0.2", optional = true }
html5ever = { version = "0.27", optional = true }
lightningcss = { version = "1.0.0-alpha.55", optional = true }
lol_html = { version = "1", optional = true }
markup5ever = { version = "0.12", optional = true }
markup5ever_rcdom = { version = "0.3", optional = true }
xml5ever = { version = "0.18", optional = true }

image = { version = "0.25", default-features = false, features = ["bmp", "gif", "jpeg", "png", "webp"] }
epub-builder = { version = "0.7", default-features = false, features = ["libzip"], optional = true }
uuid = { version = "1", features = ["v4"], optional = true }

clap = { version = "4", features = ["derive"] }
simple_logger = "4"
slug = "0.1"
rpassword = "7.3.1"
clap = { version = "4", features = ["derive"], optional = true }
simple_logger = { version = "4", optional = true }
slug = { version = "0.1", optional = true }
7 changes: 6 additions & 1 deletion src/cached.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::{
collections::BTreeSet,
error::Error,
path::{Path, PathBuf},
str::FromStr,
Expand All @@ -18,6 +17,9 @@ use crate::{
},
};

#[cfg(feature = "gen")]
use std::collections::BTreeSet;

const CACHE_ROOT: &str = "./cache";

impl Board {
Expand Down Expand Up @@ -162,6 +164,7 @@ impl Thread {

Ok(Ok(Self { post, replies }))
}
#[cfg(feature = "gen")]
pub async fn cache_all_icons(&self, invalidate_cache: bool) {
let icons: BTreeSet<_> = self.icons().collect();

Expand Down Expand Up @@ -205,6 +208,8 @@ impl Continuity {

Ok(Ok(Self { board, threads }))
}

#[cfg(feature = "gen")]
pub async fn cache_all_icons(&self, invalidate_cache: bool) {
let icons: BTreeSet<_> = self.threads.iter().flat_map(|t| t.icons()).collect();
for icon in icons {
Expand Down
3 changes: 2 additions & 1 deletion src/generate/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod cover;
pub mod cover;

#[cfg(feature = "epub")]
pub mod epub;
pub mod html;
pub mod transform;
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
mod rfc3339;

#[cfg(feature = "api")]
mod auth;

#[cfg(feature = "api")]
pub mod api;
#[cfg(feature = "api")]
pub mod cached;
#[cfg(feature = "gen")]
pub mod generate;
#[cfg(all(feature = "gen", feature = "api"))]
pub mod intern_images;
pub mod types;
pub mod utils;
Expand Down
14 changes: 8 additions & 6 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,16 @@ pub struct Reply {
}

mod helpers {
use std::{
collections::{BTreeSet, HashSet},
iter,
};

use crate::generate::transform;
use std::collections::BTreeSet;

use super::*;

#[cfg(feature = "gen")]
use {
crate::generate::transform,
std::{collections::HashSet, iter},
};

// TODO: can we rely on there always being at least one thread?
impl Continuity {
pub fn created_at(&self) -> Option<DateTime<Utc>> {
Expand Down Expand Up @@ -156,6 +157,7 @@ mod helpers {
(sections, sectionless_threads)
}
}
#[cfg(feature = "gen")]
impl Thread {
pub fn image_urls(&self) -> HashSet<String> {
let contents = iter::once(&self.post.content)
Expand Down