Compare commits
15 Commits
89445ddcf3
...
letterbox-
| Author | SHA1 | Date | |
|---|---|---|---|
| 33bb355975 | |||
| 2f20a3a8ed | |||
| 8b3bfe253f | |||
| 22b9646ac4 | |||
| 1df8ad8a0c | |||
| bb7721dbc6 | |||
| 475c552e3a | |||
| c85832c93b | |||
| 7e991186fe | |||
| 95d06ec669 | |||
| 84810d8644 | |||
| 8a86f0d0b2 | |||
| eab4986fd3 | |||
| bf7418339e | |||
| 51ff0b8e14 |
@@ -7,7 +7,7 @@ jobs:
|
|||||||
name: Check
|
name: Check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
- run: cargo check
|
- run: cargo check
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ jobs:
|
|||||||
name: Test Suite
|
name: Test Suite
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
- run: cargo test
|
- run: cargo test
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ jobs:
|
|||||||
name: Trunk
|
name: Trunk
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
@@ -35,7 +35,7 @@ jobs:
|
|||||||
name: Rustfmt
|
name: Rustfmt
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
components: rustfmt
|
components: rustfmt
|
||||||
@@ -46,7 +46,7 @@ jobs:
|
|||||||
name: build
|
name: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
- run: cargo build
|
- run: cargo build
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ jobs:
|
|||||||
name: Disallow unused dependencies
|
name: Disallow unused dependencies
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
|
|||||||
829
Cargo.lock
generated
829
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@ authors = ["Bill Thiede <git@xinu.tv>"]
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "UNLICENSED"
|
license = "UNLICENSED"
|
||||||
publish = ["xinu"]
|
publish = ["xinu"]
|
||||||
version = "0.17.55"
|
version = "0.17.58"
|
||||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ chrono-tz = "0.10"
|
|||||||
html2text = "0.16"
|
html2text = "0.16"
|
||||||
ammonia = "4.1.0"
|
ammonia = "4.1.0"
|
||||||
anyhow = "1.0.98"
|
anyhow = "1.0.98"
|
||||||
askama = { version = "0.14.0", features = ["derive"] }
|
askama = { version = "0.15.0", features = ["derive"] }
|
||||||
async-graphql = { version = "7", features = ["log", "chrono"] }
|
async-graphql = { version = "7", features = ["log", "chrono"] }
|
||||||
async-graphql-axum = "7.0.16"
|
async-graphql-axum = "7.0.16"
|
||||||
async-trait = "0.1.88"
|
async-trait = "0.1.88"
|
||||||
@@ -26,7 +26,7 @@ build-info = "0.0.42"
|
|||||||
cacher = { version = "0.2.0", registry = "xinu" }
|
cacher = { version = "0.2.0", registry = "xinu" }
|
||||||
chrono = "0.4.40"
|
chrono = "0.4.40"
|
||||||
clap = { version = "4.5.37", features = ["derive"] }
|
clap = { version = "4.5.37", features = ["derive"] }
|
||||||
css-inline = "0.18.0"
|
css-inline = "0.19.0"
|
||||||
flate2 = "1.1.2"
|
flate2 = "1.1.2"
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
headers = "0.4.0"
|
headers = "0.4.0"
|
||||||
@@ -41,7 +41,7 @@ maplit = "1.0.2"
|
|||||||
memmap = "0.7.0"
|
memmap = "0.7.0"
|
||||||
quick-xml = { version = "0.38.1", features = ["serialize"] }
|
quick-xml = { version = "0.38.1", features = ["serialize"] }
|
||||||
regex = "1.11.1"
|
regex = "1.11.1"
|
||||||
reqwest = { version = "0.12.15", features = ["blocking"] }
|
reqwest = { version = "0.13.0", features = ["blocking"] }
|
||||||
scraper = "0.25.0"
|
scraper = "0.25.0"
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
serde_json = "1.0.140"
|
serde_json = "1.0.140"
|
||||||
@@ -56,7 +56,7 @@ urlencoding = "2.1.3"
|
|||||||
#xtracing = { git = "http://git-private.h.xinu.tv/wathiede/xtracing.git" }
|
#xtracing = { git = "http://git-private.h.xinu.tv/wathiede/xtracing.git" }
|
||||||
#xtracing = { path = "../../xtracing" }
|
#xtracing = { path = "../../xtracing" }
|
||||||
xtracing = { version = "0.3.2", registry = "xinu" }
|
xtracing = { version = "0.3.2", registry = "xinu" }
|
||||||
zip = "6.0.0"
|
zip = "7.0.0"
|
||||||
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
DROP INDEX IF EXISTS movie_sets_year_id_idx;
|
||||||
|
DROP INDEX IF EXISTS movie_sets_year_idx;
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- Add index on movie_sets.year to speed up year-based queries
|
||||||
|
CREATE INDEX movie_sets_year_idx ON movie_sets(year);
|
||||||
|
|
||||||
|
-- Composite index for queries that filter by year and return id
|
||||||
|
-- This can make the subquery in UPDATE statements even faster
|
||||||
|
CREATE INDEX movie_sets_year_id_idx ON movie_sets(year, id);
|
||||||
@@ -34,6 +34,7 @@ const TEXT_PLAIN: &'static str = "text/plain";
|
|||||||
// Inline Askama filters module for template use
|
// Inline Askama filters module for template use
|
||||||
mod filters {
|
mod filters {
|
||||||
// Usage: {{ items|batch(7) }}
|
// Usage: {{ items|batch(7) }}
|
||||||
|
#[askama::filter_fn]
|
||||||
pub fn batch<T: Clone>(
|
pub fn batch<T: Clone>(
|
||||||
items: &[T],
|
items: &[T],
|
||||||
_: &dyn ::askama::Values,
|
_: &dyn ::askama::Values,
|
||||||
@@ -195,8 +196,16 @@ pub fn extract_calendar_metadata_from_mail(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let (Some(sm), Some(em)) = (month_num(start_month), month_num(end_month)) {
|
if let (Some(sm), Some(em)) = (month_num(start_month), month_num(end_month)) {
|
||||||
let current_year = chrono::Local::now().year().to_string();
|
// If start month is later in calendar year than end month, start is in previous year
|
||||||
let start = format!("{}{}{}", current_year, sm, format!("{:0>2}", start_day));
|
let sm_num: u32 = sm.parse().unwrap_or(1);
|
||||||
|
let em_num: u32 = em.parse().unwrap_or(1);
|
||||||
|
let end_year = year.parse::<i32>().unwrap_or_else(|_| chrono::Local::now().year());
|
||||||
|
let start_year: i32 = if sm_num > em_num {
|
||||||
|
end_year - 1
|
||||||
|
} else {
|
||||||
|
end_year
|
||||||
|
};
|
||||||
|
let start = format!("{}{}{}", start_year, sm, format!("{:0>2}", start_day));
|
||||||
let mut end_date_val = chrono::NaiveDate::parse_from_str(&format!("{}-{}-{}", year, em, format!("{:0>2}", end_day)), "%Y-%m-%d").ok();
|
let mut end_date_val = chrono::NaiveDate::parse_from_str(&format!("{}-{}-{}", year, em, format!("{:0>2}", end_day)), "%Y-%m-%d").ok();
|
||||||
if let Some(d) = end_date_val.as_mut() {
|
if let Some(d) = end_date_val.as_mut() {
|
||||||
*d = d.succ_opt().unwrap_or(*d);
|
*d = d.succ_opt().unwrap_or(*d);
|
||||||
@@ -2307,8 +2316,8 @@ mod tests {
|
|||||||
Some("calendar-notification@google.com".to_string())
|
Some("calendar-notification@google.com".to_string())
|
||||||
);
|
);
|
||||||
// Dates: from subject, Thu Sep 11 to Fri Jan 30, 2026
|
// Dates: from subject, Thu Sep 11 to Fri Jan 30, 2026
|
||||||
let current_year = chrono::Local::now().year();
|
// Start date is Sep 11, 2025 (one year before end since Sep > Jan)
|
||||||
assert_eq!(meta.start_date, Some(format!("{}0911", current_year)));
|
assert_eq!(meta.start_date, Some("20250911".to_string()));
|
||||||
assert_eq!(meta.end_date, Some("20260131".to_string()));
|
assert_eq!(meta.end_date, Some("20260131".to_string()));
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
@@ -2408,8 +2417,8 @@ mod tests {
|
|||||||
Some("calendar-notification@google.com".to_string())
|
Some("calendar-notification@google.com".to_string())
|
||||||
);
|
);
|
||||||
// Dates: from subject, Thu Sep 11 to Fri Jan 30, 2026
|
// Dates: from subject, Thu Sep 11 to Fri Jan 30, 2026
|
||||||
let current_year = chrono::Local::now().year();
|
// Start date is Sep 11, 2025 (one year before end since Sep > Jan)
|
||||||
assert_eq!(meta.start_date, Some(format!("{}0911", current_year)));
|
assert_eq!(meta.start_date, Some("20250911".to_string()));
|
||||||
assert_eq!(meta.end_date, Some("20260131".to_string()));
|
assert_eq!(meta.end_date, Some("20260131".to_string()));
|
||||||
// Debug: print the rendered HTML for inspection
|
// Debug: print the rendered HTML for inspection
|
||||||
if let Some(ref html) = meta.body_html {
|
if let Some(ref html) = meta.body_html {
|
||||||
@@ -2442,8 +2451,8 @@ mod tests {
|
|||||||
Some("calendar-notification@google.com".to_string())
|
Some("calendar-notification@google.com".to_string())
|
||||||
);
|
);
|
||||||
// Assert that the start and end dates are present
|
// Assert that the start and end dates are present
|
||||||
let current_year = chrono::Local::now().year();
|
// Start date is Sep 11, 2025 (one year before end since Sep > Jan)
|
||||||
assert_eq!(meta.start_date, Some(format!("{}0911", current_year)));
|
assert_eq!(meta.start_date, Some("20250911".to_string()));
|
||||||
assert_eq!(meta.end_date, Some("20260131".to_string()));
|
assert_eq!(meta.end_date, Some("20260131".to_string()));
|
||||||
// Assert that the HTML body contains recurrence info
|
// Assert that the HTML body contains recurrence info
|
||||||
if let Some(ref html) = meta.body_html {
|
if let Some(ref html) = meta.body_html {
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ use crate::{
|
|||||||
const NEWSREADER_TAG_PREFIX: &'static str = "News/";
|
const NEWSREADER_TAG_PREFIX: &'static str = "News/";
|
||||||
const NEWSREADER_THREAD_PREFIX: &'static str = "news:";
|
const NEWSREADER_THREAD_PREFIX: &'static str = "news:";
|
||||||
|
|
||||||
|
const USER_AGENT: &'static str = "letterbox news reader (letterbox-ua@xinu.tv)";
|
||||||
|
|
||||||
// TODO: figure out how to use Cow
|
// TODO: figure out how to use Cow
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
trait Transformer: Send + Sync {
|
trait Transformer: Send + Sync {
|
||||||
@@ -318,7 +320,8 @@ impl<'c> Transformer for SlurpContents<'c> {
|
|||||||
let body = if let Some(body) = cacher.get(link.as_str()) {
|
let body = if let Some(body) = cacher.get(link.as_str()) {
|
||||||
String::from_utf8_lossy(&body).to_string()
|
String::from_utf8_lossy(&body).to_string()
|
||||||
} else {
|
} else {
|
||||||
let resp = reqwest::get(link.as_str()).await?;
|
let client = reqwest::Client::builder().user_agent(USER_AGENT).build()?;
|
||||||
|
let resp = client.get(link.as_str()).send().await?;
|
||||||
let status = resp.status();
|
let status = resp.status();
|
||||||
if status.is_server_error() {
|
if status.is_server_error() {
|
||||||
error!("status error for {link}: {status}");
|
error!("status error for {link}: {status}");
|
||||||
|
|||||||
Reference in New Issue
Block a user