Skip to content

Commit

Permalink
Merge pull request #108 from ascii-dresden/feature/updates
Browse files Browse the repository at this point in the history
update deps
  • Loading branch information
hoodie authored Nov 22, 2023
2 parents 0a4369c + 622b32a commit 894edc5
Show file tree
Hide file tree
Showing 9 changed files with 471 additions and 1,435 deletions.
1,740 changes: 398 additions & 1,342 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@ log = "0.4"
env_logger = "0.10"
yaml-rust = "0.4"
chrono = "0.4"
regex = "1.4"
regex = "1.10"
lazy_static = "1.4"
maplit = "1.0"
clap = { version = "3", features = ["cargo"] }
clap_complete = "3"
enum_derive = "0.1"
custom_derive = "0.1"
open = "4"
open = "5"
crowbook-intl-runtime = "0.1"
rayon = { version = "1.5", optional = true }
rayon = { version = "1.8", optional = true }
itertools = "0.11"
rustyline = { version = "11", optional = true, features = ["derive"] }
rustyline = { version = "12", optional = true, features = ["derive"] }
linked-hash-map = { version = "0.5", features = ["serde_impl"] }
dirs = "5"
term = "0.7"
thiserror = "1.0"
anyhow = "1.0"

actix = { version = "0.13", optional = true }
actix-web = { version = "3", optional = true }
actix-web = { version = "4", optional = true }
actix-files = { version = "0.6", optional = true }

bill = { version = "0.4", features = ["serialization"] }
icalendar = "0.10"
icalendar = "0.15"

slug = "0.1"
tempdir = "0.3"
Expand All @@ -69,22 +69,22 @@ prettytable-rs = { default-features = false, version = "0.10" }

# feature: document_export
# TODO: update to 4.x is trivial but requires testing with current content
handlebars = { version = "2.0", optional = true }
handlebars = { version = "3.0", optional = true }

serde = { version = "1.0", optional = true }
serde_json = { version = "1.0", optional = true }
serde_yaml = { version = "0.9", optional = true }
serde_derive = { version = "1.0", optional = true }
ordered-float = { version = "4", optional = true }
num-traits = { version = "0.2", optional = true }
toml = "0.7"
toml = "0.8"

# feature: git_statuses
git2 = { version = "0.17", default-features = false, optional = true }
color-backtrace = "0.5"
git2 = { version = "0.18", default-features = false, optional = true }
color-backtrace = "0.6"

[dev-dependencies]
pretty_assertions = "1.0"
pretty_assertions = "1.4"

