refactor: reorganize HtmlPageContext and update imports across modules
Some checks failed
CI / Check / Test (push) Failing after 46m33s
Some checks failed
CI / Check / Test (push) Failing after 46m33s
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -320,6 +320,7 @@ dependencies = [
|
||||
"futures",
|
||||
"hex",
|
||||
"rand 0.9.4",
|
||||
"reqwest 0.13.3",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"tokio",
|
||||
@@ -5787,7 +5788,6 @@ name = "tmdb-enrichment"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"application",
|
||||
"async-trait",
|
||||
"chrono",
|
||||
"domain",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
pub use askama;
|
||||
use askama::Template;
|
||||
|
||||
use application::ports::HtmlPageContext;
|
||||
use application::rendering::HtmlPageContext;
|
||||
use chrono::Datelike;
|
||||
use domain::models::{
|
||||
DiaryEntry, FeedEntry, MonthActivity, MonthlyRating, ReviewSource, UserStats, UserTrends,
|
||||
|
||||
@@ -89,10 +89,6 @@ impl ReviewLogger for DefaultReviewLogger {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tests/review_logger.rs"]
|
||||
mod tests;
|
||||
|
||||
async fn publish_events(
|
||||
publisher: &Arc<dyn EventPublisher>,
|
||||
movie: &Movie,
|
||||
@@ -119,3 +115,7 @@ async fn publish_events(
|
||||
|
||||
publisher.publish(&review_event).await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "tests/review_logger.rs"]
|
||||
mod tests;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
pub mod config;
|
||||
pub mod jobs;
|
||||
pub mod ports;
|
||||
pub mod rendering;
|
||||
pub mod worker;
|
||||
|
||||
pub mod auth;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use async_trait::async_trait;
|
||||
use uuid::Uuid;
|
||||
|
||||
use domain::errors::DomainError;
|
||||
use domain::models::DiaryEntry;
|
||||
@@ -11,24 +10,6 @@ pub trait ReviewLogger: Send + Sync {
|
||||
async fn log_review(&self, cmd: LogReviewCommand) -> Result<(), DomainError>;
|
||||
}
|
||||
|
||||
pub struct HtmlPageContext {
|
||||
pub user_email: Option<String>,
|
||||
pub user_id: Option<Uuid>,
|
||||
pub is_admin: bool,
|
||||
pub register_enabled: bool,
|
||||
pub rss_url: String,
|
||||
pub page_title: String,
|
||||
pub canonical_url: String,
|
||||
pub csrf_token: String,
|
||||
pub page_rss_url: Option<String>,
|
||||
}
|
||||
|
||||
impl HtmlPageContext {
|
||||
pub fn is_current_user(&self, id: Uuid) -> bool {
|
||||
self.user_id == Some(id)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RssFeedRenderer: Send + Sync {
|
||||
fn render_feed(&self, entries: &[DiaryEntry], title: &str) -> Result<String, String>;
|
||||
}
|
||||
|
||||
19
crates/application/src/rendering.rs
Normal file
19
crates/application/src/rendering.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use uuid::Uuid;
|
||||
|
||||
pub struct HtmlPageContext {
|
||||
pub user_email: Option<String>,
|
||||
pub user_id: Option<Uuid>,
|
||||
pub is_admin: bool,
|
||||
pub register_enabled: bool,
|
||||
pub rss_url: String,
|
||||
pub page_title: String,
|
||||
pub canonical_url: String,
|
||||
pub csrf_token: String,
|
||||
pub page_rss_url: Option<String>,
|
||||
}
|
||||
|
||||
impl HtmlPageContext {
|
||||
pub fn is_current_user(&self, id: Uuid) -> bool {
|
||||
self.user_id == Some(id)
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ use crate::{
|
||||
use api_types::{
|
||||
LoginRequest, LoginResponse, LogoutRequest, RefreshRequest, RefreshResponse, RegisterRequest,
|
||||
};
|
||||
use application::ports::HtmlPageContext;
|
||||
use application::rendering::HtmlPageContext;
|
||||
use template_askama::{LoginTemplate, RegisterTemplate};
|
||||
|
||||
// ── HTML helpers ─────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use application::ports::HtmlPageContext;
|
||||
use application::rendering::HtmlPageContext;
|
||||
use domain::value_objects::UserId;
|
||||
|
||||
use crate::state::AppState;
|
||||
|
||||
@@ -201,7 +201,7 @@ fn format_watch_time(minutes: u32) -> String {
|
||||
fn render_wrapup(
|
||||
report: &WrapUpReport,
|
||||
year: i32,
|
||||
ctx: &application::ports::HtmlPageContext,
|
||||
ctx: &application::rendering::HtmlPageContext,
|
||||
) -> axum::response::Response {
|
||||
let rating_max = report
|
||||
.rating_distribution
|
||||
|
||||
@@ -7,7 +7,6 @@ pub mod forms;
|
||||
pub mod handlers;
|
||||
pub mod mappers;
|
||||
pub mod openapi;
|
||||
pub mod ports;
|
||||
pub mod render;
|
||||
pub mod routes;
|
||||
pub mod state;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
pub use application::ports::RssFeedRenderer;
|
||||
@@ -2,7 +2,7 @@ use std::sync::Arc;
|
||||
|
||||
use crate::context::AppContext;
|
||||
|
||||
use crate::ports::RssFeedRenderer;
|
||||
use application::ports::RssFeedRenderer;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AppState {
|
||||
|
||||
@@ -416,7 +416,7 @@ impl domain::ports::DocumentParser for Panic {
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::ports::RssFeedRenderer for Panic {
|
||||
impl application::ports::RssFeedRenderer for Panic {
|
||||
fn render_feed(&self, _: &[DiaryEntry], _: &str) -> Result<String, String> {
|
||||
panic!()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user