Expand description
title: Diaryx Core Library
author: adammharris
audience:
- public
§part_of: ../../README.md
§Diaryx Core Library
This is the diaryx_core library! It contains shared code for the Diaryx clients.
NOTE: this README is not finished yet!
§Provided functionality
§Managing frontmatter
Full key-value operations for managing frontmatter properties:
set_frontmatter_propertyget_frontmatter_propertyrename_frontmatter_propertyremove_frontmatter_propertyget_all_frontmatter
Also, sorting frontmatter properties:
sort_frontmattersort_alphabeticallysort_by_pattern
§Managing file content
Operations for managing content of markdown files separate from frontmatter:
set_contentget_contentappend_contentclear_content
§Search
Search frontmatter or content separately:
SearchQuery::contentSearchQuery::frontmatter
§Export
use diaryx_core::export::{ExportOptions, ExportPlan, Exporter};
use diaryx_core::fs::RealFileSystem;
use std::path::Path;
let workspace_root = Path::new("./workspace");
let audience = "public";
let destination = Path::new("./export");
let fs = RealFileSystem;
let exporter = Exporter::new(fs);
let plan = match exporter.plan_export(&workspace_root, audience, destination) {
Ok(plan) => plan,
Err(e) => {
eprintln!("✗ Failed to plan export: {}", e);
return;
}
};
let force = false;
let keep_audience = false;
let options = ExportOptions {
force,
keep_audience,
};
match exporter.execute_export(&plan, &options) {
Ok(stats) => {
println!("✓ {}", stats);
println!(" Exported to: {}", destination.display());
}
Err(e) => {
eprintln!("✗ Export failed: {}", e);
if !force && destination.exists() {
eprintln!(" (use --force to overwrite existing destination)");
}
}
}§Publish
§Templates
§Workspaces
§Date parsing
§Shared errors
§Configuration
§Filesystem abstraction
Re-exports§
Modules§
- backup
- Backup system for persisting workspace data Backup system for persisting workspace data to various targets.
- config
- Configuration options
- diaryx
- Unified Diaryx API - the main entry point Unified Diaryx API.
- entry
- Entry docs Entry operations module.
- error
- Error (common error types)
- export
- Export (for backup or filtering by audience property) Export module - filter and export workspace files by audience
- frontmatter
- Frontmatter parsing and manipulation utilities Shared frontmatter parsing and manipulation utilities.
- fs
- Filesystem abstraction Filesystem abstraction module.
- publish
- Publish (exports as HTML) Publishing functionality for diaryx workspaces
- search
- Search (query frontmatter or search content) Search functionality for diaryx workspaces
- template
- Templates for creating new entries Template engine for creating entries with pre-defined structures
- utils
- Utility functions (date parsing, path calculations) Utility functions for date parsing and path calculations.
- validate
- Validate (check workspace link integrity) Workspace link validation.
- workspace
- Workspace (specify a directory to work in) Workspace operations module.