### Example moul.toml Configuration Source: https://github.com/lingxiao97/moul/blob/main/docs/README.md This snippet shows a comprehensive example of the moul.toml configuration file. It demonstrates how to set up base URL, Google Analytics, favicons, page styling, profile details, social media links, and content sections. This file is crucial for customizing the behavior and appearance of the Moul project. ```toml # The HTML base element specifies the base URL to use for all relative URLs in a document. # Default to `/ base = "/" # Google Analytics tracking code. # Eg: G-J8D3EXF6JH or UA-133159807-2 ga_measurement_id = "" # Default to false, if true, below files are expected. # `favicon/favicon.svg` # `favicon/favicon-dark.png` # `favicon/favicon-light.png` # see example favicon = "true" # Control the style of the page. [style] theme = "system-preference" # possible value "system-preference | dark | light" cover = "center" # possible value "left | center | right" content = "left" # possible value "left | center | right" # Profile information [profile] name = "Sophearak Tha" bio = "Internetrovert • Indie Dev • Minimalist" # Social media handle [social] twitter = "" github = "" instagram = "" youtube = "" facebook = "" # The content of the page [content] title = "Primary title" tags = ["Adventure", "Landscape"] text = """ text """ # Additional content # Photos should be place in `photos/section/1`, `photos/section/2` accordingly [section.1] title = "another title" text = """ another text """ [section.2] title = "yet another title" text = """ another text """ ``` -------------------------------- ### Create New Photo Collection Project (CLI) Source: https://context7.com/lingxiao97/moul/llms.txt Initializes a new photo collection project with the necessary directory structure and a template configuration file. It guides the user on where to place images and configuration files, and provides commands for previewing and exporting the collection. ```bash # Create a new photo collection called "my-portfolio" moul create my-portfolio # Expected output: # ■ Creating a new collection... # Success! Created collection at `/path/to/my-portfolio` # # ■ Add your `cover`, `avatar`, and `collection` # into `my-portfolio/photos/cover|avatar|collection` # ■ Add your information in `my-portfolio/moul.toml` # # ● Preview your photo collection: `moul preview` # ● Export your photo collection: `moul export` # Directory structure created: # my-portfolio/ # ├── moul.toml # Configuration file # ├── photos/ # │ ├── cover/ # Cover image (2:1 or 16:9 recommended) # │ ├── avatar/ # Profile avatar (1:1 recommended) # │ └── collection/ # Main photo collection # └── .moul/ # Internal cache directory # └── photos/ ``` -------------------------------- ### Display Moul CLI Version (CLI) Source: https://context7.com/lingxiao97/moul/llms.txt Prints the currently installed version of the Moul command-line interface to the console. This is useful for verifying the installation and checking compatibility. ```bash moul version # Output: # 3.1.0 ``` -------------------------------- ### Moul TOML Configuration File Example Source: https://context7.com/lingxiao97/moul/llms.txt Defines the structure and parameters for the `moul.toml` configuration file, which controls all aspects of the photo collection website. It includes settings for base URL, analytics, favicons, styling, profile information, social media links, and main content details. ```toml # Base URL for the website (used for relative URLs) base = "/" # Google Analytics measurement ID (optional) # Supports both GA4 (G-XXXXXXXX) and Universal Analytics (UA-XXXXXXXX) ga_measurement_id = "G-J8D3EXF6JH" # Enable custom favicon support # When true, expects these files in favicon/ directory: # - favicon/favicon.svg # - favicon/favicon-dark.png # - favicon/favicon-light.png favicon = "true" # Visual style configuration [style] # Theme options: "system-preference" | "dark" | "light" theme = "system-preference" # Cover image alignment: "left" | "center" | "right" cover = "center" # Content text alignment: "left" | "center" | "right" content = "left" # Profile information displayed on the page [profile] name = "Jane Photographer" bio = "Landscape & Travel Photographer | Based in Tokyo" # Social media handles (username only, not full URLs) [social] twitter = "janephoto" github = "janephoto" instagram = "jane.photographer" youtube = "janephoto" facebook = "janephotography" # Main content section [content] title = "Mountain Landscapes — A Journey Through the Alps" tags = ["Landscape", "Mountains", "Adventure"] text = """ A collection of photographs captured during my three-month expedition through the European Alps. Each image tells a story of solitude, natural beauty, and the raw power of mountain landscapes. [View my equipment guide](https://example.com/gear) """ # Additional content sections with their own photo collections ``` -------------------------------- ### Update Moul Binary to Latest Version (CLI) Source: https://context7.com/lingxiao97/moul/llms.txt Checks for and installs the latest version of the Moul CLI from GitHub releases. It provides feedback on whether the update was successful or if the current version is already the latest. ```bash # Update to latest version moul update # If already on latest: # Current binary is the latest version 3.1.0 # If update available: # Successfully updated to latest version ``` -------------------------------- ### Deploy to Netlify (Bash) Source: https://context7.com/lingxiao97/moul/llms.txt Provides a bash script to export a photo collection and deploy it to Netlify. It includes steps for initializing Git, committing changes, creating a netlify.toml configuration file, and deploying using the Netlify CLI. The netlify.toml configures build settings and headers for caching. ```bash # Export the collection cd my-portfolio moul export # Initialize git and push to repository git init git add . git commit -m "Initial photo collection" # Create netlify.toml for configuration cat > netlify.toml << 'EOF' [build] publish = "public" command = "echo 'Static site ready'" [[headers]] for = "/*" [headers.values] Cache-Control = "public, max-age=31536000" EOF # Deploy via Netlify CLI netlify deploy --prod --dir=public ``` -------------------------------- ### Export Photo Collection to Static Website (CLI) Source: https://context7.com/lingxiao97/moul/llms.txt Generates a deployable static website from the photo collection. It optimizes images by resizing them to multiple resolutions and generating SVG placeholders (SQIP). The output includes HTML, CSS, JavaScript, and organized image assets. ```bash # Navigate to your collection directory cd my-portfolio # Export with default output directory (public/) moul export # Expected output: # ■ Exporting photo collection... # ● Success! Exported photo collection in `2.5s` # Output structure: # public/ # ├── index.html # ├── assets/ # │ ├── moul.0c839.js # │ └── moul.0c839.css # ├── favicon/ # If favicon = "true" in config # └── photos/ # └── {unique-id}/ # ├── cover/ # │ ├── 2560/ # Large resolution # │ ├── 1280/ # Medium resolution # │ ├── 620/ # Small resolution # │ └── sqip/ # SVG placeholders # ├── avatar/ # │ ├── 512/ # │ └── 320/ # └── collection/ # ├── 2048/ # HD resolution # └── 750/ # Standard resolution ``` -------------------------------- ### Resize: Process Photos with Multiple Resolutions and SQIP (Go) Source: https://context7.com/lingxiao97/moul/llms.txt Processes images by generating multiple resolution versions and SQIP placeholders. It takes the source directory, author name, output prefix, and an array of target widths as input. The output is structured within `.moul/photos/{unique-id}/`. ```go package internal // Resize processes images at specified sizes and generates SQIP placeholders // Parameters: // - inPath: source directory containing original photos // - author: photographer name (used in output filenames) // - outPrefix: output subdirectory name (e.g., "cover", "avatar", "collection") // - sizes: array of target widths in pixels func Resize(inPath, author, outPrefix string, sizes []int) // Example usage for different photo types: // Cover photos: 3 sizes for responsive loading internal.Resize("photos/cover", "jane-doe", "cover", []int{2560, 1280, 620}) // Avatar: 2 sizes for profile display internal.Resize("photos/avatar", "jane-doe", "avatar", []int{512, 320}) // Collection photos: HD and standard resolution internal.Resize("photos/collection", "jane-doe", "collection", []int{2048, 750}) // Output structure in .moul/photos/{unique-id}/cover/: // ├── 2560/ // │ └── photo-name-by-jane-doe.jpg // ├── 1280/ // │ └── photo-name-by-jane-doe.jpg // ├── 620/ // │ └── photo-name-by-jane-doe.jpg // └── sqip/ // └── photo-name-by-jane-doe.svg ``` -------------------------------- ### Deploy to GitHub Pages (Bash) Source: https://context7.com/lingxiao97/moul/llms.txt A bash script for exporting a photo collection and deploying it to GitHub Pages. It covers exporting the site, optionally configuring a custom domain or repository base path in moul.toml, and pushing the 'public' directory to the 'gh-pages' branch of a GitHub repository. ```bash # Export and prepare for GitHub Pages moul export # If using custom domain, update base in moul.toml: # base = "https://photos.yourdomain.com/" # For GitHub Pages subdirectory: # base = "/repository-name/" # Push to gh-pages branch cd public git init git add . git commit -m "Deploy photo collection" git remote add origin https://github.com/username/photos.git git push -f origin master:gh-pages ``` -------------------------------- ### GetDirectory: Validate Moul Project Directory (Go) Source: https://context7.com/lingxiao97/moul/llms.txt Validates the current working directory to ensure it contains a valid Moul project structure, checking for the presence of `moul.toml` and the `photos` directory. Returns the directory path or an error if validation fails. ```go package internal import ( "os" "path/filepath" "github.com/fatih/color" ) // GetDirectory validates the current directory has required Moul files func GetDirectory() (string, error) { dir, err := os.Getwd() if err != nil { return "", err } // Check for moul.toml configuration file if _, err := os.Stat(filepath.Join(dir, "moul.toml")); os.IsNotExist(err) { color.Red("`moul.toml` file is not found!") color.Green("Run `moul create my-collection` to get start") return "", err } // Check for photos directory if _, err := os.Stat(filepath.Join(dir, "photos")); os.IsNotExist(err) { color.Red("`photos` directory is not found!") color.Green("Run `moul create my-collection` to get start") return "", err } return dir, nil } // Usage: // dir, err := internal.GetDirectory() // if err != nil { // os.Exit(1) // } // fmt.Printf("Working in: %s\n", dir) ``` -------------------------------- ### GetSHA1: Compute File SHA1 Hash (Go) Source: https://context7.com/lingxiao97/moul/llms.txt Computes the SHA1 hash of a given file and returns it as a hexadecimal string. This function is crucial for change detection, enabling incremental exports and efficient caching. ```go package internal // GetSHA1 returns the SHA1 hash of a file as a hex string func GetSHA1(filePath string) string // Usage: hash := internal.GetSHA1("photos/collection/sunset.jpg") fmt.Printf("File hash: %s\n", hash) // Output: // File hash: da39a3ee5e6b4b0d3255bfef95601890afd80709 ``` -------------------------------- ### GetPhotos: Scan Directory for Image Files (Go) Source: https://context7.com/lingxiao97/moul/llms.txt Scans a specified directory and returns a slice of strings containing the paths to all valid image files (JPEG/PNG). This function is useful for discovering images to be processed. ```go package internal // GetPhotos walks a directory and returns paths to all image files func GetPhotos(path string) []string // Usage: photos := internal.GetPhotos("photos/collection") for _, photo := range photos { fmt.Printf("Found: %s\n", photo) } // Output: // Found: photos/collection/mountain-sunset.jpg // Found: photos/collection/alpine-lake.jpeg // Found: photos/collection/forest-path.png ``` -------------------------------- ### GetPhotoDimension: Read Image Dimensions (Go) Source: https://context7.com/lingxiao97/moul/llms.txt Reads and returns the width and height of a given image file. This function is essential for image manipulation tasks that require knowledge of the image's dimensions. ```go package internal // GetPhotoDimension returns width and height of an image func GetPhotoDimension(path string) (int, int) // Usage: width, height := internal.GetPhotoDimension("photos/collection/landscape.jpg") fmt.Printf("Image dimensions: %dx%d\n", width, height) // Output: // Image dimensions: 4032x3024 ``` -------------------------------- ### Encode SVG to Base64 Data URI (Go) Source: https://context7.com/lingxiao97/moul/llms.txt Converts an SVG file into a base64-encoded data URI string. This is useful for embedding SVGs directly into HTML or CSS without external file references. The function takes a file path as input and returns the data URI string. ```go package internal // GetEncodedSvg reads an SVG and returns a base64 data URI func GetEncodedSvg(pathToSvg string) string { // Implementation details would go here, reading the file and encoding it. // This is a placeholder for the actual function signature and usage. return "" } // Usage: // sqipUri := internal.GetEncodedSvg(".moul/photos/abc123/cover/sqip/photo-by-jane.svg") // fmt.Printf("Data URI: %s\n", sqipUri[:50]) // Output: // Data URI: data:image/svg+xml;base64,PHN2ZyB4bWxucz0i... ``` -------------------------------- ### UniqueID: Generate Random Identifier (Go) Source: https://context7.com/lingxiao97/moul/llms.txt Generates a cryptographically random 20-character alphanumeric identifier. This is typically used for creating unique IDs for batches of photos during processing or export. ```go package internal // UniqueID generates a random 20-character ID for photo batches func UniqueID() string // Usage: id := internal.UniqueID() fmt.Printf("Generated ID: %s\n", id) // Output: // Generated ID: aB3cD4eF5gH6iJ7kL8mN ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.