implement stripe and idenfy webhooks support

This commit is contained in:
Timur Gordon
2025-07-08 22:49:47 +02:00
parent 7dfd54a20a
commit 93977bad7a
129 changed files with 9655 additions and 3640 deletions

View File

View File

@@ -1,68 +0,0 @@
# OurWorld Example
This directory contains a complete example demonstrating a simulated "OurWorld" network, consisting of multiple interconnected "circles" (nodes). Each circle runs its own WebSocket server and a Rhai script worker, all managed by a central launcher.
This example is designed to showcase:
1. **Multi-Circle Configuration**: How to define and configure multiple circles in a single `circles.json` file.
2. **Programmatic Launching**: How to use the `launcher` library to start, manage, and monitor these circles from within a Rust application.
3. **Dynamic Key Generation**: The launcher generates unique cryptographic keypairs for each circle upon startup.
4. **Output Generation**: How to use the `--output` functionality to get a JSON file containing the connection details (public keys, WebSocket URLs, etc.) for each running circle.
5. **Graceful Shutdown**: How the launcher handles a `Ctrl+C` signal to shut down all running circles cleanly.
## Directory Contents
- `circles.json`: The main configuration file that defines the 7 circles in the OurWorld network, including their names, ports, and associated Rhai scripts.
- `scripts/`: This directory contains the individual Rhai scripts that define the behavior of each circle.
- `ourworld_output.json` (Generated): This file is created after running the example and contains the runtime details of each circle.
## How to Run the Example
There are two ways to run this example, each demonstrating a different way to use the launcher.
### 1. As a Root Example (Recommended)
This method runs the launcher programmatically from the root of the workspace and is the simplest way to see the system in action. It uses the `examples/ourworld.rs` file.
```sh
# From the root of the workspace
cargo run --example ourworld
```
### 2. As a Crate-Level Example
This method runs a similar launcher, but as an example *within* the `launcher` crate itself. It uses the `src/launcher/examples/ourworld/main.rs` file. This is useful for testing the launcher in a more isolated context.
```sh
# Navigate to the launcher's crate directory
cd src/launcher
# Run the 'ourworld' example using cargo
cargo run --example ourworld
```
### 3. Using the Launcher Binary
This method uses the main `launcher` binary to run the configuration, which is useful for testing the command-line interface.
```sh
# From the root of the workspace
cargo run -p launcher -- --config examples/ourworld/circles.json --output examples/ourworld/ourworld_output.json
```
## What to Expect
When you run the example, you will see log output indicating that the launcher is starting up, followed by a table summarizing the running circles:
```
+-----------------+------------------------------------------------------------------+------------------------------------------+-----------------------+
| Name | Public Key | Worker Queue | WS URL |
+=================+==================================================================+==========================================+=======================+
| OurWorld | 02... | rhai_tasks:02... | ws://127.0.0.1:9000/ws|
+-----------------+------------------------------------------------------------------+------------------------------------------+-----------------------+
| Dunia Cybercity | 03... | rhai_tasks:03... | ws://127.0.0.1:9001/ws|
+-----------------+------------------------------------------------------------------+------------------------------------------+-----------------------+
| ... (and so on for all 7 circles) |
+-----------------+------------------------------------------------------------------+------------------------------------------+-----------------------+
```
The launcher will then wait for you to press `Ctrl+C` to initiate a graceful shutdown of all services.

View File

@@ -1,51 +0,0 @@
[
{
"name": "Timur Gordon",
"port": 9100,
"script_path": "scripts/test_script.rhai",
"public_key": "023b0a9d409506f41f5782353857dea6abc16ae4643661cd94d8155fdb498642e3",
"secret_key": "7a7074c59ccfa3465686277e9e9da34867b36a1e256271b893b6c22fbc82929e"
},
{
"name": "Kristof de Spiegeleer",
"port": 9101,
"script_path": "scripts/test_script.rhai",
"public_key": "030b62236efa67855b3379a9d4add1facbe8a545bafa86e1d6fbac06caae5b5b12",
"secret_key": "04225fbb41d8c397581d7ec19ded8aaf02d8b9daf27fed9617525e4f8114a382"
},
{
"name": "OurWorld",
"port": 9000,
"script_path": "scripts/ourworld.rhai"
},
{
"name": "Dunia Cybercity",
"port": 9001,
"script_path": "scripts/dunia_cybercity.rhai"
},
{
"name": "Sikana",
"port": 9002,
"script_path": "scripts/sikana.rhai"
},
{
"name": "Threefold",
"port": 9003,
"script_path": "scripts/threefold.rhai"
},
{
"name": "Mbweni",
"port": 9004,
"script_path": "scripts/mbweni.rhai"
},
{
"name": "Geomind",
"port": 9005,
"script_path": "scripts/geomind.rhai"
},
{
"name": "Freezone",
"port": 9006,
"script_path": "scripts/freezone.rhai"
}
]

View File

@@ -1,90 +0,0 @@
//! Example of launching multiple circles and outputting their details to a file.
//!
//! This example demonstrates how to use the launcher library to start circles
//! programmatically, similar to how the `launcher` binary works.
//!
//! # Usage
//!
//! ```sh
//! cargo run --example ourworld
//! ```
//!
//! This will:
//! 1. Read the `circles.json` file in the `examples/ourworld` directory.
//! 2. Launch all 7 circles defined in the config.
//! 3. Create a `ourworld_output.json` file in the same directory with the details.
//! 4. The launcher will run until you stop it with Ctrl+C.
use launcher::{run_launcher, Args, CircleConfig};
use log::{error, info};
use std::error::Error as StdError;
use std::fs;
use std::path::PathBuf;
#[tokio::main]
async fn main() -> Result<(), Box<dyn StdError>> {
println!("--- Launching OurWorld Example Programmatically ---");
// The example is now at the root of the `examples` directory,
// so we can reference its assets directly.
let example_dir = PathBuf::from("./examples/ourworld");
let config_path = example_dir.join("circles.json");
let output_path = example_dir.join("ourworld_output.json");
println!("Using config file: {:?}", config_path);
println!("Output will be written to: {:?}", output_path);
// Manually construct the arguments instead of parsing from command line.
// This is useful when embedding the launcher logic in another application.
let args = Args {
config_path: config_path.clone(),
output: Some(output_path),
debug: true, // Enable debug logging for the example
verbose: 2, // Set verbosity to max
};
if !config_path.exists() {
let msg = format!("Configuration file not found at {:?}", config_path);
error!("{}", msg);
return Err(msg.into());
}
let config_content = fs::read_to_string(&config_path)?;
let mut circle_configs: Vec<CircleConfig> = match serde_json::from_str(&config_content) {
Ok(configs) => configs,
Err(e) => {
error!(
"Failed to parse {}: {}. Ensure it's a valid JSON array of CircleConfig.",
config_path.display(),
e
);
return Err(Box::new(e) as Box<dyn StdError>);
}
};
// Make script paths relative to the project root by prepending the example directory path.
for config in &mut circle_configs {
if let Some(script_path) = &config.script_path {
let full_script_path = example_dir.join(script_path);
config.script_path = Some(full_script_path.to_string_lossy().into_owned());
}
}
if circle_configs.is_empty() {
info!(
"No circle configurations found in {}. Exiting.",
config_path.display()
);
return Ok(());
}
println!("Starting launcher... Press Ctrl+C to exit.");
// The run_launcher function will setup logging, spawn circles, print the table,
// and wait for a shutdown signal (Ctrl+C).
run_launcher(args, circle_configs).await?;
println!("--- OurWorld Example Finished ---");
Ok(())
}

View File

@@ -1,65 +0,0 @@
[
{
"name": "Timur Gordon",
"public_key": "023b0a9d409506f41f5782353857dea6abc16ae4643661cd94d8155fdb498642e3",
"secret_key": "7a7074c59ccfa3465686277e9e9da34867b36a1e256271b893b6c22fbc82929e",
"worker_queue": "rhai_tasks:023b0a9d409506f41f5782353857dea6abc16ae4643661cd94d8155fdb498642e3",
"ws_url": "ws://127.0.0.1:9100"
},
{
"name": "Kristof de Spiegeleer",
"public_key": "030b62236efa67855b3379a9d4add1facbe8a545bafa86e1d6fbac06caae5b5b12",
"secret_key": "04225fbb41d8c397581d7ec19ded8aaf02d8b9daf27fed9617525e4f8114a382",
"worker_queue": "rhai_tasks:030b62236efa67855b3379a9d4add1facbe8a545bafa86e1d6fbac06caae5b5b12",
"ws_url": "ws://127.0.0.1:9101"
},
{
"name": "OurWorld",
"public_key": "02c9e7cb76e19adc3b579091d923ef273282070bc4864c1a07e94ca34a78aea8ef",
"secret_key": "cb58d003eae0a5168b6f6fc4e822879b17e7b5987e5a76b870b75fe659e3cc60",
"worker_queue": "rhai_tasks:02c9e7cb76e19adc3b579091d923ef273282070bc4864c1a07e94ca34a78aea8ef",
"ws_url": "ws://127.0.0.1:9000"
},
{
"name": "Dunia Cybercity",
"public_key": "02a19f52bdde937a3f05c1bcc9b58c467d5084586a5a0b832617e131886c961771",
"secret_key": "c2a9a0c35b7c85cadfaf9e3123829324e4b4b116239833123d73da14b13dfbde",
"worker_queue": "rhai_tasks:02a19f52bdde937a3f05c1bcc9b58c467d5084586a5a0b832617e131886c961771",
"ws_url": "ws://127.0.0.1:9001"
},
{
"name": "Sikana",
"public_key": "032db92879e51d5adf17a99df0cedba49d69e051ffb7b224e5a50e5d02a8f3c68f",
"secret_key": "3718bc30c8d3ee1e88f1d88e06ed7637197c2f9b422a5757201acf572e9c7345",
"worker_queue": "rhai_tasks:032db92879e51d5adf17a99df0cedba49d69e051ffb7b224e5a50e5d02a8f3c68f",
"ws_url": "ws://127.0.0.1:9002"
},
{
"name": "Threefold",
"public_key": "021b452667f0c73a9f96c65dfceb0810e36109ad2408e0693a90fd4cdf7d8de0f6",
"secret_key": "9e9532bdc279570f22b8bc853eadf8f7cdf5cacd3e506ae06b3a9f34778a372f",
"worker_queue": "rhai_tasks:021b452667f0c73a9f96c65dfceb0810e36109ad2408e0693a90fd4cdf7d8de0f6",
"ws_url": "ws://127.0.0.1:9003"
},
{
"name": "Mbweni",
"public_key": "029423b664660e9d9bcdbde244fda7d2064b17089463ddfb6eed301e34fb115969",
"secret_key": "b70c510765d1a3e315871355fb6b902662f465ef317ddbabf146163ad8b83937",
"worker_queue": "rhai_tasks:029423b664660e9d9bcdbde244fda7d2064b17089463ddfb6eed301e34fb115969",
"ws_url": "ws://127.0.0.1:9004"
},
{
"name": "Geomind",
"public_key": "03af7abb8737dfb0d3e7eb22d4e57d5566a82be0ca7c4fe7f7cf1b37ad595044f7",
"secret_key": "22a4b7514b3f88a697566f5c1aa12178e0974ae3f7ae6eb7054c4c9cbd30a8fa",
"worker_queue": "rhai_tasks:03af7abb8737dfb0d3e7eb22d4e57d5566a82be0ca7c4fe7f7cf1b37ad595044f7",
"ws_url": "ws://127.0.0.1:9005"
},
{
"name": "Freezone",
"public_key": "03a00761250dd79294ccbc4de916454736ff5a6488d8bb93c759d2dae5abf20b03",
"secret_key": "a09d158e6f2b6706bca97a320bbc64b6278fe795820a0759f658f230fd071003",
"worker_queue": "rhai_tasks:03a00761250dd79294ccbc4de916454736ff5a6488d8bb93c759d2dae5abf20b03",
"ws_url": "ws://127.0.0.1:9006"
}
]

View File

