chore: refactor cli and web under presentation
This commit is contained in:
parent
53308fc685
commit
8aca3b92b7
15 changed files with 20 additions and 17 deletions
|
|
@ -15,7 +15,7 @@ use tracing::error;
|
|||
|
||||
use crate::application::server::AppState;
|
||||
|
||||
use crate::presentation::templates::render_template;
|
||||
use crate::presentation::web::templates::render_template;
|
||||
|
||||
pub fn app_router(state: AppState) -> axum::Router {
|
||||
let api_routes = axum::Router::new()
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ use crate::application::server::AppState;
|
|||
use crate::domain::ids::RoasterId;
|
||||
use crate::domain::listing::{ListRequest, SortDirection};
|
||||
use crate::domain::roasters::{NewRoaster, Roaster, RoasterSortKey, UpdateRoaster};
|
||||
use crate::presentation::templates::{
|
||||
use crate::presentation::web::templates::{
|
||||
RoasterDetailTemplate, RoasterListTemplate, RoastersTemplate,
|
||||
};
|
||||
use crate::presentation::views::{ListNavigator, Paginated, RoastView, RoasterView};
|
||||
use crate::presentation::web::views::{ListNavigator, Paginated, RoastView, RoasterView};
|
||||
|
||||
const ROASTER_PAGE_PATH: &str = "/roasters";
|
||||
const ROASTER_FRAGMENT_PATH: &str = "/roasters#roaster-list";
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ use crate::domain::ids::{RoastId, RoasterId};
|
|||
use crate::domain::listing::{ListRequest, SortDirection};
|
||||
use crate::domain::roasters::RoasterSortKey;
|
||||
use crate::domain::roasts::{NewRoast, Roast, RoastSortKey, RoastWithRoaster};
|
||||
use crate::presentation::templates::{RoastDetailTemplate, RoastListTemplate, RoastsTemplate};
|
||||
use crate::presentation::views::{ListNavigator, Paginated, RoastView, RoasterOptionView};
|
||||
use crate::presentation::web::templates::{RoastDetailTemplate, RoastListTemplate, RoastsTemplate};
|
||||
use crate::presentation::web::views::{ListNavigator, Paginated, RoastView, RoasterOptionView};
|
||||
|
||||
const ROAST_PAGE_PATH: &str = "/roasts";
|
||||
const ROAST_FRAGMENT_PATH: &str = "/roasts#roast-list";
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::application::errors::{ApiError, AppError};
|
|||
use crate::domain::listing::{
|
||||
DEFAULT_PAGE_SIZE, ListRequest, Page, PageSize, SortDirection, SortKey,
|
||||
};
|
||||
use crate::presentation::views::{ListNavigator, Paginated};
|
||||
use crate::presentation::web::views::{ListNavigator, Paginated};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum PayloadSource {
|
||||
|
|
@ -113,7 +113,7 @@ pub fn render_fragment<T: Template>(
|
|||
template: T,
|
||||
selector: &'static str,
|
||||
) -> Result<Response, AppError> {
|
||||
let html = crate::presentation::templates::render_template(template)
|
||||
let html = crate::presentation::web::templates::render_template(template)
|
||||
.map_err(|err| AppError::unexpected(format!("failed to render fragment: {err}")))?;
|
||||
|
||||
let mut response = Html(html).into_response();
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@ use crate::application::routes::support::{ListQuery, is_datastar_request, normal
|
|||
use crate::application::server::AppState;
|
||||
use crate::domain::listing::ListRequest;
|
||||
use crate::domain::timeline::{TimelineEvent, TimelineSortKey};
|
||||
use crate::presentation::templates::{TimelineChunkTemplate, TimelineTemplate};
|
||||
use crate::presentation::views::{ListNavigator, Paginated, TimelineEventView, TimelineMonthView};
|
||||
use crate::presentation::web::templates::{TimelineChunkTemplate, TimelineTemplate};
|
||||
use crate::presentation::web::views::{
|
||||
ListNavigator, Paginated, TimelineEventView, TimelineMonthView,
|
||||
};
|
||||
|
||||
const TIMELINE_PAGE_PATH: &str = "/timeline";
|
||||
const TIMELINE_FRAGMENT_PATH: &str = "/timeline";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
pub mod application;
|
||||
pub mod cli;
|
||||
pub mod client;
|
||||
pub mod domain;
|
||||
pub mod infrastructure;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use anyhow::Result;
|
||||
use brewlog::application::{ServerConfig, serve};
|
||||
use brewlog::cli::{Cli, Commands, ServeCommand, roasters, roasts, tokens};
|
||||
use brewlog::client::BrewlogClient;
|
||||
use brewlog::presentation::cli::{Cli, Commands, ServeCommand, roasters, roasts, tokens};
|
||||
use clap::Parser;
|
||||
use tracing_subscriber::{EnvFilter, fmt, prelude::*};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use anyhow::{Context, Result};
|
|||
use clap::Args;
|
||||
use std::io::{self, Write};
|
||||
|
||||
use crate::cli::print_json;
|
||||
use super::print_json;
|
||||
use crate::client::BrewlogClient;
|
||||
use crate::domain::ids::TokenId;
|
||||
|
||||
|
|
@ -1,5 +1,2 @@
|
|||
pub mod templates;
|
||||
pub mod views;
|
||||
|
||||
pub use templates::*;
|
||||
pub use views::*;
|
||||
pub mod cli;
|
||||
pub mod web;
|
||||
|
|
|
|||
5
src/presentation/web/mod.rs
Normal file
5
src/presentation/web/mod.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
pub mod templates;
|
||||
pub mod views;
|
||||
|
||||
pub use templates::*;
|
||||
pub use views::*;
|
||||
Loading…
Reference in a new issue