add circles app and libraries
This commit is contained in:
0
examples/.gitkeep
Normal file
0
examples/.gitkeep
Normal file
146
examples/client_auth_example.rs
Normal file
146
examples/client_auth_example.rs
Normal file
@@ -0,0 +1,146 @@
|
||||
//! End-to-end authentication example
|
||||
//!
|
||||
//! This example demonstrates the complete authentication flow with the simplified approach:
|
||||
//! 1. Create a WebSocket client with authentication configuration
|
||||
//! 2. Authenticate using private key
|
||||
//! 3. Connect to WebSocket with authentication
|
||||
//! 4. Send authenticated requests
|
||||
//!
|
||||
//! To run this example:
|
||||
//! ```bash
|
||||
//! cargo run --example client_auth_example --features "crypto"
|
||||
//! ```
|
||||
|
||||
use circle_client_ws::CircleWsClientBuilder;
|
||||
use log::{info, 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 simplified authentication example");
|
||||
|
||||
// Configuration
|
||||
let ws_url = "ws://localhost:8080/ws".to_string();
|
||||
|
||||
// Example 1: Authenticate with private key
|
||||
info!("=== Example 1: Private Key Authentication ===");
|
||||
let private_key = "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
|
||||
|
||||
let mut client = CircleWsClientBuilder::new(ws_url.clone())
|
||||
.with_keypair(private_key.to_string())
|
||||
.build();
|
||||
|
||||
match client.connect().await {
|
||||
Ok(_) => {
|
||||
info!("Successfully connected to WebSocket");
|
||||
}
|
||||
Err(e) => {
|
||||
error!("WebSocket connection failed: {}", e);
|
||||
return Err(e.into());
|
||||
}
|
||||
}
|
||||
|
||||
match client.authenticate().await {
|
||||
Ok(true) => {
|
||||
info!("Successfully authenticated with private key");
|
||||
}
|
||||
Ok(false) => {
|
||||
error!("Authentication failed");
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Private key authentication failed: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Example 2: Send authenticated request
|
||||
info!("=== Example 2: Send Authenticated Request ===");
|
||||
let script = "print('Hello from authenticated client!');".to_string();
|
||||
match client.play(script).await {
|
||||
Ok(result) => {
|
||||
info!("Play request successful: {}", result.output);
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Play request failed: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Keep connection alive for a moment
|
||||
sleep(Duration::from_secs(2)).await;
|
||||
|
||||
// Disconnect
|
||||
client.disconnect().await;
|
||||
info!("Disconnected from WebSocket");
|
||||
|
||||
|
||||
// Example 3: Different private key authentication
|
||||
info!("=== Example 3: Different Private Key Authentication ===");
|
||||
let private_key2 = "0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321";
|
||||
|
||||
let mut client2 = CircleWsClientBuilder::new(ws_url.clone())
|
||||
.with_keypair(private_key2.to_string())
|
||||
.build();
|
||||
|
||||
match client2.connect().await {
|
||||
Ok(_) => {
|
||||
info!("Connected with second private key authentication");
|
||||
|
||||
match client2.authenticate().await {
|
||||
Ok(true) => {
|
||||
info!("Successfully authenticated with second private key");
|
||||
let script = "print('Hello from second auth!');".to_string();
|
||||
match client2.play(script).await {
|
||||
Ok(result) => {
|
||||
info!("Second auth request successful: {}", result.output);
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Second auth request failed: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(false) => {
|
||||
error!("Second private key authentication failed");
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Second private key authentication failed: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
client2.disconnect().await;
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Second auth connection failed: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Example 4: Non-authenticated connection (fallback)
|
||||
info!("=== Example 4: Non-Authenticated Connection ===");
|
||||
let mut client3 = CircleWsClientBuilder::new(ws_url).build();
|
||||
|
||||
match client3.connect().await {
|
||||
Ok(()) => {
|
||||
info!("Connected without authentication (fallback mode)");
|
||||
|
||||
let script = "print('Hello from non-auth client!');".to_string();
|
||||
match client3.play(script).await {
|
||||
Ok(result) => {
|
||||
info!("Non-auth request successful: {}", result.output);
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Non-auth request failed: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
client3.disconnect().await;
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Non-auth connection failed: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
info!("Simplified authentication example completed");
|
||||
Ok(())
|
||||
}
|
261
examples/client_auth_simulation_example.rs
Normal file
261
examples/client_auth_simulation_example.rs
Normal file
@@ -0,0 +1,261 @@
|
||||
//! Authentication simulation example
|
||||
//!
|
||||
//! This example simulates the authentication flow without requiring a running server.
|
||||
//! It demonstrates:
|
||||
//! 1. Key generation and management
|
||||
//! 2. Nonce request simulation
|
||||
//! 3. Message signing and verification
|
||||
//! 4. Credential management
|
||||
//! 5. Authentication state checking
|
||||
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use log::info;
|
||||
|
||||
// Import authentication modules
|
||||
use circle_client_ws::CircleWsClientBuilder;
|
||||
|
||||
#[cfg(feature = "crypto")]
|
||||
use circle_client_ws::auth::{
|
||||
generate_private_key,
|
||||
derive_public_key,
|
||||
sign_message,
|
||||
verify_signature,
|
||||
AuthCredentials,
|
||||
NonceResponse
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Initialize logging
|
||||
env_logger::init();
|
||||
|
||||
info!("🔐 Starting authentication simulation example");
|
||||
|
||||
// Step 1: Generate cryptographic keys
|
||||
info!("🔑 Generating cryptographic keys...");
|
||||
|
||||
#[cfg(feature = "crypto")]
|
||||
let (private_key, public_key) = {
|
||||
let private_key = generate_private_key()?;
|
||||
let public_key = derive_public_key(&private_key)?;
|
||||
info!("✅ Generated private key: {}...", &private_key[..10]);
|
||||
info!("✅ Derived public key: {}...", &public_key[..20]);
|
||||
(private_key, public_key)
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "crypto"))]
|
||||
let (private_key, _public_key) = {
|
||||
let private_key = "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef".to_string();
|
||||
let public_key = "04abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890".to_string();
|
||||
info!("📝 Using fallback keys (crypto feature disabled)");
|
||||
(private_key, public_key)
|
||||
};
|
||||
|
||||
// Step 2: Simulate nonce request and response
|
||||
info!("📡 Simulating nonce request...");
|
||||
let current_time = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs();
|
||||
|
||||
let simulated_nonce = format!("nonce_{}_{}", current_time, "abcdef123456");
|
||||
let expires_at = current_time + 300; // 5 minutes from now
|
||||
|
||||
#[cfg(feature = "crypto")]
|
||||
let nonce_response = NonceResponse {
|
||||
nonce: simulated_nonce.clone(),
|
||||
expires_at,
|
||||
};
|
||||
|
||||
info!("✅ Simulated nonce response:");
|
||||
info!(" Nonce: {}", simulated_nonce);
|
||||
info!(" Expires at: {}", expires_at);
|
||||
|
||||
// Step 3: Sign the nonce
|
||||
info!("✍️ Signing nonce with private key...");
|
||||
|
||||
#[cfg(feature = "crypto")]
|
||||
let signature = {
|
||||
match sign_message(&private_key, &simulated_nonce) {
|
||||
Ok(sig) => {
|
||||
info!("✅ Signature created: {}...", &sig[..20]);
|
||||
sig
|
||||
}
|
||||
Err(e) => {
|
||||
error!("❌ Failed to sign message: {}", e);
|
||||
return Err(e.into());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "crypto"))]
|
||||
let _signature = {
|
||||
info!("📝 Using fallback signature (crypto feature disabled)");
|
||||
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890".to_string()
|
||||
};
|
||||
|
||||
// Step 4: Verify the signature
|
||||
info!("🔍 Verifying signature...");
|
||||
|
||||
#[cfg(feature = "crypto")]
|
||||
{
|
||||
match verify_signature(&public_key, &simulated_nonce, &signature) {
|
||||
Ok(true) => info!("✅ Signature verification successful!"),
|
||||
Ok(false) => {
|
||||
error!("❌ Signature verification failed!");
|
||||
return Err("Signature verification failed".into());
|
||||
}
|
||||
Err(e) => {
|
||||
error!("❌ Signature verification error: {}", e);
|
||||
return Err(e.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "crypto"))]
|
||||
{
|
||||
info!("📝 Skipping signature verification (crypto feature disabled)");
|
||||
}
|
||||
|
||||
// Step 5: Create authentication credentials
|
||||
info!("📋 Creating authentication credentials...");
|
||||
#[cfg(feature = "crypto")]
|
||||
let credentials = AuthCredentials::new(
|
||||
public_key.clone(),
|
||||
signature.clone(),
|
||||
nonce_response.nonce.clone(),
|
||||
expires_at
|
||||
);
|
||||
|
||||
#[cfg(feature = "crypto")]
|
||||
{
|
||||
info!("✅ Credentials created:");
|
||||
info!(" Public key: {}...", &credentials.public_key()[..20]);
|
||||
info!(" Signature: {}...", &credentials.signature()[..20]);
|
||||
info!(" Nonce: {}", credentials.nonce());
|
||||
info!(" Expires at: {}", credentials.expires_at);
|
||||
info!(" Is expired: {}", credentials.is_expired());
|
||||
info!(" Expires within 60s: {}", credentials.expires_within(60));
|
||||
info!(" Expires within 400s: {}", credentials.expires_within(400));
|
||||
}
|
||||
|
||||
// Step 6: Create client with authentication
|
||||
info!("🔌 Creating WebSocket client with authentication...");
|
||||
let _client = CircleWsClientBuilder::new("ws://localhost:8080/ws".to_string())
|
||||
.with_keypair(private_key.clone())
|
||||
.build();
|
||||
|
||||
info!("✅ Client created");
|
||||
|
||||
// Step 7: Demonstrate key rotation
|
||||
info!("🔄 Demonstrating key rotation...");
|
||||
|
||||
#[cfg(feature = "crypto")]
|
||||
{
|
||||
let new_private_key = generate_private_key()?;
|
||||
let new_public_key = derive_public_key(&new_private_key)?;
|
||||
|
||||
info!("✅ Generated new keys:");
|
||||
info!(" New private key: {}...", &new_private_key[..10]);
|
||||
info!(" New public key: {}...", &new_public_key[..20]);
|
||||
|
||||
// Create new client with rotated keys
|
||||
let _new_client = CircleWsClientBuilder::new("ws://localhost:8080/ws".to_string())
|
||||
.with_keypair(new_private_key)
|
||||
.build();
|
||||
|
||||
info!("✅ Created client with rotated keys");
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "crypto"))]
|
||||
{
|
||||
info!("📝 Skipping key rotation (crypto feature disabled)");
|
||||
}
|
||||
|
||||
// Step 8: Demonstrate credential expiration
|
||||
info!("⏰ Demonstrating credential expiration...");
|
||||
|
||||
// Create credentials that expire soon
|
||||
#[cfg(feature = "crypto")]
|
||||
let short_lived_credentials = AuthCredentials::new(
|
||||
public_key,
|
||||
signature,
|
||||
nonce_response.nonce,
|
||||
current_time + 5 // Expires in 5 seconds
|
||||
);
|
||||
|
||||
#[cfg(feature = "crypto")]
|
||||
{
|
||||
info!("✅ Created short-lived credentials:");
|
||||
info!(" Expires at: {}", short_lived_credentials.expires_at);
|
||||
info!(" Is expired: {}", short_lived_credentials.is_expired());
|
||||
info!(" Expires within 10s: {}", short_lived_credentials.expires_within(10));
|
||||
|
||||
// Wait a moment and check again
|
||||
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
||||
info!("⏳ After 1 second:");
|
||||
info!(" Is expired: {}", short_lived_credentials.is_expired());
|
||||
info!(" Expires within 5s: {}", short_lived_credentials.expires_within(5));
|
||||
}
|
||||
|
||||
info!("🎉 Authentication simulation completed successfully!");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_key_generation() {
|
||||
#[cfg(feature = "crypto")]
|
||||
{
|
||||
let private_key = generate_private_key().unwrap();
|
||||
assert!(private_key.starts_with("0x"));
|
||||
assert_eq!(private_key.len(), 66); // 0x + 64 hex chars
|
||||
|
||||
let public_key = derive_public_key(&private_key).unwrap();
|
||||
assert!(public_key.starts_with("04"));
|
||||
assert_eq!(public_key.len(), 130); // 04 + 128 hex chars (uncompressed)
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_signature_flow() {
|
||||
#[cfg(feature = "crypto")]
|
||||
{
|
||||
let private_key = generate_private_key().unwrap();
|
||||
let public_key = derive_public_key(&private_key).unwrap();
|
||||
let message = "test_nonce_12345";
|
||||
|
||||
let signature = sign_message(&private_key, message).unwrap();
|
||||
let is_valid = verify_signature(&public_key, message, &signature).unwrap();
|
||||
|
||||
assert!(is_valid);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_credentials() {
|
||||
let current_time = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs();
|
||||
|
||||
#[cfg(feature = "crypto")]
|
||||
let credentials = AuthCredentials::new(
|
||||
"04abcdef...".to_string(),
|
||||
"0x123456...".to_string(),
|
||||
"nonce_123".to_string(),
|
||||
current_time + 300
|
||||
);
|
||||
|
||||
#[cfg(feature = "crypto")]
|
||||
{
|
||||
assert!(!credentials.is_expired());
|
||||
assert!(credentials.expires_within(400));
|
||||
assert!(!credentials.expires_within(100));
|
||||
}
|
||||
}
|
||||
}
|
68
examples/ourworld/README.md
Normal file
68
examples/ourworld/README.md
Normal file
@@ -0,0 +1,68 @@
|
||||
# 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.
|
37
examples/ourworld/circles.json
Normal file
37
examples/ourworld/circles.json
Normal file
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
83
examples/ourworld/main.rs
Normal file
83
examples/ourworld/main.rs
Normal file
@@ -0,0 +1,83 @@
|
||||
//! 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 std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::error::Error as StdError;
|
||||
use log::{error, info};
|
||||
|
||||
#[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(())
|
||||
}
|
51
examples/ourworld/ourworld_output.json
Normal file
51
examples/ourworld/ourworld_output.json
Normal file
@@ -0,0 +1,51 @@
|
||||
[
|
||||
{
|
||||
"name": "OurWorld",
|
||||
"public_key": "02acbca22369b7f10584348056ae48779e04534cd34d37b7db0f4996f4d9d5e2a5",
|
||||
"secret_key": "0c75df7425c799eb769049cf48891299761660396d772c687fa84cac5ec62570",
|
||||
"worker_queue": "rhai_tasks:02acbca22369b7f10584348056ae48779e04534cd34d37b7db0f4996f4d9d5e2a5",
|
||||
"ws_url": "ws://127.0.0.1:9000"
|
||||
},
|
||||
{
|
||||
"name": "Dunia Cybercity",
|
||||
"public_key": "03d97b1a357c3ceb2f0eb78f8e2c71beda9190db5cb7e5112150105132effb35e0",
|
||||
"secret_key": "4fad664608e8de55f0e5e1712241e71dc0864be125bc8633e50601fca8040791",
|
||||
"worker_queue": "rhai_tasks:03d97b1a357c3ceb2f0eb78f8e2c71beda9190db5cb7e5112150105132effb35e0",
|
||||
"ws_url": "ws://127.0.0.1:9001"
|
||||
},
|
||||
{
|
||||
"name": "Sikana",
|
||||
"public_key": "0389595b28cfa98b45fa3c222db79892f3face65e7ef06d44e35d642967e45ed6e",
|
||||
"secret_key": "fd59ddbf0d0bada725c911dc7e3317754ac552aa1ac84cfcb899bdfe3591e1f4",
|
||||
"worker_queue": "rhai_tasks:0389595b28cfa98b45fa3c222db79892f3face65e7ef06d44e35d642967e45ed6e",
|
||||
"ws_url": "ws://127.0.0.1:9002"
|
||||
},
|
||||
{
|
||||
"name": "Threefold",
|
||||
"public_key": "03270f06ee4a7d42a9f6c22c9a7d6d0138cd15d4fa659026e2e6572fc6c6a6ea18",
|
||||
"secret_key": "e204c0215bec80f74df49ea5b1592de3c6739cced339ace801bb7e158eb62231",
|
||||
"worker_queue": "rhai_tasks:03270f06ee4a7d42a9f6c22c9a7d6d0138cd15d4fa659026e2e6572fc6c6a6ea18",
|
||||
"ws_url": "ws://127.0.0.1:9003"
|
||||
},
|
||||
{
|
||||
"name": "Mbweni",
|
||||
"public_key": "02724cf23e4ac95d0f14984f55c6955b3ca5ab2275d7ac2a2e4baf3596caf8606c",
|
||||
"secret_key": "3c013e2e5f64692f044d17233e5fabdb0577629f898359115e69c3e594d5f43e",
|
||||
"worker_queue": "rhai_tasks:02724cf23e4ac95d0f14984f55c6955b3ca5ab2275d7ac2a2e4baf3596caf8606c",
|
||||
"ws_url": "ws://127.0.0.1:9004"
|
||||
},
|
||||
{
|
||||
"name": "Geomind",
|
||||
"public_key": "030d8ceb47d445c92b7c3f13e9e134eebcb1d83beed424425f734164544eb58eed",
|
||||
"secret_key": "dbd6dd383a6f56042710f72ce2ac68266650bbfb61432cdd139e98043b693e7c",
|
||||
"worker_queue": "rhai_tasks:030d8ceb47d445c92b7c3f13e9e134eebcb1d83beed424425f734164544eb58eed",
|
||||
"ws_url": "ws://127.0.0.1:9005"
|
||||
},
|
||||
{
|
||||
"name": "Freezone",
|
||||
"public_key": "02dd21025c1d47421eccc2264c87538d41126da772a9a3f0e7226807fed89c9971",
|
||||
"secret_key": "0c0c6b02c20fcd4ccfb2afeae249979ddd623e6f6edd17af4a9a5a19bc1b15ae",
|
||||
"worker_queue": "rhai_tasks:02dd21025c1d47421eccc2264c87538d41126da772a9a3f0e7226807fed89c9971",
|
||||
"ws_url": "ws://127.0.0.1:9006"
|
||||
}
|
||||
]
|
249
examples/ourworld/scripts/dunia_cybercity.rhai
Normal file
249
examples/ourworld/scripts/dunia_cybercity.rhai
Normal file
@@ -0,0 +1,249 @@
|
||||
// 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("https://images.unsplash.com/photo-1569163139394-de4e4f43e4e3?w=1200", "Global Temperature Rise")
|
||||
.add_slide("https://images.unsplash.com/photo-1578662996442-48f60103fc96?w=1200", "Melting Ice Caps")
|
||||
.add_slide("https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1200", "Extreme Weather Events")
|
||||
.add_slide("https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=1200", "Renewable Energy Solutions")
|
||||
.add_slide("https://images.unsplash.com/photo-1497436072909-f5e4be1dffea?w=1200", "Sustainable Transportation"));
|
||||
|
||||
let innovation_slides = save_slides(new_slides()
|
||||
.title("Innovation Showcase")
|
||||
.description("Cutting-edge technologies for a sustainable future")
|
||||
.add_slide("https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=1200", "AI and Machine Learning")
|
||||
.add_slide("https://images.unsplash.com/photo-1639322537228-f710d846310a?w=1200", "Blockchain Technology")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092160562-40aa08e78837?w=1200", "IoT and Smart Cities")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?w=1200", "Quantum Computing")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092162384-8987c1d64718?w=1200", "Biotechnology Advances"));
|
||||
|
||||
let nature_slides = save_slides(new_slides()
|
||||
.title("Biodiversity Gallery")
|
||||
.description("Celebrating Earth's incredible biodiversity")
|
||||
.add_slide("https://images.unsplash.com/photo-1564349683136-77e08dba1ef7?w=1200", "Tropical Rainforest")
|
||||
.add_slide("https://images.unsplash.com/photo-1559827260-dc66d52bef19?w=1200", "Coral Reef Ecosystem")
|
||||
.add_slide("https://images.unsplash.com/photo-1551698618-1dfe5d97d256?w=1200", "Arctic Wildlife")
|
||||
.add_slide("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200", "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");
|
249
examples/ourworld/scripts/freezone.rhai
Normal file
249
examples/ourworld/scripts/freezone.rhai
Normal file
@@ -0,0 +1,249 @@
|
||||
// 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("https://images.unsplash.com/photo-1569163139394-de4e4f43e4e3?w=1200", "Global Temperature Rise")
|
||||
.add_slide("https://images.unsplash.com/photo-1578662996442-48f60103fc96?w=1200", "Melting Ice Caps")
|
||||
.add_slide("https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1200", "Extreme Weather Events")
|
||||
.add_slide("https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=1200", "Renewable Energy Solutions")
|
||||
.add_slide("https://images.unsplash.com/photo-1497436072909-f5e4be1dffea?w=1200", "Sustainable Transportation"));
|
||||
|
||||
let innovation_slides = save_slides(new_slides()
|
||||
.title("Innovation Showcase")
|
||||
.description("Cutting-edge technologies for a sustainable future")
|
||||
.add_slide("https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=1200", "AI and Machine Learning")
|
||||
.add_slide("https://images.unsplash.com/photo-1639322537228-f710d846310a?w=1200", "Blockchain Technology")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092160562-40aa08e78837?w=1200", "IoT and Smart Cities")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?w=1200", "Quantum Computing")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092162384-8987c1d64718?w=1200", "Biotechnology Advances"));
|
||||
|
||||
let nature_slides = save_slides(new_slides()
|
||||
.title("Biodiversity Gallery")
|
||||
.description("Celebrating Earth's incredible biodiversity")
|
||||
.add_slide("https://images.unsplash.com/photo-1564349683136-77e08dba1ef7?w=1200", "Tropical Rainforest")
|
||||
.add_slide("https://images.unsplash.com/photo-1559827260-dc66d52bef19?w=1200", "Coral Reef Ecosystem")
|
||||
.add_slide("https://images.unsplash.com/photo-1551698618-1dfe5d97d256?w=1200", "Arctic Wildlife")
|
||||
.add_slide("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200", "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");
|
249
examples/ourworld/scripts/geomind.rhai
Normal file
249
examples/ourworld/scripts/geomind.rhai
Normal file
@@ -0,0 +1,249 @@
|
||||
// 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("https://images.unsplash.com/photo-1569163139394-de4e4f43e4e3?w=1200", "Global Temperature Rise")
|
||||
.add_slide("https://images.unsplash.com/photo-1578662996442-48f60103fc96?w=1200", "Melting Ice Caps")
|
||||
.add_slide("https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1200", "Extreme Weather Events")
|
||||
.add_slide("https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=1200", "Renewable Energy Solutions")
|
||||
.add_slide("https://images.unsplash.com/photo-1497436072909-f5e4be1dffea?w=1200", "Sustainable Transportation"));
|
||||
|
||||
let innovation_slides = save_slides(new_slides()
|
||||
.title("Innovation Showcase")
|
||||
.description("Cutting-edge technologies for a sustainable future")
|
||||
.add_slide("https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=1200", "AI and Machine Learning")
|
||||
.add_slide("https://images.unsplash.com/photo-1639322537228-f710d846310a?w=1200", "Blockchain Technology")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092160562-40aa08e78837?w=1200", "IoT and Smart Cities")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?w=1200", "Quantum Computing")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092162384-8987c1d64718?w=1200", "Biotechnology Advances"));
|
||||
|
||||
let nature_slides = save_slides(new_slides()
|
||||
.title("Biodiversity Gallery")
|
||||
.description("Celebrating Earth's incredible biodiversity")
|
||||
.add_slide("https://images.unsplash.com/photo-1564349683136-77e08dba1ef7?w=1200", "Tropical Rainforest")
|
||||
.add_slide("https://images.unsplash.com/photo-1559827260-dc66d52bef19?w=1200", "Coral Reef Ecosystem")
|
||||
.add_slide("https://images.unsplash.com/photo-1551698618-1dfe5d97d256?w=1200", "Arctic Wildlife")
|
||||
.add_slide("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200", "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");
|
249
examples/ourworld/scripts/mbweni.rhai
Normal file
249
examples/ourworld/scripts/mbweni.rhai
Normal file
@@ -0,0 +1,249 @@
|
||||
// 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("https://images.unsplash.com/photo-1569163139394-de4e4f43e4e3?w=1200", "Global Temperature Rise")
|
||||
.add_slide("https://images.unsplash.com/photo-1578662996442-48f60103fc96?w=1200", "Melting Ice Caps")
|
||||
.add_slide("https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1200", "Extreme Weather Events")
|
||||
.add_slide("https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=1200", "Renewable Energy Solutions")
|
||||
.add_slide("https://images.unsplash.com/photo-1497436072909-f5e4be1dffea?w=1200", "Sustainable Transportation"));
|
||||
|
||||
let innovation_slides = save_slides(new_slides()
|
||||
.title("Innovation Showcase")
|
||||
.description("Cutting-edge technologies for a sustainable future")
|
||||
.add_slide("https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=1200", "AI and Machine Learning")
|
||||
.add_slide("https://images.unsplash.com/photo-1639322537228-f710d846310a?w=1200", "Blockchain Technology")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092160562-40aa08e78837?w=1200", "IoT and Smart Cities")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?w=1200", "Quantum Computing")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092162384-8987c1d64718?w=1200", "Biotechnology Advances"));
|
||||
|
||||
let nature_slides = save_slides(new_slides()
|
||||
.title("Biodiversity Gallery")
|
||||
.description("Celebrating Earth's incredible biodiversity")
|
||||
.add_slide("https://images.unsplash.com/photo-1564349683136-77e08dba1ef7?w=1200", "Tropical Rainforest")
|
||||
.add_slide("https://images.unsplash.com/photo-1559827260-dc66d52bef19?w=1200", "Coral Reef Ecosystem")
|
||||
.add_slide("https://images.unsplash.com/photo-1551698618-1dfe5d97d256?w=1200", "Arctic Wildlife")
|
||||
.add_slide("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200", "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");
|
255
examples/ourworld/scripts/ourworld.rhai
Normal file
255
examples/ourworld/scripts/ourworld.rhai
Normal file
@@ -0,0 +1,255 @@
|
||||
// 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")
|
||||
.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("https://images.unsplash.com/photo-1569163139394-de4e4f43e4e3?w=1200", "Global Temperature Rise")
|
||||
.add_slide("https://images.unsplash.com/photo-1578662996442-48f60103fc96?w=1200", "Melting Ice Caps")
|
||||
.add_slide("https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1200", "Extreme Weather Events")
|
||||
.add_slide("https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=1200", "Renewable Energy Solutions")
|
||||
.add_slide("https://images.unsplash.com/photo-1497436072909-f5e4be1dffea?w=1200", "Sustainable Transportation"));
|
||||
|
||||
let innovation_slides = save_slides(new_slides()
|
||||
.title("Innovation Showcase")
|
||||
.description("Cutting-edge technologies for a sustainable future")
|
||||
.add_slide("https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=1200", "AI and Machine Learning")
|
||||
.add_slide("https://images.unsplash.com/photo-1639322537228-f710d846310a?w=1200", "Blockchain Technology")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092160562-40aa08e78837?w=1200", "IoT and Smart Cities")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?w=1200", "Quantum Computing")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092162384-8987c1d64718?w=1200", "Biotechnology Advances"));
|
||||
|
||||
let nature_slides = save_slides(new_slides()
|
||||
.title("Biodiversity Gallery")
|
||||
.description("Celebrating Earth's incredible biodiversity")
|
||||
.add_slide("https://images.unsplash.com/photo-1564349683136-77e08dba1ef7?w=1200", "Tropical Rainforest")
|
||||
.add_slide("https://images.unsplash.com/photo-1559827260-dc66d52bef19?w=1200", "Coral Reef Ecosystem")
|
||||
.add_slide("https://images.unsplash.com/photo-1551698618-1dfe5d97d256?w=1200", "Arctic Wildlife")
|
||||
.add_slide("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200", "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");
|
249
examples/ourworld/scripts/sikana.rhai
Normal file
249
examples/ourworld/scripts/sikana.rhai
Normal file
@@ -0,0 +1,249 @@
|
||||
// OurWorld Circle and Library Data
|
||||
|
||||
new_circle()
|
||||
.title("Sikana")
|
||||
.description("Creating a better world.")
|
||||
.ws_url("ws://localhost:8092/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("https://images.unsplash.com/photo-1569163139394-de4e4f43e4e3?w=1200", "Global Temperature Rise")
|
||||
.add_slide("https://images.unsplash.com/photo-1578662996442-48f60103fc96?w=1200", "Melting Ice Caps")
|
||||
.add_slide("https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1200", "Extreme Weather Events")
|
||||
.add_slide("https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=1200", "Renewable Energy Solutions")
|
||||
.add_slide("https://images.unsplash.com/photo-1497436072909-f5e4be1dffea?w=1200", "Sustainable Transportation"));
|
||||
|
||||
let innovation_slides = save_slides(new_slides()
|
||||
.title("Innovation Showcase")
|
||||
.description("Cutting-edge technologies for a sustainable future")
|
||||
.add_slide("https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=1200", "AI and Machine Learning")
|
||||
.add_slide("https://images.unsplash.com/photo-1639322537228-f710d846310a?w=1200", "Blockchain Technology")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092160562-40aa08e78837?w=1200", "IoT and Smart Cities")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?w=1200", "Quantum Computing")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092162384-8987c1d64718?w=1200", "Biotechnology Advances"));
|
||||
|
||||
let nature_slides = save_slides(new_slides()
|
||||
.title("Biodiversity Gallery")
|
||||
.description("Celebrating Earth's incredible biodiversity")
|
||||
.add_slide("https://images.unsplash.com/photo-1564349683136-77e08dba1ef7?w=1200", "Tropical Rainforest")
|
||||
.add_slide("https://images.unsplash.com/photo-1559827260-dc66d52bef19?w=1200", "Coral Reef Ecosystem")
|
||||
.add_slide("https://images.unsplash.com/photo-1551698618-1dfe5d97d256?w=1200", "Arctic Wildlife")
|
||||
.add_slide("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200", "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");
|
249
examples/ourworld/scripts/threefold.rhai
Normal file
249
examples/ourworld/scripts/threefold.rhai
Normal file
@@ -0,0 +1,249 @@
|
||||
// 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("https://images.unsplash.com/photo-1569163139394-de4e4f43e4e3?w=1200", "Global Temperature Rise")
|
||||
.add_slide("https://images.unsplash.com/photo-1578662996442-48f60103fc96?w=1200", "Melting Ice Caps")
|
||||
.add_slide("https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1200", "Extreme Weather Events")
|
||||
.add_slide("https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=1200", "Renewable Energy Solutions")
|
||||
.add_slide("https://images.unsplash.com/photo-1497436072909-f5e4be1dffea?w=1200", "Sustainable Transportation"));
|
||||
|
||||
let innovation_slides = save_slides(new_slides()
|
||||
.title("Innovation Showcase")
|
||||
.description("Cutting-edge technologies for a sustainable future")
|
||||
.add_slide("https://images.unsplash.com/photo-1518709268805-4e9042af2176?w=1200", "AI and Machine Learning")
|
||||
.add_slide("https://images.unsplash.com/photo-1639322537228-f710d846310a?w=1200", "Blockchain Technology")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092160562-40aa08e78837?w=1200", "IoT and Smart Cities")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092918056-0c4c3acd3789?w=1200", "Quantum Computing")
|
||||
.add_slide("https://images.unsplash.com/photo-1581092162384-8987c1d64718?w=1200", "Biotechnology Advances"));
|
||||
|
||||
let nature_slides = save_slides(new_slides()
|
||||
.title("Biodiversity Gallery")
|
||||
.description("Celebrating Earth's incredible biodiversity")
|
||||
.add_slide("https://images.unsplash.com/photo-1564349683136-77e08dba1ef7?w=1200", "Tropical Rainforest")
|
||||
.add_slide("https://images.unsplash.com/photo-1559827260-dc66d52bef19?w=1200", "Coral Reef Ecosystem")
|
||||
.add_slide("https://images.unsplash.com/photo-1551698618-1dfe5d97d256?w=1200", "Arctic Wildlife")
|
||||
.add_slide("https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=1200", "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");
|
132
examples/server_e2e_rhai_flow.rs
Normal file
132
examples/server_e2e_rhai_flow.rs
Normal file
@@ -0,0 +1,132 @@
|
||||
use std::process::{Command, Child, Stdio};
|
||||
use std::time::Duration;
|
||||
use std::path::PathBuf;
|
||||
use tokio::time::sleep;
|
||||
// tokio_tungstenite and direct futures_util for ws stream are no longer needed here
|
||||
// use tokio_tungstenite::{connect_async, tungstenite::protocol::Message as WsMessage};
|
||||
// use futures_util::{StreamExt, SinkExt};
|
||||
// use serde_json::Value; // No longer needed as CircleWsClient::play takes String
|
||||
// Uuid is handled by CircleWsClient internally for requests.
|
||||
// use uuid::Uuid;
|
||||
use circle_client_ws::CircleWsClientBuilder;
|
||||
// PlayResultClient and CircleWsClientError will be resolved via the client methods if needed,
|
||||
// or this indicates they were not actually needed in the scope of this file directly.
|
||||
// The compiler warning suggests they are unused from this specific import.
|
||||
|
||||
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";
|
||||
|
||||
// RAII guard for cleaning up child processes
|
||||
struct ChildProcessGuard {
|
||||
child: Child,
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl ChildProcessGuard {
|
||||
fn new(child: Child, name: String) -> Self {
|
||||
Self { child, name }
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for ChildProcessGuard {
|
||||
fn drop(&mut self) {
|
||||
log::info!("Cleaning up {} process (PID: {})...", self.name, self.child.id());
|
||||
match self.child.kill() {
|
||||
Ok(_) => {
|
||||
log::info!("Successfully sent kill signal to {} (PID: {}).", self.name, self.child.id());
|
||||
// Optionally wait for a short period or check status
|
||||
match self.child.wait() {
|
||||
Ok(status) => log::info!("{} (PID: {}) exited with status: {}", self.name, self.child.id(), status),
|
||||
Err(e) => log::warn!("Error waiting for {} (PID: {}): {}", self.name, self.child.id(), e),
|
||||
}
|
||||
}
|
||||
Err(e) => log::error!("Failed to kill {} (PID: {}): {}", self.name, self.child.id(), e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn find_target_dir() -> Result<PathBuf, String> {
|
||||
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").map_err(|_| "CARGO_MANIFEST_DIR not set".to_string())?;
|
||||
let workspace_root = PathBuf::from(manifest_dir).parent().ok_or("Failed to get workspace root")?.to_path_buf();
|
||||
Ok(workspace_root.join("target").join("debug"))
|
||||
}
|
||||
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
|
||||
|
||||
let target_dir = find_target_dir().map_err(|e| {
|
||||
log::error!("Could not determine target directory: {}", e);
|
||||
e
|
||||
})?;
|
||||
|
||||
let rhai_worker_path = target_dir.join(RHAI_WORKER_BIN_NAME);
|
||||
let circle_server_ws_path = target_dir.join(CIRCLE_SERVER_WS_BIN_NAME);
|
||||
|
||||
if !rhai_worker_path.exists() {
|
||||
return Err(format!("Rhai worker binary not found at {:?}. Ensure it's built (e.g., cargo build --package rhai_worker)", rhai_worker_path).into());
|
||||
}
|
||||
if !circle_server_ws_path.exists() {
|
||||
return Err(format!("Circle server WS binary not found at {:?}. Ensure it's built (e.g., cargo build --package circle_server_ws)", circle_server_ws_path).into());
|
||||
}
|
||||
|
||||
log::info!("Starting {}...", RHAI_WORKER_BIN_NAME);
|
||||
let rhai_worker_process = Command::new(&rhai_worker_path)
|
||||
.args(["--circles", TEST_CIRCLE_NAME])
|
||||
.stdout(Stdio::piped()) // Capture stdout
|
||||
.stderr(Stdio::piped()) // Capture stderr
|
||||
.spawn()?;
|
||||
let _rhai_worker_guard = ChildProcessGuard::new(rhai_worker_process, RHAI_WORKER_BIN_NAME.to_string());
|
||||
log::info!("{} started with PID {}", RHAI_WORKER_BIN_NAME, _rhai_worker_guard.child.id());
|
||||
|
||||
log::info!("Starting {} for circle '{}' on port {}...", CIRCLE_SERVER_WS_BIN_NAME, TEST_CIRCLE_NAME, TEST_SERVER_PORT);
|
||||
let circle_server_process = Command::new(&circle_server_ws_path)
|
||||
.args(["--port", &TEST_SERVER_PORT.to_string(), "--circle-name", TEST_CIRCLE_NAME])
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()?;
|
||||
let _circle_server_guard = ChildProcessGuard::new(circle_server_process, CIRCLE_SERVER_WS_BIN_NAME.to_string());
|
||||
log::info!("{} started with PID {}", CIRCLE_SERVER_WS_BIN_NAME, _circle_server_guard.child.id());
|
||||
|
||||
// Give servers a moment to start
|
||||
sleep(Duration::from_secs(3)).await; // Increased sleep
|
||||
|
||||
let ws_url_str = format!("ws://127.0.0.1:{}/ws", TEST_SERVER_PORT);
|
||||
|
||||
log::info!("Creating CircleWsClient for {}...", ws_url_str);
|
||||
let mut client = CircleWsClientBuilder::new(ws_url_str.clone()).build();
|
||||
|
||||
log::info!("Connecting CircleWsClient...");
|
||||
client.connect().await.map_err(|e| {
|
||||
log::error!("CircleWsClient connection failed: {}", e);
|
||||
format!("CircleWsClient connection failed: {}", e)
|
||||
})?;
|
||||
log::info!("CircleWsClient connected successfully.");
|
||||
|
||||
let script_to_run = "let a = 5; let b = 10; print(\"E2E Rhai: \" + (a+b)); a + b";
|
||||
|
||||
log::info!("Sending 'play' request via CircleWsClient for script: '{}'", script_to_run);
|
||||
|
||||
match client.play(script_to_run.to_string()).await {
|
||||
Ok(play_result) => {
|
||||
log::info!("Received play result: {:?}", play_result);
|
||||
assert_eq!(play_result.output, "15");
|
||||
log::info!("E2E Test Passed! Correct output '15' received via CircleWsClient.");
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("CircleWsClient play request failed: {}", e);
|
||||
return Err(format!("CircleWsClient play request failed: {}", e).into());
|
||||
}
|
||||
}
|
||||
|
||||
log::info!("Disconnecting CircleWsClient...");
|
||||
client.disconnect().await;
|
||||
log::info!("CircleWsClient disconnected.");
|
||||
|
||||
log::info!("E2E Rhai flow example completed successfully.");
|
||||
// Guards will automatically clean up child processes when they go out of scope here
|
||||
Ok(())
|
||||
}
|
130
examples/server_timeout_demonstration.rs
Normal file
130
examples/server_timeout_demonstration.rs
Normal file
@@ -0,0 +1,130 @@
|
||||
// Example: Timeout Demonstration for circle_server_ws
|
||||
//
|
||||
// This example demonstrates how circle_server_ws handles Rhai scripts that exceed
|
||||
// the configured execution timeout (default 30 seconds).
|
||||
//
|
||||
// This example will attempt to start its own instance of circle_server_ws.
|
||||
// Ensure circle_server_ws is compiled (cargo build --bin circle_server_ws).
|
||||
|
||||
use circle_client_ws::CircleWsClientBuilder;
|
||||
use tokio::time::{sleep, Duration};
|
||||
use std::process::{Command, Child, Stdio};
|
||||
use std::path::PathBuf;
|
||||
|
||||
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 SCRIPT_TIMEOUT_SECONDS: u64 = 30; // This is the server-side timeout we expect to hit
|
||||
|
||||
// RAII guard for cleaning up child processes
|
||||
struct ChildProcessGuard {
|
||||
child: Child,
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl ChildProcessGuard {
|
||||
fn new(child: Child, name: String) -> Self {
|
||||
log::info!("{} process started with PID: {}", name, child.id());
|
||||
Self { child, name }
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for ChildProcessGuard {
|
||||
fn drop(&mut self) {
|
||||
log::info!("Cleaning up {} process (PID: {})...", self.name, self.child.id());
|
||||
match self.child.kill() {
|
||||
Ok(_) => {
|
||||
log::info!("Successfully sent kill signal to {} (PID: {}).", self.name, self.child.id());
|
||||
match self.child.wait() {
|
||||
Ok(status) => log::info!("{} (PID: {}) exited with status: {}", self.name, self.child.id(), status),
|
||||
Err(e) => log::warn!("Error waiting for {} (PID: {}): {}", self.name, self.child.id(), e),
|
||||
}
|
||||
}
|
||||
Err(e) => log::error!("Failed to kill {} (PID: {}): {}", self.name, self.child.id(), e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn find_target_bin_path(bin_name: &str) -> Result<PathBuf, String> {
|
||||
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").map_err(|_| "CARGO_MANIFEST_DIR not set".to_string())?;
|
||||
let workspace_root = PathBuf::from(manifest_dir).parent().ok_or("Failed to get workspace root")?.to_path_buf();
|
||||
let bin_path = workspace_root.join("target").join("debug").join(bin_name);
|
||||
if !bin_path.exists() {
|
||||
return Err(format!("Binary '{}' not found at {:?}. Ensure it's built.", bin_name, bin_path));
|
||||
}
|
||||
Ok(bin_path)
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
|
||||
|
||||
let server_bin_path = find_target_bin_path(CIRCLE_SERVER_WS_BIN_NAME)?;
|
||||
log::info!("Found server binary at: {:?}", server_bin_path);
|
||||
|
||||
log::info!("Starting {} for circle '{}' on port {}...", CIRCLE_SERVER_WS_BIN_NAME, CIRCLE_NAME_FOR_EXAMPLE, EXAMPLE_SERVER_PORT);
|
||||
let server_process = Command::new(&server_bin_path)
|
||||
.args([
|
||||
"--port", &EXAMPLE_SERVER_PORT.to_string(),
|
||||
"--circle-name", CIRCLE_NAME_FOR_EXAMPLE
|
||||
])
|
||||
.stdout(Stdio::piped()) // Pipe stdout to keep terminal clean, or Stdio::inherit() to see server logs
|
||||
.stderr(Stdio::piped()) // Pipe stderr as well
|
||||
.spawn()
|
||||
.map_err(|e| format!("Failed to start {}: {}. Ensure it is built.", CIRCLE_SERVER_WS_BIN_NAME, e))?;
|
||||
|
||||
let _server_guard = ChildProcessGuard::new(server_process, CIRCLE_SERVER_WS_BIN_NAME.to_string());
|
||||
|
||||
log::info!("Giving the server a moment to start up...");
|
||||
sleep(Duration::from_secs(3)).await; // Wait for server to initialize
|
||||
|
||||
log::info!("Attempting to connect to WebSocket server at: {}", WS_URL);
|
||||
let mut client = CircleWsClientBuilder::new(WS_URL.to_string()).build();
|
||||
|
||||
log::info!("Connecting client...");
|
||||
if let Err(e) = client.connect().await {
|
||||
log::error!("Failed to connect to WebSocket server: {}", e);
|
||||
log::error!("Please check server logs if it failed to start correctly.");
|
||||
return Err(e.into());
|
||||
}
|
||||
log::info!("Client connected successfully.");
|
||||
|
||||
// This Rhai script is designed to run for much longer than the typical server timeout.
|
||||
let long_running_script = "
|
||||
let mut x = 0;
|
||||
for i in 0..9999999999 { // Extremely large loop
|
||||
x = x + i;
|
||||
}
|
||||
// This part should not be reached if timeout works correctly.
|
||||
print(x);
|
||||
x
|
||||
".to_string();
|
||||
|
||||
log::info!("Sending long-running script (expected to time out on server after ~{}s)...", SCRIPT_TIMEOUT_SECONDS);
|
||||
|
||||
match client.play(long_running_script).await {
|
||||
Ok(play_result) => {
|
||||
log::warn!("Received unexpected success from play request: {:?}", play_result);
|
||||
log::warn!("This might indicate the script finished faster than expected, or the timeout didn't trigger.");
|
||||
}
|
||||
Err(e) => {
|
||||
log::info!("Received expected error from play request: {}", e);
|
||||
log::info!("This demonstrates the server timing out the script execution.");
|
||||
// You can further inspect the error details if CircleWsClientError provides them.
|
||||
// For example, if e.to_string().contains('code: -32002' or 'timed out'.
|
||||
if e.to_string().contains("timed out") || e.to_string().contains("-32002") {
|
||||
log::info!("Successfully received timeout error from the server!");
|
||||
} else {
|
||||
log::warn!("Received an error, but it might not be the expected timeout error: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log::info!("Disconnecting client...");
|
||||
client.disconnect().await;
|
||||
log::info!("Client disconnected.");
|
||||
log::info!("Timeout demonstration example finished.");
|
||||
|
||||
Ok(())
|
||||
}
|
Reference in New Issue
Block a user