@@ -1,249 +0,0 @@
// OurWorld Circle and Library Data
new_circle()
.title("Dunia Cybercity")
.description("Creating a better world.")
.ws_url("ws://localhost:8091/ws")
.logo("🌍")
.save_circle();
let circle = get_circle();
print("--- Creating OurWorld Library ---");
// === IMAGES ===
print("Creating images...");
let nature1 = save_image(new_image()
.title("Mountain Sunrise")
.description("Breathtaking sunrise over mountain peaks")
.url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800")
.width(800).height(600));
let nature2 = save_image(new_image()
.title("Ocean Waves")
.description("Powerful ocean waves crashing on rocks")
.url("https://images.unsplash.com/photo-1505142468610-359e7d316be0?w=800")
.width(800).height(600));
let nature3 = save_image(new_image()
.title("Forest Path")
.description("Peaceful path through ancient forest")
.url("https://images.unsplash.com/photo-1441974231531-c6227db76b6e?w=800")
.width(800).height(600));
let tech1 = save_image(new_image()
.title("Solar Panels")
.description("Modern solar panel installation")
.url("https://images.unsplash.com/photo-1509391366360-2e959784a276?w=800")
.width(800).height(600));
let tech2 = save_image(new_image()
.title("Wind Turbines")
.description("Wind turbines generating clean energy")
.url("https://images.unsplash.com/photo-1466611653911-95081537e5b7?w=800")
.width(800).height(600));
let space1 = save_image(new_image()
.title("Earth from Space")
.description("Our beautiful planet from orbit")
.url("https://images.unsplash.com/photo-1446776877081-d282a0f896e2?w=800")
.width(800).height(600));
let space2 = save_image(new_image()
.title("Galaxy Spiral")
.description("Stunning spiral galaxy in deep space")
.url("https://images.unsplash.com/photo-1502134249126-9f3755a50d78?w=800")
.width(800).height(600));
let city1 = save_image(new_image()
.title("Smart City")
.description("Futuristic smart city at night")
.url("https://images.unsplash.com/photo-1480714378408-67cf0d13bc1f?w=800")
.width(800).height(600));
// === PDFs ===
print("Creating PDFs...");
let pdf1 = save_pdf(new_pdf()
.title("Climate Action Report 2024")
.description("Comprehensive analysis of global climate initiatives")
.url("https://www.ipcc.ch/site/assets/uploads/2018/02/ipcc_wg3_ar5_summary-for-policymakers.pdf")
.page_count(42));
let pdf2 = save_pdf(new_pdf()
.title("Sustainable Development Goals")
.description("UN SDG implementation guide")
.url("https://sdgs.un.org/sites/default/files/publications/21252030%20Agenda%20for%20Sustainable%20Development%20web.pdf")
.page_count(35));
let pdf3 = save_pdf(new_pdf()
.title("Renewable Energy Handbook")
.description("Technical guide to renewable energy systems")
.url("https://www.irena.org/-/media/Files/IRENA/Agency/Publication/2019/Oct/IRENA_Renewable-Energy-Statistics-2019.pdf")
.page_count(280));
let pdf4 = save_pdf(new_pdf()
.title("Blockchain for Good")
.description("How blockchain technology can solve global challenges")
.url("https://www.weforum.org/whitepapers/blockchain-beyond-the-hype")
.page_count(24));
let pdf5 = save_pdf(new_pdf()
.title("Future of Work Report")
.description("Analysis of changing work patterns and remote collaboration")
.url("https://www.mckinsey.com/featured-insights/future-of-work")
.page_count(156));
// === MARKDOWN DOCUMENTS ===
print("Creating markdown documents...");
let md1 = save_markdown(new_markdown()
.title("OurWorld Mission Statement")
.description("Our vision for a better world")
.content("# OurWorld Mission\n\n## Vision\nTo create a more sustainable, equitable, and connected world through technology and collaboration.\n\n## Values\n- **Sustainability**: Every decision considers environmental impact\n- **Inclusivity**: Technology that serves everyone\n- **Transparency**: Open source and open governance\n- **Innovation**: Pushing boundaries for positive change\n\n## Goals\n1. Reduce global carbon footprint by 50% by 2030\n2. Provide internet access to 1 billion underserved people\n3. Create 10 million green jobs worldwide\n4. Establish 1000 sustainable communities"));
let md2 = save_markdown(new_markdown()
.title("Getting Started Guide")
.description("How to join the OurWorld movement")
.content("# Getting Started with OurWorld\n\n## Welcome!\nThank you for joining our mission to create a better world.\n\n## First Steps\n1. **Explore**: Browse our projects and initiatives\n2. **Connect**: Join our community forums\n3. **Contribute**: Find ways to get involved\n4. **Learn**: Access our educational resources\n\n## Ways to Contribute\n- **Developers**: Contribute to open source projects\n- **Activists**: Organize local initiatives\n- **Educators**: Share knowledge and skills\n- **Investors**: Support sustainable ventures\n\n## Resources\n- [Community Forum](https://forum.ourworld.tf)\n- [Developer Portal](https://dev.ourworld.tf)\n- [Learning Hub](https://learn.ourworld.tf)"));
let md3 = save_markdown(new_markdown()
.title("Technology Roadmap 2024")
.description("Our technical development plans")
.content("# Technology Roadmap 2024\n\n## Q1 Objectives\n- Launch decentralized identity system\n- Deploy carbon tracking blockchain\n- Release mobile app v2.0\n\n## Q2 Objectives\n- Implement AI-powered resource optimization\n- Launch peer-to-peer energy trading platform\n- Deploy IoT sensor network\n\n## Q3 Objectives\n- Release virtual collaboration spaces\n- Launch digital twin cities pilot\n- Implement quantum-safe encryption\n\n## Q4 Objectives\n- Deploy autonomous governance systems\n- Launch global impact measurement platform\n- Release AR/VR sustainability training"));
let md4 = save_markdown(new_markdown()
.title("Community Guidelines")
.description("How we work together")
.content("# Community Guidelines\n\n## Our Principles\n- **Respect**: Treat everyone with dignity\n- **Collaboration**: Work together towards common goals\n- **Constructive**: Focus on solutions, not problems\n- **Inclusive**: Welcome diverse perspectives\n\n## Communication Standards\n- Use clear, respectful language\n- Listen actively to others\n- Provide constructive feedback\n- Share knowledge freely\n\n## Conflict Resolution\n1. Address issues directly and respectfully\n2. Seek to understand different viewpoints\n3. Involve mediators when needed\n4. Focus on solutions that benefit everyone"));
let investor = new_contact()
.name("Example Investor")
.save_contact();
let investors = new_group()
.name("Investors")
.description("A group for example inverstors of ourworld");
investors.add_contact(investor.id)
.save_group();
// === BOOKS ===
print("Creating books...");
let sustainability_book = save_book(new_book()
.title("Sustainability Handbook")
.description("Complete guide to sustainable living and practices")
.add_page("# Introduction to Sustainability\n\nSustainability is about meeting our present needs without compromising the ability of future generations to meet their own needs.\n\n## Key Principles\n- Environmental stewardship\n- Social equity\n- Economic viability\n\n## Why It Matters\nOur planet faces unprecedented challenges from climate change, resource depletion, and environmental degradation.")
.add_page("# Energy Efficiency\n\n## Home Energy Savings\n- LED lighting reduces energy consumption by 75%\n- Smart thermostats can save 10-15% on heating/cooling\n- Energy-efficient appliances make a significant difference\n\n## Renewable Energy\n- Solar panels: Clean electricity from sunlight\n- Wind power: Harnessing natural wind currents\n- Hydroelectric: Using water flow for energy\n\n## Transportation\n- Electric vehicles reduce emissions\n- Public transit decreases individual carbon footprint\n- Cycling and walking for short distances")
.add_page("# Waste Reduction\n\n## The 5 R's\n1. **Refuse**: Say no to unnecessary items\n2. **Reduce**: Use less of what you need\n3. **Reuse**: Find new purposes for items\n4. **Recycle**: Process materials into new products\n5. **Rot**: Compost organic waste\n\n## Practical Tips\n- Use reusable bags and containers\n- Buy products with minimal packaging\n- Repair instead of replacing\n- Donate items you no longer need")
.add_page("# Sustainable Food\n\n## Local and Seasonal\n- Support local farmers and reduce transport emissions\n- Eat seasonal produce for better nutrition and taste\n- Visit farmers markets and join CSAs\n\n## Plant-Based Options\n- Reduce meat consumption for environmental benefits\n- Explore diverse plant proteins\n- Grow your own herbs and vegetables\n\n## Food Waste Prevention\n- Plan meals and make shopping lists\n- Store food properly to extend freshness\n- Use leftovers creatively")
.add_toc_entry(new_toc_entry().title("Introduction to Sustainability").page(0))
.add_toc_entry(new_toc_entry().title("Energy Efficiency").page(1))
.add_toc_entry(new_toc_entry().title("Waste Reduction").page(2))
.add_toc_entry(new_toc_entry().title("Sustainable Food").page(3)));
let tech_guide_book = save_book(new_book()
.title("Green Technology Guide")
.description("Understanding and implementing green technologies")
.add_page("# Green Technology Overview\n\nGreen technology, also known as clean technology, refers to the use of science and technology to create products and services that are environmentally friendly.\n\n## Categories\n- Renewable energy systems\n- Energy efficiency technologies\n- Pollution prevention and cleanup\n- Sustainable materials and manufacturing\n\n## Benefits\n- Reduced environmental impact\n- Lower operating costs\n- Improved public health\n- Economic opportunities")
.add_page("# Solar Technology\n\n## How Solar Works\nSolar panels convert sunlight directly into electricity using photovoltaic cells.\n\n## Types of Solar Systems\n- **Grid-tied**: Connected to the electrical grid\n- **Off-grid**: Standalone systems with battery storage\n- **Hybrid**: Combination of grid-tied and battery backup\n\n## Installation Considerations\n- Roof orientation and shading\n- Local climate and sun exposure\n- Energy consumption patterns\n- Available incentives and rebates")
.add_page("# Smart Home Technology\n\n## Automation Benefits\n- Optimized energy usage\n- Enhanced comfort and convenience\n- Remote monitoring and control\n- Predictive maintenance\n\n## Key Technologies\n- Smart thermostats\n- Automated lighting systems\n- Energy monitoring devices\n- Smart appliances\n- Home energy management systems")
.add_toc_entry(new_toc_entry().title("Green Technology Overview").page(0))
.add_toc_entry(new_toc_entry().title("Solar Technology").page(1))
.add_toc_entry(new_toc_entry().title("Smart Home Technology").page(2)));
let community_book = save_book(new_book()
.title("Building Communities")
.description("Guide to creating sustainable and inclusive communities")
.add_page("# Community Building Fundamentals\n\n## What Makes a Strong Community?\n- Shared values and vision\n- Open communication channels\n- Mutual support and cooperation\n- Inclusive decision-making processes\n\n## Benefits of Strong Communities\n- Enhanced quality of life\n- Economic resilience\n- Social cohesion\n- Environmental stewardship")
.add_page("# Governance and Leadership\n\n## Collaborative Leadership\n- Distributed decision-making\n- Transparent processes\n- Accountability mechanisms\n- Conflict resolution systems\n\n## Community Engagement\n- Regular town halls and meetings\n- Digital participation platforms\n- Volunteer coordination\n- Feedback and improvement cycles")
.add_toc_entry(new_toc_entry().title("Community Building Fundamentals").page(0))
.add_toc_entry(new_toc_entry().title("Governance and Leadership").page(1)));
// === SLIDES ===
print("Creating slides...");
let climate_slides = save_slides(new_slides()
.title("Climate Change Awareness")
.description("Visual presentation on climate change impacts and solutions")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1569163139394-de4e4f43e4e3?w=1200").title("Global Temperature Rise"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1578662996442-48f60103fc96?w=1200").title("Melting Ice Caps"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1200").title("Extreme Weather Events"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=1200").title("Renewable Energy Solutions"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1497436072909-f5e4be1dffea?w=1200").title("Sustainable Transportation")));
let innovation_slides = save_slides(new_slides()
.title("Innovation Showcase")
.description("Cutting-edge technologies for a sustainable future")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=1200").title("AI and Machine Learning"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1639322537228-f710d846310a?w=1200").title("Blockchain Technology"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092160562-40aa08e78837?w=1200").title("IoT and Smart Cities"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?w=1200").title("Quantum Computing"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092162384-8987c1d64718?w=1200").title("Biotechnology Advances")));
let nature_slides = save_slides(new_slides()
.title("Biodiversity Gallery")
.description("Celebrating Earth's incredible biodiversity")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1564349683136-77e08dba1ef7?w=1200").title("Tropical Rainforest"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1559827260-dc66d52bef19?w=1200").title("Coral Reef Ecosystem"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1551698618-1dfe5d97d256?w=1200").title("Arctic Wildlife"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200").title("Mountain Ecosystems")));
// === COLLECTIONS ===
print("Creating collections...");
let nature_collection = save_collection(new_collection()
.title("Nature & Environment")
.description("Beautiful images and resources about our natural world")
.add_image(nature1.id)
.add_image(nature2.id)
.add_image(nature3.id)
.add_pdf(pdf1.id)
.add_markdown(md1.id)
.add_book(sustainability_book.id)
.add_slides(nature_slides.id));
let technology_collection = save_collection(new_collection()
.title("Sustainable Technology")
.description("Innovations driving positive change")
.add_image(tech1.id)
.add_image(tech2.id)
.add_pdf(pdf3.id)
.add_pdf(pdf4.id)
.add_markdown(md3.id)
.add_book(tech_guide_book.id)
.add_slides(innovation_slides.id));
let space_collection = save_collection(new_collection()
.title("Space & Cosmos")
.description("Exploring the universe and our place in it")
.add_image(space1.id)
.add_image(space2.id)
.add_pdf(pdf2.id)
.add_markdown(md2.id));
let community_collection = save_collection(new_collection()
.title("Community & Collaboration")
.description("Building better communities together")
.add_image(city1.id)
.add_pdf(pdf5.id)
.add_markdown(md4.id)
.add_book(community_book.id));
let climate_collection = save_collection(new_collection()
.title("Climate Action")
.description("Understanding and addressing climate change")
.add_slides(climate_slides.id)
.add_pdf(pdf1.id)
.add_markdown(md1.id));
print("✅ OurWorld library created successfully!");
print("📚 Collections: 5");
print("🖼️ Images: 8");
print("📄 PDFs: 5");
print("📝 Markdown docs: 4");
print("📖 Books: 3");
print("🎞️ Slide shows: 3");

View File

@@ -1,249 +0,0 @@
// OurWorld Circle and Library Data
new_circle()
.title("Zanzibar Digital Freezone")
.description("Creating a better world.")
.ws_url("ws://localhost:8096/ws")
.logo("🌍")
.save_circle();
let circle = get_circle();
print("--- Creating OurWorld Library ---");
// === IMAGES ===
print("Creating images...");
let nature1 = save_image(new_image()
.title("Mountain Sunrise")
.description("Breathtaking sunrise over mountain peaks")
.url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800")
.width(800).height(600));
let nature2 = save_image(new_image()
.title("Ocean Waves")
.description("Powerful ocean waves crashing on rocks")
.url("https://images.unsplash.com/photo-1505142468610-359e7d316be0?w=800")
.width(800).height(600));
let nature3 = save_image(new_image()
.title("Forest Path")
.description("Peaceful path through ancient forest")
.url("https://images.unsplash.com/photo-1441974231531-c6227db76b6e?w=800")
.width(800).height(600));
let tech1 = save_image(new_image()
.title("Solar Panels")
.description("Modern solar panel installation")
.url("https://images.unsplash.com/photo-1509391366360-2e959784a276?w=800")
.width(800).height(600));
let tech2 = save_image(new_image()
.title("Wind Turbines")
.description("Wind turbines generating clean energy")
.url("https://images.unsplash.com/photo-1466611653911-95081537e5b7?w=800")
.width(800).height(600));
let space1 = save_image(new_image()
.title("Earth from Space")
.description("Our beautiful planet from orbit")
.url("https://images.unsplash.com/photo-1446776877081-d282a0f896e2?w=800")
.width(800).height(600));
let space2 = save_image(new_image()
.title("Galaxy Spiral")
.description("Stunning spiral galaxy in deep space")
.url("https://images.unsplash.com/photo-1502134249126-9f3755a50d78?w=800")
.width(800).height(600));
let city1 = save_image(new_image()
.title("Smart City")
.description("Futuristic smart city at night")
.url("https://images.unsplash.com/photo-1480714378408-67cf0d13bc1f?w=800")
.width(800).height(600));
// === PDFs ===
print("Creating PDFs...");
let pdf1 = save_pdf(new_pdf()
.title("Climate Action Report 2024")
.description("Comprehensive analysis of global climate initiatives")
.url("https://www.ipcc.ch/site/assets/uploads/2018/02/ipcc_wg3_ar5_summary-for-policymakers.pdf")
.page_count(42));
let pdf2 = save_pdf(new_pdf()
.title("Sustainable Development Goals")
.description("UN SDG implementation guide")
.url("https://sdgs.un.org/sites/default/files/publications/21252030%20Agenda%20for%20Sustainable%20Development%20web.pdf")
.page_count(35));
let pdf3 = save_pdf(new_pdf()
.title("Renewable Energy Handbook")
.description("Technical guide to renewable energy systems")
.url("https://www.irena.org/-/media/Files/IRENA/Agency/Publication/2019/Oct/IRENA_Renewable-Energy-Statistics-2019.pdf")
.page_count(280));
let pdf4 = save_pdf(new_pdf()
.title("Blockchain for Good")
.description("How blockchain technology can solve global challenges")
.url("https://www.weforum.org/whitepapers/blockchain-beyond-the-hype")
.page_count(24));
let pdf5 = save_pdf(new_pdf()
.title("Future of Work Report")
.description("Analysis of changing work patterns and remote collaboration")
.url("https://www.mckinsey.com/featured-insights/future-of-work")
.page_count(156));
// === MARKDOWN DOCUMENTS ===
print("Creating markdown documents...");
let md1 = save_markdown(new_markdown()
.title("OurWorld Mission Statement")
.description("Our vision for a better world")
.content("# OurWorld Mission\n\n## Vision\nTo create a more sustainable, equitable, and connected world through technology and collaboration.\n\n## Values\n- **Sustainability**: Every decision considers environmental impact\n- **Inclusivity**: Technology that serves everyone\n- **Transparency**: Open source and open governance\n- **Innovation**: Pushing boundaries for positive change\n\n## Goals\n1. Reduce global carbon footprint by 50% by 2030\n2. Provide internet access to 1 billion underserved people\n3. Create 10 million green jobs worldwide\n4. Establish 1000 sustainable communities"));
let md2 = save_markdown(new_markdown()
.title("Getting Started Guide")
.description("How to join the OurWorld movement")
.content("# Getting Started with OurWorld\n\n## Welcome!\nThank you for joining our mission to create a better world.\n\n## First Steps\n1. **Explore**: Browse our projects and initiatives\n2. **Connect**: Join our community forums\n3. **Contribute**: Find ways to get involved\n4. **Learn**: Access our educational resources\n\n## Ways to Contribute\n- **Developers**: Contribute to open source projects\n- **Activists**: Organize local initiatives\n- **Educators**: Share knowledge and skills\n- **Investors**: Support sustainable ventures\n\n## Resources\n- [Community Forum](https://forum.ourworld.tf)\n- [Developer Portal](https://dev.ourworld.tf)\n- [Learning Hub](https://learn.ourworld.tf)"));
let md3 = save_markdown(new_markdown()
.title("Technology Roadmap 2024")
.description("Our technical development plans")
.content("# Technology Roadmap 2024\n\n## Q1 Objectives\n- Launch decentralized identity system\n- Deploy carbon tracking blockchain\n- Release mobile app v2.0\n\n## Q2 Objectives\n- Implement AI-powered resource optimization\n- Launch peer-to-peer energy trading platform\n- Deploy IoT sensor network\n\n## Q3 Objectives\n- Release virtual collaboration spaces\n- Launch digital twin cities pilot\n- Implement quantum-safe encryption\n\n## Q4 Objectives\n- Deploy autonomous governance systems\n- Launch global impact measurement platform\n- Release AR/VR sustainability training"));
let md4 = save_markdown(new_markdown()
.title("Community Guidelines")
.description("How we work together")
.content("# Community Guidelines\n\n## Our Principles\n- **Respect**: Treat everyone with dignity\n- **Collaboration**: Work together towards common goals\n- **Constructive**: Focus on solutions, not problems\n- **Inclusive**: Welcome diverse perspectives\n\n## Communication Standards\n- Use clear, respectful language\n- Listen actively to others\n- Provide constructive feedback\n- Share knowledge freely\n\n## Conflict Resolution\n1. Address issues directly and respectfully\n2. Seek to understand different viewpoints\n3. Involve mediators when needed\n4. Focus on solutions that benefit everyone"));
let investor = new_contact()
.name("Example Investor")
.save_contact();
let investors = new_group()
.name("Investors")
.description("A group for example inverstors of ourworld");
investors.add_contact(investor.id)
.save_group();
// === BOOKS ===
print("Creating books...");
let sustainability_book = save_book(new_book()
.title("Sustainability Handbook")
.description("Complete guide to sustainable living and practices")
.add_page("# Introduction to Sustainability\n\nSustainability is about meeting our present needs without compromising the ability of future generations to meet their own needs.\n\n## Key Principles\n- Environmental stewardship\n- Social equity\n- Economic viability\n\n## Why It Matters\nOur planet faces unprecedented challenges from climate change, resource depletion, and environmental degradation.")
.add_page("# Energy Efficiency\n\n## Home Energy Savings\n- LED lighting reduces energy consumption by 75%\n- Smart thermostats can save 10-15% on heating/cooling\n- Energy-efficient appliances make a significant difference\n\n## Renewable Energy\n- Solar panels: Clean electricity from sunlight\n- Wind power: Harnessing natural wind currents\n- Hydroelectric: Using water flow for energy\n\n## Transportation\n- Electric vehicles reduce emissions\n- Public transit decreases individual carbon footprint\n- Cycling and walking for short distances")
.add_page("# Waste Reduction\n\n## The 5 R's\n1. **Refuse**: Say no to unnecessary items\n2. **Reduce**: Use less of what you need\n3. **Reuse**: Find new purposes for items\n4. **Recycle**: Process materials into new products\n5. **Rot**: Compost organic waste\n\n## Practical Tips\n- Use reusable bags and containers\n- Buy products with minimal packaging\n- Repair instead of replacing\n- Donate items you no longer need")
.add_page("# Sustainable Food\n\n## Local and Seasonal\n- Support local farmers and reduce transport emissions\n- Eat seasonal produce for better nutrition and taste\n- Visit farmers markets and join CSAs\n\n## Plant-Based Options\n- Reduce meat consumption for environmental benefits\n- Explore diverse plant proteins\n- Grow your own herbs and vegetables\n\n## Food Waste Prevention\n- Plan meals and make shopping lists\n- Store food properly to extend freshness\n- Use leftovers creatively")
.add_toc_entry(new_toc_entry().title("Introduction to Sustainability").page(0))
.add_toc_entry(new_toc_entry().title("Energy Efficiency").page(1))
.add_toc_entry(new_toc_entry().title("Waste Reduction").page(2))
.add_toc_entry(new_toc_entry().title("Sustainable Food").page(3)));
let tech_guide_book = save_book(new_book()
.title("Green Technology Guide")
.description("Understanding and implementing green technologies")
.add_page("# Green Technology Overview\n\nGreen technology, also known as clean technology, refers to the use of science and technology to create products and services that are environmentally friendly.\n\n## Categories\n- Renewable energy systems\n- Energy efficiency technologies\n- Pollution prevention and cleanup\n- Sustainable materials and manufacturing\n\n## Benefits\n- Reduced environmental impact\n- Lower operating costs\n- Improved public health\n- Economic opportunities")
.add_page("# Solar Technology\n\n## How Solar Works\nSolar panels convert sunlight directly into electricity using photovoltaic cells.\n\n## Types of Solar Systems\n- **Grid-tied**: Connected to the electrical grid\n- **Off-grid**: Standalone systems with battery storage\n- **Hybrid**: Combination of grid-tied and battery backup\n\n## Installation Considerations\n- Roof orientation and shading\n- Local climate and sun exposure\n- Energy consumption patterns\n- Available incentives and rebates")
.add_page("# Smart Home Technology\n\n## Automation Benefits\n- Optimized energy usage\n- Enhanced comfort and convenience\n- Remote monitoring and control\n- Predictive maintenance\n\n## Key Technologies\n- Smart thermostats\n- Automated lighting systems\n- Energy monitoring devices\n- Smart appliances\n- Home energy management systems")
.add_toc_entry(new_toc_entry().title("Green Technology Overview").page(0))
.add_toc_entry(new_toc_entry().title("Solar Technology").page(1))
.add_toc_entry(new_toc_entry().title("Smart Home Technology").page(2)));
let community_book = save_book(new_book()
.title("Building Communities")
.description("Guide to creating sustainable and inclusive communities")
.add_page("# Community Building Fundamentals\n\n## What Makes a Strong Community?\n- Shared values and vision\n- Open communication channels\n- Mutual support and cooperation\n- Inclusive decision-making processes\n\n## Benefits of Strong Communities\n- Enhanced quality of life\n- Economic resilience\n- Social cohesion\n- Environmental stewardship")
.add_page("# Governance and Leadership\n\n## Collaborative Leadership\n- Distributed decision-making\n- Transparent processes\n- Accountability mechanisms\n- Conflict resolution systems\n\n## Community Engagement\n- Regular town halls and meetings\n- Digital participation platforms\n- Volunteer coordination\n- Feedback and improvement cycles")
.add_toc_entry(new_toc_entry().title("Community Building Fundamentals").page(0))
.add_toc_entry(new_toc_entry().title("Governance and Leadership").page(1)));
// === SLIDES ===
print("Creating slides...");
let climate_slides = save_slides(new_slides()
.title("Climate Change Awareness")
.description("Visual presentation on climate change impacts and solutions")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1569163139394-de4e4f43e4e3?w=1200").title("Global Temperature Rise"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1578662996442-48f60103fc96?w=1200").title("Melting Ice Caps"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1200").title("Extreme Weather Events"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=1200").title("Renewable Energy Solutions"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1497436072909-f5e4be1dffea?w=1200").title("Sustainable Transportation")));
let innovation_slides = save_slides(new_slides()
.title("Innovation Showcase")
.description("Cutting-edge technologies for a sustainable future")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=1200").title("AI and Machine Learning"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1639322537228-f710d846310a?w=1200").title("Blockchain Technology"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092160562-40aa08e78837?w=1200").title("IoT and Smart Cities"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?w=1200").title("Quantum Computing"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092162384-8987c1d64718?w=1200").title("Biotechnology Advances")));
let nature_slides = save_slides(new_slides()
.title("Biodiversity Gallery")
.description("Celebrating Earth's incredible biodiversity")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1564349683136-77e08dba1ef7?w=1200").title("Tropical Rainforest"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1559827260-dc66d52bef19?w=1200").title("Coral Reef Ecosystem"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1551698618-1dfe5d97d256?w=1200").title("Arctic Wildlife"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200").title("Mountain Ecosystems")));
// === COLLECTIONS ===
print("Creating collections...");
let nature_collection = save_collection(new_collection()
.title("Nature & Environment")
.description("Beautiful images and resources about our natural world")
.add_image(nature1.id)
.add_image(nature2.id)
.add_image(nature3.id)
.add_pdf(pdf1.id)
.add_markdown(md1.id)
.add_book(sustainability_book.id)
.add_slides(nature_slides.id));
let technology_collection = save_collection(new_collection()
.title("Sustainable Technology")
.description("Innovations driving positive change")
.add_image(tech1.id)
.add_image(tech2.id)
.add_pdf(pdf3.id)
.add_pdf(pdf4.id)
.add_markdown(md3.id)
.add_book(tech_guide_book.id)
.add_slides(innovation_slides.id));
let space_collection = save_collection(new_collection()
.title("Space & Cosmos")
.description("Exploring the universe and our place in it")
.add_image(space1.id)
.add_image(space2.id)
.add_pdf(pdf2.id)
.add_markdown(md2.id));
let community_collection = save_collection(new_collection()
.title("Community & Collaboration")
.description("Building better communities together")
.add_image(city1.id)
.add_pdf(pdf5.id)
.add_markdown(md4.id)
.add_book(community_book.id));
let climate_collection = save_collection(new_collection()
.title("Climate Action")
.description("Understanding and addressing climate change")
.add_slides(climate_slides.id)
.add_pdf(pdf1.id)
.add_markdown(md1.id));
print("✅ OurWorld library created successfully!");
print("📚 Collections: 5");
print("🖼️ Images: 8");
print("📄 PDFs: 5");
print("📝 Markdown docs: 4");
print("📖 Books: 3");
print("🎞️ Slide shows: 3");

