# Project: WordPress Post Orchestrator

## 1. High-Level Vision
A desktop-based "Post Orchestrator" that bridges the gap between content creation (Google Docs/Markdown) and WordPress publishing. The goal is to automate the manual work of creating pages/posts while allowing the user to finish the "last mile" (internal links/SEO) in a draft state.

## 2. Technical Stack
- **Language:** Python
- **API:** WordPress REST API (using Application Passwords)
- **Environment:** .env for sensitive credentials (WP_URL, WP_USER, WP_APP_PASS)
- **Editor Logic:** Support for both 'Classic Editor' and 'Gutenberg (Block) Editor'

## 3. The Modular Workflow
### Component A: Source Connector (The Input)
- Reads metadata (YAML Front Matter) from Markdown files.
- Fetches content from Google Docs (future goal).
- **Template Mapping:** Logic to map source fields (e.g., `author_name`) to WP fields (e.g., `author`).

### Component B: UI Controller (The Brain)
- Handles the selection of sites and sources.
- Previews the content before sending.
- Provides a "Deep Link" to the WordPress draft after a successful post.

### Component C: WP-Publisher (The Output)
- Handles Media Uploads first to get `attachment_id`.
- Formats content:
    - **Classic Mode:** Clean HTML strings.
    - **Gutenberg Mode:** HTML wrapped in `` comments.
- Sends POST request to `/wp-json/wp/v2/pages` or `/posts`.

## 4. Current Progress
- ✅ Environment variables configured in `.env`.
- ✅ Initial Python script can read `titles.txt` and post basic pages.
- ⬜ (Next) Implement `python-frontmatter` to read full `.md` files.
- ⬜ (Next) Add logic to wrap HTML in Gutenberg comments if the site is not in "Classic" mode.

## 5. Coding Principles for AI Assist
- **Modular Code:** Keep API logic separate from File-Reading logic.
- **Error Handling:** Always check for `201 Created` and print clear error messages.
- **Scannable UI:** Use clear variable names like `is_classic_mode` to toggle formatting logic.