EaglePress v1.0 — Plugin System
================================

EaglePress supports a plugin architecture for extending functionality.

## Plugin Directory Structure

Each plugin lives in its own directory under:
  /var/websites/EaglePress/www/html/pyEaglePress/plugins/PluginName/

## Required Files

  plugins/PluginName/
  ├── plugin.py        ← Entry point (required)
  ├── config.py        ← Plugin configuration (optional)
  ├── css/             ← Plugin stylesheets (optional)
  ├── js/              ← Plugin scripts (optional)
  └── templates/       ← Plugin HTML templates (optional)

## Plugin Entry Point (plugin.py)

The plugin.py file is exec()'d by index.py if the plugin is active.
It has access to the same variables as the main router:

  - db          : Database instance
  - _settings   : Site settings dict
  - _current_user: Current user dict or None
  - All _page_* variables

## Activating Plugins

To activate a plugin, it must be listed in ep_settings:
  setting_key = 'active_plugins'
  setting_value = 'PluginName1,PluginName2'

Or loaded manually in index.py by adding:
  _plugin_file = f"{INCLUDE_WEB_ROOT}/plugins/MyPlugin/plugin.py"
  if os.path.isfile(_plugin_file):
      with open(_plugin_file) as _pf:
          exec(_pf.read())

## Example Plugin Structure (plugin.py)

  # MyPlugin/plugin.py
  # EaglePress Plugin: My Plugin
  # Description: Does something cool
  # Version: 1.0

  def my_plugin_shortcode(content):
      return content.replace('[my-shortcode]', '<div class="my-plugin">Hello!</div>')

  # Hook into page rendering
  if _page_type == 'post' and _post:
      _post['rendered_content'] = my_plugin_shortcode(_post.get('rendered_content', ''))

## Plugin API

Plugins can:
  - Modify _page_content, _post, _posts before theme rendering
  - Add new admin routes by checking _path_parts
  - Register new AJAX endpoints (add .py files to ajax/ directory)
  - Add CSS/JS by injecting into _page_title (workaround) or modifying theme vars
  - Query the database via the `db` object
  - Access current user info via _current_user

## Example Included Plugin

  plugins/Plugin1/ — Sample plugin skeleton demonstrating the structure

## Notes

- Plugins are loaded BEFORE the theme executes
- Plugins should not print output directly (use variables to pass data to theme)
- AJAX endpoints in plugins should follow the same pattern as core ajax/ scripts
- Plugins run in the same Python scope as index.py

For more information, see the EaglePress documentation.