View File

@@ -1,249 +0,0 @@
// OurWorld Circle and Library Data
new_circle()
.title("Geomind")
.description("Creating a better world.")
.ws_url("ws://localhost:8095/ws")
.logo("🌍")
.save_circle();
let circle = get_circle();
print("--- Creating OurWorld Library ---");
// === IMAGES ===
print("Creating images...");
let nature1 = save_image(new_image()
.title("Mountain Sunrise")
.description("Breathtaking sunrise over mountain peaks")
.url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800")
.width(800).height(600));
let nature2 = save_image(new_image()
.title("Ocean Waves")
.description("Powerful ocean waves crashing on rocks")
.url("https://images.unsplash.com/photo-1505142468610-359e7d316be0?w=800")
.width(800).height(600));
let nature3 = save_image(new_image()
.title("Forest Path")
.description("Peaceful path through ancient forest")
.url("https://images.unsplash.com/photo-1441974231531-c6227db76b6e?w=800")
.width(800).height(600));
let tech1 = save_image(new_image()
.title("Solar Panels")
.description("Modern solar panel installation")
.url("https://images.unsplash.com/photo-1509391366360-2e959784a276?w=800")
.width(800).height(600));
let tech2 = save_image(new_image()
.title("Wind Turbines")
.description("Wind turbines generating clean energy")
.url("https://images.unsplash.com/photo-1466611653911-95081537e5b7?w=800")
.width(800).height(600));
let space1 = save_image(new_image()
.title("Earth from Space")
.description("Our beautiful planet from orbit")
.url("https://images.unsplash.com/photo-1446776877081-d282a0f896e2?w=800")
.width(800).height(600));
let space2 = save_image(new_image()
.title("Galaxy Spiral")
.description("Stunning spiral galaxy in deep space")
.url("https://images.unsplash.com/photo-1502134249126-9f3755a50d78?w=800")
.width(800).height(600));
let city1 = save_image(new_image()
.title("Smart City")
.description("Futuristic smart city at night")
.url("https://images.unsplash.com/photo-1480714378408-67cf0d13bc1f?w=800")
.width(800).height(600));
// === PDFs ===
print("Creating PDFs...");
let pdf1 = save_pdf(new_pdf()
.title("Climate Action Report 2024")
.description("Comprehensive analysis of global climate initiatives")
.url("https://www.ipcc.ch/site/assets/uploads/2018/02/ipcc_wg3_ar5_summary-for-policymakers.pdf")
.page_count(42));
let pdf2 = save_pdf(new_pdf()
.title("Sustainable Development Goals")
.description("UN SDG implementation guide")
.url("https://sdgs.un.org/sites/default/files/publications/21252030%20Agenda%20for%20Sustainable%20Development%20web.pdf")
.page_count(35));
let pdf3 = save_pdf(new_pdf()
.title("Renewable Energy Handbook")
.description("Technical guide to renewable energy systems")
.url("https://www.irena.org/-/media/Files/IRENA/Agency/Publication/2019/Oct/IRENA_Renewable-Energy-Statistics-2019.pdf")
.page_count(280));
let pdf4 = save_pdf(new_pdf()
.title("Blockchain for Good")
.description("How blockchain technology can solve global challenges")
.url("https://www.weforum.org/whitepapers/blockchain-beyond-the-hype")
.page_count(24));
let pdf5 = save_pdf(new_pdf()
.title("Future of Work Report")
.description("Analysis of changing work patterns and remote collaboration")
.url("https://www.mckinsey.com/featured-insights/future-of-work")
.page_count(156));
// === MARKDOWN DOCUMENTS ===
print("Creating markdown documents...");
let md1 = save_markdown(new_markdown()
.title("OurWorld Mission Statement")
.description("Our vision for a better world")
.content("# OurWorld Mission\n\n## Vision\nTo create a more sustainable, equitable, and connected world through technology and collaboration.\n\n## Values\n- **Sustainability**: Every decision considers environmental impact\n- **Inclusivity**: Technology that serves everyone\n- **Transparency**: Open source and open governance\n- **Innovation**: Pushing boundaries for positive change\n\n## Goals\n1. Reduce global carbon footprint by 50% by 2030\n2. Provide internet access to 1 billion underserved people\n3. Create 10 million green jobs worldwide\n4. Establish 1000 sustainable communities"));
let md2 = save_markdown(new_markdown()
.title("Getting Started Guide")
.description("How to join the OurWorld movement")
.content("# Getting Started with OurWorld\n\n## Welcome!\nThank you for joining our mission to create a better world.\n\n## First Steps\n1. **Explore**: Browse our projects and initiatives\n2. **Connect**: Join our community forums\n3. **Contribute**: Find ways to get involved\n4. **Learn**: Access our educational resources\n\n## Ways to Contribute\n- **Developers**: Contribute to open source projects\n- **Activists**: Organize local initiatives\n- **Educators**: Share knowledge and skills\n- **Investors**: Support sustainable ventures\n\n## Resources\n- [Community Forum](https://forum.ourworld.tf)\n- [Developer Portal](https://dev.ourworld.tf)\n- [Learning Hub](https://learn.ourworld.tf)"));
let md3 = save_markdown(new_markdown()
.title("Technology Roadmap 2024")
.description("Our technical development plans")
.content("# Technology Roadmap 2024\n\n## Q1 Objectives\n- Launch decentralized identity system\n- Deploy carbon tracking blockchain\n- Release mobile app v2.0\n\n## Q2 Objectives\n- Implement AI-powered resource optimization\n- Launch peer-to-peer energy trading platform\n- Deploy IoT sensor network\n\n## Q3 Objectives\n- Release virtual collaboration spaces\n- Launch digital twin cities pilot\n- Implement quantum-safe encryption\n\n## Q4 Objectives\n- Deploy autonomous governance systems\n- Launch global impact measurement platform\n- Release AR/VR sustainability training"));
let md4 = save_markdown(new_markdown()
.title("Community Guidelines")
.description("How we work together")
.content("# Community Guidelines\n\n## Our Principles\n- **Respect**: Treat everyone with dignity\n- **Collaboration**: Work together towards common goals\n- **Constructive**: Focus on solutions, not problems\n- **Inclusive**: Welcome diverse perspectives\n\n## Communication Standards\n- Use clear, respectful language\n- Listen actively to others\n- Provide constructive feedback\n- Share knowledge freely\n\n## Conflict Resolution\n1. Address issues directly and respectfully\n2. Seek to understand different viewpoints\n3. Involve mediators when needed\n4. Focus on solutions that benefit everyone"));
let investor = new_contact()
.name("Example Investor")
.save_contact();
let investors = new_group()
.name("Investors")
.description("A group for example inverstors of ourworld");
investors.add_contact(investor.id)
.save_group();
// === BOOKS ===
print("Creating books...");
let sustainability_book = save_book(new_book()
.title("Sustainability Handbook")
.description("Complete guide to sustainable living and practices")
.add_page("# Introduction to Sustainability\n\nSustainability is about meeting our present needs without compromising the ability of future generations to meet their own needs.\n\n## Key Principles\n- Environmental stewardship\n- Social equity\n- Economic viability\n\n## Why It Matters\nOur planet faces unprecedented challenges from climate change, resource depletion, and environmental degradation.")
.add_page("# Energy Efficiency\n\n## Home Energy Savings\n- LED lighting reduces energy consumption by 75%\n- Smart thermostats can save 10-15% on heating/cooling\n- Energy-efficient appliances make a significant difference\n\n## Renewable Energy\n- Solar panels: Clean electricity from sunlight\n- Wind power: Harnessing natural wind currents\n- Hydroelectric: Using water flow for energy\n\n## Transportation\n- Electric vehicles reduce emissions\n- Public transit decreases individual carbon footprint\n- Cycling and walking for short distances")
.add_page("# Waste Reduction\n\n## The 5 R's\n1. **Refuse**: Say no to unnecessary items\n2. **Reduce**: Use less of what you need\n3. **Reuse**: Find new purposes for items\n4. **Recycle**: Process materials into new products\n5. **Rot**: Compost organic waste\n\n## Practical Tips\n- Use reusable bags and containers\n- Buy products with minimal packaging\n- Repair instead of replacing\n- Donate items you no longer need")
.add_page("# Sustainable Food\n\n## Local and Seasonal\n- Support local farmers and reduce transport emissions\n- Eat seasonal produce for better nutrition and taste\n- Visit farmers markets and join CSAs\n\n## Plant-Based Options\n- Reduce meat consumption for environmental benefits\n- Explore diverse plant proteins\n- Grow your own herbs and vegetables\n\n## Food Waste Prevention\n- Plan meals and make shopping lists\n- Store food properly to extend freshness\n- Use leftovers creatively")
.add_toc_entry(new_toc_entry().title("Introduction to Sustainability").page(0))
.add_toc_entry(new_toc_entry().title("Energy Efficiency").page(1))
.add_toc_entry(new_toc_entry().title("Waste Reduction").page(2))
.add_toc_entry(new_toc_entry().title("Sustainable Food").page(3)));
let tech_guide_book = save_book(new_book()
.title("Green Technology Guide")
.description("Understanding and implementing green technologies")
.add_page("# Green Technology Overview\n\nGreen technology, also known as clean technology, refers to the use of science and technology to create products and services that are environmentally friendly.\n\n## Categories\n- Renewable energy systems\n- Energy efficiency technologies\n- Pollution prevention and cleanup\n- Sustainable materials and manufacturing\n\n## Benefits\n- Reduced environmental impact\n- Lower operating costs\n- Improved public health\n- Economic opportunities")
.add_page("# Solar Technology\n\n## How Solar Works\nSolar panels convert sunlight directly into electricity using photovoltaic cells.\n\n## Types of Solar Systems\n- **Grid-tied**: Connected to the electrical grid\n- **Off-grid**: Standalone systems with battery storage\n- **Hybrid**: Combination of grid-tied and battery backup\n\n## Installation Considerations\n- Roof orientation and shading\n- Local climate and sun exposure\n- Energy consumption patterns\n- Available incentives and rebates")
.add_page("# Smart Home Technology\n\n## Automation Benefits\n- Optimized energy usage\n- Enhanced comfort and convenience\n- Remote monitoring and control\n- Predictive maintenance\n\n## Key Technologies\n- Smart thermostats\n- Automated lighting systems\n- Energy monitoring devices\n- Smart appliances\n- Home energy management systems")
.add_toc_entry(new_toc_entry().title("Green Technology Overview").page(0))
.add_toc_entry(new_toc_entry().title("Solar Technology").page(1))
.add_toc_entry(new_toc_entry().title("Smart Home Technology").page(2)));
let community_book = save_book(new_book()
.title("Building Communities")
.description("Guide to creating sustainable and inclusive communities")
.add_page("# Community Building Fundamentals\n\n## What Makes a Strong Community?\n- Shared values and vision\n- Open communication channels\n- Mutual support and cooperation\n- Inclusive decision-making processes\n\n## Benefits of Strong Communities\n- Enhanced quality of life\n- Economic resilience\n- Social cohesion\n- Environmental stewardship")
.add_page("# Governance and Leadership\n\n## Collaborative Leadership\n- Distributed decision-making\n- Transparent processes\n- Accountability mechanisms\n- Conflict resolution systems\n\n## Community Engagement\n- Regular town halls and meetings\n- Digital participation platforms\n- Volunteer coordination\n- Feedback and improvement cycles")
.add_toc_entry(new_toc_entry().title("Community Building Fundamentals").page(0))
.add_toc_entry(new_toc_entry().title("Governance and Leadership").page(1)));
// === SLIDES ===
print("Creating slides...");
let climate_slides = save_slides(new_slides()
.title("Climate Change Awareness")
.description("Visual presentation on climate change impacts and solutions")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1569163139394-de4e4f43e4e3?w=1200").title("Global Temperature Rise"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1578662996442-48f60103fc96?w=1200").title("Melting Ice Caps"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1200").title("Extreme Weather Events"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=1200").title("Renewable Energy Solutions"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1497436072909-f5e4be1dffea?w=1200").title("Sustainable Transportation")));
let innovation_slides = save_slides(new_slides()
.title("Innovation Showcase")
.description("Cutting-edge technologies for a sustainable future")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=1200").title("AI and Machine Learning"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1639322537228-f710d846310a?w=1200").title("Blockchain Technology"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092160562-40aa08e78837?w=1200").title("IoT and Smart Cities"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?w=1200").title("Quantum Computing"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092162384-8987c1d64718?w=1200").title("Biotechnology Advances")));
let nature_slides = save_slides(new_slides()
.title("Biodiversity Gallery")
.description("Celebrating Earth's incredible biodiversity")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1564349683136-77e08dba1ef7?w=1200").title("Tropical Rainforest"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1559827260-dc66d52bef19?w=1200").title("Coral Reef Ecosystem"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1551698618-1dfe5d97d256?w=1200").title("Arctic Wildlife"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200").title("Mountain Ecosystems")));
// === COLLECTIONS ===
print("Creating collections...");
let nature_collection = save_collection(new_collection()
.title("Nature & Environment")
.description("Beautiful images and resources about our natural world")
.add_image(nature1.id)
.add_image(nature2.id)
.add_image(nature3.id)
.add_pdf(pdf1.id)
.add_markdown(md1.id)
.add_book(sustainability_book.id)
.add_slides(nature_slides.id));
let technology_collection = save_collection(new_collection()
.title("Sustainable Technology")
.description("Innovations driving positive change")
.add_image(tech1.id)
.add_image(tech2.id)
.add_pdf(pdf3.id)
.add_pdf(pdf4.id)
.add_markdown(md3.id)
.add_book(tech_guide_book.id)
.add_slides(innovation_slides.id));
let space_collection = save_collection(new_collection()
.title("Space & Cosmos")
.description("Exploring the universe and our place in it")
.add_image(space1.id)
.add_image(space2.id)
.add_pdf(pdf2.id)
.add_markdown(md2.id));
let community_collection = save_collection(new_collection()
.title("Community & Collaboration")
.description("Building better communities together")
.add_image(city1.id)
.add_pdf(pdf5.id)
.add_markdown(md4.id)
.add_book(community_book.id));
let climate_collection = save_collection(new_collection()
.title("Climate Action")
.description("Understanding and addressing climate change")
.add_slides(climate_slides.id)
.add_pdf(pdf1.id)
.add_markdown(md1.id));
print("✅ OurWorld library created successfully!");
print("📚 Collections: 5");
print("🖼️ Images: 8");
print("📄 PDFs: 5");
print("📝 Markdown docs: 4");
print("📖 Books: 3");
print("🎞️ Slide shows: 3");

