...
This commit is contained in:
parent
29ccc54a4d
commit
1e914aa56d
@ -72,7 +72,12 @@ fn main() -> Result<()> {
|
||||
.subcommand(
|
||||
SubCommand::with_name("export_to_ipfs")
|
||||
.about("Export a collection to IPFS")
|
||||
.arg(Arg::with_name("collection").required(true).help("Name of the collection"))
|
||||
.arg(Arg::with_name("collection")
|
||||
.short("c".chars().next().unwrap())
|
||||
.long("collection")
|
||||
.takes_value(true)
|
||||
.required(false)
|
||||
.help("Name of the collection (export all if not specified)"))
|
||||
.arg(Arg::with_name("output").required(true).help("Output directory for IPFS export"))
|
||||
.arg(Arg::with_name("doctree").long("doctree").takes_value(true).help("Name of the doctree (default: 'default')")),
|
||||
)
|
||||
@ -350,13 +355,13 @@ fn main() -> Result<()> {
|
||||
doctree.delete_collection(collection)?;
|
||||
println!("Collection '{}' deleted successfully", collection);
|
||||
} else if let Some(matches) = matches.subcommand_matches("export_to_ipfs") {
|
||||
let collection_name = matches.value_of("collection").unwrap();
|
||||
let output_path = matches.value_of("output").unwrap();
|
||||
let output_path_str = matches.value_of("output").unwrap();
|
||||
let output_path = Path::new(output_path_str);
|
||||
let doctree_name = matches.value_of("doctree").unwrap_or("default");
|
||||
let collection_name_opt = matches.value_of("collection");
|
||||
|
||||
if debug_mode {
|
||||
println!("DEBUG: Exporting collection '{}' from doctree '{}' to IPFS output path '{}'",
|
||||
collection_name, doctree_name, output_path);
|
||||
println!("DEBUG: Handling export_to_ipfs command.");
|
||||
}
|
||||
|
||||
// Create a storage with the specified doctree name
|
||||
@ -377,14 +382,36 @@ fn main() -> Result<()> {
|
||||
// Load collections from Redis
|
||||
doctree.load_collections_from_redis()?;
|
||||
|
||||
// Get the collection
|
||||
let collection = doctree.get_collection(collection_name)?;
|
||||
|
||||
// Call the synchronous export_collection_to_ipfs_sync function from the doctree crate
|
||||
let output_path = Path::new(output_path);
|
||||
match collection_name_opt {
|
||||
Some(collection_name) => {
|
||||
// Export a specific collection
|
||||
if debug_mode {
|
||||
println!("DEBUG: Exporting specific collection '{}'", collection_name);
|
||||
}
|
||||
doctree.export_collection_to_ipfs(collection_name, output_path)?;
|
||||
|
||||
println!("Successfully exported collection '{}' to IPFS and generated metadata CSV at {:?}.", collection_name, output_path.join(format!("{}.csv", collection_name)));
|
||||
}
|
||||
None => {
|
||||
// Export all collections
|
||||
if debug_mode {
|
||||
println!("DEBUG: Exporting all collections.");
|
||||
}
|
||||
let collections = doctree.list_collections();
|
||||
if collections.is_empty() {
|
||||
println!("No collections found to export.");
|
||||
} else {
|
||||
println!("Exporting the following collections:");
|
||||
for collection_name in collections {
|
||||
println!("- {}", collection_name);
|
||||
if let Err(e) = doctree.export_collection_to_ipfs(&collection_name, output_path) {
|
||||
eprintln!("Error exporting collection '{}': {}", collection_name, e);
|
||||
} else {
|
||||
println!("Successfully exported collection '{}' to IPFS and generated metadata CSV at {:?}.", collection_name, output_path.join(format!("{}.csv", collection_name)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if let Some(matches) = matches.subcommand_matches("reset") {
|
||||
let doctree_name = matches.value_of("doctree").unwrap_or("default");
|
||||
|
20
examples/doctreenew/sites/demo1/collection.hjson
Normal file
20
examples/doctreenew/sites/demo1/collection.hjson
Normal file
@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
name: docs_hero
|
||||
#existing docusaurus site can be used as collection as long as no duplicates
|
||||
url: https://git.ourworld.tf/tfgrid/docs_tfgrid4/src/branch/main/aibox/docs
|
||||
description: Documentation for the ThreeFold Hero project.
|
||||
}
|
||||
|
||||
{
|
||||
name: biz
|
||||
url: https://git.ourworld.tf/tfgrid/docs_tfgrid4/src/branch/main/aibox/collectios/aaa
|
||||
description: Business documentation.
|
||||
}
|
||||
|
||||
{
|
||||
name: products
|
||||
url: https://git.ourworld.tf/tfgrid/docs_tfgrid4/src/branch/main/aibox/collectios/vvv
|
||||
description: Information about ThreeFold products.
|
||||
}
|
||||
]
|
33
examples/doctreenew/sites/demo1/footer.hjson
Normal file
33
examples/doctreenew/sites/demo1/footer.hjson
Normal file
@ -0,0 +1,33 @@
|
||||
# Footer configuration for the site
|
||||
|
||||
title: "Explore More"
|
||||
|
||||
sections: [
|
||||
{
|
||||
title: "Pages"
|
||||
links: [
|
||||
{ label: "Home", href: "/" }
|
||||
{ label: "About Us", href: "/about" }
|
||||
{ label: "Contact", href: "/contact" }
|
||||
{ label: "Blog", href: "/blog" }
|
||||
]
|
||||
}
|
||||
|
||||
{
|
||||
title: "Resources"
|
||||
links: [
|
||||
{ label: "Docs", href: "/docs" }
|
||||
{ label: "API", href: "/api" }
|
||||
]
|
||||
}
|
||||
|
||||
{
|
||||
title: "Social"
|
||||
links: [
|
||||
{ label: "GitHub", href: "https://github.com/yourproject" }
|
||||
{ label: "Twitter", href: "https://twitter.com/yourhandle" }
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
copyright: "© 2025 YourSite. All rights reserved."
|
32
examples/doctreenew/sites/demo1/header.hjson
Normal file
32
examples/doctreenew/sites/demo1/header.hjson
Normal file
@ -0,0 +1,32 @@
|
||||
# Site Branding
|
||||
logo:
|
||||
src: /img/logo.svg
|
||||
alt: Site Logo
|
||||
|
||||
# Site Title
|
||||
title: ThreeFold Hero
|
||||
|
||||
# Navigation Menu
|
||||
menu: [
|
||||
{
|
||||
label: Home
|
||||
link: /
|
||||
}
|
||||
{
|
||||
label: Docs
|
||||
link: /docs/
|
||||
}
|
||||
{
|
||||
label: About
|
||||
link: /about/
|
||||
}
|
||||
]
|
||||
|
||||
# Login Button
|
||||
login:
|
||||
visible: true
|
||||
label: Login
|
||||
link: /login/
|
||||
|
||||
|
||||
|
14
examples/doctreenew/sites/demo1/main.hjson
Normal file
14
examples/doctreenew/sites/demo1/main.hjson
Normal file
@ -0,0 +1,14 @@
|
||||
# Site Main Info
|
||||
title: ThreeFold Hero Docs
|
||||
tagline: Your Personal Hero
|
||||
favicon: img/favicon.png
|
||||
url: https://threefold.info
|
||||
|
||||
# SEO / Social Metadata
|
||||
metadata:
|
||||
title: ThreeFold Hero Docs
|
||||
description: ThreeFold Hero - Your Personal Hero
|
||||
image: https://threefold.info/herodocs/img/tf_graph.png
|
||||
|
||||
# Copyright Notice
|
||||
copyright: ThreeFold
|
33
examples/doctreenew/sites/demo1/pages.hjson
Normal file
33
examples/doctreenew/sites/demo1/pages.hjson
Normal file
@ -0,0 +1,33 @@
|
||||
[
|
||||
{
|
||||
name: home
|
||||
title: Home Page
|
||||
description: This is the main landing page.
|
||||
navPath: /
|
||||
collection: acollection
|
||||
}
|
||||
|
||||
{
|
||||
name: about
|
||||
title: About Us
|
||||
navPath: /about
|
||||
collection: acollection
|
||||
}
|
||||
|
||||
{
|
||||
name: docs
|
||||
title: Documentation
|
||||
navPath: /sub/docs
|
||||
collection: docs_hero
|
||||
}
|
||||
|
||||
{
|
||||
name: hidden-page
|
||||
title: Hidden Page
|
||||
description: This page is not shown in navigation.
|
||||
hidden: true
|
||||
navPath: /cantsee
|
||||
collection: acollection
|
||||
}
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user