v2.5.1: Admin theme refactor, Navigation plugin, user roles, guide restructure

- Reorganize admin into admin/theme/default/ (views + assets)
- Rename GuideNav to Navigation plugin (essential, protected)
- Plugin assets support (SCSS/CSS) loaded after theme CSS
- User roles: Admin, Content Manager, BI Manager, Site Admin
- Role-based access control (RBAC) for admin routes and sidebar
- Guide restructure: sub-topics in separate folders with sidebar nav
- Dynamic breadcrumb for homepage and subdirectories
- Fix theme path traversal (../../ -> ../) in admin.php
- Fix CodeMirror mode load order (xml -> css -> js -> htmlmixed -> php)
- Fix editor-toolbar.js null checks for plugin edit pages
- Layout select from theme.json with live frontmatter update
- Footer sticky at bottom of viewport (min-height: 100vh)
- Breadcrumb color fix (var(--nav-font) -> var(--header-bg))
- Remove language switcher from guide pages
- Update README.md and README.en.md
- Bump version to 2.5.1
This commit is contained in:
2026-08-10 15:36:29 +02:00
parent 0961b23b8d
commit cd498c8c3a
209 changed files with 11033 additions and 9125 deletions
+168 -164
View File
@@ -1,223 +1,227 @@
# CodePress CMS
**[🇳🇱 Nederlands](README.md) | [🇬🇧 English](#)**
**[🇳🇱 Dutch](README.md) | [🇬🇧 English](#)**
A lightweight, file-based content management system built with PHP.
A lightweight, file-based content management system built with PHP (≥8.0).
**Version:** 1.5.0 | **License:** AGPL v3 / Commercial
**Version:** 2.5.1 | **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
- 📝 **Multi-format Content** - Markdown, PHP and HTML files
- 🧭 **Dynamic Navigation** - Automatic menu generation
- 🌍 **Multi-language** - NL/EN/DE/FR support
- 🔍 **Search** - Full-text search
- 📱 **Responsive** - Bootstrap 5 themes
- 🔒 **Security** - 100/100 pentest score
- 🛡️ **Admin Console** - CodeMirror editor, media management, themes, plugins
- 👥 **User Roles** - Admin, Content Manager, BI Manager, Site Admin
- 📊 **Analytics** - Visitor statistics with GeoIP
- 🤖 **BotGuard** - Bot/AI protection
- 📈 **Logging** - Comprehensive logging system
- 🔌 **Plugin System** - Sidebar plugins with own CSS/SCSS, Twig templates
## 🚀 Quick Start
```bash
php -S localhost:8080 -t public
# Install dependencies
composer install
# Start server with router for clean URLs
php -S localhost:8080 cms/router.php
```
Visit `http://localhost:8080` in your browser.
Admin panel: `http://localhost:8080/admin.php` (login: `admin` / `admin`)
**Website:** `http://localhost:8080`
**Admin:** `http://localhost:8080/admin` (login: `admin` / `admin`)
## 📚 Documentation
See **[guide/](guide/)** for extensive documentation per role:
| Role | Guide |
|------|-------|
| 📝 Content Editor | [Content Manager](guide/en/content-beheerder.md) |
| ⚙️ Administrator | [Admin Manager](guide/en/admin-beheerder.md) |
| 🎨 Theme Developer | [Theme Developer](guide/en/theme-developer.md) |
| 💻 Developer | [CodePress Developer](guide/en/codepress-developer.md) |
Each guide has sub-topics in separate folders with sidebar navigation.
## 👥 User Roles
| Role | Permissions |
|------|------------|
| **Admin** | Full access (everything) |
| **Content Manager** | Content management, guide |
| **BI Manager** | Statistics, logs, guide |
| **Site Admin** | Theme, plugins, statistics, logs, update, guide |
## 📁 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
├── cms/ # Core CMS engine
│ ├── core/class/ # CMS classes (CodePressCMS, ThemeManager, etc.)
│ ├── core/plugin/ # Plugin system (PluginManager, CMSAPI)
├── lang/ # Translation files (nl.php, en.php)
└── router.php # PHP dev server router (clean URLs)
├── admin/ # Admin console
├── config/ # Admin configuration (admin.json)
├── src/AdminAuth.php # Authentication, roles, permissions
├── storage/ # Logs, cache, geoip
└── theme/default/ # Admin theme
├── assets/ # CSS, JS, fonts, codemirror
├── views/ # Twig templates (layouts, pages)
── theme.json # Admin theme configuration
├── themes/ # Website themes
│ ├── default/ # Default theme
│ │ ── theme.json # Layout mapping, colors
│ ├── base.twig # Main layout
│ ├── *.twig # Layout templates
│ │ ├── partials/ # Header, navigation, footer
│ └── assets/ # SCSS, CSS, JS, img
└── demo/ # Demo theme
├── plugins/ # Plugins
│ ├── HTMLBlock/ # Example sidebar plugin
└── Navigation/ # Essential navigation plugin (protected)
├── Navigation.php # Plugin code
├── plugin.json # Plugin metadata
├── assets/scss/ # Plugin SCSS source
── assets/css/ # Plugin CSS
├── content/ # Website content (.md, .php, .html)
├── public/ # Web root
── index.php # Website entry point
│ └── admin.php # Admin entry point + routing
├── guide/ # Documentation (nl/en)
│ ├── nl/ # Dutch guides
│ └── en/ # English guides
├── cli/test/ # Test suites
├── var/ # Cache (twig)
├── config.json # Site configuration
├── composer.json # PHP dependencies
└── version.php # Version information
```
## ⚙️ Configuration
### Basic Configuration (`config.json`)
### config.json
```json
{
"site_title": "CodePress",
"content_dir": "content",
"default_page": "index",
"active_theme": "default",
"default_page": "auto",
"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"
},
"enabled_plugins": ["HTMLBlock", "Navigation"],
"features": {
"auto_link_pages": true,
"search_enabled": true,
"breadcrumbs_enabled": true
}
},
"security": {
"block_ai_bots": true,
"rate_limit_enabled": true
},
"analytics": { "enabled": true },
"logging": { "enabled": true }
}
```
## 📝 Content Types
## 🔧 Dependencies
### 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 ≥8.0** with extensions: json, mbstring
- **Composer** packages:
- twig/twig (templating)
- scssphp/scssphp (SCSS compilation)
- league/commonmark (Markdown with HeadingPermalinks)
- maxmind-db/reader (GeoIP)
### PHP (.php)
- Full PHP support
- Dynamic content generation
## 🔐 Security
### HTML (.html)
- Static HTML pages
- Bootstrap components
- ✅ XSS prevention (htmlspecialchars)
- ✅ CSRF tokens (admin forms)
- ✅ Path traversal prevention (realpath checks)
- ✅ Secure cookies (HttpOnly, SameSite)
- ✅ Security headers (X-Frame-Options, CSP)
- ✅ Bot/AI protection (BotGuard)
- ✅ Rate limiting per IP
- ✅ Role-based access control (RBAC)
## 🛡️ Admin Console
## 🔌 Plugins
CodePress includes a built-in admin panel for managing your website.
### Plugin structure
**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"
}
```
plugins/MyPlugin/
├── MyPlugin.php # Plugin code (name = plugin name)
├── plugin.json # Plugin metadata
├── assets/scss/ # Plugin SCSS source
└── assets/css/ # Plugin CSS (after compilation)
```
## 🌍 Multi-language Support
### Essential plugins
- 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
The **Navigation** plugin is an essential plugin and cannot be disabled, edited, or deleted. This plugin automatically generates sidebar navigation for guides and content.
## 🔧 Requirements
### Plugin CSS
- **PHP 8.1+**
- **Web server** (Apache, Nginx, or PHP built-in server)
- **Composer** (for `league/commonmark`)
Plugin CSS is automatically loaded after theme CSS, so themes can override plugin styling.
## 🛠️ Installation
## 📝 Content Examples
### Markdown with frontmatter
```markdown
---
layout: full_content
plugins: HTMLBlock, Navigation
---
# Page title
Content in Markdown format...
```
### PHP content
```php
<?php
/** @var ContentAPI $api */
$pages = $api->getAllPages();
echo "<h1>My Page</h1>";
echo "<p>Number of pages: " . count($pages) . "</p>";
```
## 🧪 Testing
```bash
git clone https://git.noorlander.info/E.Noorlander/CodePress.git
cd CodePress
composer install
php -S localhost:8080 -t public
# Penetration tests
cli/test/pentest/security-test.sh
# Accessibility tests (WCAG 2.1 AA)
cli/test/accessibility.sh
# Functional tests
cli/test/functional/*.sh
```
## 📖 Documentation
## 📞 Support
- **[Guide (NL)](guide/nl.codepress.md)**
- **[Guide (EN)](guide/en.codepress.md)**
- **[TODO](TODO.md)** - Upcoming improvements
- **[AGENTS.md](AGENTS.md)** - Developer instructions
- **Documentation:** [guide/](guide/)
- **Issues:** Git repository
- **Contact:** commercial@noorlander.info
## 📄 License
CodePress CMS is available under a **dual-license model**: AGPL v3 (open-source) or Commercial.
**Dual-licensed:**
- **AGPL v3** - For open-source projects
- **Commercial** - For proprietary use
See [LICENSE](LICENSE) for details.
---
*Built by Edwin Noorlander*
**CodePress CMS** - Built by E.Noorlander / CodePress Development Team