Crate diaryx_core

Crate diaryx_core 

Source
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_property
  • get_frontmatter_property
  • rename_frontmatter_property
  • remove_frontmatter_property
  • get_all_frontmatter

Also, sorting frontmatter properties:

  • sort_frontmatter
  • sort_alphabetically
  • sort_by_pattern

§Managing file content

Operations for managing content of markdown files separate from frontmatter:

  • set_content
  • get_content
  • append_content
  • clear_content

§Search

Search frontmatter or content separately:

  • SearchQuery::content
  • SearchQuery::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§

pub use utils::date;
pub use utils::path as path_utils;

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.