# CodePress CMS **[πŸ‡³πŸ‡± Nederlands](README.md) | [πŸ‡¬πŸ‡§ English](#)** A lightweight, file-based content management system built with PHP. **Version:** 1.5.0 | **License:** AGPL v3 / Commercial ## ✨ Features - πŸ“ **Multi-format Content** - Supports Markdown, PHP and HTML files - 🧭 **Dynamic Navigation** - Automatic menu generation with dropdowns - 🌍 **Multi-language** - Dutch and English with automatic detection - πŸ” **Search Functionality** - Full-text search through all content - 🧭 **Breadcrumb Navigation** - Intuitive navigation paths with sidebar toggle - πŸ”— **Auto-linking** - Automatic links between pages - πŸ“± **Responsive Design** - Works perfectly on all devices - βš™οΈ **JSON Configuration** - Easy configuration via JSON - 🎨 **Themes** - Customizable themes with colors and backgrounds - πŸ”’ **Security** - Secure content management (100/100 security score) - πŸ›‘οΈ **Admin Console** - Built-in admin panel with CodeMirror editor, media browser, theme manager, and plugin configuration ## πŸš€ Quick Start ```bash php -S localhost:8080 -t public ``` Visit `http://localhost:8080` in your browser. Admin panel: `http://localhost:8080/admin.php` (login: `admin` / `admin`) ## πŸ“ Project Structure ``` codepress/ β”œβ”€β”€ cms/ # Core CMS engine β”‚ β”œβ”€β”€ core/ β”‚ β”‚ β”œβ”€β”€ class/ β”‚ β”‚ β”‚ β”œβ”€β”€ CodePressCMS.php # Main CMS class β”‚ β”‚ β”‚ β”œβ”€β”€ Logger.php # Logging system β”‚ β”‚ β”‚ β”œβ”€β”€ SimpleTemplate.php # Mustache-style template engine β”‚ β”‚ β”‚ β”œβ”€β”€ Cache.php β”‚ β”‚ β”‚ β”œβ”€β”€ AssetManager.php β”‚ β”‚ β”‚ β”œβ”€β”€ SearchEngine.php β”‚ β”‚ β”‚ β”œβ”€β”€ ContentSecurityPolicy.php β”‚ β”‚ β”‚ └── ... β”‚ β”‚ β”œβ”€β”€ plugin/ β”‚ β”‚ β”‚ β”œβ”€β”€ PluginManager.php # Plugin loader β”‚ β”‚ β”‚ └── CMSAPI.php # Plugin API β”‚ β”‚ β”œβ”€β”€ config.php # Configuration loader β”‚ β”‚ └── index.php # Bootstrap (autoloader) β”‚ β”œβ”€β”€ lang/ # Language files (nl.php, en.php) β”‚ └── router.php # PHP dev server router (also serves /themes/) β”œβ”€β”€ themes/ # Dynamic themes (fully self-contained) β”‚ β”œβ”€β”€ default/ # Default theme β”‚ β”‚ β”œβ”€β”€ theme.json # { title, default_layout, layoutβ†’.twig mapping, colors } β”‚ β”‚ β”œβ”€β”€ base.twig # Main layout β”‚ β”‚ β”œβ”€β”€ full_content.twig # Layout: full width β”‚ β”‚ β”œβ”€β”€ left_sidebar.twig # Layout: sidebar left β”‚ β”‚ β”œβ”€β”€ right_sidebar.twig # Layout: sidebar right β”‚ β”‚ β”œβ”€β”€ custom1.twig # Layout: custom β”‚ β”‚ β”œβ”€β”€ partials/ # header, navigation, footer β”‚ β”‚ β”œβ”€β”€ css/theme.scss # SCSS source (compiled at runtime) β”‚ β”‚ └── js/theme.js # Theme JavaScript β”‚ β”œβ”€β”€ demo/ # Demo theme β”‚ └── test/ # Test theme β”œβ”€β”€ admin/ # Admin panel β”‚ β”œβ”€β”€ config/ β”‚ β”‚ β”œβ”€β”€ app.php # Admin configuration β”‚ β”‚ └── admin.json # Users & security β”‚ β”œβ”€β”€ src/ β”‚ β”‚ └── AdminAuth.php # Authentication (sessions, bcrypt, CSRF) β”‚ β”œβ”€β”€ templates/ β”‚ β”‚ β”œβ”€β”€ login.php β”‚ β”‚ β”œβ”€β”€ layout.php β”‚ β”‚ └── pages/ (dashboard, content, content-edit, content-new, β”‚ β”‚ content-dir-form, content-move-form, config, plugins, β”‚ β”‚ plugins-edit, plugins-new, plugin-config, theme, media, users) β”‚ └── storage/logs/ β”œβ”€β”€ cli/test/ # CLI scripts & tests β”œβ”€β”€ plugins/ # CMS plugins (HTMLBlock, MQTTTracker) β”œβ”€β”€ public/ # Web root β”‚ β”œβ”€β”€ assets/ β”‚ β”‚ β”œβ”€β”€ css/ (Bootstrap, styles, editor.css) β”‚ β”‚ β”œβ”€β”€ js/ (Bootstrap, app.js, editor-toolbar.js) β”‚ β”‚ └── codemirror/ (CodeMirror editor + modes) β”‚ β”œβ”€β”€ index.php # Website entry point β”‚ β”œβ”€β”€ admin.php # Admin entry point + router β”‚ └── themes/ # Uploaded theme backgrounds β”œβ”€β”€ themes/ # Theme configurations β”‚ β”œβ”€β”€ default/theme.json β”‚ └── test/theme.json β”œβ”€β”€ content/ # Content files β”œβ”€β”€ guide/ # Manuals (nl/en) β”œβ”€β”€ docs/ # Documentation └── config.json # Site configuration ``` ## βš™οΈ Configuration ### Basic Configuration (`config.json`) ```json { "site_title": "CodePress", "content_dir": "content", "default_page": "index", "active_theme": "default", "language": { "default": "nl", "available": ["nl", "en"] }, "seo": { "description": "CodePress CMS - Lightweight file-based content management system", "keywords": "cms, php, content management, file-based" }, "author": { "name": "E. Noorlander", "website": "https://noorlander.info" }, "features": { "auto_link_pages": true, "search_enabled": true, "breadcrumbs_enabled": true } } ``` ## πŸ“ Content Types ### Markdown (.md) - Auto-linking between pages - GitHub Flavored Markdown via `league/commonmark` - Automatic title extraction - Multi-language with `en.page.md` and `nl.page.md` ### PHP (.php) - Full PHP support - Dynamic content generation ### HTML (.html) - Static HTML pages - Bootstrap components ## πŸ›‘οΈ Admin Console CodePress includes a built-in admin panel for managing your website. **Access:** `/admin.php` | **Default login:** `admin` / `admin` ### Modules - **Dashboard** - Overview with statistics and quick actions - **Content** - Browse, create, edit, rename, move, and delete files - **CodeMirror Editor** - Syntax highlighting with toolbar (bold, italic, heading, link, image, list, media) - **Media Browser** - Upload and insert images/video/audio with size prompt - **Configuration** - Edit `config.json` with JSON validation - **Themes** - Create, activate, edit, delete themes with background upload - **Plugins** - Overview, install, configure, and toggle - **Users** - Add, remove users and change passwords ### Security - Session-based authentication with bcrypt password hashing - CSRF protection on all forms - Brute-force protection (5 attempts, 15 min lockout) - Path traversal protection via `realpath()` + prefix-check - Session timeout (30 min) - Security headers: CSP, X-Frame-Options, X-Content-Type-Options > **Important:** Change the default password immediately after installation via Users. ## 🎨 Themes Themes are stored in `themes/name/theme.json`: ```json { "name": "default", "label": "Standard", "header_color": "#0a369d", "header_font_color": "#ffffff", "navigation_color": "#2754b4", "navigation_font_color": "#ffffff", "sidebar_background": "#f8f9fa", "sidebar_border": "#dee2e6", "background_image": "/themes/default_bg.jpg" } ``` ## 🌍 Multi-language Support - File naming convention: `nl.[page].md` and `en.[page].md` - Language prefix is automatically removed from display - URL: `/?page=test&lang=nl` or `/?page=test&lang=en` - Automatic language detection via browser or config ## πŸ”§ Requirements - **PHP 8.1+** - **Web server** (Apache, Nginx, or PHP built-in server) - **Composer** (for `league/commonmark`) ## πŸ› οΈ Installation ```bash git clone https://git.noorlander.info/E.Noorlander/CodePress.git cd CodePress composer install php -S localhost:8080 -t public ``` ## πŸ“– Documentation - **[Guide (NL)](guide/nl.codepress.md)** - **[Guide (EN)](guide/en.codepress.md)** - **[TODO](TODO.md)** - Upcoming improvements - **[AGENTS.md](AGENTS.md)** - Developer instructions ## πŸ“„ License CodePress CMS is available under a **dual-license model**: AGPL v3 (open-source) or Commercial. --- *Built by Edwin Noorlander*