editorial-system

Editorial System Documentation

Purpose

This application gives the editorial team a single-page operations console for harvesting outside sources, enriching them with keywords, preventing duplicates, and mirroring select content from WordPress. The stack is intentionally minimal: plain PHP 8 for every server concern and a vanilla JavaScript frontend served from index.html.

Quick Facts

Directory Overview

| Path | Description | | — | — | | index.html | Serves the SPA shell (styles.css, main.js). | | main.js | Implements the entire frontend (routing, UI state, API calls, WordPress helpers). | | styles.css | Default styling for the dashboard (Flexbox layout, panels, chips, etc.). | | includes/ | Configuration schema + defaults, bootstrap (init.php), ORM-like Model, WordPress helpers, and cron utilities. | | api/ | Thin endpoint scripts that validate inputs and dispatch to Model methods. | | docs/ | Documentation set (this file plus backend, frontend, and operations guides). |

High-Level Flow

  1. User signs in via the SPA login form and loads index.html.
  2. Frontend initializes (main.js), pulling /api/users.php to hydrate appState.users, reading the cached author id and Basic Auth credentials from localStorage, and mounting hash-based routes.
  3. Editors capture sources through the “新規ソース” workflow:
    • Paste a URL; Firecrawl scrapes metadata and Markdown via /api/crawl.php.
    • The UI triggers /api/detect-keywords.php, stores suggested keywords/title, and forces /api/sources.php duplicate checks.
    • If the reviewer approves, /api/sources.php creates the record, kicks the Slack webhook, and enforces rate limits (WORKING_SOURCES_LIMIT).
  4. Source triage + keyword views read from /api/sources.php, /api/search-sources.php, /api/keywords.php, /api/keyword-counts.php, etc.
  5. WordPress ingestion flows through cron endpoints like /api/cron.php or CLI backfill scripts that call WordPressConfig::back_fill(), persist posts, and detect keywords per post. New WordPress posts can also trigger background fact/editorial checks.
  6. WordPress browsing inside the SPA uses /api/wp-post.php+/api/search-keywords.php and displays titles via the decoding helper introduced in main.js (resolveWordPressTitle).

Additional Documents