View File

@@ -1,15 +0,0 @@
// OurWorld Circle and Library Data
new_circle()
.title("Kristof de Spiegeleer")
.description("Creating a better world.")
.ws_url("ws://localhost:9101/ws")
.add_circle("ws://localhost:9000/ws")
.add_circle("ws://localhost:9001/ws")
.add_circle("ws://localhost:9002/ws")
.add_circle("ws://localhost:9003/ws")
.add_circle("ws://localhost:9004/ws")
.add_circle("ws://localhost:9005/ws")
.add_circle("ws://localhost:8096/ws")
.logo("🌍")
.save_circle();

View File

@@ -1,249 +0,0 @@
// OurWorld Circle and Library Data
new_circle()
.title("Mbweni Ruins & Gardens")
.description("Mbweni ruins and Gardens")
.ws_url("ws://localhost:8094/ws")
.logo("🌍")
.save_circle();
let circle = get_circle();
print("--- Creating OurWorld Library ---");
// === IMAGES ===
print("Creating images...");
let nature1 = save_image(new_image()
.title("Mountain Sunrise")
.description("Breathtaking sunrise over mountain peaks")
.url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800")
.width(800).height(600));
let nature2 = save_image(new_image()
.title("Ocean Waves")
.description("Powerful ocean waves crashing on rocks")
.url("https://images.unsplash.com/photo-1505142468610-359e7d316be0?w=800")
.width(800).height(600));
let nature3 = save_image(new_image()
.title("Forest Path")
.description("Peaceful path through ancient forest")
.url("https://images.unsplash.com/photo-1441974231531-c6227db76b6e?w=800")
.width(800).height(600));
let tech1 = save_image(new_image()
.title("Solar Panels")
.description("Modern solar panel installation")
.url("https://images.unsplash.com/photo-1509391366360-2e959784a276?w=800")
.width(800).height(600));
let tech2 = save_image(new_image()
.title("Wind Turbines")
.description("Wind turbines generating clean energy")
.url("https://images.unsplash.com/photo-1466611653911-95081537e5b7?w=800")
.width(800).height(600));
let space1 = save_image(new_image()
.title("Earth from Space")
.description("Our beautiful planet from orbit")
.url("https://images.unsplash.com/photo-1446776877081-d282a0f896e2?w=800")
.width(800).height(600));
let space2 = save_image(new_image()
.title("Galaxy Spiral")
.description("Stunning spiral galaxy in deep space")
.url("https://images.unsplash.com/photo-1502134249126-9f3755a50d78?w=800")
.width(800).height(600));
let city1 = save_image(new_image()
.title("Smart City")
.description("Futuristic smart city at night")
.url("https://images.unsplash.com/photo-1480714378408-67cf0d13bc1f?w=800")
.width(800).height(600));
// === PDFs ===
print("Creating PDFs...");
let pdf1 = save_pdf(new_pdf()
.title("Climate Action Report 2024")
.description("Comprehensive analysis of global climate initiatives")
.url("https://www.ipcc.ch/site/assets/uploads/2018/02/ipcc_wg3_ar5_summary-for-policymakers.pdf")
.page_count(42));
let pdf2 = save_pdf(new_pdf()
.title("Sustainable Development Goals")
.description("UN SDG implementation guide")
.url("https://sdgs.un.org/sites/default/files/publications/21252030%20Agenda%20for%20Sustainable%20Development%20web.pdf")
.page_count(35));
let pdf3 = save_pdf(new_pdf()
.title("Renewable Energy Handbook")
.description("Technical guide to renewable energy systems")
.url("https://www.irena.org/-/media/Files/IRENA/Agency/Publication/2019/Oct/IRENA_Renewable-Energy-Statistics-2019.pdf")
.page_count(280));
let pdf4 = save_pdf(new_pdf()
.title("Blockchain for Good")
.description("How blockchain technology can solve global challenges")
.url("https://www.weforum.org/whitepapers/blockchain-beyond-the-hype")
.page_count(24));
let pdf5 = save_pdf(new_pdf()
.title("Future of Work Report")
.description("Analysis of changing work patterns and remote collaboration")
.url("https://www.mckinsey.com/featured-insights/future-of-work")
.page_count(156));
// === MARKDOWN DOCUMENTS ===
print("Creating markdown documents...");
let md1 = save_markdown(new_markdown()
.title("OurWorld Mission Statement")
.description("Our vision for a better world")
.content("# OurWorld Mission\n\n## Vision\nTo create a more sustainable, equitable, and connected world through technology and collaboration.\n\n## Values\n- **Sustainability**: Every decision considers environmental impact\n- **Inclusivity**: Technology that serves everyone\n- **Transparency**: Open source and open governance\n- **Innovation**: Pushing boundaries for positive change\n\n## Goals\n1. Reduce global carbon footprint by 50% by 2030\n2. Provide internet access to 1 billion underserved people\n3. Create 10 million green jobs worldwide\n4. Establish 1000 sustainable communities"));
let md2 = save_markdown(new_markdown()
.title("Getting Started Guide")
.description("How to join the OurWorld movement")
.content("# Getting Started with OurWorld\n\n## Welcome!\nThank you for joining our mission to create a better world.\n\n## First Steps\n1. **Explore**: Browse our projects and initiatives\n2. **Connect**: Join our community forums\n3. **Contribute**: Find ways to get involved\n4. **Learn**: Access our educational resources\n\n## Ways to Contribute\n- **Developers**: Contribute to open source projects\n- **Activists**: Organize local initiatives\n- **Educators**: Share knowledge and skills\n- **Investors**: Support sustainable ventures\n\n## Resources\n- [Community Forum](https://forum.ourworld.tf)\n- [Developer Portal](https://dev.ourworld.tf)\n- [Learning Hub](https://learn.ourworld.tf)"));
let md3 = save_markdown(new_markdown()
.title("Technology Roadmap 2024")
.description("Our technical development plans")
.content("# Technology Roadmap 2024\n\n## Q1 Objectives\n- Launch decentralized identity system\n- Deploy carbon tracking blockchain\n- Release mobile app v2.0\n\n## Q2 Objectives\n- Implement AI-powered resource optimization\n- Launch peer-to-peer energy trading platform\n- Deploy IoT sensor network\n\n## Q3 Objectives\n- Release virtual collaboration spaces\n- Launch digital twin cities pilot\n- Implement quantum-safe encryption\n\n## Q4 Objectives\n- Deploy autonomous governance systems\n- Launch global impact measurement platform\n- Release AR/VR sustainability training"));
let md4 = save_markdown(new_markdown()
.title("Community Guidelines")
.description("How we work together")
.content("# Community Guidelines\n\n## Our Principles\n- **Respect**: Treat everyone with dignity\n- **Collaboration**: Work together towards common goals\n- **Constructive**: Focus on solutions, not problems\n- **Inclusive**: Welcome diverse perspectives\n\n## Communication Standards\n- Use clear, respectful language\n- Listen actively to others\n- Provide constructive feedback\n- Share knowledge freely\n\n## Conflict Resolution\n1. Address issues directly and respectfully\n2. Seek to understand different viewpoints\n3. Involve mediators when needed\n4. Focus on solutions that benefit everyone"));
let investor = new_contact()
.name("Example Investor")
.save_contact();
let investors = new_group()
.name("Investors")
.description("A group for example inverstors of ourworld");
investors.add_contact(investor.id)
.save_group();
// === BOOKS ===
print("Creating books...");
let sustainability_book = save_book(new_book()
.title("Sustainability Handbook")
.description("Complete guide to sustainable living and practices")
.add_page("# Introduction to Sustainability\n\nSustainability is about meeting our present needs without compromising the ability of future generations to meet their own needs.\n\n## Key Principles\n- Environmental stewardship\n- Social equity\n- Economic viability\n\n## Why It Matters\nOur planet faces unprecedented challenges from climate change, resource depletion, and environmental degradation.")
.add_page("# Energy Efficiency\n\n## Home Energy Savings\n- LED lighting reduces energy consumption by 75%\n- Smart thermostats can save 10-15% on heating/cooling\n- Energy-efficient appliances make a significant difference\n\n## Renewable Energy\n- Solar panels: Clean electricity from sunlight\n- Wind power: Harnessing natural wind currents\n- Hydroelectric: Using water flow for energy\n\n## Transportation\n- Electric vehicles reduce emissions\n- Public transit decreases individual carbon footprint\n- Cycling and walking for short distances")
.add_page("# Waste Reduction\n\n## The 5 R's\n1. **Refuse**: Say no to unnecessary items\n2. **Reduce**: Use less of what you need\n3. **Reuse**: Find new purposes for items\n4. **Recycle**: Process materials into new products\n5. **Rot**: Compost organic waste\n\n## Practical Tips\n- Use reusable bags and containers\n- Buy products with minimal packaging\n- Repair instead of replacing\n- Donate items you no longer need")
.add_page("# Sustainable Food\n\n## Local and Seasonal\n- Support local farmers and reduce transport emissions\n- Eat seasonal produce for better nutrition and taste\n- Visit farmers markets and join CSAs\n\n## Plant-Based Options\n- Reduce meat consumption for environmental benefits\n- Explore diverse plant proteins\n- Grow your own herbs and vegetables\n\n## Food Waste Prevention\n- Plan meals and make shopping lists\n- Store food properly to extend freshness\n- Use leftovers creatively")
.add_toc_entry(new_toc_entry().title("Introduction to Sustainability").page(0))
.add_toc_entry(new_toc_entry().title("Energy Efficiency").page(1))
.add_toc_entry(new_toc_entry().title("Waste Reduction").page(2))
.add_toc_entry(new_toc_entry().title("Sustainable Food").page(3)));
let tech_guide_book = save_book(new_book()
.title("Green Technology Guide")
.description("Understanding and implementing green technologies")
.add_page("# Green Technology Overview\n\nGreen technology, also known as clean technology, refers to the use of science and technology to create products and services that are environmentally friendly.\n\n## Categories\n- Renewable energy systems\n- Energy efficiency technologies\n- Pollution prevention and cleanup\n- Sustainable materials and manufacturing\n\n## Benefits\n- Reduced environmental impact\n- Lower operating costs\n- Improved public health\n- Economic opportunities")
.add_page("# Solar Technology\n\n## How Solar Works\nSolar panels convert sunlight directly into electricity using photovoltaic cells.\n\n## Types of Solar Systems\n- **Grid-tied**: Connected to the electrical grid\n- **Off-grid**: Standalone systems with battery storage\n- **Hybrid**: Combination of grid-tied and battery backup\n\n## Installation Considerations\n- Roof orientation and shading\n- Local climate and sun exposure\n- Energy consumption patterns\n- Available incentives and rebates")
.add_page("# Smart Home Technology\n\n## Automation Benefits\n- Optimized energy usage\n- Enhanced comfort and convenience\n- Remote monitoring and control\n- Predictive maintenance\n\n## Key Technologies\n- Smart thermostats\n- Automated lighting systems\n- Energy monitoring devices\n- Smart appliances\n- Home energy management systems")
.add_toc_entry(new_toc_entry().title("Green Technology Overview").page(0))
.add_toc_entry(new_toc_entry().title("Solar Technology").page(1))
.add_toc_entry(new_toc_entry().title("Smart Home Technology").page(2)));
let community_book = save_book(new_book()
.title("Building Communities")
.description("Guide to creating sustainable and inclusive communities")
.add_page("# Community Building Fundamentals\n\n## What Makes a Strong Community?\n- Shared values and vision\n- Open communication channels\n- Mutual support and cooperation\n- Inclusive decision-making processes\n\n## Benefits of Strong Communities\n- Enhanced quality of life\n- Economic resilience\n- Social cohesion\n- Environmental stewardship")
.add_page("# Governance and Leadership\n\n## Collaborative Leadership\n- Distributed decision-making\n- Transparent processes\n- Accountability mechanisms\n- Conflict resolution systems\n\n## Community Engagement\n- Regular town halls and meetings\n- Digital participation platforms\n- Volunteer coordination\n- Feedback and improvement cycles")
.add_toc_entry(new_toc_entry().title("Community Building Fundamentals").page(0))
.add_toc_entry(new_toc_entry().title("Governance and Leadership").page(1)));
// === SLIDES ===
print("Creating slides...");
let climate_slides = save_slides(new_slides()
.title("Climate Change Awareness")
.description("Visual presentation on climate change impacts and solutions")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1569163139394-de4e4f43e4e3?w=1200").title("Global Temperature Rise"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1578662996442-48f60103fc96?w=1200").title("Melting Ice Caps"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1200").title("Extreme Weather Events"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=1200").title("Renewable Energy Solutions"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1497436072909-f5e4be1dffea?w=1200").title("Sustainable Transportation")));
let innovation_slides = save_slides(new_slides()
.title("Innovation Showcase")
.description("Cutting-edge technologies for a sustainable future")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=1200").title("AI and Machine Learning"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1639322537228-f710d846310a?w=1200").title("Blockchain Technology"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092160562-40aa08e78837?w=1200").title("IoT and Smart Cities"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?w=1200").title("Quantum Computing"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092162384-8987c1d64718?w=1200").title("Biotechnology Advances")));
let nature_slides = save_slides(new_slides()
.title("Biodiversity Gallery")
.description("Celebrating Earth's incredible biodiversity")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1564349683136-77e08dba1ef7?w=1200").title("Tropical Rainforest"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1559827260-dc66d52bef19?w=1200").title("Coral Reef Ecosystem"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1551698618-1dfe5d97d256?w=1200").title("Arctic Wildlife"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200").title("Mountain Ecosystems")));
// === COLLECTIONS ===
print("Creating collections...");
let nature_collection = save_collection(new_collection()
.title("Nature & Environment")
.description("Beautiful images and resources about our natural world")
.add_image(nature1.id)
.add_image(nature2.id)
.add_image(nature3.id)
.add_pdf(pdf1.id)
.add_markdown(md1.id)
.add_book(sustainability_book.id)
.add_slides(nature_slides.id));
let technology_collection = save_collection(new_collection()
.title("Sustainable Technology")
.description("Innovations driving positive change")
.add_image(tech1.id)
.add_image(tech2.id)
.add_pdf(pdf3.id)
.add_pdf(pdf4.id)
.add_markdown(md3.id)
.add_book(tech_guide_book.id)
.add_slides(innovation_slides.id));
let space_collection = save_collection(new_collection()
.title("Space & Cosmos")
.description("Exploring the universe and our place in it")
.add_image(space1.id)
.add_image(space2.id)
.add_pdf(pdf2.id)
.add_markdown(md2.id));
let community_collection = save_collection(new_collection()
.title("Community & Collaboration")
.description("Building better communities together")
.add_image(city1.id)
.add_pdf(pdf5.id)
.add_markdown(md4.id)
.add_book(community_book.id));
let climate_collection = save_collection(new_collection()
.title("Climate Action")
.description("Understanding and addressing climate change")
.add_slides(climate_slides.id)
.add_pdf(pdf1.id)
.add_markdown(md1.id));
print("✅ OurWorld library created successfully!");
print("📚 Collections: 5");
print("🖼️ Images: 8");
print("📄 PDFs: 5");
print("📝 Markdown docs: 4");
print("📖 Books: 3");
print("🎞️ Slide shows: 3");

