Skip to content

Commit

Permalink
some tweaks, probably more buggy, still doesnt compile :-(
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Nov 2, 2023
1 parent 9b0baac commit 8abc42f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 25 deletions.
4 changes: 3 additions & 1 deletion fastn-core/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
9 changes: 4 additions & 5 deletions fastn-core/src/commands/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ fn handle_redirect(
/// path: /<file-name>/
///
#[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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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")) {
Expand Down
10 changes: 5 additions & 5 deletions fastn-core/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<ftd::interpreter::Value> {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion fastn-core/src/library/fastn_dot_ftd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
10 changes: 5 additions & 5 deletions fastn-core/src/library2022/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)>,
Expand All @@ -25,7 +25,7 @@ pub struct Library2022<'m, 'o: 'm> {
pub module_package_map: std::collections::BTreeMap<String, String>,
}

impl Library2022<'_, '_> {
impl Library2022<'_> {
pub async fn get_with_result(
&mut self,
name: &str,
Expand Down Expand Up @@ -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()?;
Expand Down Expand Up @@ -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();
Expand Down
16 changes: 8 additions & 8 deletions fastn-core/src/package/package_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ impl From<FTDResult> 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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8abc42f

Please sign in to comment.