...
This commit is contained in:
1
examples/web/.gitignore
vendored
Normal file
1
examples/web/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
build
|
||||
77
examples/web/cfg/docusaurus_example_config.heroscript
Normal file
77
examples/web/cfg/docusaurus_example_config.heroscript
Normal file
@@ -0,0 +1,77 @@
|
||||
!!docusaurus.config
|
||||
name:"my-documentation"
|
||||
title:"My Documentation Site"
|
||||
tagline:"Documentation made simple with V and Docusaurus"
|
||||
url:"https://docs.example.com"
|
||||
url_home:"docs/"
|
||||
base_url:"/"
|
||||
favicon:"img/favicon.png"
|
||||
image:"img/hero.png"
|
||||
copyright:"© 2025 Example Organization"
|
||||
|
||||
!!docusaurus.config_meta
|
||||
description:"Comprehensive documentation for our amazing project"
|
||||
image:"https://docs.example.com/img/social-card.png"
|
||||
title:"My Documentation | Official Docs"
|
||||
|
||||
!!docusaurus.ssh_connection
|
||||
name:"production"
|
||||
host:"example.com"
|
||||
login:"deploy"
|
||||
port:22
|
||||
key_path:"~/.ssh/id_rsa"
|
||||
|
||||
!!docusaurus.build_dest
|
||||
ssh_name:"production"
|
||||
path:"/var/www/docs"
|
||||
|
||||
!!docusaurus.navbar
|
||||
title:"My Project"
|
||||
|
||||
!!docusaurus.navbar_item
|
||||
label:"Documentation"
|
||||
href:"/docs"
|
||||
position:"left"
|
||||
|
||||
!!docusaurus.navbar_item
|
||||
label:"API"
|
||||
href:"/api"
|
||||
position:"left"
|
||||
|
||||
!!docusaurus.navbar_item
|
||||
label:"GitHub"
|
||||
href:"https://github.com/example/repo"
|
||||
position:"right"
|
||||
|
||||
!!docusaurus.footer
|
||||
style:"dark"
|
||||
|
||||
!!docusaurus.footer_item
|
||||
title:"Documentation"
|
||||
label:"Introduction"
|
||||
to:"/docs"
|
||||
|
||||
!!docusaurus.footer_item
|
||||
title:"Documentation"
|
||||
label:"API Reference"
|
||||
to:"/api"
|
||||
|
||||
!!docusaurus.footer_item
|
||||
title:"Community"
|
||||
label:"GitHub"
|
||||
href:"https://github.com/example/repo"
|
||||
|
||||
!!docusaurus.footer_item
|
||||
title:"Community"
|
||||
label:"Discord"
|
||||
href:"https://discord.gg/example"
|
||||
|
||||
!!docusaurus.footer_item
|
||||
title:"More"
|
||||
label:"Blog"
|
||||
href:"https://blog.example.com"
|
||||
|
||||
!!docusaurus.import_source
|
||||
url:"https://github.com/example/external-docs"
|
||||
dest:"external"
|
||||
replace:"PROJECT_NAME:My Project, VERSION:1.0.0"
|
||||
125
examples/web/doctreeclient_example.vsh
Executable file
125
examples/web/doctreeclient_example.vsh
Executable file
@@ -0,0 +1,125 @@
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.web.doctreeclient
|
||||
import freeflowuniverse.herolib.data.doctree
|
||||
import os
|
||||
|
||||
println('DocTreeClient Example')
|
||||
println('=====================')
|
||||
|
||||
// Step 1: First, populate Redis with doctree data
|
||||
println('\n1. Setting up doctree data in Redis...')
|
||||
|
||||
|
||||
tree.scan(
|
||||
git_url: 'https://git.ourworld.tf/tfgrid/docs_tfgrid4/src/branch/main/collections'
|
||||
git_pull: false
|
||||
)!
|
||||
|
||||
tree.export(
|
||||
destination: '/tmp/mdexport'
|
||||
reset: true
|
||||
exclude_errors: false
|
||||
)!
|
||||
|
||||
println('Doctree data populated in Redis')
|
||||
|
||||
// Step 2: Create a DocTreeClient instance
|
||||
println('\n2. Creating DocTreeClient...')
|
||||
mut client := doctreeclient.new()!
|
||||
println('DocTreeClient created successfully')
|
||||
|
||||
// Step 3: List all collections
|
||||
println('\n3. Listing collections:')
|
||||
collections := client.list_collections()!
|
||||
println('Found ${collections.len} collections: ${collections}')
|
||||
|
||||
if collections.len == 0 {
|
||||
println('No collections found. Example cannot continue.')
|
||||
return
|
||||
}
|
||||
|
||||
// Step 4: Use the example_docs collection
|
||||
collection_name := 'example_docs'
|
||||
println('\n4. Using collection: ${collection_name}')
|
||||
|
||||
// Step 5: List pages in the collection
|
||||
println('\n5. Listing pages:')
|
||||
pages := client.list_pages(collection_name)!
|
||||
println('Found ${pages.len} pages: ${pages}')
|
||||
|
||||
// Step 6: Get content of a page
|
||||
if pages.len > 0 {
|
||||
page_name := 'introduction'
|
||||
println('\n6. Getting content of page: ${page_name}')
|
||||
|
||||
// Check if page exists
|
||||
exists := client.page_exists(collection_name, page_name)
|
||||
println('Page exists: ${exists}')
|
||||
|
||||
// Get page path
|
||||
page_path := client.get_page_path(collection_name, page_name)!
|
||||
println('Page path: ${page_path}')
|
||||
|
||||
// Get page content
|
||||
content := client.get_page_content(collection_name, page_name)!
|
||||
println('Page content:')
|
||||
println('---')
|
||||
println(content)
|
||||
println('---')
|
||||
}
|
||||
|
||||
// Step 7: List images in the collection
|
||||
println('\n7. Listing images:')
|
||||
images := client.list_images(collection_name)!
|
||||
println('Found ${images.len} images: ${images}')
|
||||
|
||||
// Step 8: Get image path
|
||||
if images.len > 0 {
|
||||
image_name := images[0]
|
||||
println('\n8. Getting path of image: ${image_name}')
|
||||
|
||||
// Check if image exists
|
||||
exists := client.image_exists(collection_name, image_name)
|
||||
println('Image exists: ${exists}')
|
||||
|
||||
// Get image path
|
||||
image_path := client.get_image_path(collection_name, image_name)!
|
||||
println('Image path: ${image_path}')
|
||||
}
|
||||
|
||||
// Step 9: List files in the collection
|
||||
println('\n9. Listing files:')
|
||||
files := client.list_files(collection_name)!
|
||||
println('Found ${files.len} files: ${files}')
|
||||
|
||||
// Step 10: Get file path
|
||||
if files.len > 0 {
|
||||
file_name := files[0]
|
||||
println('\n10. Getting path of file: ${file_name}')
|
||||
|
||||
// Check if file exists
|
||||
exists := client.file_exists(collection_name, file_name)
|
||||
println('File exists: ${exists}')
|
||||
|
||||
// Get file path
|
||||
file_path := client.get_file_path(collection_name, file_name)!
|
||||
println('File path: ${file_path}')
|
||||
}
|
||||
|
||||
// Step 11: Error handling example
|
||||
println('\n11. Error handling example:')
|
||||
println('Trying to access a non-existent page...')
|
||||
|
||||
non_existent_page := 'non_existent_page'
|
||||
content := client.get_page_content(collection_name, non_existent_page) or {
|
||||
println('Error caught: ${err}')
|
||||
'Error content'
|
||||
}
|
||||
|
||||
// Step 12: Clean up
|
||||
println('\n12. Cleaning up...')
|
||||
os.rmdir_all(example_dir) or { println('Failed to remove example directory: ${err}') }
|
||||
os.rmdir_all(export_dir) or { println('Failed to remove export directory: ${err}') }
|
||||
|
||||
println('\nExample completed successfully!')
|
||||
8
examples/web/docusaurus_example.vsh
Executable file
8
examples/web/docusaurus_example.vsh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.web.docusaurus
|
||||
|
||||
// Create a new docusaurus factory
|
||||
mut docs := docusaurus.new(
|
||||
build_path: '/tmp/docusaurus_build'
|
||||
)!
|
||||
91
examples/web/docusaurus_example_cli.sh
Executable file
91
examples/web/docusaurus_example_cli.sh
Executable file
@@ -0,0 +1,91 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Exit script on any error
|
||||
set -e
|
||||
|
||||
echo "Starting Docusaurus Example with Hero CLI"
|
||||
|
||||
# Define the source directory for the Docusaurus site content
|
||||
# Using a different name (_cli) to avoid conflicts with the previous example
|
||||
SOURCE_DIR="${HOME}/hero/var/docusaurus_demo_src_cli"
|
||||
DOCS_SUBDIR="${SOURCE_DIR}/docs"
|
||||
|
||||
# Create the site source directory and the docs subdirectory if they don't exist
|
||||
echo "Creating site source directory: ${SOURCE_DIR}"
|
||||
mkdir -p "${DOCS_SUBDIR}"
|
||||
|
||||
# --- Create Sample Markdown Content ---
|
||||
# The 'hero docusaurus' command doesn't automatically create content,
|
||||
# so we do it here like the V example script did.
|
||||
|
||||
echo "Creating sample markdown content..."
|
||||
|
||||
# Create intro.md
|
||||
# Using 'EOF' to prevent shell expansion within the heredoc
|
||||
cat > "${DOCS_SUBDIR}/intro.md" << 'EOF'
|
||||
---
|
||||
title: Introduction (CLI Example)
|
||||
slug: /
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Welcome to My Documentation (CLI Version)
|
||||
|
||||
This is a sample documentation site created with Docusaurus and HeroLib V using the `hero docusaurus` command and a HeroScript configuration file.
|
||||
|
||||
## Features
|
||||
|
||||
- Easy to use
|
||||
- Markdown support
|
||||
- Customizable
|
||||
- Search functionality
|
||||
|
||||
## Getting Started
|
||||
|
||||
Follow these steps to get started:
|
||||
|
||||
1. Installation
|
||||
2. Configuration
|
||||
3. Adding content
|
||||
4. Deployment
|
||||
EOF
|
||||
|
||||
# Create quick-start.md
|
||||
cat > "${DOCS_SUBDIR}/quick-start.md" << 'EOF'
|
||||
---
|
||||
title: Quick Start (CLI Example)
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# Quick Start Guide (CLI Version)
|
||||
|
||||
This guide will help you get up and running quickly.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install my-project
|
||||
```
|
||||
|
||||
## Basic Usage
|
||||
|
||||
```javascript
|
||||
import { myFunction } from "my-project";
|
||||
|
||||
// Use the function
|
||||
const result = myFunction();
|
||||
console.log(result);
|
||||
```
|
||||
EOF
|
||||
|
||||
echo "Sample markdown content created."
|
||||
|
||||
|
||||
# --- Run Docusaurus Directly via V Script ---
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
# -n initializes the site structure if it doesn't exist (--new)
|
||||
# -d runs the development server (--dev)
|
||||
hero docusaurus -buildpath "${HOME}/hero/var/docusaurus_demo_src_cli" -path "${SCRIPT_DIR}/cfg/docusaurus_example_config.heroscript" -new -dev
|
||||
|
||||
echo "Hero docusaurus command finished. Check for errors or dev server output."
|
||||
238
examples/web/docusaurus_example_complete.vsh
Executable file
238
examples/web/docusaurus_example_complete.vsh
Executable file
@@ -0,0 +1,238 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.web.docusaurus
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
import freeflowuniverse.herolib.core.playbook
|
||||
import os
|
||||
|
||||
fn main() {
|
||||
println('Starting Docusaurus Example with HeroScript')
|
||||
|
||||
// Define the HeroScript that configures our Docusaurus site
|
||||
hero_script := '
|
||||
!!docusaurus.config
|
||||
name:"my-documentation"
|
||||
title:"My Documentation Site"
|
||||
tagline:"Documentation made simple with V and Docusaurus"
|
||||
url:"https://docs.example.com"
|
||||
url_home:"docs/"
|
||||
base_url:"/"
|
||||
favicon:"img/favicon.png"
|
||||
image:"img/hero.png"
|
||||
copyright:"© 2025 Example Organization"
|
||||
|
||||
!!docusaurus.config_meta
|
||||
description:"Comprehensive documentation for our amazing project"
|
||||
image:"https://docs.example.com/img/social-card.png"
|
||||
title:"My Documentation | Official Docs"
|
||||
|
||||
!!docusaurus.ssh_connection
|
||||
name:"production"
|
||||
host:"example.com"
|
||||
login:"deploy"
|
||||
port:22
|
||||
key_path:"~/.ssh/id_rsa"
|
||||
|
||||
!!docusaurus.build_dest
|
||||
ssh_name:"production"
|
||||
path:"/var/www/docs"
|
||||
|
||||
!!docusaurus.navbar
|
||||
title:"My Project"
|
||||
|
||||
!!docusaurus.navbar_item
|
||||
label:"Documentation"
|
||||
href:"/docs"
|
||||
position:"left"
|
||||
|
||||
!!docusaurus.navbar_item
|
||||
label:"API"
|
||||
href:"/api"
|
||||
position:"left"
|
||||
|
||||
!!docusaurus.navbar_item
|
||||
label:"GitHub"
|
||||
href:"https://github.com/example/repo"
|
||||
position:"right"
|
||||
|
||||
!!docusaurus.footer
|
||||
style:"dark"
|
||||
|
||||
!!docusaurus.footer_item
|
||||
title:"Documentation"
|
||||
label:"Introduction"
|
||||
to:"/docs"
|
||||
|
||||
!!docusaurus.footer_item
|
||||
title:"Documentation"
|
||||
label:"API Reference"
|
||||
to:"/api"
|
||||
|
||||
!!docusaurus.footer_item
|
||||
title:"Community"
|
||||
label:"GitHub"
|
||||
href:"https://github.com/example/repo"
|
||||
|
||||
!!docusaurus.footer_item
|
||||
title:"Community"
|
||||
label:"Discord"
|
||||
href:"https://discord.gg/example"
|
||||
|
||||
!!docusaurus.footer_item
|
||||
title:"More"
|
||||
label:"Blog"
|
||||
href:"https://blog.example.com"
|
||||
|
||||
!!docusaurus.import_source
|
||||
url:"https://github.com/example/external-docs"
|
||||
dest:"external"
|
||||
replace:"PROJECT_NAME:My Project, VERSION:1.0.0"
|
||||
'
|
||||
|
||||
mut docs := docusaurus.new(
|
||||
build_path: os.join_path(os.home_dir(), 'hero/var/docusaurus_demo1')
|
||||
update: true // Update the templates
|
||||
heroscript: hero_script
|
||||
) or {
|
||||
eprintln('Error creating docusaurus factory with inline script: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// Create a site directory if it doesn't exist
|
||||
site_path := os.join_path(os.home_dir(), 'hero/var/docusaurus_demo_src')
|
||||
os.mkdir_all(site_path) or {
|
||||
eprintln('Error creating site directory: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// Get or create a site using the factory
|
||||
println('Creating site...')
|
||||
mut site := docs.get(
|
||||
name: 'my-documentation'
|
||||
path: site_path
|
||||
init: true // Create if it doesn't exist
|
||||
// Note: The site will use the config from the previously processed HeroScript
|
||||
) or {
|
||||
eprintln('Error creating site: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// Generate a sample markdown file for the docs
|
||||
println('Creating sample markdown content...')
|
||||
mut docs_dir := pathlib.get_dir(path: os.join_path(site_path, 'docs'), create: true) or {
|
||||
eprintln('Error creating docs directory: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// Create intro.md file
|
||||
mut intro_file := docs_dir.file_get_new('intro.md') or {
|
||||
eprintln('Error creating intro file: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
intro_content := '---
|
||||
title: Introduction
|
||||
slug: /
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Welcome to My Documentation
|
||||
|
||||
This is a sample documentation site created with Docusaurus and HeroLib V using HeroScript configuration.
|
||||
|
||||
## Features
|
||||
|
||||
- Easy to use
|
||||
- Markdown support
|
||||
- Customizable
|
||||
- Search functionality
|
||||
|
||||
## Getting Started
|
||||
|
||||
Follow these steps to get started:
|
||||
|
||||
1. Installation
|
||||
2. Configuration
|
||||
3. Adding content
|
||||
4. Deployment
|
||||
'
|
||||
intro_file.write(intro_content) or {
|
||||
eprintln('Error writing to intro file: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// Create quick-start.md file
|
||||
mut quickstart_file := docs_dir.file_get_new('quick-start.md') or {
|
||||
eprintln('Error creating quickstart file: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
quickstart_content := '---
|
||||
title: Quick Start
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# Quick Start Guide
|
||||
|
||||
This guide will help you get up and running quickly.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install my-project
|
||||
```
|
||||
|
||||
## Basic Usage
|
||||
|
||||
```javascript
|
||||
import { myFunction } from "my-project";
|
||||
|
||||
// Use the function
|
||||
const result = myFunction();
|
||||
console.log(result);
|
||||
```
|
||||
'
|
||||
quickstart_file.write(quickstart_content) or {
|
||||
eprintln('Error writing to quickstart file: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// Generate the site
|
||||
println('Generating site...')
|
||||
site.generate() or {
|
||||
eprintln('Error generating site: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
println('Site generated successfully!')
|
||||
|
||||
// Choose which operation to perform:
|
||||
|
||||
// Option 1: Run in development mode
|
||||
// This will start a development server in a screen session
|
||||
println('Starting development server...')
|
||||
site.dev() or {
|
||||
eprintln('Error starting development server: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
// Option 2: Build for production (uncomment to use)
|
||||
/*
|
||||
println('Building site for production...')
|
||||
site.build() or {
|
||||
eprintln('Error building site: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
println('Site built successfully!')
|
||||
*/
|
||||
|
||||
// Option 3: Build and publish to the remote server (uncomment to use)
|
||||
/*
|
||||
println('Building and publishing site...')
|
||||
site.build_publish() or {
|
||||
eprintln('Error publishing site: ${err}')
|
||||
exit(1)
|
||||
}
|
||||
println('Site published successfully!')
|
||||
*/
|
||||
}
|
||||
93
examples/web/markdown_renderer/markdown_parser.vsh
Executable file
93
examples/web/markdown_renderer/markdown_parser.vsh
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none run
|
||||
|
||||
import freeflowuniverse.herolib.data.markdownparser2
|
||||
|
||||
// Sample markdown text
|
||||
text := '# Heading 1
|
||||
|
||||
This is a paragraph with **bold** and *italic* text.
|
||||
|
||||
## Heading 2
|
||||
|
||||
- List item 1
|
||||
- List item 2
|
||||
- Nested item
|
||||
- List item 3
|
||||
|
||||
```v
|
||||
fn main() {
|
||||
println("Hello, world!")
|
||||
}
|
||||
```
|
||||
|
||||
> This is a blockquote
|
||||
> with multiple lines
|
||||
|
||||
| Column 1 | Column 2 | Column 3 |
|
||||
|----------|:--------:|---------:|
|
||||
| Left | Center | Right |
|
||||
| Cell 1 | Cell 2 | Cell 3 |
|
||||
|
||||
[Link to V language](https://vlang.io)
|
||||
|
||||

|
||||
|
||||
Footnote reference[^1]
|
||||
|
||||
[^1]: This is a footnote.
|
||||
'
|
||||
|
||||
// Example 1: Using the plain text renderer
|
||||
println('=== PLAINTEXT RENDERING ===')
|
||||
println(markdownparser2.to_plain(text))
|
||||
println('')
|
||||
|
||||
// Example 2: Using the structure renderer to show markdown structure
|
||||
println('=== STRUCTURE RENDERING ===')
|
||||
println(markdownparser2.to_structure(text))
|
||||
|
||||
// Example 3: Using the navigator to find specific elements
|
||||
println('\n=== NAVIGATION EXAMPLE ===')
|
||||
|
||||
// Parse the markdown text
|
||||
doc := markdownparser2.parse(text)
|
||||
|
||||
// Create a navigator
|
||||
mut nav := markdownparser2.new_navigator(doc)
|
||||
|
||||
// Find all headings
|
||||
headings := nav.find_all_by_type(.heading)
|
||||
println('Found ${headings.len} headings:')
|
||||
for heading in headings {
|
||||
level := heading.attributes['level']
|
||||
println(' ${'#'.repeat(level.int())} ${heading.content}')
|
||||
}
|
||||
|
||||
// Find all code blocks
|
||||
code_blocks := nav.find_all_by_type(.code_block)
|
||||
println('\nFound ${code_blocks.len} code blocks:')
|
||||
for block in code_blocks {
|
||||
language := block.attributes['language']
|
||||
println(' Language: ${language}')
|
||||
println(' Content length: ${block.content.len} characters')
|
||||
}
|
||||
|
||||
// Find all list items
|
||||
list_items := nav.find_all_by_type(.list_item)
|
||||
println('\nFound ${list_items.len} list items:')
|
||||
for item in list_items {
|
||||
println(' - ${item.content}')
|
||||
}
|
||||
|
||||
// Find content containing specific text
|
||||
if element := nav.find_by_content('blockquote') {
|
||||
println('\nFound element containing "blockquote":')
|
||||
println(' Type: ${element.typ}')
|
||||
println(' Content: ${element.content}')
|
||||
}
|
||||
|
||||
// Find all footnotes
|
||||
println('\nFootnotes:')
|
||||
for id, footnote in nav.footnotes() {
|
||||
println(' [^${id}]: ${footnote.content}')
|
||||
}
|
||||
27
examples/web/markdown_renderer/markdown_render.vsh
Executable file
27
examples/web/markdown_renderer/markdown_render.vsh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
// import freeflowuniverse.herolib.core.texttools
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import log
|
||||
import os
|
||||
import markdown
|
||||
import freeflowuniverse.herolib.data.markdownparser2
|
||||
|
||||
path2 := '${os.home_dir()}/code/github/freeflowuniverse/herolib/examples/webtools/mdbook_markdown/content/links.md'
|
||||
path1 := '${os.home_dir()}/code/github/freeflowuniverse/herolib/examples/webtools/mdbook_markdown/content/test.md'
|
||||
|
||||
text := os.read_file(path1)!
|
||||
|
||||
// Example 1: Using the built-in plaintext renderer
|
||||
println('=== PLAINTEXT RENDERING ===')
|
||||
println(markdown.to_plain(text))
|
||||
println('')
|
||||
|
||||
// Example 2: Using our custom structure renderer to show markdown structure
|
||||
println('=== STRUCTURE RENDERING ===')
|
||||
println(markdownparser2.to_structure(text))
|
||||
|
||||
// // Example 3: Using a simple markdown example to demonstrate structure
|
||||
// println('\n=== STRUCTURE OF A SIMPLE MARKDOWN EXAMPLE ===')
|
||||
// simple_md := '# Heading 1\n\nThis is a paragraph with **bold** and *italic* text.\n\n- List item 1\n- List item 2\n\n```v\nfn main() {\n\tprintln("Hello, world!")\n}\n```\n\n[Link to V language](https://vlang.io)'
|
||||
// println(markdown.to_structure(simple_md))
|
||||
6
examples/web/mdbook_markdown/.gitignore
vendored
Normal file
6
examples/web/mdbook_markdown/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
mdbook_example
|
||||
markdown_example
|
||||
markdown_example0
|
||||
doctree_example
|
||||
tree_scan
|
||||
*.dSYM
|
||||
29
examples/web/mdbook_markdown/content/cybercity.md
Normal file
29
examples/web/mdbook_markdown/content/cybercity.md
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
sidebar_position: 10
|
||||
title: 'Dunia CyberCity'
|
||||
description: 'Co-create the Future'
|
||||
---
|
||||
|
||||

|
||||
|
||||
|
||||
We are building a 700,000 m2 Regenerative Startup Cyber City
|
||||
|
||||
- 100% co-owned
|
||||
- regenerative
|
||||
- autonomous zone
|
||||
|
||||
a city for startups and its creators
|
||||
|
||||
- build a system for augmented collective intelligence
|
||||
- operate business wise from a digital freezone
|
||||
- (co)own assets (shares, digital currencies) safely and privately
|
||||
|
||||
|
||||
## More Info
|
||||
|
||||
> see [https://friends.threefold.info/cybercity](https://friends.threefold.info/cybercity)
|
||||
|
||||
- login:```planet```
|
||||
- passwd:```first```
|
||||
|
||||
10
examples/web/mdbook_markdown/content/doc.md
Normal file
10
examples/web/mdbook_markdown/content/doc.md
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
## The Internet Today
|
||||
|
||||

|
||||
|
||||
|
||||
The internet today is constructed in a centralized way, we exist many times and became a product of big centralized corporations. There is also a real cyber pandemic going on; there are cyber attacks everywhere and backdoors in most of the electronic equipment we use. This architecture is unsafe, not scalable, power hungry and unable to deliver equality. Still, more than half of our planet does not have decent affordable access to the internet.
|
||||
|
||||
|
||||
Blockchain technology is a huge step in the right direction but it's a shared architecture distributed over the world where data gets replicated in many locations. It is a good technology choice for use-cases like money, smart contracts, voting, digital notary services and identity management but not at all suited for building a new internet. This is also called web4. Developers still need to develop applications connecting to multiple blockchains and centralization is often not good enough.
|
||||
29
examples/web/mdbook_markdown/content/launch.md
Normal file
29
examples/web/mdbook_markdown/content/launch.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# this is a test
|
||||
|
||||
Some normal text //somecomment at end
|
||||
- [this is link](something.md)
|
||||
- 
|
||||
Some normal text behind
|
||||
|
||||
//somecomment at start
|
||||
|
||||
## ts
|
||||
|
||||

|
||||
|
||||
```html
|
||||
<html>
|
||||
|
||||
</html>
|
||||
```
|
||||
<html>
|
||||
<p>para</p>
|
||||
</html>
|
||||
<!-- 1 -->
|
||||
|
||||
In Between Comment
|
||||
|
||||
<!-- This is comment
|
||||
|
||||
commmmment
|
||||
-->
|
||||
10
examples/web/mdbook_markdown/content/links.md
Normal file
10
examples/web/mdbook_markdown/content/links.md
Normal file
@@ -0,0 +1,10 @@
|
||||

|
||||
|
||||
## Planet First
|
||||
|
||||
|
||||
[mycommunity](freeflow:community.md)
|
||||
|
||||
test
|
||||
|
||||

|
||||
115
examples/web/mdbook_markdown/content/macros.md
Normal file
115
examples/web/mdbook_markdown/content/macros.md
Normal file
@@ -0,0 +1,115 @@
|
||||
# this is a test
|
||||
|
||||
Its our attempt to use markdown to execute a certain state.
|
||||
|
||||
It allows us to specify parser which need to be done, only !! at start of line is executed.
|
||||
|
||||
```yaml
|
||||
yes = 1
|
||||
```
|
||||
|
||||
"""yaml
|
||||
yes = 2
|
||||
"""
|
||||
|
||||
comments allowed, the next thing is not useful but good for testing, it specifies name argument on git.ensure, its the same anyhow
|
||||
|
||||
!!action.define name:download_git
|
||||
|
||||
!!git.ensure url:'https://github.com/threefoldfoundation/info_foundation' autocommit:'mychanges' update:true
|
||||
|
||||
!!git.ensure url:https://github.com/threefoldfoundation/legal autocommit:'mychanges' update:true
|
||||
name:legal
|
||||
|
||||
> can be multiline
|
||||
|
||||
!!git.ensure url:https://github.com/threefoldfoundation/info_gridmanual
|
||||
autocommit:'mychanges'
|
||||
update:true
|
||||
|
||||
<!-- comments should not stop -->
|
||||
|
||||
!!publisher.server.params port:8082
|
||||
|
||||
!!action.define name:server_start depends:download_git,get_content
|
||||
|
||||
!!publisher.server.start
|
||||
|
||||
!!action.run name:server_start
|
||||
|
||||
can be in code block or without, it does not matter
|
||||
|
||||
## git
|
||||
|
||||
<!-- Means a git command,
|
||||
|
||||
### git ensure
|
||||
|
||||
makes sure a git repo is on system. -->
|
||||
|
||||
|
||||
## action does not have to be in code block
|
||||
|
||||
!!action.define2 name:get_content
|
||||
|
||||
> if we don't specify source of content, then its the document itself
|
||||
|
||||
!!markdown.section.get1 start:'### git ensure' name:testcontent.blue
|
||||
|
||||
> we now remove the first line which matched, the last line is never included, but now we forced to include it + 1 extra line
|
||||
|
||||
!!markdown.section.get2 start:'### git ensure' end:'# end of' name:testcontent.red trim_end:+3 trim_start:+1
|
||||
|
||||
> fetch a full document, there will be no start/stop
|
||||
|
||||
!!markdown.section.get3 name:testcontent.pink gitrepo:info_foundation
|
||||
file:'communication.md'
|
||||
|
||||
### end of block
|
||||
|
||||
This should be in the found block.
|
||||
|
||||
### we can even do task management with it
|
||||
|
||||
|
||||
!!taskcontext name:myproject1
|
||||
|
||||
!!task id:a1
|
||||
name:'need to do something 1'
|
||||
description:
|
||||
## markdown works in it
|
||||
|
||||
description can be multiline
|
||||
lets see what happens
|
||||
|
||||
- a
|
||||
- something else
|
||||
|
||||
### subtitle
|
||||
|
||||
```python
|
||||
#even code block in the other block, crazy parsing for sure
|
||||
def test():
|
||||
print("test")
|
||||
```
|
||||
priority:10
|
||||
|
||||
|
||||
//lets now create another task which depends on the previous one
|
||||
|
||||
!!task id:a1 name:'something else' assign:'kristof(50%),jan' effort:1d
|
||||
depends:a1
|
||||
|
||||
!!dao.deposit currency:usdc amount:10
|
||||
!!dao.withdraw currency:usdc amount:10
|
||||
|
||||
!!dao.pool.deposit currency:usdc amount:10
|
||||
!!dao.pool.withdraw currency:usdc amount:10
|
||||
|
||||
!!dao.pool.buy currency:tft amount:100
|
||||
|
||||
!!dao.wallets.info currency:usdc
|
||||
!!dao.wallets.info
|
||||
|
||||
!!dao.exchange.buy currency:tft amount:100 price_max_usd:0.05 deadline:10h
|
||||
|
||||
51
examples/web/mdbook_markdown/content/test.md
Normal file
51
examples/web/mdbook_markdown/content/test.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# this is a header
|
||||
## another header
|
||||
|
||||
This is some text.
|
||||
Same paragraph [my link](https://github.com/vlang/v/blob/master/doc/docs.md).
|
||||
|
||||
Next paragraph.
|
||||
|
||||
- list item
|
||||
- list item 2
|
||||
- list item 3
|
||||
- list item 4
|
||||
|
||||
|
||||
!!another.action key:val key2:val2
|
||||
!!actor.name k1:v1
|
||||
k2:v2
|
||||
|
||||
# header2
|
||||
text in paragraph
|
||||
|
||||
| Month | Savings |
|
||||
| -------- | ------- |
|
||||
| January | $250 |
|
||||
| February | $80 |
|
||||
| March | $420 |
|
||||
|
||||
```vlang
|
||||
fn main(){
|
||||
println('hello world')
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
!!another.action2 key:val key2:val2
|
||||
!!myactor.myname k1:v1
|
||||
k2:v2
|
||||
|
||||
```
|
||||
|
||||
!!include this is an include
|
||||
|
||||
<html>text on same line as beginning tag is ignored
|
||||
this text is part of the html element
|
||||
# this header too
|
||||
```
|
||||
codeblock too
|
||||
```
|
||||
</html>this is ignored too
|
||||
|
||||
<!-- this is my comment -->
|
||||
9
examples/web/mdbook_markdown/content/test_para.md
Normal file
9
examples/web/mdbook_markdown/content/test_para.md
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
qwpoejfpqwoejf
|
||||
qoweifjjf
|
||||
|
||||
- list item
|
||||
- list item 2
|
||||
- list item 3
|
||||
- list item 4
|
||||
test
|
||||
24
examples/web/mdbook_markdown/doctree_export.vsh
Executable file
24
examples/web/mdbook_markdown/doctree_export.vsh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.data.doctree
|
||||
|
||||
mut tree := doctree.new(name: 'test')!
|
||||
|
||||
// path string
|
||||
// heal bool = true // healing means we fix images
|
||||
// git_url string
|
||||
// git_reset bool
|
||||
// git_root string
|
||||
// git_pull bool
|
||||
|
||||
tree.scan(
|
||||
git_url: 'https://git.ourworld.tf/tfgrid/docs_tfgrid4/src/branch/main/collections'
|
||||
git_pull: false
|
||||
)!
|
||||
|
||||
tree.export(
|
||||
destination: '/tmp/mdexport'
|
||||
reset: true
|
||||
exclude_errors: false
|
||||
)!
|
||||
|
||||
44
examples/web/mdbook_markdown/markdown_example.vsh
Executable file
44
examples/web/mdbook_markdown/markdown_example.vsh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
// import freeflowuniverse.herolib.core.texttools
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import log
|
||||
import freeflowuniverse.herolib.data.markdownparser
|
||||
import os
|
||||
|
||||
console.print_header('Print markdown in treeview.')
|
||||
println('')
|
||||
// mut session := play.session_new(
|
||||
// context_name: "test"
|
||||
// interactive: true
|
||||
// )!
|
||||
|
||||
// get path local to the current script
|
||||
path_my_content := '${os.dir(@FILE)}/content'
|
||||
|
||||
mut doc1 := markdownparser.new(
|
||||
path: '${path_my_content}/test.md'
|
||||
)!
|
||||
content1 := doc1.markdown()!
|
||||
|
||||
println(doc1.treeview())
|
||||
|
||||
console.print_header('Markdown output:')
|
||||
println('')
|
||||
println(content1)
|
||||
|
||||
console.print_header('Actions:')
|
||||
println('')
|
||||
println(doc1.actions(actor: 'myactor', name: 'myname'))
|
||||
|
||||
// console.print_header('Action Pointers:')
|
||||
// println('')
|
||||
// for a in doc1.action_pointers(actor: 'myactor', name: 'myname') {
|
||||
// doc1.content_set(a.element_id, '> THIS IS WHAT WE FILL IN FROM ACTOR')
|
||||
// println(a)
|
||||
// }
|
||||
|
||||
console.print_header("Markdown output after macro's:")
|
||||
println('')
|
||||
content2 := doc1.treeview()
|
||||
println(content2)
|
||||
9
examples/web/siteconfig.vsh
Executable file
9
examples/web/siteconfig.vsh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.web.siteconfig
|
||||
import os
|
||||
mypath :='${os.dir(@FILE)}/siteconfigexample'
|
||||
|
||||
mut sc:=siteconfig.new(mypath)!
|
||||
|
||||
println(sc)
|
||||
100
examples/web/siteconfigexample/config.heroscript
Normal file
100
examples/web/siteconfigexample/config.heroscript
Normal file
@@ -0,0 +1,100 @@
|
||||
!!site.config
|
||||
name:"depin"
|
||||
description:"ThreeFold is laying the foundation for a geo aware Web 4, the next generation of the Internet."
|
||||
tagline:"Geo Aware Internet Platform"
|
||||
favicon:"img/favicon.png"
|
||||
image:"img/tf_graph.png"
|
||||
copyright:"ThreeFold"
|
||||
|
||||
!!site.menu
|
||||
title:"ThreeFold DePIN Tech"
|
||||
logo_alt:"ThreeFold Logo"
|
||||
logo_src:"img/logo.svg"
|
||||
logo_src_dark:"img/new_logo_tft.png"
|
||||
|
||||
!!site.menu_item
|
||||
label:"ThreeFold.io"
|
||||
href:"https://threefold.io"
|
||||
position:"right"
|
||||
|
||||
!!site.menu_item
|
||||
label:"Mycelium Network"
|
||||
href:"https://mycelium.threefold.io/"
|
||||
position:"right"
|
||||
|
||||
!!site.menu_item
|
||||
label:"AI Box"
|
||||
href:"https://aibox.threefold.io/"
|
||||
position:"right"
|
||||
|
||||
!!site.footer
|
||||
style:"dark"
|
||||
|
||||
!!site.footer_item
|
||||
title:"Docs"
|
||||
label:"Introduction"
|
||||
href:"https://docs.threefold.io/docs/introduction"
|
||||
|
||||
!!site.footer_item
|
||||
title:"Docs"
|
||||
label:"Litepaper"
|
||||
href:"https://docs.threefold.io/docs/litepaper/"
|
||||
|
||||
!!site.footer_item
|
||||
title:"Docs"
|
||||
label:"Roadmap"
|
||||
href:"https://docs.threefold.io/docs/roadmap"
|
||||
|
||||
!!site.footer_item
|
||||
title:"Docs"
|
||||
label:"Manual"
|
||||
href:"https://manual.grid.tf/"
|
||||
|
||||
!!site.footer_item
|
||||
title:"Features"
|
||||
label:"Become a Farmer"
|
||||
href:"https://docs.threefold.io/docs/category/become-a-farmer"
|
||||
|
||||
!!site.footer_item
|
||||
title:"Features"
|
||||
label:"Components"
|
||||
href:"https://docs.threefold.io/docs/category/components"
|
||||
|
||||
!!site.footer_item
|
||||
title:"Features"
|
||||
label:"Technology"
|
||||
href:"https://threefold.info/tech/"
|
||||
|
||||
!!site.footer_item
|
||||
title:"Features"
|
||||
label:"Tokenomics"
|
||||
href:"https://docs.threefold.io/docs/tokens/tokenomics"
|
||||
|
||||
!!site.footer_item
|
||||
title:"Web"
|
||||
label:"ThreeFold.io"
|
||||
href:"https://threefold.io"
|
||||
|
||||
!!site.footer_item
|
||||
title:"Web"
|
||||
label:"Dashboard"
|
||||
href:"https://dashboard.grid.tf"
|
||||
|
||||
!!site.footer_item
|
||||
title:"Web"
|
||||
label:"GitHub"
|
||||
href:"https://github.com/threefoldtech/home"
|
||||
|
||||
!!site.footer_item
|
||||
title:"Web"
|
||||
label:"Mycelium Network"
|
||||
href:"https://mycelium.threefold.io/"
|
||||
|
||||
!!site.footer_item
|
||||
title:"Web"
|
||||
label:"AI Box"
|
||||
href:"https://www2.aibox.threefold.io/"
|
||||
|
||||
!!site.collections
|
||||
url:"https://github.com/example/external-docs"
|
||||
replace:"PROJECT_NAME:My Project, VERSION:1.0.0"
|
||||
18
examples/web/siteconfigexample/site.heroscript
Normal file
18
examples/web/siteconfigexample/site.heroscript
Normal file
@@ -0,0 +1,18 @@
|
||||
!!site.page name:intro
|
||||
description:"ThreeFold is laying the foundation for a geo aware Web 4, the next generation of the Internet."
|
||||
|
||||
//next is example where we use all properties, folder is where the page is located, prio is the order of the page, if not used the filled in from order in which we parse this config file
|
||||
!!site.page name:mycelium draft:true folder:"/specs/components" prio:4
|
||||
content:"the page content itself, only for small pages"
|
||||
title:"Mycelium as Title"
|
||||
description:"..."
|
||||
|
||||
!!site.page name:fungistor folder:"/specs/components" prio:1
|
||||
src:"mycollection:mycelium.md"
|
||||
title:"fungistor as Title"
|
||||
description:"...."
|
||||
|
||||
!!site.page name:fungistor folder:"/specs/components" prio:1
|
||||
src:"mycollection:mycelium" //can be without .md
|
||||
title:"fungistor as Title"
|
||||
description:"..."
|
||||
17
examples/web/starllight_example.vsh
Executable file
17
examples/web/starllight_example.vsh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.web.starlight
|
||||
// import freeflowuniverse.herolib.data.doctree
|
||||
|
||||
// Create a new starlight factory
|
||||
mut docs := starlight.new(
|
||||
build_path: '/tmp/starlight_build'
|
||||
)!
|
||||
|
||||
// Create a new starlight site
|
||||
mut site := docs.get(
|
||||
url: 'https://git.ourworld.tf/tfgrid/docs_aibox'
|
||||
init: true // init means we put config files if not there
|
||||
)!
|
||||
|
||||
site.dev()!
|
||||
Reference in New Issue
Block a user