View File

@@ -1,257 +0,0 @@
// OurWorld Circle and Library Data
new_circle()
.title("Ourworld")
.description("Creating a better world.")
.ws_url("ws://localhost:9000/ws")
.add_circle("ws://localhost:9001/ws")
.add_circle("ws://localhost:9002/ws")
.add_circle("ws://localhost:9003/ws")
.add_circle("ws://localhost:9004/ws")
.add_circle("ws://localhost:9005/ws")
.add_circle("ws://localhost:8096/ws")
.add_member("023b0a9d409506f41f5782353857dea6abc16ae4643661cd94d8155fdb498642e3")
.add_member("030b62236efa67855b3379a9d4add1facbe8a545bafa86e1d6fbac06caae5b5b12")
.logo("🌍")
.save_circle();
let circle = get_circle();
print("--- Creating OurWorld Library ---");
// === IMAGES ===
print("Creating images...");
let nature1 = save_image(new_image()
.title("Mountain Sunrise")
.description("Breathtaking sunrise over mountain peaks")
.url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800")
.width(800).height(600));
let nature2 = save_image(new_image()
.title("Ocean Waves")
.description("Powerful ocean waves crashing on rocks")
.url("https://images.unsplash.com/photo-1505142468610-359e7d316be0?w=800")
.width(800).height(600));
let nature3 = save_image(new_image()
.title("Forest Path")
.description("Peaceful path through ancient forest")
.url("https://images.unsplash.com/photo-1441974231531-c6227db76b6e?w=800")
.width(800).height(600));
let tech1 = save_image(new_image()
.title("Solar Panels")
.description("Modern solar panel installation")
.url("https://images.unsplash.com/photo-1509391366360-2e959784a276?w=800")
.width(800).height(600));
let tech2 = save_image(new_image()
.title("Wind Turbines")
.description("Wind turbines generating clean energy")
.url("https://images.unsplash.com/photo-1466611653911-95081537e5b7?w=800")
.width(800).height(600));
let space1 = save_image(new_image()
.title("Earth from Space")
.description("Our beautiful planet from orbit")
.url("https://images.unsplash.com/photo-1446776877081-d282a0f896e2?w=800")
.width(800).height(600));
let space2 = save_image(new_image()
.title("Galaxy Spiral")
.description("Stunning spiral galaxy in deep space")
.url("https://images.unsplash.com/photo-1502134249126-9f3755a50d78?w=800")
.width(800).height(600));
let city1 = save_image(new_image()
.title("Smart City")
.description("Futuristic smart city at night")
.url("https://images.unsplash.com/photo-1480714378408-67cf0d13bc1f?w=800")
.width(800).height(600));
// === PDFs ===
print("Creating PDFs...");
let pdf1 = save_pdf(new_pdf()
.title("Climate Action Report 2024")
.description("Comprehensive analysis of global climate initiatives")
.url("https://www.ipcc.ch/site/assets/uploads/2018/02/ipcc_wg3_ar5_summary-for-policymakers.pdf")
.page_count(42));
let pdf2 = save_pdf(new_pdf()
.title("Sustainable Development Goals")
.description("UN SDG implementation guide")
.url("https://sdgs.un.org/sites/default/files/publications/21252030%20Agenda%20for%20Sustainable%20Development%20web.pdf")
.page_count(35));
let pdf3 = save_pdf(new_pdf()
.title("Renewable Energy Handbook")
.description("Technical guide to renewable energy systems")
.url("https://www.irena.org/-/media/Files/IRENA/Agency/Publication/2019/Oct/IRENA_Renewable-Energy-Statistics-2019.pdf")
.page_count(280));
let pdf4 = save_pdf(new_pdf()
.title("Blockchain for Good")
.description("How blockchain technology can solve global challenges")
.url("https://www.weforum.org/whitepapers/blockchain-beyond-the-hype")
.page_count(24));
let pdf5 = save_pdf(new_pdf()
.title("Future of Work Report")
.description("Analysis of changing work patterns and remote collaboration")
.url("https://www.mckinsey.com/featured-insights/future-of-work")
.page_count(156));
// === MARKDOWN DOCUMENTS ===
print("Creating markdown documents...");
let md1 = save_markdown(new_markdown()
.title("OurWorld Mission Statement")
.description("Our vision for a better world")
.content("# OurWorld Mission\n\n## Vision\nTo create a more sustainable, equitable, and connected world through technology and collaboration.\n\n## Values\n- **Sustainability**: Every decision considers environmental impact\n- **Inclusivity**: Technology that serves everyone\n- **Transparency**: Open source and open governance\n- **Innovation**: Pushing boundaries for positive change\n\n## Goals\n1. Reduce global carbon footprint by 50% by 2030\n2. Provide internet access to 1 billion underserved people\n3. Create 10 million green jobs worldwide\n4. Establish 1000 sustainable communities"));
let md2 = save_markdown(new_markdown()
.title("Getting Started Guide")
.description("How to join the OurWorld movement")
.content("# Getting Started with OurWorld\n\n## Welcome!\nThank you for joining our mission to create a better world.\n\n## First Steps\n1. **Explore**: Browse our projects and initiatives\n2. **Connect**: Join our community forums\n3. **Contribute**: Find ways to get involved\n4. **Learn**: Access our educational resources\n\n## Ways to Contribute\n- **Developers**: Contribute to open source projects\n- **Activists**: Organize local initiatives\n- **Educators**: Share knowledge and skills\n- **Investors**: Support sustainable ventures\n\n## Resources\n- [Community Forum](https://forum.ourworld.tf)\n- [Developer Portal](https://dev.ourworld.tf)\n- [Learning Hub](https://learn.ourworld.tf)"));
let md3 = save_markdown(new_markdown()
.title("Technology Roadmap 2024")
.description("Our technical development plans")
.content("# Technology Roadmap 2024\n\n## Q1 Objectives\n- Launch decentralized identity system\n- Deploy carbon tracking blockchain\n- Release mobile app v2.0\n\n## Q2 Objectives\n- Implement AI-powered resource optimization\n- Launch peer-to-peer energy trading platform\n- Deploy IoT sensor network\n\n## Q3 Objectives\n- Release virtual collaboration spaces\n- Launch digital twin cities pilot\n- Implement quantum-safe encryption\n\n## Q4 Objectives\n- Deploy autonomous governance systems\n- Launch global impact measurement platform\n- Release AR/VR sustainability training"));
let md4 = save_markdown(new_markdown()
.title("Community Guidelines")
.description("How we work together")
.content("# Community Guidelines\n\n## Our Principles\n- **Respect**: Treat everyone with dignity\n- **Collaboration**: Work together towards common goals\n- **Constructive**: Focus on solutions, not problems\n- **Inclusive**: Welcome diverse perspectives\n\n## Communication Standards\n- Use clear, respectful language\n- Listen actively to others\n- Provide constructive feedback\n- Share knowledge freely\n\n## Conflict Resolution\n1. Address issues directly and respectfully\n2. Seek to understand different viewpoints\n3. Involve mediators when needed\n4. Focus on solutions that benefit everyone"));
let investor = new_contact()
.name("Example Investor")
.save_contact();
let investors = new_group()
.name("Investors")
.description("A group for example inverstors of ourworld");
investors.add_contact(investor.id)
.save_group();
// === BOOKS ===
print("Creating books...");
let sustainability_book = save_book(new_book()
.title("Sustainability Handbook")
.description("Complete guide to sustainable living and practices")
.add_page("# Introduction to Sustainability\n\nSustainability is about meeting our present needs without compromising the ability of future generations to meet their own needs.\n\n## Key Principles\n- Environmental stewardship\n- Social equity\n- Economic viability\n\n## Why It Matters\nOur planet faces unprecedented challenges from climate change, resource depletion, and environmental degradation.")
.add_page("# Energy Efficiency\n\n## Home Energy Savings\n- LED lighting reduces energy consumption by 75%\n- Smart thermostats can save 10-15% on heating/cooling\n- Energy-efficient appliances make a significant difference\n\n## Renewable Energy\n- Solar panels: Clean electricity from sunlight\n- Wind power: Harnessing natural wind currents\n- Hydroelectric: Using water flow for energy\n\n## Transportation\n- Electric vehicles reduce emissions\n- Public transit decreases individual carbon footprint\n- Cycling and walking for short distances")
.add_page("# Waste Reduction\n\n## The 5 R's\n1. **Refuse**: Say no to unnecessary items\n2. **Reduce**: Use less of what you need\n3. **Reuse**: Find new purposes for items\n4. **Recycle**: Process materials into new products\n5. **Rot**: Compost organic waste\n\n## Practical Tips\n- Use reusable bags and containers\n- Buy products with minimal packaging\n- Repair instead of replacing\n- Donate items you no longer need")
.add_page("# Sustainable Food\n\n## Local and Seasonal\n- Support local farmers and reduce transport emissions\n- Eat seasonal produce for better nutrition and taste\n- Visit farmers markets and join CSAs\n\n## Plant-Based Options\n- Reduce meat consumption for environmental benefits\n- Explore diverse plant proteins\n- Grow your own herbs and vegetables\n\n## Food Waste Prevention\n- Plan meals and make shopping lists\n- Store food properly to extend freshness\n- Use leftovers creatively")
.add_toc_entry(new_toc_entry().title("Introduction to Sustainability").page(0))
.add_toc_entry(new_toc_entry().title("Energy Efficiency").page(1))
.add_toc_entry(new_toc_entry().title("Waste Reduction").page(2))
.add_toc_entry(new_toc_entry().title("Sustainable Food").page(3)));
let tech_guide_book = save_book(new_book()
.title("Green Technology Guide")
.description("Understanding and implementing green technologies")
.add_page("# Green Technology Overview\n\nGreen technology, also known as clean technology, refers to the use of science and technology to create products and services that are environmentally friendly.\n\n## Categories\n- Renewable energy systems\n- Energy efficiency technologies\n- Pollution prevention and cleanup\n- Sustainable materials and manufacturing\n\n## Benefits\n- Reduced environmental impact\n- Lower operating costs\n- Improved public health\n- Economic opportunities")
.add_page("# Solar Technology\n\n## How Solar Works\nSolar panels convert sunlight directly into electricity using photovoltaic cells.\n\n## Types of Solar Systems\n- **Grid-tied**: Connected to the electrical grid\n- **Off-grid**: Standalone systems with battery storage\n- **Hybrid**: Combination of grid-tied and battery backup\n\n## Installation Considerations\n- Roof orientation and shading\n- Local climate and sun exposure\n- Energy consumption patterns\n- Available incentives and rebates")
.add_page("# Smart Home Technology\n\n## Automation Benefits\n- Optimized energy usage\n- Enhanced comfort and convenience\n- Remote monitoring and control\n- Predictive maintenance\n\n## Key Technologies\n- Smart thermostats\n- Automated lighting systems\n- Energy monitoring devices\n- Smart appliances\n- Home energy management systems")
.add_toc_entry(new_toc_entry().title("Green Technology Overview").page(0))
.add_toc_entry(new_toc_entry().title("Solar Technology").page(1))
.add_toc_entry(new_toc_entry().title("Smart Home Technology").page(2)));
let community_book = save_book(new_book()
.title("Building Communities")
.description("Guide to creating sustainable and inclusive communities")
.add_page("# Community Building Fundamentals\n\n## What Makes a Strong Community?\n- Shared values and vision\n- Open communication channels\n- Mutual support and cooperation\n- Inclusive decision-making processes\n\n## Benefits of Strong Communities\n- Enhanced quality of life\n- Economic resilience\n- Social cohesion\n- Environmental stewardship")
.add_page("# Governance and Leadership\n\n## Collaborative Leadership\n- Distributed decision-making\n- Transparent processes\n- Accountability mechanisms\n- Conflict resolution systems\n\n## Community Engagement\n- Regular town halls and meetings\n- Digital participation platforms\n- Volunteer coordination\n- Feedback and improvement cycles")
.add_toc_entry(new_toc_entry().title("Community Building Fundamentals").page(0))
.add_toc_entry(new_toc_entry().title("Governance and Leadership").page(1)));
// === SLIDES ===
print("Creating slides...");
let climate_slides = save_slides(new_slides()
.title("Climate Change Awareness")
.description("Visual presentation on climate change impacts and solutions")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1569163139394-de4e4f43e4e3?w=1200").title("Global Temperature Rise"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1578662996442-48f60103fc96?w=1200").title("Melting Ice Caps"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1200").title("Extreme Weather Events"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=1200").title("Renewable Energy Solutions"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1497436072909-f5e4be1dffea?w=1200").title("Sustainable Transportation")));
let innovation_slides = save_slides(new_slides()
.title("Innovation Showcase")
.description("Cutting-edge technologies for a sustainable future")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=1200").title("AI and Machine Learning"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1639322537228-f710d846310a?w=1200").title("Blockchain Technology"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092160562-40aa08e78837?w=1200").title("IoT and Smart Cities"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?w=1200").title("Quantum Computing"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092162384-8987c1d64718?w=1200").title("Biotechnology Advances")));
let nature_slides = save_slides(new_slides()
.title("Biodiversity Gallery")
.description("Celebrating Earth's incredible biodiversity")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1564349683136-77e08dba1ef7?w=1200").title("Tropical Rainforest"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1559827260-dc66d52bef19?w=1200").title("Coral Reef Ecosystem"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1551698618-1dfe5d97d256?w=1200").title("Arctic Wildlife"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200").title("Mountain Ecosystems")));
// === COLLECTIONS ===
print("Creating collections...");
let nature_collection = save_collection(new_collection()
.title("Nature & Environment")
.description("Beautiful images and resources about our natural world")
.add_image(nature1.id)
.add_image(nature2.id)
.add_image(nature3.id)
.add_pdf(pdf1.id)
.add_markdown(md1.id)
.add_book(sustainability_book.id)
.add_slides(nature_slides.id));
let technology_collection = save_collection(new_collection()
.title("Sustainable Technology")
.description("Innovations driving positive change")
.add_image(tech1.id)
.add_image(tech2.id)
.add_pdf(pdf3.id)
.add_pdf(pdf4.id)
.add_markdown(md3.id)
.add_book(tech_guide_book.id)
.add_slides(innovation_slides.id));
let space_collection = save_collection(new_collection()
.title("Space & Cosmos")
.description("Exploring the universe and our place in it")
.add_image(space1.id)
.add_image(space2.id)
.add_pdf(pdf2.id)
.add_markdown(md2.id));
let community_collection = save_collection(new_collection()
.title("Community & Collaboration")
.description("Building better communities together")
.add_image(city1.id)
.add_pdf(pdf5.id)
.add_markdown(md4.id)
.add_book(community_book.id));
let climate_collection = save_collection(new_collection()
.title("Climate Action")
.description("Understanding and addressing climate change")
.add_slides(climate_slides.id)
.add_pdf(pdf1.id)
.add_markdown(md1.id));
print("✅ OurWorld library created successfully!");
print("📚 Collections: 5");
print("🖼️ Images: 8");
print("📄 PDFs: 5");
print("📝 Markdown docs: 4");
print("📖 Books: 3");
print("🎞️ Slide shows: 3");

View File

