From 8abc42f4910de203f8bc6738d489102b78bffe7d Mon Sep 17 00:00:00 2001 From: Amit Upadhyay Date: Thu, 2 Nov 2023 17:50:18 +0530 Subject: [PATCH] some tweaks, probably more buggy, still doesnt compile :-( --- fastn-core/src/commands/build.rs | 4 +++- fastn-core/src/commands/serve.rs | 9 ++++----- fastn-core/src/doc.rs | 10 +++++----- fastn-core/src/library/fastn_dot_ftd.rs | 2 +- fastn-core/src/library2022/mod.rs | 10 +++++----- fastn-core/src/package/package_doc.rs | 16 ++++++++-------- 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/fastn-core/src/commands/build.rs b/fastn-core/src/commands/build.rs index 9b9341559e..b674b96bc1 100644 --- a/fastn-core/src/commands/build.rs +++ b/fastn-core/src/commands/build.rs @@ -609,7 +609,9 @@ async fn handle_file_( match (resp, ignore_failed) { (Ok(r), _) => { - let dependencies = req_config.dependencies_during_render; + // TODO: what to do with dependencies? + // let dependencies = req_config.dependencies_during_render; + let dependencies = vec![]; if let Some(cache) = cache { cache.documents.insert( remove_extension(doc.id.as_str()), diff --git a/fastn-core/src/commands/serve.rs b/fastn-core/src/commands/serve.rs index 342cd58626..5f4155b2f5 100644 --- a/fastn-core/src/commands/serve.rs +++ b/fastn-core/src/commands/serve.rs @@ -18,8 +18,8 @@ fn handle_redirect( /// path: // /// #[tracing::instrument(skip_all)] -async fn serve_file( - config: &mut fastn_core::RequestConfig<'_>, +async fn serve_file<'o, 'm: 'o>( + config: &'m mut fastn_core::RequestConfig<'o>, path: &camino::Utf8Path, ) -> fastn_core::http::Response { if let Some(r) = handle_redirect(config.config, path) { @@ -123,8 +123,8 @@ async fn serve_file( } } -async fn serve_cr_file( - req_config: &mut fastn_core::RequestConfig<'_>, +async fn serve_cr_file<'o, 'm: 'o>( + req_config: &'m mut fastn_core::RequestConfig<'o>, path: &camino::Utf8Path, cr_number: usize, ) -> fastn_core::http::Response { @@ -241,7 +241,6 @@ pub async fn serve( let mut req_config = fastn_core::RequestConfig::new(config, &req); - // TODO: remove unwrap let path: camino::Utf8PathBuf = req.path().replacen('/', "", 1).parse()?; Ok(if path.eq(&camino::Utf8PathBuf::new().join("FASTN.ftd")) { diff --git a/fastn-core/src/doc.rs b/fastn-core/src/doc.rs index e488de90e8..b6da5feab3 100644 --- a/fastn-core/src/doc.rs +++ b/fastn-core/src/doc.rs @@ -29,7 +29,7 @@ fn cached_parse( pub async fn interpret_helper<'a>( name: &str, source: &str, - lib: &'a mut fastn_core::Library2022<'_, '_>, + lib: &'a mut fastn_core::Library2022<'_>, base_url: &str, download_assets: bool, line_number: usize, @@ -160,7 +160,7 @@ pub async fn resolve_import<'a>( // source, foreign_variable, foreign_function pub async fn resolve_import_2022<'a>( - lib: &'a mut fastn_core::Library2022<'_, '_>, + lib: &'a mut fastn_core::Library2022<'_>, _state: &mut ftd::interpreter::InterpreterState, module: &str, caller_module: &str, @@ -293,7 +293,7 @@ pub async fn resolve_import_2022<'a>( pub async fn resolve_foreign_variable2022( variable: &str, doc_name: &str, - lib: &mut fastn_core::Library2022<'_, '_>, + lib: &mut fastn_core::Library2022<'_>, base_url: &str, download_assets: bool, caller_module: &str, @@ -355,7 +355,7 @@ pub async fn resolve_foreign_variable2022( module: &str, package: &fastn_core::Package, files: &str, - lib: &mut fastn_core::Library2022<'_, '_>, + lib: &mut fastn_core::Library2022<'_>, base_url: &str, download_assets: bool, // true: in case of `fastn build` ) -> ftd::ftd2021::p1::Result { @@ -549,7 +549,7 @@ pub async fn resolve_foreign_variable2022( } async fn download( - lib: &mut fastn_core::Library2022<'_, '_>, + lib: &mut fastn_core::Library2022<'_>, download_assets: bool, package: &fastn_core::Package, path: &str, diff --git a/fastn-core/src/library/fastn_dot_ftd.rs b/fastn-core/src/library/fastn_dot_ftd.rs index 0d2e19191b..b12c74200c 100644 --- a/fastn-core/src/library/fastn_dot_ftd.rs +++ b/fastn-core/src/library/fastn_dot_ftd.rs @@ -824,7 +824,7 @@ pub(crate) async fn get2(lib: &fastn_core::Library2<'_>) -> String { get(&lib).await } -pub(crate) async fn get2022(lib: &fastn_core::Library2022<'_, '_>) -> String { +pub(crate) async fn get2022(lib: &fastn_core::Library2022<'_>) -> String { let lib = fastn_core::Library { config: lib.config.clone(), markdown: lib.markdown.clone(), diff --git a/fastn-core/src/library2022/mod.rs b/fastn-core/src/library2022/mod.rs index 5c50219607..8521d4b132 100644 --- a/fastn-core/src/library2022/mod.rs +++ b/fastn-core/src/library2022/mod.rs @@ -14,8 +14,8 @@ impl KeyValueData { } #[derive(Debug)] -pub struct Library2022<'m, 'o: 'm> { - pub config: &'m mut fastn_core::RequestConfig<'o>, +pub struct Library2022<'m> { + pub config: &'m mut fastn_core::RequestConfig<'m>, /// If the current module being parsed is a markdown file, `.markdown` contains the name and /// content of that file pub markdown: Option<(String, String)>, @@ -25,7 +25,7 @@ pub struct Library2022<'m, 'o: 'm> { pub module_package_map: std::collections::BTreeMap, } -impl Library2022<'_, '_> { +impl Library2022<'_> { pub async fn get_with_result( &mut self, name: &str, @@ -86,7 +86,7 @@ impl Library2022<'_, '_> { async fn get_for_package( name: &str, - lib: &mut fastn_core::Library2022<'_, '_>, + lib: &mut fastn_core::Library2022<'_>, current_processing_module: &str, ) -> Option<(String, String, usize)> { let package = lib.get_current_package(current_processing_module).ok()?; @@ -150,7 +150,7 @@ impl Library2022<'_, '_> { async fn get_data_from_package( name: &str, package: &fastn_core::Package, - lib: &mut fastn_core::Library2022<'_, '_>, + lib: &mut fastn_core::Library2022<'_>, ) -> Option<(String, usize)> { lib.push_package_under_process(name, package).await.ok()?; let packages = lib.config.config.all_packages.borrow(); diff --git a/fastn-core/src/package/package_doc.rs b/fastn-core/src/package/package_doc.rs index bae826f7a0..60a772ce42 100644 --- a/fastn-core/src/package/package_doc.rs +++ b/fastn-core/src/package/package_doc.rs @@ -363,8 +363,8 @@ impl From for fastn_core::http::Response { } #[tracing::instrument(skip_all)] -pub(crate) async fn read_ftd( - config: &mut fastn_core::RequestConfig<'_>, +pub(crate) async fn read_ftd<'o, 'm: 'o>( + config: &'m mut fastn_core::RequestConfig<'o>, main: &fastn_core::Document, base_url: &str, download_assets: bool, @@ -385,8 +385,8 @@ pub(crate) async fn read_ftd( } #[tracing::instrument(name = "read_ftd_2022", skip_all)] -pub(crate) async fn read_ftd_2022( - config: &mut fastn_core::RequestConfig<'_>, +pub(crate) async fn read_ftd_2022<'o, 'm: 'o>( + config: &'m mut fastn_core::RequestConfig<'o>, main: &fastn_core::Document, base_url: &str, download_assets: bool, @@ -460,8 +460,8 @@ pub(crate) async fn read_ftd_2022( #[allow(clippy::await_holding_refcell_ref)] #[tracing::instrument(name = "read_ftd_2023", skip_all)] -pub(crate) async fn read_ftd_2023( - config: &mut fastn_core::RequestConfig<'_>, +pub(crate) async fn read_ftd_2023<'o, 'm: 'o>( + config: &'m mut fastn_core::RequestConfig<'o>, main: &fastn_core::Document, base_url: &str, download_assets: bool, @@ -541,8 +541,8 @@ pub(crate) async fn read_ftd_2023( Ok(FTDResult::Html(file_content.into())) } -pub(crate) async fn process_ftd( - config: &mut fastn_core::RequestConfig<'_>, +pub(crate) async fn process_ftd<'o, 'm: 'o>( + config: &'m mut fastn_core::RequestConfig<'o>, main: &fastn_core::Document, base_url: &str, build_static_files: bool,