This is dynamic content with PHP.
-\`\`\` +### Access -#### HTML (`.html`) -\`\`\`html -This is static HTML content.
-\`\`\` +- **URL**: `/admin.php` +- **Default login**: `admin` / `admin` -### File Naming Conventions +### Routes -- **Lowercase names**: Use lowercase for all files -- **No spaces**: Use hyphens (-) or underscores (_) -- **Language prefixes**: `en.page.md` and `nl.page.md` -- **Display names**: `file-name.md` displays as "File Name" in menus +| Route | Description | +|---|---| +| `login` | Login page | +| `logout` | Logout | +| `dashboard` | Dashboard with statistics | +| `content` | Content overview (browse, upload) | +| `content-edit` | Edit content (CodeMirror editor) | +| `content-new` | Create new content | +| `content-delete` | Delete content | +| `content-move` | Move content to another directory | +| `content-dir-form` | Create or edit directory | +| `content-dir-rename` | Rename directory | +| `content-dir-create` | Create directory (POST) | +| `content-dir-delete` | Delete directory (empty only) | +| `config` | Configuration editor (`config.json`) | +| `theme` | Theme management | +| `plugins` | Plugin overview | +| `plugins-new` | Create new plugin | +| `plugins-edit` | Edit plugin PHP source code | +| `plugins-config` | Edit plugin configuration | +| `plugins-toggle` | Enable/disable plugin | +| `plugins-delete` | Delete plugin | +| `media` | Media management (upload, delete) | +| `media-list` | JSON list of all media (for editor modal) | +| `users` | User management | + +### Editor Features + +The content editor (`content-edit`, `content-new`) includes: + +- **CodeMirror** syntax highlighting for Markdown/PHP/HTML +- **Toolbar** with buttons for: bold, italic, heading, link, image, list, media insert +- **Media browser modal** - Open via the "Media" button to select images/files +- **Inline filename rename** - Inline filename input with extension badge +- **Layout selector** - Choose from available layouts +- **Plugin per-page visibility** - Select which plugins to show on this page +- **Upload and "Create" buttons** are disabled until input is provided +- **"Cancel" button** (instead of "Back") for unsaved changes ## Templates @@ -173,93 +304,44 @@ $title = "Dynamic Page"; - `author_git` - Git repository link #### Page Info -- `page_title` - Page title (filename without extension) -- `content` - Page content (HTML) -- `file_info` - File information (dates, size) -- `is_homepage` - Boolean: is this homepage? +- `page_title` - Page title +- `content` - Content (HTML) +- `file_info` - File information +- `is_homepage` - Boolean: is this the homepage? #### Navigation - `menu` - Navigation menu - `breadcrumb` - Breadcrumb navigation - `homepage` - Homepage link -#### Theme +#### Theme (from theme.json) - `header_color` - Header background color - `header_font_color` - Header text color +- `header_height` - Header height in pixels - `navigation_color` - Navigation background color - `navigation_font_color` - Navigation text color +- `nav_height` - Navigation height in pixels +- `sidebar_background` - Sidebar background color +- `sidebar_border` - Sidebar border color +- `background_image_css` - CSS for background image +- `background_image_opacity` - Overlay opacity #### Language - `current_lang` - Current language (en/nl) - `current_lang_upper` - Current language (EN/NL) - `t_*` - Translated strings -## URL Structure - -### Basic URLs -- **Home**: `/` or `?page=home` -- **Page**: `?page=blog/article` -- **Search**: `?search=query` -- **Guide**: `?guide` -- **Language**: `?lang=en` or `?lang=nl` - -## SEO Optimization - -### Meta Tags - -The CMS automatically adds meta tags: - -\`\`\`html - - - - - - - -\`\`\` - -## π Plugin System - -### Plugin Structure - -\`\`\` -plugins/ -βββ README.md # Plugin documentation -βββ HTMLBlock/ -β βββ HTMLBlock.php # Plugin class -β βββ README.md # Plugin specific documentation -βββ MQTTTracker/ - βββ MQTTTracker.php # Plugin class - βββ config.json # Plugin configuration - βββ README.md # Plugin documentation -\`\`\` - -### Plugin Development - -- **API access** via `CMSAPI` class -- **Sidebar content** with `getSidebarContent()` -- **Metadata access** from YAML frontmatter -- **Configuration** via JSON files -- **Event hooks** for extension - -### Available Plugins - -- **HTMLBlock** - Custom HTML blocks in sidebar -- **MQTTTracker** - Real-time analytics and tracking - -## π― Template System - ### Layout Options Use YAML frontmatter to select layout: -\`\`\`yaml +```yaml --- title: My Page layout: sidebar-content +plugins: HTMLBlock --- -\`\`\` +``` ### Available Layouts @@ -271,70 +353,227 @@ layout: sidebar-content ### Meta Data -\`\`\`yaml +```yaml --- title: Page Title layout: content-sidebar description: Page description author: Author Name date: 2025-11-26 +plugins: HTMLBlock, MQTTTracker --- -\`\`\` +``` -## π Analytics & Tracking +## URL Structure + +### Frontend Page URLs +- **Home**: `/` or `?page=index&lang=en` +- **Page**: `?page=folder/page&lang=en` +- **Search**: `?search=query` +- **Guide**: `?guide` +- **Language switch**: `?lang=nl` or `?lang=en` + +### Media URLs +- **Media**: `/-media/path/to/file.jpg` (from any content subdirectory) +- **Assets**: `/-assets/file.jpg` (from content/-assets/, backward compatible) + +### Admin URLs +- **Admin**: `admin.php?route=dashboard` +- **Edit content**: `admin.php?route=content-edit&file=page.md` +- **New content**: `admin.php?route=content-new&dir=folder` +- **Edit theme**: `admin.php?route=theme&edit=themename` + +## SEO Optimization + +### Meta Tags + +The CMS automatically adds meta tags: +```html + + + + +``` + +### Security Headers + +```http +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-XSS-Protection: 1; mode=block +Referrer-Policy: strict-origin-when-cross-origin +Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline'; ... +``` + +## Plugin System + +### Plugin Structure + +``` +plugins/ +βββ HTMLBlock/ +β βββ HTMLBlock.php # Plugin class (required) +β βββ config.json # Configuration (optional) +β βββ README.md # Documentation (optional) +βββ MQTTTracker/ +β βββ MQTTTracker.php +β βββ config.json +β βββ README.md +βββ test/ + βββ test.php + βββ config.json + βββ README.md +``` + +### Plugin Development + +- **API access** via `CMSAPI` class - gives access to CMS configuration, templates, menu +- **Sidebar content** with `getSidebarContent()` - returns HTML for sidebar +- **Metadata access** from YAML frontmatter via `CMSAPI` +- **Configuration** via `config.json` - editable through admin panel +- **viewable** field in config.json determines if plugin is visible in sidebar +- **Per-page visibility** - via the editor plugin selector per page + +### Plugin Boilerplate + +```php +config = [ + 'viewable' => true, + ]; + } + + public function setAPI(CMSAPI $api): void + { + $this->api = $api; + } + + public function getSidebarContent(): string + { + return ''; + } + + public function getConfig(): array + { + return $this->config; + } + + public function setConfig(array $config): void + { + $this->config = array_merge($this->config, $config); + } +} +``` + +### Available Plugins + +- **HTMLBlock** - Custom HTML blocks in sidebar +- **MQTTTracker** - Real-time analytics and tracking via MQTT +- **test** - Example/test plugin + +### Known Issue: MQTTTracker Credentials + +The MQTTTracker plugin stores `broker_host`, `broker_port`, `client_id`, `username` and `password` in plain text in `plugins/MQTTTracker/config.json`. This is a known open security issue - in a production environment it is recommended to externalize these credentials to environment variables or a separate credential manager. + +## Analytics & Tracking ### MQTT Tracker -- Real-time page tracking +- Real-time page tracking via MQTT broker - Session management - Business Intelligence data - Privacy aware (GDPR compliant) - MQTT integration for dashboards +- Optional: visitor tracking, page views, performance metrics, user flows -### Data Format +## Frequently Asked Questions -\`\`\`json -{ - "timestamp": "2025-11-26T15:30:00+00:00", - "session_id": "cms_1234567890abcdef", - "page_url": "?page=demo/sidebar-content&lang=en", - "page_title": "Sidebar-Content Layout", - "language": "en", - "layout": "sidebar-content" -} -\`\`\` +### How do I set the homepage? -## Tips and Tricks +1. **Automatic**: Set `"default_page": "index"` in `config.json` (or omit the field) +2. **Manual**: Set `"default_page": "page-name"` in `config.json` -### Page Organization +### How does navigation work? -- Use subdirectories for categories -- Give each directory an `index.md` for an overview page -- Keep file names short and descriptive -- Use language prefixes: `en.page.md` and `nl.page.md` +- **Directories** become dropdown menus +- **Files** become direct links +- **Sub-directories** become nested dropdowns +- Only files without a language prefix show in the menu -### Content Optimization +### How do I add new content? -- Use clear headings (H1, H2, H3) -- Add descriptive meta information -- Use internal links for better navigation +1. Via the admin panel: `admin.php?route=content-new` +2. Or upload files to the `content/` directory +3. Organize in logical directories +4. Use correct filenames and extensions + +### How do I move a file or directory? + +1. Go to `admin.php?route=content` +2. Click "Move" next to the item +3. Select the target directory +4. Confirm the move + +### How do I create a new theme? + +1. Go to `admin.php?route=theme` +2. Enter a name and click "Create" +3. Adjust colors, heights and background +4. Activate the theme ## Troubleshooting -### Common Issues +### Page not found (404) -- **Empty pages**: Check file permissions -- **Template errors**: Verify template syntax -- **404 errors**: Check file names and paths -- **Navigation not updated**: Reload the page +1. Check filename and path +2. Check file extension (.md, .php, .html) +3. Check file permissions +4. Check if the file has the correct language prefix (`nl.` or `en.`) + +### Navigation not updated + +1. Reload the page +2. Check content directory structure +3. Check filenames (no spaces) +4. Files with language prefix only show in the correct language mode + +### Admin panel not accessible + +1. Check if the session is still valid +2. On lockout: wait 15 minutes or clear lockout data in `admin/config/admin.json` +3. Check CSRF token (reload the page) + +## Security + +- **CSRF protection** via tokens on all admin forms +- **Brute-force lockout** after 5 failed attempts (15 minute block) +- **Bcrypt password hashing** for user passwords +- **Path traversal prevention** via `realpath()` and prefix check +- **Direct content access** blocked (403 Forbidden) +- **Security headers** for all pages +- **PHP execution** in content directory blocked +- **File upload restrictions** on allowed extensions + +## Version + +Current version: **1.5.0** (codename: "Enhanced") +Release date: 2025-11-26 ## Support -### More Information +For technical support: +- **Git**: https://git.noorlander.info/E.Noorlander/CodePress +- **Website**: https://noorlander.info +- **Issues**: Report problems via Git issues -- Documentation: [CodePress Git](https://git.noorlander.info/E.Noorlander/CodePress) -- Issues and feature requests: [Git Issues](https://git.noorlander.info/E.Noorlander/CodePress/issues) +## License ---- - -*This guide is part of CodePress CMS and is automatically displayed when no content is available.* \ No newline at end of file +CodePress CMS is open-source software under dual-license: AGPL v3 for open-source use, commercial license for proprietary use. diff --git a/guide/nl.codepress.md b/guide/nl.codepress.md index 7f47544..4996de6 100644 --- a/guide/nl.codepress.md +++ b/guide/nl.codepress.md @@ -2,60 +2,66 @@ ## Overzicht -CodePress CMS is een lichtgewicht, file-based content management systeem gebouwd met PHP. Werkt zonder database. +CodePress CMS is een lichtgewicht, file-based content management systeem gebouwd met PHP (>=8.0). Werkt zonder database. ## Functies -### π Navigatie -- Tab-style navigatie met Bootstrap styling +### Navigatie +- Tab-style navigatie met Bootstrap 5 styling - Dropdown menus voor mappen en sub-mappen - Home knop met icoon -- Automatische menu generatie +- Automatische menu generatie op basis van directory structuur - Responsive design - Breadcrumb navigatie met sidebar toggle - Active state marking - **Sidebar toggle** - Knop links van HOME in de breadcrumb om de sidebar te openen/sluiten. Het icoon wisselt tussen open en gesloten status. De keuze blijft behouden tijdens de sessie -### π Content Types -- **Markdown (.md)** - CommonMark ondersteuning +### Content Types +- **Markdown (.md)** - CommonMark ondersteuning via `league/commonmark` - **PHP (.php)** - Dynamische content - **HTML (.html)** - Statische HTML pagina's - **Directory listings** - Automatische directory overzichten - **Language-specific content** - `nl.` en `en.` prefix -### π Zoekfunctionaliteit +### Zoekfunctionaliteit - Volledige tekst zoek door alle content - Resultaten met snippets en highlighting - Directe navigatie naar gevonden pagina's - SEO-vriendelijke zoekresultaten - Search URL: `?search=zoekterm` -### π§ Configuratie +### Configuratie - **JSON configuratie** in `config.json` -- Dynamische homepage instelling +- Dynamische homepage instelling (`default_page`) - SEO instellingen (description, keywords) - Author informatie met links -- Thema configuratie met kleuren +- Thema configuratie via `themes/` directory - Language settings -- Feature toggles +- Feature toggles (auto_link_pages, search_enabled, breadcrumbs_enabled) -### π¨ Layout & Design +### Layout & Design - Flexbox layout voor responsive structuur - Fixed header met logo en zoekfunctie - Breadcrumb navigatie - Fixed footer met file info en links - Bootstrap 5 styling -- Mustache templates +- Mustache templates (`cms/templates/`) - Semantic HTML5 structuur - **Dynamic layouts** met YAML frontmatter - **Sidebar support** met plugin integratie en toggle functie via breadcrumb +- **Thema ondersteuning** via `themes/` map met theme.json per thema -### π‘οΈ Admin Console +### Admin Console - Ingebouwd admin paneel op `/admin.php` -- **Dashboard** met statistieken en snelle acties -- **Content beheer** - Bestanden browsen, aanmaken, bewerken en verwijderen +- **Dashboard** met statistieken (aantal pagina's, mappen, plugins) en snelle acties +- **Content beheer** - Bestanden browsen, uploaden, aanmaken, bewerken, hernoemen, verplaatsen en verwijderen +- **CodeMirror editor** met toolbar (vet, cursief, kop, link, afbeelding, lijst, media invoegen) +- **Media browser modal** in de editor voor het selecteren van afbeeldingen/bestanden +- **Map beheer** - Mappen aanmaken, hernoemen en verwijderen (alleen lege mappen) - **Configuratie editor** - `config.json` bewerken met JSON-validatie -- **Plugin overzicht** - Status van alle geinstalleerde plugins +- **Thema beheer** - Thema's aanmaken, activeren, bewerken (kleuren, achtergrond) en verwijderen +- **Plugin beheer** - Overzicht, aanmaken, bewerken, configureren, in-/uitschakelen en verwijderen +- **Media beheer** - Uploaden en verwijderen van mediabestanden in `content/-assets/` - **Gebruikersbeheer** - Gebruikers toevoegen, verwijderen, wachtwoorden wijzigen - Session-based authenticatie met bcrypt hashing - CSRF-bescherming, brute-force lockout (5 pogingen, 15 min) @@ -65,63 +71,164 @@ CodePress CMS is een lichtgewicht, file-based content management systeem gebouwd 1. Upload bestanden naar webserver 2. Stel permissies in voor webserver -3. Configureer `config.json` indien nodig -4. Toegang tot website via browser +3. Voer `composer install` uit voor CommonMark dependency +4. Configureer `config.json` indien nodig +5. Toegang tot website via browser +6. **PHP ontwikkelserver**: `php -S localhost:8080 -t public` (gebruikt `cms/router.php`) + +## Projectstructuur + +``` +codepress/ +βββ cms/ # Core CMS engine +β βββ core/ +β β βββ class/ +β β β βββ CodePressCMS.php # Hoofd CMS class (content, navigatie, search) +β β β βββ Logger.php # Gestructureerd logging systeem +β β β βββ SimpleTemplate.php # Mustache-style template engine +β β βββ plugin/ +β β β βββ PluginManager.php # Plugin lader en beheer +β β β βββ CMSAPI.php # API voor plugin developers +β β βββ config.php # Configuratie lader (merge met config.json) +β β βββ index.php # Bootstrap (autoloader, requires) +β βββ lang/ # Taalbestanden +β β βββ nl.php # Nederlandse vertalingen +β β βββ en.php # Engelse vertalingen +β βββ logs/ # CMS logs +β βββ templates/ # Mustache templates +β β βββ layout.mustache # Hoofd layout (CSS, structuur) +β β βββ assets/ # Header, navigation, footer partials +β β βββ markdown_content.mustache +β β βββ php_content.mustache +β β βββ html_content.mustache +β βββ router.php # PHP dev server router +βββ admin/ # Admin paneel +β βββ config/ +β β βββ app.php # Admin app configuratie (paden, timezone) +β β βββ admin.json # Gebruikers & security (bcrypt hashes) +β βββ src/ +β β βββ AdminAuth.php # Authenticatie (sessies, bcrypt, CSRF, lockout) +β βββ templates/ +β β βββ login.php # Login pagina +β β βββ layout.php # Admin layout met sidebar navigatie +β β βββ pages/ +β β βββ dashboard.php # Dashboard met statistieken +β β βββ content.php # Content overzicht met bestanden uploaden +β β βββ content-edit.php # CodeMirror editor met toolbar en rename +β β βββ content-new.php # Nieuwe content aanmaken +β β βββ content-dir-form.php # Map aanmaken/bewerken +β β βββ content-move-form.php # Content verplaatsen +β β βββ config.php # Configuratie editor (JSON) +β β βββ plugins.php # Plugin overzicht +β β βββ plugins-edit.php # Plugin PHP broncode editor +β β βββ plugins-new.php # Nieuwe plugin aanmaken +β β βββ plugin-config.php # Plugin configuratie editor +β β βββ theme.php # Thema beheer (aanmaken, activeren, bewerken) +β β βββ media.php # Media beheer (uploaden, verwijderen) +β β βββ users.php # Gebruikersbeheer +β βββ storage/logs/ # Admin logs +βββ cli/ # CLI scripts & tests +βββ content/ # Content bestanden +β βββ -assets/ # Geuploade mediabestanden +β βββ index.md # Standaard homepage +β βββ ... # Overige content +βββ plugins/ # CMS plugins +β βββ HTMLBlock/ # Custom HTML blokken in sidebar +β βββ MQTTTracker/ # Real-time analytics en tracking +β βββ test/ # Test plugin +βββ public/ # Web root +β βββ index.php # Website entry point (media serving + CMS) +β βββ admin.php # Admin entry point + routing +β βββ .htaccess # Apache rewrite/security rules +β βββ assets/ # CSS, JS, favicons +β β βββ codemirror/ # CodeMirror editor (minified JS/CSS) +β β βββ css/js/ # Bootstrap, icons, app CSS/JS +β βββ themes/ # Geuploade theme achtergronden +β βββ manifest.json / sw.js # PWA ondersteuning +βββ themes/ # Thema definities +β βββ default/ # Standaard thema +β β βββ theme.json # Kleuren, hoogtes, achtergrond +β βββ test/ # Test thema +β βββ theme.json +βββ config.json # Site configuratie +βββ version.php # Versie informatie (1.5.0) +βββ vendor/ # Composer dependencies +``` ## Configuratie ### Basis Configuratie (`config.json`) -\`\`\`json +```json { "site_title": "CodePress", "content_dir": "content", - "templates_dir": "engine/templates", - "default_page": "auto", + "templates_dir": "cms\/templates", + "default_page": "index", + "active_theme": "default", "language": { "default": "nl", "available": ["nl", "en"] }, - "theme": { - "header_color": "#0a369d", - "header_font_color": "#ffffff", - "navigation_color": "#2754b4", - "navigation_font_color": "#ffffff", - "sidebar_background": "#f8f9fa", - "sidebar_border": "#dee2e6" - }, - "author": { - "name": "E. Noorlander", - "website": "https://noorlander.info" - }, "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 } } -\`\`\` +``` + +- `active_theme` - Bepaalt welk thema uit `themes/` actief is +- `templates_dir` - Map met Mustache templates (`cms/templates`) +- `default_page` - Standaard pagina (bijv. `index`) +- `content_dir` - Map met content bestanden (wordt gewoonlijk niet gewijzigd) + +### Thema Configuratie (`themes/