@@ -1,249 +0,0 @@
// OurWorld Circle and Library Data
new_circle()
.title("Sikana")
.description("Creating a better world.")
.ws_url("ws://localhost:9002/ws")
.logo("🌍")
.save_circle();
let circle = get_circle();
print("--- Creating OurWorld Library ---");
// === IMAGES ===
print("Creating images...");
let nature1 = save_image(new_image()
.title("Mountain Sunrise")
.description("Breathtaking sunrise over mountain peaks")
.url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800")
.width(800).height(600));
let nature2 = save_image(new_image()
.title("Ocean Waves")
.description("Powerful ocean waves crashing on rocks")
.url("https://images.unsplash.com/photo-1505142468610-359e7d316be0?w=800")
.width(800).height(600));
let nature3 = save_image(new_image()
.title("Forest Path")
.description("Peaceful path through ancient forest")
.url("https://images.unsplash.com/photo-1441974231531-c6227db76b6e?w=800")
.width(800).height(600));
let tech1 = save_image(new_image()
.title("Solar Panels")
.description("Modern solar panel installation")
.url("https://images.unsplash.com/photo-1509391366360-2e959784a276?w=800")
.width(800).height(600));
let tech2 = save_image(new_image()
.title("Wind Turbines")
.description("Wind turbines generating clean energy")
.url("https://images.unsplash.com/photo-1466611653911-95081537e5b7?w=800")
.width(800).height(600));
let space1 = save_image(new_image()
.title("Earth from Space")
.description("Our beautiful planet from orbit")
.url("https://images.unsplash.com/photo-1446776877081-d282a0f896e2?w=800")
.width(800).height(600));
let space2 = save_image(new_image()
.title("Galaxy Spiral")
.description("Stunning spiral galaxy in deep space")
.url("https://images.unsplash.com/photo-1502134249126-9f3755a50d78?w=800")
.width(800).height(600));
let city1 = save_image(new_image()
.title("Smart City")
.description("Futuristic smart city at night")
.url("https://images.unsplash.com/photo-1480714378408-67cf0d13bc1f?w=800")
.width(800).height(600));
// === PDFs ===
print("Creating PDFs...");
let pdf1 = save_pdf(new_pdf()
.title("Climate Action Report 2024")
.description("Comprehensive analysis of global climate initiatives")
.url("https://www.ipcc.ch/site/assets/uploads/2018/02/ipcc_wg3_ar5_summary-for-policymakers.pdf")
.page_count(42));
let pdf2 = save_pdf(new_pdf()
.title("Sustainable Development Goals")
.description("UN SDG implementation guide")
.url("https://sdgs.un.org/sites/default/files/publications/21252030%20Agenda%20for%20Sustainable%20Development%20web.pdf")
.page_count(35));
let pdf3 = save_pdf(new_pdf()
.title("Renewable Energy Handbook")
.description("Technical guide to renewable energy systems")
.url("https://www.irena.org/-/media/Files/IRENA/Agency/Publication/2019/Oct/IRENA_Renewable-Energy-Statistics-2019.pdf")
.page_count(280));
let pdf4 = save_pdf(new_pdf()
.title("Blockchain for Good")
.description("How blockchain technology can solve global challenges")
.url("https://www.weforum.org/whitepapers/blockchain-beyond-the-hype")
.page_count(24));
let pdf5 = save_pdf(new_pdf()
.title("Future of Work Report")
.description("Analysis of changing work patterns and remote collaboration")
.url("https://www.mckinsey.com/featured-insights/future-of-work")
.page_count(156));
// === MARKDOWN DOCUMENTS ===
print("Creating markdown documents...");
let md1 = save_markdown(new_markdown()
.title("OurWorld Mission Statement")
.description("Our vision for a better world")
.content("# OurWorld Mission\n\n## Vision\nTo create a more sustainable, equitable, and connected world through technology and collaboration.\n\n## Values\n- **Sustainability**: Every decision considers environmental impact\n- **Inclusivity**: Technology that serves everyone\n- **Transparency**: Open source and open governance\n- **Innovation**: Pushing boundaries for positive change\n\n## Goals\n1. Reduce global carbon footprint by 50% by 2030\n2. Provide internet access to 1 billion underserved people\n3. Create 10 million green jobs worldwide\n4. Establish 1000 sustainable communities"));
let md2 = save_markdown(new_markdown()
.title("Getting Started Guide")
.description("How to join the OurWorld movement")
.content("# Getting Started with OurWorld\n\n## Welcome!\nThank you for joining our mission to create a better world.\n\n## First Steps\n1. **Explore**: Browse our projects and initiatives\n2. **Connect**: Join our community forums\n3. **Contribute**: Find ways to get involved\n4. **Learn**: Access our educational resources\n\n## Ways to Contribute\n- **Developers**: Contribute to open source projects\n- **Activists**: Organize local initiatives\n- **Educators**: Share knowledge and skills\n- **Investors**: Support sustainable ventures\n\n## Resources\n- [Community Forum](https://forum.ourworld.tf)\n- [Developer Portal](https://dev.ourworld.tf)\n- [Learning Hub](https://learn.ourworld.tf)"));
let md3 = save_markdown(new_markdown()
.title("Technology Roadmap 2024")
.description("Our technical development plans")
.content("# Technology Roadmap 2024\n\n## Q1 Objectives\n- Launch decentralized identity system\n- Deploy carbon tracking blockchain\n- Release mobile app v2.0\n\n## Q2 Objectives\n- Implement AI-powered resource optimization\n- Launch peer-to-peer energy trading platform\n- Deploy IoT sensor network\n\n## Q3 Objectives\n- Release virtual collaboration spaces\n- Launch digital twin cities pilot\n- Implement quantum-safe encryption\n\n## Q4 Objectives\n- Deploy autonomous governance systems\n- Launch global impact measurement platform\n- Release AR/VR sustainability training"));
let md4 = save_markdown(new_markdown()
.title("Community Guidelines")
.description("How we work together")
.content("# Community Guidelines\n\n## Our Principles\n- **Respect**: Treat everyone with dignity\n- **Collaboration**: Work together towards common goals\n- **Constructive**: Focus on solutions, not problems\n- **Inclusive**: Welcome diverse perspectives\n\n## Communication Standards\n- Use clear, respectful language\n- Listen actively to others\n- Provide constructive feedback\n- Share knowledge freely\n\n## Conflict Resolution\n1. Address issues directly and respectfully\n2. Seek to understand different viewpoints\n3. Involve mediators when needed\n4. Focus on solutions that benefit everyone"));
let investor = new_contact()
.name("Example Investor")
.save_contact();
let investors = new_group()
.name("Investors")
.description("A group for example inverstors of ourworld");
investors.add_contact(investor.id)
.save_group();
// === BOOKS ===
print("Creating books...");
let sustainability_book = save_book(new_book()
.title("Sustainability Handbook")
.description("Complete guide to sustainable living and practices")
.add_page("# Introduction to Sustainability\n\nSustainability is about meeting our present needs without compromising the ability of future generations to meet their own needs.\n\n## Key Principles\n- Environmental stewardship\n- Social equity\n- Economic viability\n\n## Why It Matters\nOur planet faces unprecedented challenges from climate change, resource depletion, and environmental degradation.")
.add_page("# Energy Efficiency\n\n## Home Energy Savings\n- LED lighting reduces energy consumption by 75%\n- Smart thermostats can save 10-15% on heating/cooling\n- Energy-efficient appliances make a significant difference\n\n## Renewable Energy\n- Solar panels: Clean electricity from sunlight\n- Wind power: Harnessing natural wind currents\n- Hydroelectric: Using water flow for energy\n\n## Transportation\n- Electric vehicles reduce emissions\n- Public transit decreases individual carbon footprint\n- Cycling and walking for short distances")
.add_page("# Waste Reduction\n\n## The 5 R's\n1. **Refuse**: Say no to unnecessary items\n2. **Reduce**: Use less of what you need\n3. **Reuse**: Find new purposes for items\n4. **Recycle**: Process materials into new products\n5. **Rot**: Compost organic waste\n\n## Practical Tips\n- Use reusable bags and containers\n- Buy products with minimal packaging\n- Repair instead of replacing\n- Donate items you no longer need")
.add_page("# Sustainable Food\n\n## Local and Seasonal\n- Support local farmers and reduce transport emissions\n- Eat seasonal produce for better nutrition and taste\n- Visit farmers markets and join CSAs\n\n## Plant-Based Options\n- Reduce meat consumption for environmental benefits\n- Explore diverse plant proteins\n- Grow your own herbs and vegetables\n\n## Food Waste Prevention\n- Plan meals and make shopping lists\n- Store food properly to extend freshness\n- Use leftovers creatively")
.add_toc_entry(new_toc_entry().title("Introduction to Sustainability").page(0))
.add_toc_entry(new_toc_entry().title("Energy Efficiency").page(1))
.add_toc_entry(new_toc_entry().title("Waste Reduction").page(2))
.add_toc_entry(new_toc_entry().title("Sustainable Food").page(3)));
let tech_guide_book = save_book(new_book()
.title("Green Technology Guide")
.description("Understanding and implementing green technologies")
.add_page("# Green Technology Overview\n\nGreen technology, also known as clean technology, refers to the use of science and technology to create products and services that are environmentally friendly.\n\n## Categories\n- Renewable energy systems\n- Energy efficiency technologies\n- Pollution prevention and cleanup\n- Sustainable materials and manufacturing\n\n## Benefits\n- Reduced environmental impact\n- Lower operating costs\n- Improved public health\n- Economic opportunities")
.add_page("# Solar Technology\n\n## How Solar Works\nSolar panels convert sunlight directly into electricity using photovoltaic cells.\n\n## Types of Solar Systems\n- **Grid-tied**: Connected to the electrical grid\n- **Off-grid**: Standalone systems with battery storage\n- **Hybrid**: Combination of grid-tied and battery backup\n\n## Installation Considerations\n- Roof orientation and shading\n- Local climate and sun exposure\n- Energy consumption patterns\n- Available incentives and rebates")
.add_page("# Smart Home Technology\n\n## Automation Benefits\n- Optimized energy usage\n- Enhanced comfort and convenience\n- Remote monitoring and control\n- Predictive maintenance\n\n## Key Technologies\n- Smart thermostats\n- Automated lighting systems\n- Energy monitoring devices\n- Smart appliances\n- Home energy management systems")
.add_toc_entry(new_toc_entry().title("Green Technology Overview").page(0))
.add_toc_entry(new_toc_entry().title("Solar Technology").page(1))
.add_toc_entry(new_toc_entry().title("Smart Home Technology").page(2)));
let community_book = save_book(new_book()
.title("Building Communities")
.description("Guide to creating sustainable and inclusive communities")
.add_page("# Community Building Fundamentals\n\n## What Makes a Strong Community?\n- Shared values and vision\n- Open communication channels\n- Mutual support and cooperation\n- Inclusive decision-making processes\n\n## Benefits of Strong Communities\n- Enhanced quality of life\n- Economic resilience\n- Social cohesion\n- Environmental stewardship")
.add_page("# Governance and Leadership\n\n## Collaborative Leadership\n- Distributed decision-making\n- Transparent processes\n- Accountability mechanisms\n- Conflict resolution systems\n\n## Community Engagement\n- Regular town halls and meetings\n- Digital participation platforms\n- Volunteer coordination\n- Feedback and improvement cycles")
.add_toc_entry(new_toc_entry().title("Community Building Fundamentals").page(0))
.add_toc_entry(new_toc_entry().title("Governance and Leadership").page(1)));
// === SLIDES ===
print("Creating slides...");
let climate_slides = save_slides(new_slides()
.title("Climate Change Awareness")
.description("Visual presentation on climate change impacts and solutions")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1569163139394-de4e4f43e4e3?w=1200").title("Global Temperature Rise"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1578662996442-48f60103fc96?w=1200").title("Melting Ice Caps"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1200").title("Extreme Weather Events"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=1200").title("Renewable Energy Solutions"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1497436072909-f5e4be1dffea?w=1200").title("Sustainable Transportation")));
let innovation_slides = save_slides(new_slides()
.title("Innovation Showcase")
.description("Cutting-edge technologies for a sustainable future")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=1200").title("AI and Machine Learning"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1639322537228-f710d846310a?w=1200").title("Blockchain Technology"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092160562-40aa08e78837?w=1200").title("IoT and Smart Cities"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?w=1200").title("Quantum Computing"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092162384-8987c1d64718?w=1200").title("Biotechnology Advances")));
let nature_slides = save_slides(new_slides()
.title("Biodiversity Gallery")
.description("Celebrating Earth's incredible biodiversity")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1564349683136-77e08dba1ef7?w=1200").title("Tropical Rainforest"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1559827260-dc66d52bef19?w=1200").title("Coral Reef Ecosystem"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1551698618-1dfe5d97d256?w=1200").title("Arctic Wildlife"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200").title("Mountain Ecosystems")));
// === COLLECTIONS ===
print("Creating collections...");
let nature_collection = save_collection(new_collection()
.title("Nature & Environment")
.description("Beautiful images and resources about our natural world")
.add_image(nature1.id)
.add_image(nature2.id)
.add_image(nature3.id)
.add_pdf(pdf1.id)
.add_markdown(md1.id)
.add_book(sustainability_book.id)
.add_slides(nature_slides.id));
let technology_collection = save_collection(new_collection()
.title("Sustainable Technology")
.description("Innovations driving positive change")
.add_image(tech1.id)
.add_image(tech2.id)
.add_pdf(pdf3.id)
.add_pdf(pdf4.id)
.add_markdown(md3.id)
.add_book(tech_guide_book.id)
.add_slides(innovation_slides.id));
let space_collection = save_collection(new_collection()
.title("Space & Cosmos")
.description("Exploring the universe and our place in it")
.add_image(space1.id)
.add_image(space2.id)
.add_pdf(pdf2.id)
.add_markdown(md2.id));
let community_collection = save_collection(new_collection()
.title("Community & Collaboration")
.description("Building better communities together")
.add_image(city1.id)
.add_pdf(pdf5.id)
.add_markdown(md4.id)
.add_book(community_book.id));
let climate_collection = save_collection(new_collection()
.title("Climate Action")
.description("Understanding and addressing climate change")
.add_slides(climate_slides.id)
.add_pdf(pdf1.id)
.add_markdown(md1.id));
print("✅ OurWorld library created successfully!");
print("📚 Collections: 5");
print("🖼️ Images: 8");
print("📄 PDFs: 5");
print("📝 Markdown docs: 4");
print("📖 Books: 3");
print("🎞️ Slide shows: 3");

View File

