Skip to content

Commit

Permalink
added ftd files in .build folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Arpita-Jaiswal committed Mar 10, 2023
1 parent 6fcdede commit 7f7d69f
Show file tree
Hide file tree
Showing 20 changed files with 1,057 additions and 19 deletions.
30 changes: 16 additions & 14 deletions fastn-core/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,26 @@ pub async fn build(
if !config
.ftd_edition
.eq(&fastn_core::config::FTDEdition::FTD2021)
&& doc.id.eq("FASTN.ftd")
{
tokio::fs::copy(
fastn_core::utils::copy(
config.root.join(doc.id.as_str()),
config.root.join(".build").join(doc.id.as_str()),
)
.await?;

fastn_core::utils::print_end(
format!(
"Processed {}/{}",
config.package.name.as_str(),
main.get_id()
)
.as_str(),
start,
);
continue;
.await
.ok();

if doc.id.eq("FASTN.ftd") {
fastn_core::utils::print_end(
format!(
"Processed {}/{}",
config.package.name.as_str(),
main.get_id()
)
.as_str(),
start,
);
continue;
}
}
let resp = fastn_core::package::package_doc::process_ftd(
config, doc, base_url, no_static, test,
Expand Down
3 changes: 3 additions & 0 deletions fastn-core/src/commands/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ async fn serve_file(

match f {
fastn_core::File::Ftd(main_document) => {
if fastn_core::utils::is_ftd_path(path.as_str()) {
return fastn_core::http::ok(main_document.content.as_bytes().to_vec());
}
match fastn_core::package::package_doc::read_ftd(
config,
&main_document,
Expand Down
4 changes: 2 additions & 2 deletions fastn-core/src/package/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,14 +719,14 @@ impl PackageTemp {
.collect::<Vec<Package>>();

Package {
name: self.name,
name: self.name.clone(),
versioned: self.versioned,
translation_of: Box::new(translation_of),
translations,
language: self.language,
about: self.about,
zip: self.zip,
download_base_url: self.download_base_url,
download_base_url: self.download_base_url.or(Some(self.name)),
translation_status_summary: None,
canonical_url: self.canonical_url,
dependencies: vec![],
Expand Down
4 changes: 4 additions & 0 deletions fastn-core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,3 +778,7 @@ mod tests {
pub fn ignore_headers() -> Vec<&'static str> {
vec!["host", "x-forwarded-ssl"]
}

pub(crate) fn is_ftd_path(path: &str) -> bool {
path.trim_matches('/').ends_with(".ftd")
}
3 changes: 3 additions & 0 deletions fastn-core/tests/02-hello/output/fail_doc.ftd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- import: xyz

-- xyz.dummy_component: Caption
34 changes: 34 additions & 0 deletions fastn-core/tests/02-hello/output/index.ftd
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- ftd.text: hello

-- ftd.text: Hello World
region: h2
role: $rtype


-- ftd.text: hello_h1
region: h1
role: $inherited.types.copy-regular
color: $inherited.colors.text

-- ftd.text: hello_h0
region: h3
role: $dtype


-- ftd.type dtype:
size.px: 40
weight: 700
font-family: cursive
line-height.px: 65
letter-spacing.px: 5

-- ftd.type mtype:
size.px: 20
weight: 100
font-family: fantasy
line-height.px: 35
letter-spacing.px: 3

-- ftd.responsive-type rtype:
desktop: $dtype
mobile: $mtype
1 change: 1 addition & 0 deletions fastn-core/tests/03-nested-document/output/index.ftd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- ftd.text: hello
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- ftd.text: nested document
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- ftd.text: This should be rendered inside amitu/nested/index/index.html
11 changes: 11 additions & 0 deletions fastn-core/tests/04-import-code-block/output/index.ftd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- import: amitu/lib
-- import: fifthtry.github.io/package-doc/typography as pd

-- lib.block:

-- pd.h1: Heading 1

Heading 1 content


-- end: lib.block
10 changes: 10 additions & 0 deletions fastn-core/tests/04-import-code-block/output/lib.ftd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- component block:
children wrapper:

-- ftd.row:
background.solid: #000000
children: $block.wrapper

-- end: ftd.row

-- end: block
1 change: 1 addition & 0 deletions fastn-core/tests/05-hello-font/cmd.p1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Processing www.amitu.com/hello.py ... done in <omitted>
Processing www.amitu.com/hello/world/test.py ... done in <omitted>
Processing www.amitu.com/index ... done in <omitted>
Processing www.amitu.com/index.ftd ... Processing www.amitu.com/index.jpg ... done in <omitted>
Processing www.amitu.com/index-dark.jpg ... done in <omitted>
Processing www.amitu.com/index.ftd ... done in <omitted>
Processing www.amitu.com/hello/world/test.py ... done in <omitted>
Processing www.amitu.com/hello.py ... done in <omitted>
Expand Down
Loading

0 comments on commit 7f7d69f

Please sign in to comment.