[features]
default = [
Expand Down
2 changes: 1 addition & 1 deletion lang/default.pot
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ msgstr ""
msgid "Project file is younger than pdf, continue anyway?"
msgstr ""

#: /Users/hendrik/code/rust/asciii/src/lib.rs:82
#: /Users/hendrik/code/rust/asciii/src/lib.rs:70
msgid "Documentation at: {}"
msgstr ""

Expand Down
110 changes: 52 additions & 58 deletions src/bin/asciii-web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ pub mod api {
}

#[get("/version")]
pub fn version() -> HttpResponse {
pub async fn version() -> HttpResponse {
let version: &str = asciii::VERSION_JSON.as_ref();
log::info!("version {}", version);
HttpResponse::Ok()
.set_header(header::CONTENT_TYPE, "application/json")
.insert_header((header::CONTENT_TYPE, "application/json"))
.body(version)
}

Expand All @@ -77,7 +77,7 @@ pub mod api {
use asciii::project::spec::HasEvents;

#[get("/calendar")]
pub fn calendar() -> HttpResponse {
pub async fn calendar() -> HttpResponse {
log::info!("calendar");
self::CHANNEL.send(()).unwrap();
let loader = self::PROJECTS.lock().unwrap();
Expand All @@ -94,7 +94,7 @@ pub mod api {
cal.append(&mut tasks);

HttpResponse::Ok()
.set_header(header::CONTENT_TYPE, "text/calendar")
.insert_header((header::CONTENT_TYPE, "text/calendar"))
.body(cal.to_string())
}
}
Expand All @@ -103,7 +103,7 @@ pub mod api {
use super::*;

#[get("/year")]
pub fn years(_req: HttpRequest) -> HttpResponse {
pub async fn years(_req: HttpRequest) -> HttpResponse {
log::info!("years");
self::CHANNEL.send(()).unwrap();
let loader = self::PROJECTS.lock().unwrap();
Expand All @@ -112,7 +112,7 @@ pub mod api {
}

#[get("/year/{year}")]
pub fn by_year(param: web::Path<YearRequest>) -> HttpResponse {
pub async fn by_year(param: web::Path<YearRequest>) -> HttpResponse {
log::info!("by_year");
self::CHANNEL.send(()).unwrap();
let loader = self::PROJECTS.lock().unwrap();
Expand All @@ -134,7 +134,7 @@ pub mod api {
}

#[get("/{name}")]
pub fn by_name(param: web::Path<NameRequest>) -> HttpResponse {
pub async fn by_name(param: web::Path<NameRequest>) -> HttpResponse {
log::info!("by_name({:?})", param.name);
self::CHANNEL.send(()).unwrap();
let loader = self::PROJECTS.lock().unwrap();
Expand All @@ -153,7 +153,7 @@ pub mod api {
}

#[get("/workingdir")]
pub fn working_dir() -> HttpResponse {
pub async fn working_dir() -> HttpResponse {
log::info!("projects/workingdir");
let loader = self::PROJECTS.lock().unwrap();
let list = loader.state.working.iter().map(|(ident, _)| ident).collect::<Vec<_>>();
Expand All @@ -163,7 +163,7 @@ pub mod api {
HttpResponse::Ok().json(&list)
}

pub fn all_names() -> HttpResponse {
pub async fn all_names() -> HttpResponse {
let loader = self::PROJECTS.lock().unwrap();
let list = loader.state.mapped.iter().map(|(ident, _)| ident).collect::<Vec<_>>();

Expand All @@ -177,7 +177,7 @@ pub mod api {
use super::*;

#[get("/year/{year}")]
pub fn by_year(param: web::Path<YearRequest>) -> HttpResponse {
pub async fn by_year(param: web::Path<YearRequest>) -> HttpResponse {
let loader = self::PROJECTS.lock().unwrap();
let exported = loader
.state
Expand All @@ -202,7 +202,7 @@ pub mod api {
}

#[get("/workingdir")]
pub fn working_dir() -> HttpResponse {
pub async fn working_dir() -> HttpResponse {
log::info!("full_projects/workingdir");
let loader = self::PROJECTS.lock().unwrap();
let list = loader
Expand All @@ -222,8 +222,9 @@ pub mod api {
}
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
// color_backtrace::install();
#[actix_web::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
color_backtrace::install();

if env::var(LOG_VAR).is_err() {
//env::set_var(LOG_VAR, "asciii=debug, asciii_web=debug, actix_web=debug");
Expand All @@ -235,55 +236,48 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
log::info!("running asciii-web");
log::warn!("do not host this on a public server, there is no security by design");

let sys = actix::System::new();

let server =
|| {
HttpServer::new(move || {
App::new()
.wrap(middleware::Logger::default())
let server = HttpServer::new(move || {
App::new()
.wrap(middleware::Logger::default())
.service(
web::scope("api")
.service(web::resource("projects").route(web::get().to(api::projects::all_names)))
.service(api::version)
.service(
web::scope("projects")
.service(api::projects::years)
.service(api::projects::by_year)
.service(api::projects::working_dir)
.service(api::projects::by_name),
)
.service(
web::scope("api")
.service(web::resource("projects").route(web::get().to(api::projects::all_names)))
.service(api::version)
.service(
web::scope("projects")
.service(api::projects::years)
.service(api::projects::by_year)
.service(api::projects::working_dir)
.service(api::projects::by_name),
)
.service(
web::scope("full_projects")
.service(api::full_projects::by_year)
.service(api::full_projects::working_dir)
.service(api::projects::years),
)
.service(api::calendar::calendar),
web::scope("full_projects")
.service(api::full_projects::by_year)
.service(api::full_projects::working_dir)
.service(api::projects::years),
)
// .service(fs::Files::new("/", "webapp/public").index_file("index.html"))
.service(web::resource("/").route(
web::get().to(|| HttpResponse::Ok().body(include_str!("../../webapp/public/index.html"))),
))
.service(web::resource("/bundle.css").route(
web::get().to(|| HttpResponse::Ok().body(include_str!("../../webapp/public/bundle.css"))),
))
.service(web::resource("/bundle.js").route(web::get().to(|| {
HttpResponse::Ok()
.content_type("application/javascript")
.body(include_str!("../../webapp/public/bundle.js"))
})))
// .service(
// web::resource("/bundle.js.map").route(
// web::get().to(|| HttpResponse::Ok().content_type("application/javascript").body(include_str!("../../webapp/public/bundle.js.map")))
// ))
})
};
.service(api::calendar::calendar),
)
// .service(fs::Files::new("/", "webapp/public").index_file("index.html"))
.service(web::resource("/").route(
web::get().to(|| async { HttpResponse::Ok().body(include_str!("../../webapp/public/index.html")) }),
))
.service(web::resource("/bundle.css").route(
web::get().to(|| async { HttpResponse::Ok().body(include_str!("../../webapp/public/bundle.css")) }),
))
.service(web::resource("/bundle.js").route(web::get().to(|| async {
HttpResponse::Ok()
.content_type("application/javascript")
.body(include_str!("../../webapp/public/bundle.js"))
})))
// .service(
// web::resource("/bundle.js.map").route(
// web::get().to(|| HttpResponse::Ok().content_type("application/javascript").body(include_str!("../../webapp/public/bundle.js.map")))
// ))
});

log::info!("listening on http://{}", bind_to);
server().bind(bind_to)?.run();

sys.run()?;
server.bind(bind_to)?.run().await?;
log::info!("shutting down I guess");

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions src/document_export/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl HelperDef for IncHelper {
h: &Helper<'_, '_>,
_: &Handlebars,
_: &Context,
_: &mut RenderContext<'_>,
_: &mut RenderContext<'_, '_>,
out: &mut dyn Output,
) -> HelperResult {
let param = h.param(0).unwrap().value();
Expand All @@ -79,7 +79,7 @@ impl HelperDef for CountHelper {
h: &Helper<'_, '_>,
_: &Handlebars,
_: &Context,
_: &mut RenderContext<'_>,
_: &mut RenderContext<'_, '_>,
out: &mut dyn Output,
) -> HelperResult {
let count = h.param(0).unwrap().value().as_array().map_or(0, Vec::len);
Expand Down
16 changes: 1 addition & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,7 @@
//!
#![cfg_attr(feature = "manual", doc = include_str!("../manual.md"))]
#![allow(deprecated)]
#![allow(clippy::uninlined_format_args)]
#![warn(//missing_docs,
//missing_copy_implementations,
//missing_debug_implementations,
unstable_features,
unused_import_braces,
// clippy::pedantic
)]
// #![allow(
// clippy::if_not_else,
// clippy::must_use_candidate,
// clippy::missing_errors_doc,
// clippy::missing_panics_doc,
// clippy::wildcard_imports,
// )]
#![warn(clippy::if_not_else)]
#![recursion_limit = "1024"]
#![deny(trivial_casts, trivial_numeric_casts)]
#![warn(unused_import_braces, unused_qualifications)]
Expand Down
8 changes: 4 additions & 4 deletions src/project/spec_yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::str::FromStr;

use anyhow::bail;
use bill::{Bill, Currency, Tax};
use icalendar::{Calendar, Component, Event as CalEvent};
use icalendar::{Calendar, Component, Event as CalEvent, EventLike as _};
use yaml_rust::Yaml;

use super::{
Expand Down Expand Up @@ -80,10 +80,10 @@ impl HasEvents for Project {
}

if let Some(end) = event.end {
cal_event.start_date(event.begin);
cal_event.end_date(end);
cal_event.starts(event.begin);
cal_event.ends(end);
} else {
cal_event.all_day(event.begin);
cal_event.all_day(event.begin.naive_local());
}

cal_event.summary(self.name().unwrap_or("unnamed"));
Expand Down
2 changes: 1 addition & 1 deletion src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub fn get_storage_path() -> PathBuf {
// TODO: make replace tilde a Trait function
let storage_path = replace_home_tilde(&storage_path);

if !storage_path.is_absolute() {
if storage_path.is_relative() {
current_dir().unwrap().join(storage_path)
} else {
storage_path
Expand Down
2 changes: 1 addition & 1 deletion src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ where
/// takes a path that could be relative or contains a `~` and turn it into a path that exists
pub fn get_valid_path<T: AsRef<OsStr>>(p: T) -> Option<PathBuf> {
let path = replace_home_tilde(Path::new(&p));
let path = if !path.is_absolute() {
let path = if path.is_relative() {
if cfg!(target_arch = "wasm32") {
Ok(PathBuf::from(std::env::var("PWD").expect("can't access $PWD")))
} else {
Expand Down

0 comments on commit 894edc5

Please sign in to comment.