@@ -1,249 +0,0 @@
// OurWorld Circle and Library Data
new_circle()
.title("Threefold DMCC")
.description("Creating a better world.")
.ws_url("ws://localhost:8093/ws")
.logo("🌍")
.save_circle();
let circle = get_circle();
print("--- Creating OurWorld Library ---");
// === IMAGES ===
print("Creating images...");
let nature1 = save_image(new_image()
.title("Mountain Sunrise")
.description("Breathtaking sunrise over mountain peaks")
.url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800")
.width(800).height(600));
let nature2 = save_image(new_image()
.title("Ocean Waves")
.description("Powerful ocean waves crashing on rocks")
.url("https://images.unsplash.com/photo-1505142468610-359e7d316be0?w=800")
.width(800).height(600));
let nature3 = save_image(new_image()
.title("Forest Path")
.description("Peaceful path through ancient forest")
.url("https://images.unsplash.com/photo-1441974231531-c6227db76b6e?w=800")
.width(800).height(600));
let tech1 = save_image(new_image()
.title("Solar Panels")
.description("Modern solar panel installation")
.url("https://images.unsplash.com/photo-1509391366360-2e959784a276?w=800")
.width(800).height(600));
let tech2 = save_image(new_image()
.title("Wind Turbines")
.description("Wind turbines generating clean energy")
.url("https://images.unsplash.com/photo-1466611653911-95081537e5b7?w=800")
.width(800).height(600));
let space1 = save_image(new_image()
.title("Earth from Space")
.description("Our beautiful planet from orbit")
.url("https://images.unsplash.com/photo-1446776877081-d282a0f896e2?w=800")
.width(800).height(600));
let space2 = save_image(new_image()
.title("Galaxy Spiral")
.description("Stunning spiral galaxy in deep space")
.url("https://images.unsplash.com/photo-1502134249126-9f3755a50d78?w=800")
.width(800).height(600));
let city1 = save_image(new_image()
.title("Smart City")
.description("Futuristic smart city at night")
.url("https://images.unsplash.com/photo-1480714378408-67cf0d13bc1f?w=800")
.width(800).height(600));
// === PDFs ===
print("Creating PDFs...");
let pdf1 = save_pdf(new_pdf()
.title("Climate Action Report 2024")
.description("Comprehensive analysis of global climate initiatives")
.url("https://www.ipcc.ch/site/assets/uploads/2018/02/ipcc_wg3_ar5_summary-for-policymakers.pdf")
.page_count(42));
let pdf2 = save_pdf(new_pdf()
.title("Sustainable Development Goals")
.description("UN SDG implementation guide")
.url("https://sdgs.un.org/sites/default/files/publications/21252030%20Agenda%20for%20Sustainable%20Development%20web.pdf")
.page_count(35));
let pdf3 = save_pdf(new_pdf()
.title("Renewable Energy Handbook")
.description("Technical guide to renewable energy systems")
.url("https://www.irena.org/-/media/Files/IRENA/Agency/Publication/2019/Oct/IRENA_Renewable-Energy-Statistics-2019.pdf")
.page_count(280));
let pdf4 = save_pdf(new_pdf()
.title("Blockchain for Good")
.description("How blockchain technology can solve global challenges")
.url("https://www.weforum.org/whitepapers/blockchain-beyond-the-hype")
.page_count(24));
let pdf5 = save_pdf(new_pdf()
.title("Future of Work Report")
.description("Analysis of changing work patterns and remote collaboration")
.url("https://www.mckinsey.com/featured-insights/future-of-work")
.page_count(156));
// === MARKDOWN DOCUMENTS ===
print("Creating markdown documents...");
let md1 = save_markdown(new_markdown()
.title("OurWorld Mission Statement")
.description("Our vision for a better world")
.content("# OurWorld Mission\n\n## Vision\nTo create a more sustainable, equitable, and connected world through technology and collaboration.\n\n## Values\n- **Sustainability**: Every decision considers environmental impact\n- **Inclusivity**: Technology that serves everyone\n- **Transparency**: Open source and open governance\n- **Innovation**: Pushing boundaries for positive change\n\n## Goals\n1. Reduce global carbon footprint by 50% by 2030\n2. Provide internet access to 1 billion underserved people\n3. Create 10 million green jobs worldwide\n4. Establish 1000 sustainable communities"));
let md2 = save_markdown(new_markdown()
.title("Getting Started Guide")
.description("How to join the OurWorld movement")
.content("# Getting Started with OurWorld\n\n## Welcome!\nThank you for joining our mission to create a better world.\n\n## First Steps\n1. **Explore**: Browse our projects and initiatives\n2. **Connect**: Join our community forums\n3. **Contribute**: Find ways to get involved\n4. **Learn**: Access our educational resources\n\n## Ways to Contribute\n- **Developers**: Contribute to open source projects\n- **Activists**: Organize local initiatives\n- **Educators**: Share knowledge and skills\n- **Investors**: Support sustainable ventures\n\n## Resources\n- [Community Forum](https://forum.ourworld.tf)\n- [Developer Portal](https://dev.ourworld.tf)\n- [Learning Hub](https://learn.ourworld.tf)"));
let md3 = save_markdown(new_markdown()
.title("Technology Roadmap 2024")
.description("Our technical development plans")
.content("# Technology Roadmap 2024\n\n## Q1 Objectives\n- Launch decentralized identity system\n- Deploy carbon tracking blockchain\n- Release mobile app v2.0\n\n## Q2 Objectives\n- Implement AI-powered resource optimization\n- Launch peer-to-peer energy trading platform\n- Deploy IoT sensor network\n\n## Q3 Objectives\n- Release virtual collaboration spaces\n- Launch digital twin cities pilot\n- Implement quantum-safe encryption\n\n## Q4 Objectives\n- Deploy autonomous governance systems\n- Launch global impact measurement platform\n- Release AR/VR sustainability training"));
let md4 = save_markdown(new_markdown()
.title("Community Guidelines")
.description("How we work together")
.content("# Community Guidelines\n\n## Our Principles\n- **Respect**: Treat everyone with dignity\n- **Collaboration**: Work together towards common goals\n- **Constructive**: Focus on solutions, not problems\n- **Inclusive**: Welcome diverse perspectives\n\n## Communication Standards\n- Use clear, respectful language\n- Listen actively to others\n- Provide constructive feedback\n- Share knowledge freely\n\n## Conflict Resolution\n1. Address issues directly and respectfully\n2. Seek to understand different viewpoints\n3. Involve mediators when needed\n4. Focus on solutions that benefit everyone"));
let investor = new_contact()
.name("Example Investor")
.save_contact();
let investors = new_group()
.name("Investors")
.description("A group for example inverstors of ourworld");
investors.add_contact(investor.id)
.save_group();
// === BOOKS ===
print("Creating books...");
let sustainability_book = save_book(new_book()
.title("Sustainability Handbook")
.description("Complete guide to sustainable living and practices")
.add_page("# Introduction to Sustainability\n\nSustainability is about meeting our present needs without compromising the ability of future generations to meet their own needs.\n\n## Key Principles\n- Environmental stewardship\n- Social equity\n- Economic viability\n\n## Why It Matters\nOur planet faces unprecedented challenges from climate change, resource depletion, and environmental degradation.")
.add_page("# Energy Efficiency\n\n## Home Energy Savings\n- LED lighting reduces energy consumption by 75%\n- Smart thermostats can save 10-15% on heating/cooling\n- Energy-efficient appliances make a significant difference\n\n## Renewable Energy\n- Solar panels: Clean electricity from sunlight\n- Wind power: Harnessing natural wind currents\n- Hydroelectric: Using water flow for energy\n\n## Transportation\n- Electric vehicles reduce emissions\n- Public transit decreases individual carbon footprint\n- Cycling and walking for short distances")
.add_page("# Waste Reduction\n\n## The 5 R's\n1. **Refuse**: Say no to unnecessary items\n2. **Reduce**: Use less of what you need\n3. **Reuse**: Find new purposes for items\n4. **Recycle**: Process materials into new products\n5. **Rot**: Compost organic waste\n\n## Practical Tips\n- Use reusable bags and containers\n- Buy products with minimal packaging\n- Repair instead of replacing\n- Donate items you no longer need")
.add_page("# Sustainable Food\n\n## Local and Seasonal\n- Support local farmers and reduce transport emissions\n- Eat seasonal produce for better nutrition and taste\n- Visit farmers markets and join CSAs\n\n## Plant-Based Options\n- Reduce meat consumption for environmental benefits\n- Explore diverse plant proteins\n- Grow your own herbs and vegetables\n\n## Food Waste Prevention\n- Plan meals and make shopping lists\n- Store food properly to extend freshness\n- Use leftovers creatively")
.add_toc_entry(new_toc_entry().title("Introduction to Sustainability").page(0))
.add_toc_entry(new_toc_entry().title("Energy Efficiency").page(1))
.add_toc_entry(new_toc_entry().title("Waste Reduction").page(2))
.add_toc_entry(new_toc_entry().title("Sustainable Food").page(3)));
let tech_guide_book = save_book(new_book()
.title("Green Technology Guide")
.description("Understanding and implementing green technologies")
.add_page("# Green Technology Overview\n\nGreen technology, also known as clean technology, refers to the use of science and technology to create products and services that are environmentally friendly.\n\n## Categories\n- Renewable energy systems\n- Energy efficiency technologies\n- Pollution prevention and cleanup\n- Sustainable materials and manufacturing\n\n## Benefits\n- Reduced environmental impact\n- Lower operating costs\n- Improved public health\n- Economic opportunities")
.add_page("# Solar Technology\n\n## How Solar Works\nSolar panels convert sunlight directly into electricity using photovoltaic cells.\n\n## Types of Solar Systems\n- **Grid-tied**: Connected to the electrical grid\n- **Off-grid**: Standalone systems with battery storage\n- **Hybrid**: Combination of grid-tied and battery backup\n\n## Installation Considerations\n- Roof orientation and shading\n- Local climate and sun exposure\n- Energy consumption patterns\n- Available incentives and rebates")
.add_page("# Smart Home Technology\n\n## Automation Benefits\n- Optimized energy usage\n- Enhanced comfort and convenience\n- Remote monitoring and control\n- Predictive maintenance\n\n## Key Technologies\n- Smart thermostats\n- Automated lighting systems\n- Energy monitoring devices\n- Smart appliances\n- Home energy management systems")
.add_toc_entry(new_toc_entry().title("Green Technology Overview").page(0))
.add_toc_entry(new_toc_entry().title("Solar Technology").page(1))
.add_toc_entry(new_toc_entry().title("Smart Home Technology").page(2)));
let community_book = save_book(new_book()
.title("Building Communities")
.description("Guide to creating sustainable and inclusive communities")
.add_page("# Community Building Fundamentals\n\n## What Makes a Strong Community?\n- Shared values and vision\n- Open communication channels\n- Mutual support and cooperation\n- Inclusive decision-making processes\n\n## Benefits of Strong Communities\n- Enhanced quality of life\n- Economic resilience\n- Social cohesion\n- Environmental stewardship")
.add_page("# Governance and Leadership\n\n## Collaborative Leadership\n- Distributed decision-making\n- Transparent processes\n- Accountability mechanisms\n- Conflict resolution systems\n\n## Community Engagement\n- Regular town halls and meetings\n- Digital participation platforms\n- Volunteer coordination\n- Feedback and improvement cycles")
.add_toc_entry(new_toc_entry().title("Community Building Fundamentals").page(0))
.add_toc_entry(new_toc_entry().title("Governance and Leadership").page(1)));
// === SLIDES ===
print("Creating slides...");
let climate_slides = save_slides(new_slides()
.title("Climate Change Awareness")
.description("Visual presentation on climate change impacts and solutions")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1569163139394-de4e4f43e4e3?w=1200").title("Global Temperature Rise"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1578662996442-48f60103fc96?w=1200").title("Melting Ice Caps"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1200").title("Extreme Weather Events"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=1200").title("Renewable Energy Solutions"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1497436072909-f5e4be1dffea?w=1200").title("Sustainable Transportation")));
let innovation_slides = save_slides(new_slides()
.title("Innovation Showcase")
.description("Cutting-edge technologies for a sustainable future")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=1200").title("AI and Machine Learning"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1639322537228-f710d846310a?w=1200").title("Blockchain Technology"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092160562-40aa08e78837?w=1200").title("IoT and Smart Cities"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?w=1200").title("Quantum Computing"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1581092162384-8987c1d64718?w=1200").title("Biotechnology Advances")));
let nature_slides = save_slides(new_slides()
.title("Biodiversity Gallery")
.description("Celebrating Earth's incredible biodiversity")
.add_slide(new_slide().url("https://images.unsplash.com/photo-1564349683136-77e08dba1ef7?w=1200").title("Tropical Rainforest"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1559827260-dc66d52bef19?w=1200").title("Coral Reef Ecosystem"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1551698618-1dfe5d97d256?w=1200").title("Arctic Wildlife"))
.add_slide(new_slide().url("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200").title("Mountain Ecosystems")));
// === COLLECTIONS ===
print("Creating collections...");
let nature_collection = save_collection(new_collection()
.title("Nature & Environment")
.description("Beautiful images and resources about our natural world")
.add_image(nature1.id)
.add_image(nature2.id)
.add_image(nature3.id)
.add_pdf(pdf1.id)
.add_markdown(md1.id)
.add_book(sustainability_book.id)
.add_slides(nature_slides.id));
let technology_collection = save_collection(new_collection()
.title("Sustainable Technology")
.description("Innovations driving positive change")
.add_image(tech1.id)
.add_image(tech2.id)
.add_pdf(pdf3.id)
.add_pdf(pdf4.id)
.add_markdown(md3.id)
.add_book(tech_guide_book.id)
.add_slides(innovation_slides.id));
let space_collection = save_collection(new_collection()
.title("Space & Cosmos")
.description("Exploring the universe and our place in it")
.add_image(space1.id)
.add_image(space2.id)
.add_pdf(pdf2.id)
.add_markdown(md2.id));
let community_collection = save_collection(new_collection()
.title("Community & Collaboration")
.description("Building better communities together")
.add_image(city1.id)
.add_pdf(pdf5.id)
.add_markdown(md4.id)
.add_book(community_book.id));
let climate_collection = save_collection(new_collection()
.title("Climate Action")
.description("Understanding and addressing climate change")
.add_slides(climate_slides.id)
.add_pdf(pdf1.id)
.add_markdown(md1.id));
print("✅ OurWorld library created successfully!");
print("📚 Collections: 5");
print("🖼️ Images: 8");
print("📄 PDFs: 5");
print("📝 Markdown docs: 4");
print("📖 Books: 3");
print("🎞️ Slide shows: 3");

View File

@@ -1,15 +0,0 @@
// OurWorld Circle and Library Data
new_circle()
.title("Timur Gordon")
.description("Creating a better world.")
.ws_url("ws://localhost:9100/ws")
.add_circle("ws://localhost:9000/ws")
.add_circle("ws://localhost:9001/ws")
.add_circle("ws://localhost:9002/ws")
.add_circle("ws://localhost:9003/ws")
.add_circle("ws://localhost:9004/ws")
.add_circle("ws://localhost:9005/ws")
.add_circle("ws://localhost:8096/ws")
.logo("🌍")
.save_circle();

View File

@@ -16,7 +16,7 @@ use circle_client_ws::CircleWsClientBuilder;
const TEST_CIRCLE_NAME: &str = "e2e_test_circle";
const TEST_SERVER_PORT: u16 = 9876; // Choose a unique port for the test
const RHAI_WORKER_BIN_NAME: &str = "worker";
const CIRCLE_SERVER_WS_BIN_NAME: &str = "server_ws";
const CIRCLE_SERVER_WS_BIN_NAME: &str = "server";
// RAII guard for cleaning up child processes
struct ChildProcessGuard {

View File

@@ -14,7 +14,7 @@ use tokio::time::{sleep, Duration};
const EXAMPLE_SERVER_PORT: u16 = 8089; // Using a specific port for this example
const WS_URL: &str = "ws://127.0.0.1:8089/ws";
const CIRCLE_NAME_FOR_EXAMPLE: &str = "timeout_example_circle";
const CIRCLE_SERVER_WS_BIN_NAME: &str = "server_ws";
const CIRCLE_SERVER_WS_BIN_NAME: &str = "server";
const SCRIPT_TIMEOUT_SECONDS: u64 = 30; // This is the server-side timeout we expect to hit
// RAII guard for cleaning up child processes

View File

@@ -0,0 +1,83 @@
//! WSS + Authentication Example
//!
//! This example demonstrates a secure WebSocket server with:
//! - TLS/WSS encryption
//! - secp256k1 authentication
//! - Message handling with authentication verification
//!
//! Usage: cargo run --manifest-path src/server/Cargo.toml --example wss_auth_example
use circle_ws_lib::{ServerConfig, spawn_circle_server};
use log::{info, warn};
use std::time::Duration;
use tokio::time::sleep;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize logging
env_logger::init();
info!("🔐 Starting WSS + Authentication Server Example");
info!("🛡️ This example demonstrates secure WebSocket with authentication");
// Create server configuration with TLS and authentication enabled
let mut config = ServerConfig::new(
"127.0.0.1".to_string(),
8080, // Regular WebSocket port
"redis://127.0.0.1:6379".to_string(),
);
// Configure TLS settings
config.enable_tls = true;
config.tls_port = Some(8443);
config.cert_path = Some("cert.pem".to_string());
config.key_path = Some("key.pem".to_string());
config.enable_auth = true; // Enable secp256k1 authentication
info!("📋 Server Configuration:");
info!(" Host: {}", config.host);
info!(" Regular WS Port: {}", config.port);
info!(" WSS Port: {}", config.tls_port.unwrap_or(0));
info!(" TLS Enabled: {}", config.enable_tls);
info!(" Auth Enabled: {}", config.enable_auth);
info!(" Certificate: {:?}", config.cert_path);
info!(" Private Key: {:?}", config.key_path);
// Start the server
let (join_handle, _server_handle) = spawn_circle_server(config)
.map_err(|e| -> Box<dyn std::error::Error> {
warn!("❌ Failed to start WSS + Auth server: {}", e);
Box::new(e)
})?;
info!("✅ WSS + Auth Server started successfully!");
info!("🔒 Secure WebSocket URL: wss://127.0.0.1:8443/ws");
info!("🔓 Regular WebSocket URL: ws://127.0.0.1:8080/ws");
info!("🛡️ Authentication: secp256k1 signatures required");
info!("");
info!("🧪 To test authenticated connections:");
info!(" 1. Generate a secp256k1 key pair");
info!(" 2. Sign your messages with the private key");
info!(" 3. Include the signature in your WebSocket messages");
info!(" 4. The server will verify signatures before processing");
info!("");
info!("📝 Message format for authenticated requests:");
info!(" {{");
info!(" \"type\": \"your_message_type\",");
info!(" \"data\": {{...}},");
info!(" \"signature\": \"hex_encoded_signature\",");
info!(" \"public_key\": \"hex_encoded_public_key\"");
info!(" }}");
info!("");
// Keep server running for demonstration
info!("⏰ Server will run for 60 seconds, then shutdown...");
sleep(Duration::from_secs(60)).await;
info!("🛑 Shutting down WSS + Auth server example");
// Wait for the server to finish
let _ = join_handle.await;
Ok(())
}

View File

@@ -0,0 +1,69 @@
//! Basic WSS (WebSocket Secure) server example
//!
//! This example demonstrates how to start a WSS server with TLS enabled.
//! It uses the existing certificate and key files for testing.
//!
//! To run this example:
//! ```bash
//! cargo run --example wss_basic_example
//! ```
use circle_ws_lib::{spawn_circle_server, ServerConfig};
use log::info;
use std::time::Duration;
use tokio::time::sleep;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize logging
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
info!("🚀 Starting Basic WSS Server Example");
// Create server configuration with TLS enabled
let config = ServerConfig::new(
"127.0.0.1".to_string(),
8443, // Use port 8443 for WSS
"redis://127.0.0.1/".to_string(),
)
.with_tls("cert.pem".to_string(), "key.pem".to_string())
.with_tls_port(8443);
info!("📋 Server Configuration:");
info!(" Host: {}", config.host);
info!(" WSS Port: {}", config.get_tls_port());
info!(" TLS Enabled: {}", config.enable_tls);
info!(" Auth Enabled: {}", config.enable_auth);
info!(" Certificate: {:?}", config.cert_path);
info!(" Private Key: {:?}", config.key_path);
// Start the WSS server
let (server_task, server_handle) = spawn_circle_server(config)?;
info!("✅ WSS Server started successfully!");
info!("🔒 You can now connect to: wss://127.0.0.1:8443/ws");
info!("📝 Note: This uses a self-signed certificate for testing");
info!("");
info!("🧪 To test the connection, you can use:");
info!(" - A WebSocket client that supports WSS");
info!(" - The client_ws library with TLS support");
info!(" - Browser developer tools (may show certificate warnings)");
info!("");
info!("⏰ Server will run for 30 seconds, then shutdown...");
// Let the server run for 30 seconds
sleep(Duration::from_secs(30)).await;
info!("🛑 Shutting down WSS server...");
server_handle.stop(true).await;
// Wait for the server task to complete
match server_task.await {
Ok(Ok(())) => info!("✅ WSS server shut down successfully"),
Ok(Err(e)) => info!("⚠️ WSS server shut down with error: {}", e),
Err(e) => info!("❌ Failed to wait for server shutdown: {}", e),
}
info!("🏁 Basic WSS example completed");
Ok(())
}

7
examples/wss_demo/.gitignore vendored Normal file
View File

@@ -0,0 +1,7 @@
# TLS Certificates (uncomment if you want to exclude them)
# cert.pem
# key.pem
# Temporary files
*.tmp
*.log

2958
examples/wss_demo/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,35 @@
[package]
name = "wss_demo"
version = "0.1.0"
edition = "2021"
# Empty workspace table to exclude from parent workspace
[workspace]
[[bin]]
name = "wss_client"
path = "wss_client.rs"
[[bin]]
name = "wss_server"
path = "wss_server.rs"
[dependencies]
# WebSocket client library
circle_client_ws = { path = "../../src/client_ws", features = ["crypto"] }
# Server library for the WSS server demo
circle_ws_lib = { path = "../../src/server", features = ["auth"] }
# Common dependencies
tokio = { version = "1.45", features = ["full"] }
env_logger = "0.10"
log = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
# Server-specific dependencies
actix = "0.13"
actix-web = "4.11"
actix-web-actors = "4.3"
clap = { version = "4.5", features = ["derive"] }

204
examples/wss_demo/README.md Normal file
View File

@@ -0,0 +1,204 @@
# WSS (WebSocket Secure) Demo
This directory contains a complete demonstration of WSS (WebSocket Secure) functionality with TLS encryption and authentication.
## Contents
- `cert.pem` - Self-signed TLS certificate for testing
- `key.pem` - Private key for the TLS certificate
- `wss_server.rs` - WSS server example with authentication
- `wss_client.rs` - WSS client example for testing
## Quick Start
### 1. Start the WSS Server
```bash
# From the project root - specify the correct package and feature
cargo run --manifest-path src/server/Cargo.toml --example wss_server --features circle_ws_lib/auth
# OR run from the wss_demo directory
cd examples/wss_demo
cargo run --bin wss_server
```
The server will start on:
- **WSS (Secure)**: `wss://127.0.0.1:8443/ws`
- **WS (Regular)**: `ws://127.0.0.1:8080/ws`
### 2. Test with the WSS Client
Run the WSS client that uses the circle_client_ws library:
```bash
# Navigate to the wss_demo directory
cd examples/wss_demo
# Run with logging (recommended)
RUST_LOG=info cargo run --bin wss_client
# Or without logging
cargo run --bin wss_client
```
This will run the `wss_client.rs` file which demonstrates:
- Automatic credential generation using secp256k1
- WSS connection with TLS encryption
- Full authentication flow
- Script execution over secure WebSocket
**Note**: The WSS client must be run from the `examples/wss_demo` directory as it's a standalone project with its own dependencies.
## Features Demonstrated
### 🔒 **TLS/WSS Encryption**
- Self-signed certificate for development/testing
- Secure WebSocket connections over TLS
- Certificate validation and error handling
### 🛡️ **Authentication**
- secp256k1 signature-based authentication
- Nonce generation and verification
- Authenticated vs unauthenticated request handling
### 📝 **JSON-RPC Protocol**
- Standard JSON-RPC 2.0 over WebSocket
- Method calls: `fetch_nonce`, `authenticate`, `play`
- Error handling and response validation
## Certificate Information
The included certificate is a **self-signed certificate** for development and testing purposes only.
**Certificate Details:**
- **Subject**: `/C=US/ST=Demo/L=Demo/O=WSS Demo/CN=localhost`
- **Validity**: 365 days from generation
- **Key Size**: RSA 4096-bit
- **Usage**: Development/Testing only
⚠️ **Security Notice**: Do not use this certificate in production. Generate proper certificates from a trusted Certificate Authority for production use.
## Testing with Browser
You can test the WSS connection using browser developer tools:
```javascript
// Open browser console and run:
const ws = new WebSocket('wss://127.0.0.1:8443/ws');
ws.onopen = () => {
console.log('WSS Connected!');
// Send a test message
ws.send(JSON.stringify({
jsonrpc: "2.0",
method: "fetch_nonce",
params: { pubkey: "test_key" },
id: 1
}));
};
ws.onmessage = (event) => {
console.log('Response:', JSON.parse(event.data));
};
```
**Note**: Your browser may show a security warning due to the self-signed certificate. This is expected for development.
## Testing with websocat
You can also test with websocat (WebSocket command-line client):
```bash
# Install websocat if not already installed
cargo install websocat
# Connect to WSS server (ignoring certificate validation for self-signed cert)
websocat --insecure wss://127.0.0.1:8443/ws
# Or with more explicit options
websocat -k wss://127.0.0.1:8443/ws
# Send a test message (after connecting)
{"jsonrpc":"2.0","method":"fetch_nonce","params":{"pubkey":"test_key"},"id":1}
```
**Note**: The `--insecure` or `-k` flag is needed because we're using a self-signed certificate.
## Authentication Flow
### 1. Fetch Nonce
```json
{
"jsonrpc": "2.0",
"method": "fetch_nonce",
"params": { "pubkey": "your_public_key_hex" },
"id": 1
}
```
### 2. Authenticate
```json
{
"jsonrpc": "2.0",
"method": "authenticate",
"params": {
"pubkey": "your_public_key_hex",
"signature": "signed_nonce_hex"
},
"id": 2
}
```
### 3. Execute Commands
```json
{
"jsonrpc": "2.0",
"method": "play",
"params": { "script": "40 + 2" },
"id": 3
}
```
## Troubleshooting
### Certificate Issues
If you encounter certificate-related errors:
1. **Regenerate certificates**:
```bash
cd examples/wss_demo
rm cert.pem key.pem
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -subj "/C=US/ST=Demo/L=Demo/O=WSS Demo/CN=localhost"
```
2. **Check file permissions**:
```bash
ls -la cert.pem key.pem
```
### Connection Issues
- Ensure no other services are using ports 8080 or 8443
- Check firewall settings
- Verify the server started successfully (look for "✅ WSS Server started successfully!" message)
### Authentication Issues
- Ensure you're using valid secp256k1 signatures
- Check that the nonce hasn't expired (default: 5 minutes)
- Verify the public key format is correct hex encoding
## Production Deployment
For production use:
1. **Use proper certificates** from a trusted CA
2. **Configure proper hostnames** (not localhost)
3. **Set up proper firewall rules**
4. **Use environment variables** for sensitive configuration
5. **Enable proper logging and monitoring**
6. **Consider load balancing** for high availability
## Related Documentation
- [WSS Implementation Plan](../../WSS_IMPLEMENTATION_PLAN.md)
- [Server WS README](../../src/server/README.md)
- [Client WS README](../../src/client_ws/README.md)

View File

@@ -0,0 +1,94 @@
//! WSS Client Demo using Circle WebSocket Client
//!
//! This example demonstrates connecting to a WSS (WebSocket Secure) server
//! using the circle_client_ws library with proper authentication.
use circle_client_ws::{CircleWsClientBuilder, auth};
use log::{info, error};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize logging - use RUST_LOG=info for detailed output
env_logger::init();
println!("🧪 Starting WSS Client Demo");
// Generate authentication credentials
let private_key = auth::generate_private_key()?;
let public_key = auth::derive_public_key(&private_key)?;
info!("🔑 Generated credentials - Public key: {}...", &public_key[..20]);
// WSS server URL (secure WebSocket)
let wss_url = "wss://127.0.0.1:8443/ws";
info!("🔗 Connecting to WSS server at {}", wss_url);
println!("🔌 Connecting to WSS server...");
// Create WSS client with authentication
let mut client = CircleWsClientBuilder::new(wss_url.to_string())
.with_keypair(private_key)
.build();
// Connect to the server
match client.connect().await {
Ok(()) => {
println!("✅ Successfully connected to WSS server!");
info!("📡 Response status: 101 Switching Protocols");
println!("\n🧪 Testing WSS connection with JSON-RPC messages...");
// Test 1: Authentication
println!("📤 Test 1: Performing authentication");
match client.authenticate().await {
Ok(true) => {
println!("✅ Authentication successful!");
info!("🔐 Client authenticated with server");
// Test 2: Execute script (authenticated request)
println!("\n📤 Test 2: Executing script (authenticated request)");
let test_script = "40 + 2".to_string();
match client.play(test_script).await {
Ok(result) => {
println!("✅ Script execution successful!");
println!("📊 Result: {}", result.output);
info!("Script output: {}", result.output);
}
Err(e) => {
error!("❌ Script execution failed: {}", e);
println!("❌ Script execution failed: {}", e);
}
}
}
Ok(false) => {
println!("❌ Authentication failed - server rejected credentials");
error!("Authentication failed");
}
Err(e) => {
error!("❌ Authentication error: {}", e);
println!("❌ Authentication error: {}", e);
}
}
// Disconnect
client.disconnect().await;
println!("\n🔌 Disconnected from WSS server");
println!("\n🎉 Summary:");
println!(" ✅ WSS connection established");
println!(" ✅ TLS encryption working");
println!(" ✅ JSON-RPC protocol working");
println!(" ✅ Authentication system working");
println!(" ✅ Script execution working");
}
Err(e) => {
error!("❌ Failed to connect to WSS server: {}", e);
println!("❌ Connection failed: {}", e);
println!("\n💡 Make sure the WSS server is running:");
println!(" cargo run --manifest-path src/server/Cargo.toml --example wss_server --features auth");
}
}
Ok(())
}

