Compare commits

...

2 commits

Author SHA1 Message Date
saji 183ddb322b add nasa IOTD service
Some checks failed
cargo_test_bench / Run Benchmarks (push) Has been cancelled
cargo_test_bench / Run Tests (push) Has been cancelled
2024-08-11 23:11:57 -05:00
saji 821954b774 update gitignore 2024-08-11 15:00:26 -05:00
5 changed files with 748 additions and 27 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
/target /target
result result
display.bmp

753
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -10,6 +10,7 @@ anyhow = "1.0.86"
axum = { version = "0.7.5", features = ["macros", "multipart"] } axum = { version = "0.7.5", features = ["macros", "multipart"] }
axum-macros = "0.4.1" axum-macros = "0.4.1"
base64 = "0.22.1" base64 = "0.22.1"
bytes = "1.7.1"
clap = { version = "4.5.7", features = ["derive"] } clap = { version = "4.5.7", features = ["derive"] }
epd-waveshare = { git = "https://github.com/caemor/epd-waveshare.git"} epd-waveshare = { git = "https://github.com/caemor/epd-waveshare.git"}
image = "0.25.1" image = "0.25.1"
@ -21,6 +22,8 @@ minijinja = { version = "2.1.0", features = ["loader"] }
minijinja-embed = "2.1.1" minijinja-embed = "2.1.1"
palette = "0.7.6" palette = "0.7.6"
rayon = "1.10.0" rayon = "1.10.0"
reqwest = { version = "0.12.5", features = ["multipart"] }
rss = "2.0.8"
rusqlite = { version = "0.32.1", features = ["bundled"] } rusqlite = { version = "0.32.1", features = ["bundled"] }
serde = { version = "1.0.204", features = ["derive"] } serde = { version = "1.0.204", features = ["derive"] }
strum = { version = "0.26.3", features = ["derive"] } strum = { version = "0.26.3", features = ["derive"] }

View file

@ -2,6 +2,7 @@ use crate::api;
use crate::display::create_display_thread; use crate::display::create_display_thread;
use crate::dither::{DitherMethod, DitheredImage}; use crate::dither::{DitherMethod, DitheredImage};
use crate::eink::Palette; use crate::eink::Palette;
use crate::imageprovider::nasa_task;
use axum::extract::{Path, State}; use axum::extract::{Path, State};
use axum::http::{header, StatusCode}; use axum::http::{header, StatusCode};
use axum::response::{IntoResponse, Response}; use axum::response::{IntoResponse, Response};
@ -11,7 +12,6 @@ use base64::{engine::general_purpose::STANDARD, Engine as _};
use image::imageops::{resize, FilterType}; use image::imageops::{resize, FilterType};
use include_dir::{include_dir, Dir, DirEntry}; use include_dir::{include_dir, Dir, DirEntry};
use minijinja::{context, Environment}; use minijinja::{context, Environment};
use mime_guess::Mime;
use std::io::Cursor; use std::io::Cursor;
use std::sync::mpsc; use std::sync::mpsc;
use std::sync::Arc; use std::sync::Arc;
@ -105,12 +105,16 @@ fn make_environment() -> Result<Environment<'static>, anyhow::Error> {
} }
pub fn make_app_router() -> Router { pub fn make_app_router() -> Router {
let context = AppState::default();
tokio::task::spawn(nasa_task(context.clone()));
Router::new() Router::new()
.route("/app", get(app_handler)) .route("/app", get(app_handler))
.route("/app/preview", post(app_preview)) .route("/app/preview", post(app_preview))
.nest("/api", api::router()) .nest("/api", api::router())
.route("/static/*path", get(asset_handler)) .route("/static/*path", get(asset_handler))
.with_state(AppState::default()) .with_state(context)
} }
#[instrument(skip(ctx))] #[instrument(skip(ctx))]

View file

@ -3,8 +3,8 @@ pub mod app;
pub mod display; pub mod display;
pub mod dither; pub mod dither;
pub mod eink; pub mod eink;
pub mod imageprovider;
use serde::Deserialize;
use std::path::PathBuf; use std::path::PathBuf;
use tower_http::trace::TraceLayer; use tower_http::trace::TraceLayer;
@ -15,14 +15,6 @@ use clap::{Args, Parser, Subcommand};
use image::RgbImage; use image::RgbImage;
use tracing::{error, info}; use tracing::{error, info};
/// Application config, including sqlite db path, scan folders, and scheduling.
#[derive(Deserialize, Debug)]
struct Config {
database_path: PathBuf,
search_paths: Vec<PathBuf>,
host: String,
}
/// Display images on E-Ink Displays /// Display images on E-Ink Displays
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
#[command(version, about)] #[command(version, about)]