Add comprehensive Obsidian integration as intermediate step toward PostgreSQL migration, enabling modern Markdown-based note editing: **Features:** - Obsidian Local REST API integration for vault access - Coordinate-based note matching (searches vault YAML frontmatter) - Shows top 5-8 closest matches when clicking burgs/markers - Modern Markdown editor with live preview - [[Wikilink]] support for connecting notes - "Open in Obsidian" button to jump to native app - Configuration UI for API setup and testing **Technical Implementation:** - modules/io/obsidian-bridge.js - Core API integration layer - modules/ui/obsidian-notes-editor.js - Markdown editor UI - modules/ui/obsidian-config.js - Configuration panel - OBSIDIAN_INTEGRATION.md - Complete setup/usage guide **Coordinate Matching:** - Parses YAML frontmatter for x/y coordinates - Calculates distance to clicked element - Supports nested (coordinates.x) and flat (x:) formats - Handles missing FMG IDs (common with PostgreSQL imports) **User Workflow:** 1. Configure Obsidian REST API connection 2. Click burg/marker in FMG 3. System finds matching notes by coordinates 4. Select note or create new one 5. Edit in modern Markdown editor 6. Save syncs to Obsidian vault instantly This replaces the "Win95-style TinyMCE" editor with a clean, modern Markdown experience while maintaining compatibility with the eventual PostgreSQL backend migration. Users can edit notes in either FMG or Obsidian - both stay in sync via file system. Version: 1.108.13
6.1 KiB
Obsidian Vault Integration for Fantasy Map Generator
Overview
Fantasy Map Generator now supports deep integration with your Obsidian vault for managing map lore and notes! This allows you to:
- Store all your world lore in Markdown format
- Edit notes in a modern Markdown editor (no more Win95-style TinyMCE!)
- Automatically link map elements to Obsidian notes by coordinates
- Keep your notes in sync between FMG and Obsidian
- Use wikilinks to connect related notes
- Edit in either FMG or Obsidian - changes sync both ways
Setup
1. Install Obsidian Local REST API Plugin
- Open Obsidian
- Go to Settings → Community Plugins
- Click Browse and search for "Local REST API"
- Install and Enable the plugin
- Go to Settings → Local REST API
- Copy your API Key (you'll need this!)
- Note the Server Port (default: 27123)
2. Configure in Fantasy Map Generator
- Open Fantasy Map Generator
- Go to Menu → Tools → ⚙ Obsidian
- Enter your settings:
- API URL:
http://127.0.0.1:27123(default) - API Key: Paste from Obsidian plugin settings
- Vault Name: Name of your Obsidian vault
- API URL:
- Click Test Connection to verify
- Click Save Configuration
Usage
Linking Map Elements to Notes
When you click on a burg or marker in FMG:
- FMG searches your Obsidian vault for notes with matching coordinates in YAML frontmatter
- Shows you the top 5-8 closest matches
- You select the note you want, or create a new one
Note Format
Notes in your vault should have YAML frontmatter like this:
---
fmg-id: burg123
fmg-type: burg
coordinates:
x: 234.5
y: 456.7
lat: 45.23
lon: -73.45
tags:
- capital
- settlement
- ancient
aliases:
- Eldoria
- The Ancient City
---
# Eldoria
The ancient capital sits upon the [[River Mystral]], founded in year 1203.
## History
The city was established by [[King Aldric the First]]...
## Notable Locations
- [[The Grand Library]]
- [[Temple of the Seven Stars]]
- [[Market Square]]
Coordinate Matching
Since your burgs/markers may have been imported from PostgreSQL without FMG IDs, the system matches by X/Y coordinates:
- FMG extracts the coordinates from the clicked element
- Searches all
.mdfiles in your vault for matchingx:andy:values - Calculates distance and shows closest matches
- You pick the right one!
Supported Coordinate Formats
The system recognizes these formats in YAML frontmatter:
# Nested object (recommended)
coordinates:
x: 123.4
y: 567.8
# Or flat
x: 123.4
y: 567.8
# Case insensitive
X: 123.4
Y: 567.8
Creating New Notes
If no matches are found:
- FMG offers to create a new note
- Enter a name (e.g., "Eldoria")
- Optionally specify a folder (e.g., "Locations/Cities")
- FMG generates a template with coordinates
- Opens in the Markdown editor
- Saved directly to your Obsidian vault!
Editing Notes
The modern Markdown editor includes:
- Live preview: Toggle between edit/preview modes
- Wikilinks: Link to other notes in your vault
- Syntax highlighting: Clean monospace font
- Open in Obsidian: Button to jump to the note in Obsidian app
- Save to Vault: Changes sync immediately
Using Wikilinks
Create connections between notes:
The [[King Aldric the First]] ruled from [[Eldoria]].
The city controls access to [[River Mystral]].
When you save in FMG, these links work in Obsidian!
Migration from PostgreSQL
If you have existing lore in PostgreSQL with coordinates:
- Export your data to Markdown files with YAML frontmatter
- Include
x,y,lat,lonin the frontmatter - Place files in your Obsidian vault
- FMG will auto-match by coordinates!
Example export script template:
for location in locations:
frontmatter = f"""---
fmg-type: {location.type}
coordinates:
x: {location.x}
y: {location.y}
lat: {location.lat}
lon: {location.lon}
tags: {location.tags}
---
# {location.name}
{location.description}
"""
with open(f"vault/{location.name}.md", "w") as f:
f.write(frontmatter)
Tips & Tricks
Organize Your Vault
Create folders for different types:
My Vault/
├── Locations/
│ ├── Cities/
│ ├── Landmarks/
│ └── Regions/
├── Characters/
├── History/
└── Lore/
Use Templates
Create Obsidian templates for different element types:
Templates/City.mdTemplates/Landmark.mdTemplates/Character.md
Search and Graph
In Obsidian:
- Use Search (
Ctrl+Shift+F) to find notes by coordinates - Use Graph View to see connections between locations
- Use Tags to organize by type
Sync Across Devices
Use Obsidian Sync or Git to keep your vault synced across computers!
Troubleshooting
Connection Failed
- Make sure Obsidian is running
- Verify the Local REST API plugin is enabled
- Check the port number (default 27123)
- Try restarting Obsidian
No Matches Found
- Check that your notes have
x:andy:fields in frontmatter - Verify coordinates are numbers, not strings
- Try increasing the search radius
Changes Not Appearing in Obsidian
- Obsidian should auto-detect file changes
- If not, try switching to another note and back
- Or close/reopen the note
Advanced
Custom Coordinate Systems
If you use a different coordinate system:
- Map your coordinates to FMG's system
- Store both in frontmatter:
coordinates:
x: 234.5 # FMG coordinates
y: 456.7
custom_x: 1000 # Your system
custom_y: 2000
Database Bridge
For the future PostgreSQL migration:
- Keep coordinates in both Obsidian and database
- Use coordinates as the join key
- Sync changes via API
- Eventually replace file storage with DB
Future Features
Planned enhancements:
- Time slider - view notes across historical periods
- Automatic tagging by region/culture
- Bulk import from database
- Real-time collaboration
- Custom Markdown extensions
Enjoy your modern, Markdown-powered world-building! 🗺️✨