View File

@@ -0,0 +1,91 @@
//! WSS Server Demo
//!
//! This example demonstrates a complete WSS (WebSocket Secure) server with:
//! - TLS encryption using self-signed certificates
//! - secp256k1 authentication
//! - JSON-RPC protocol support
//! - Comprehensive logging and error handling
//!
//! Usage: cargo run --example wss_server --features auth
use circle_ws_lib::{ServerConfig, spawn_circle_server};
use log::{info, warn, error};
use std::time::Duration;
use tokio::time::sleep;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize logging
env_logger::init();
info!("🚀 Starting WSS Server Demo");
info!("🔐 This demo includes TLS encryption and secp256k1 authentication");
info!("");
// Create server configuration with TLS and authentication enabled
let config = ServerConfig::new(
"127.0.0.1".to_string(),
8080, // Regular WebSocket port
"redis://127.0.0.1:6379".to_string(),
)
.with_tls(
"../../src/server/examples/wss_demo/cert.pem".to_string(),
"../../src/server/examples/wss_demo/key.pem".to_string()
)
.with_tls_port(8443) // Secure WebSocket port
.with_auth(); // Enable secp256k1 authentication
info!("📋 Server Configuration:");
info!(" Host: {}", config.host);
info!(" Regular WS Port: {}", config.port);
info!(" WSS Port: {}", config.get_tls_port());
info!(" TLS Enabled: {}", config.enable_tls);
info!(" Auth Enabled: {}", config.enable_auth);
info!(" Certificate: {:?}", config.cert_path);
info!(" Private Key: {:?}", config.key_path);
info!("");
// Start the server
let (join_handle, _server_handle) = spawn_circle_server(config)
.map_err(|e| -> Box<dyn std::error::Error> {
error!("❌ Failed to start WSS server: {}", e);
Box::new(e)
})?;
info!("✅ WSS Server started successfully!");
info!("");
info!("🔗 Connection URLs:");
info!(" 🔒 Secure WebSocket: wss://127.0.0.1:8443/ws");
info!(" 🔓 Regular WebSocket: ws://127.0.0.1:8080/ws");
info!("");
info!("🛡️ Authentication: secp256k1 signatures required for 'play' commands");
info!("🔓 Public methods: 'fetch_nonce' (no auth required)");
info!("");
info!("📝 Example JSON-RPC requests:");
info!(" 1. Fetch nonce (no auth):");
info!(" {{\"jsonrpc\":\"2.0\",\"method\":\"fetch_nonce\",\"params\":{{\"pubkey\":\"your_pubkey\"}},\"id\":1}}");
info!("");
info!(" 2. Authenticate:");
info!(" {{\"jsonrpc\":\"2.0\",\"method\":\"authenticate\",\"params\":{{\"pubkey\":\"your_pubkey\",\"signature\":\"signed_nonce\"}},\"id\":2}}");
info!("");
info!(" 3. Execute script (requires auth):");
info!(" {{\"jsonrpc\":\"2.0\",\"method\":\"play\",\"params\":{{\"script\":\"40 + 2\"}},\"id\":3}}");
info!("");
info!("🧪 Test with the WSS client:");
info!(" cargo run --example wss_client");
info!("");
info!("🌐 Test with browser (open console):");
info!(" const ws = new WebSocket('wss://127.0.0.1:8443/ws');");
info!(" ws.onopen = () => ws.send(JSON.stringify({{jsonrpc:'2.0',method:'fetch_nonce',params:{{pubkey:'test'}},id:1}}));");
info!(" ws.onmessage = (e) => console.log(JSON.parse(e.data));");
info!("");
info!("⚠️ Note: Browser may show certificate warning (self-signed cert)");
info!("");
info!("🔄 Server running... Press Ctrl+C to stop");
// Keep server running until interrupted
let _ = join_handle.await;
info!("🛑 WSS Server stopped");
Ok(())
}

136
examples/wss_test_client.rs Normal file
View File

@@ -0,0 +1,136 @@
//! WSS Test Client
//!
//! This example demonstrates connecting to a WSS server for testing purposes.
//! It's a simple client that connects to the WSS server and sends a test message.
//!
//! Usage: cargo run --manifest-path src/server/Cargo.toml --example wss_test_client
use tokio_tungstenite::{connect_async_tls_with_config, Connector};
use tokio_tungstenite::tungstenite::protocol::Message;
use futures_util::{SinkExt, StreamExt};
use log::{info, warn, error};
use std::time::Duration;
use tokio::time::timeout;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize logging
env_logger::init();
info!("🧪 Starting WSS Test Client");
info!("🔗 Attempting to connect to wss://127.0.0.1:8443/ws");
// Create a TLS connector that accepts self-signed certificates for testing
let connector = Connector::NativeTls(
native_tls::TlsConnector::builder()
.danger_accept_invalid_certs(true)
.danger_accept_invalid_hostnames(true)
.build()
.map_err(|e| format!("TLS connector error: {}", e))?
);
let config = Some(tokio_tungstenite::tungstenite::protocol::WebSocketConfig {
max_send_queue: None,
max_message_size: Some(64 << 20), // 64 MB
max_frame_size: Some(16 << 20), // 16 MB
accept_unmasked_frames: false,
});
// Connect to the WSS server
info!("🔌 Connecting to WSS server...");
let connect_result = timeout(
Duration::from_secs(10),
connect_async_tls_with_config(
"wss://127.0.0.1:8443/ws",
config,
false,
Some(connector)
)
).await;
let (ws_stream, response) = match connect_result {
Ok(Ok((stream, response))) => {
info!("✅ Successfully connected to WSS server!");
info!("📡 Response status: {}", response.status());
(stream, response)
}
Ok(Err(e)) => {
error!("❌ Failed to connect to WSS server: {}", e);
return Err(format!("Connection failed: {}", e).into());
}
Err(_) => {
error!("❌ Connection timeout after 10 seconds");
return Err("Connection timeout".into());
}
};
let (mut ws_sender, mut ws_receiver) = ws_stream.split();
// Send a test JSON-RPC message
let test_message = serde_json::json!({
"jsonrpc": "2.0",
"method": "fetch_nonce",
"params": {
"pubkey": "test_public_key_123"
},
"id": 1
});
info!("📤 Sending test message: {}", test_message);
ws_sender.send(Message::Text(test_message.to_string())).await
.map_err(|e| format!("Send error: {}", e))?;
// Wait for response
info!("⏳ Waiting for server response...");
let response_result = timeout(Duration::from_secs(5), ws_receiver.next()).await;
match response_result {
Ok(Some(Ok(Message::Text(response)))) => {
info!("📥 Received response: {}", response);
// Parse the JSON response
match serde_json::from_str::<serde_json::Value>(&response) {
Ok(json_response) => {
if json_response.get("result").is_some() {
info!("✅ Server responded with valid JSON-RPC result");
info!("🎉 WSS connection and communication test PASSED!");
} else if json_response.get("error").is_some() {
warn!("⚠️ Server responded with error (expected for unauthenticated request)");
info!("✅ WSS connection test PASSED (server is responding correctly)");
} else {
warn!("⚠️ Unexpected response format");
}
}
Err(e) => {
warn!("⚠️ Failed to parse JSON response: {}", e);
}
}
}
Ok(Some(Ok(message))) => {
info!("📥 Received non-text message: {:?}", message);
}
Ok(Some(Err(e))) => {
error!("❌ WebSocket error: {}", e);
return Err(format!("WebSocket error: {}", e).into());
}
Ok(None) => {
warn!("⚠️ Connection closed by server");
}
Err(_) => {
error!("❌ Response timeout after 5 seconds");
return Err("Response timeout".into());
}
}
// Close the connection
info!("🔌 Closing WSS connection...");
ws_sender.close().await
.map_err(|e| format!("Close error: {}", e))?;
info!("✅ WSS Test Client completed successfully!");
Ok(())
}