# CodePress CMS **[🇳🇱 Nederlands](README.md) | [🇬🇧 English](#)** A lightweight, file-based content management system built with PHP. **Version:** 1.0.0 | **License:** AGPL v3 / Commercial ## ✨ Features - 📝 **Multi-format Content** - Supports Markdown, PHP and HTML files - 🧭 **Dynamic Navigation** - Automatic menu generation with dropdowns - 🔍 **Search Functionality** - Full-text search through all content - 🧭 **Breadcrumb Navigation** - Intuitive navigation paths - 🔗 **Auto-linking** - Automatic links between pages - 📱 **Responsive Design** - Works perfectly on all devices - ⚙️ **JSON Configuration** - Easy configuration via JSON - 🎨 **Bootstrap 5** - Modern UI framework - 🔒 **Security** - Secure content management (100/100 security score) ## 🚀 Quick Start 1. **Upload** files to web server 2. **Set permissions** for web server 3. **Configure** (optional) via `config.json` 4. **Visit** website via browser ## 📁 Project Structure ``` codepress/ ├── engine/ │ ├── core/ │ │ ├── class/ │ │ │ ├── CodePressCMS.php # Main CMS class │ │ │ ├── Logger.php # Logging system │ │ │ └── SimpleTemplate.php # Template engine │ │ ├── config.php # Configuration loader │ │ └── index.php # CMS engine │ ├── lang/ # Language files (nl.php, en.php) │ └── templates/ # Template files │ ├── layout.mustache │ ├── assets/ │ │ ├── header.mustache │ │ ├── navigation.mustache │ │ └── footer.mustache │ ├── markdown_content.mustache │ ├── php_content.mustache │ └── html_content.mustache ├── public/ # Web root │ ├── assets/ │ │ ├── css/ │ │ ├── js/ │ │ └── favicon.svg │ ├── content/ # Content files │ │ ├── nl.homepage.md # Dutch homepage │ │ ├── en.homepage.md # English homepage │ │ └── [lang].[page].md # Multi-language pages │ └── index.php # Entry point ├── config.json # Configuration ├── version.php # Version tracking └── README.md # This file ``` ## ⚙️ Configuration ### Basic Configuration (`config.json`) ```json { "site_title": "CodePress", "content_dir": "public/content", "templates_dir": "engine/templates", "default_page": "homepage", "default_lang": "nl", "author": { "name": "Edwin Noorlander", "website": "https://noorlander.info", "git": "https://git.noorlander.info/E.Noorlander/CodePress.git" }, "seo": { "description": "CodePress CMS - Lightweight file-based content management system", "keywords": "cms, php, content management, file-based" } } ``` ### Configuration Options - **`site_title`** - Website name - **`content_dir`** - Directory with content files - **`templates_dir`** - Directory with template files - **`default_page`** - Default page (e.g., `"homepage"`) - **`default_lang`** - Default language (`"nl"` or `"en"`) - **`author`** - Author information with links - **`seo`** - SEO settings ## 📝 Content Types ### Markdown (.md) - Auto-linking between pages - GitHub Flavored Markdown support - Syntax highlighting for code blocks - Automatic title extraction - Multi-language support with `[lang].[page].md` format ### PHP (.php) - Full PHP support - Dynamic content generation - Database integration possible - Session management available ### HTML (.html) - Static HTML pages - Bootstrap components - Custom CSS and JavaScript - Full HTML5 validation ## 🌍 Multi-language Support CodePress supports multiple languages with automatic detection: ### File Naming Convention - `nl.[page].md` - Dutch content - `en.[page].md` - English content - Language prefix is automatically removed from display ### URL Format - `/?page=test&lang=nl` - Dutch version - `/?page=test&lang=en` - English version - `/?page=test` - Uses default language from config ### Language Switching - Automatic language selector in navigation - Preserves current page when switching languages - Falls back to default language if translation missing ## 🎨 Design Features ### Navigation - **Tab-style navigation** with Bootstrap - **Dropdown menus** for folders and sub-folders - **Home button** with icon - **Active state** indication - **Responsive** hamburger menu - **Language selector** with flags ### Layout - **Flexbox layout** for modern structure - **Fixed header** with logo and search - **Breadcrumb navigation** between header and content - **Fixed footer** with metadata and version - **Scrollable content** area ### Responsive - **Mobile-first** approach - **Touch-friendly** interaction - **Adaptive** widths - **Consistent** experience ## 🔧 Requirements - **PHP 8.4+** or higher - **Web server** (Apache, Nginx, etc.) - **Write permissions** for PHP files - **Mod_rewrite** (optional for pretty URLs) ## 🛠️ Installation ### Via Composer ```bash composer create-project codepress/codepress cd codepress ``` ### Manual 1. **Download** the files 2. **Upload** to web server 3. **Set permissions** (755 for directories, 644 for files) 4. **Configure** `config.json` ### Web Server Configuration #### Apache ```apache AllowOverride All Require all granted RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [QSA,L] ``` #### Nginx ```nginx server { root /var/www/codepress/public; index index.php; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { fastcgi_pass unix:/var/run/php/php8.4-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } ``` ## 🏗️ PHP Classes ### SimpleTemplate Class `engine/core/class/SimpleTemplate.php` Lightweight template rendering engine supporting Mustache-style syntax without external dependencies. **Methods:** - `render($template, $data)` - Renders template with data - `replacePartial($matches)` - Replaces `{{>partial}}` placeholders **Features:** - `{{>partial}}` - Partial includes - `{{#variable}}...{{/variable}}` - Conditional blocks - `{{^variable}}...{{/variable}}` - Negative conditional blocks - `{{{variable}}}` - Unescaped HTML content - `{{variable}}` - Escaped content ### CodePressCMS Class `engine/core/class/CodePressCMS.php` Main CMS class managing all content management functionality. **Public Methods:** - `__construct($config)` - Initialize CMS with configuration - `getPage()` - Retrieves current page content - `getMenu()` - Generates navigation structure - `render()` - Renders complete page with templates **Private Methods:** - `buildMenu()` - Builds menu structure from content directory - `scanDirectory($dir, $prefix)` - Scans directory for content - `performSearch($query)` - Executes search query - `parseMarkdown($content)` - Converts Markdown to HTML - `parsePHP($filePath)` - Processes PHP files - `parseHTML($content)` - Processes HTML files - `getBreadcrumb()` - Generates breadcrumb navigation - `renderMenu($items, $level)` - Renders menu HTML - `getContentType($page)` - Determines content type - `formatDisplayName($name)` - Formats file/directory names for display **Features:** - Multi-format content support (MD, PHP, HTML) - Dynamic navigation with dropdowns - Search functionality with snippets - Breadcrumb navigation - Auto-linking between pages - File metadata tracking - Responsive template rendering - Multi-language support ### Logger Class `engine/core/class/Logger.php` Structured logging system for debugging and monitoring. **Methods:** - `__construct($logFile, $level)` - Initialize logger - `debug($message, $context)` - Debug level logging - `info($message, $context)` - Info level logging - `warning($message, $context)` - Warning level logging - `error($message, $context)` - Error level logging **Features:** - PSR-3 compatible logging interface - Configurable log levels - JSON context support - File-based logging with rotation - Timestamp and severity tracking ## 🔒 Security CodePress CMS has undergone comprehensive security testing: - **Security Score:** 100/100 - **Penetration Tests:** 40+ tests passed - **Vulnerabilities:** 0 critical, 0 high, 0 medium - **Protection:** XSS, SQL Injection, Path Traversal, CSRF - **Headers:** CSP, X-Frame-Options, X-Content-Type-Options - **Input Validation:** All user inputs sanitized - **Output Encoding:** htmlspecialchars() on all output See [pentest/PENTEST.md](pentest/PENTEST.md) for detailed security report. ## 📊 Quality Metrics ### Functionality: 92/100 - ✅ 46/50 tests passed - ✅ Core functionality working - ⚠️ 4 minor issues (non-critical) ### Code Quality: 98/100 - ✅ Clean, maintainable code - ✅ PSR-12 compliant - ✅ No unused functions - ✅ Structured logging system ### Overall: 96/100 See [function-test/test-report.md](function-test/test-report.md) for detailed test results. ## 📖 Documentation - **[Guide (NL)](guide/nl.codepress.md)** - Dutch documentation - **[Guide (EN)](guide/en.codepress.md)** - English documentation - **[AGENTS.md](AGENTS.md)** - Developer instructions - **[DEVELOPMENT.md](DEVELOPMENT.md)** - Development guide - **[CONTRIBUTING.md](CONTRIBUTING.md)** - Contribution guidelines ## 🤝 Contributing Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. **Important:** - All contributions must be notified to the author - Contributions are subject to AGPL v3 terms - Contact commercial@noorlander.info for commercial licensing ## 📄 License CodePress CMS is available under a **dual-license model**: ### 🆓 AGPL v3 (Open-Source) - **Free** for non-commercial use - **Requires** sharing modifications - **Copyleft** protection - See [LICENSE](LICENSE) for details ### 💼 Commercial License For commercial use without AGPL obligations: - **Individual:** €99 (1 developer) - **Business:** €499 (10 developers) - **Enterprise:** €2499 (unlimited) - **SaaS:** €999/year 📧 **Contact:** commercial@noorlander.info 📖 **More info:** [LICENSE-INFO.md](LICENSE-INFO.md) ## 🔗 Links - **Website**: https://noorlander.info - **Repository**: https://git.noorlander.info/E.Noorlander/CodePress - **Issues**: https://git.noorlander.info/E.Noorlander/CodePress/issues - **Releases**: https://git.noorlander.info/E.Noorlander/CodePress/releases ## 📦 Version History See [version.php](version.php) for detailed changelog. **Current Version: 1.0.0** - Initial production release - AGPL v3 + Commercial dual-license - Multi-language support (NL/EN) - Security score: 100/100 - Code quality: 98/100 - Comprehensive testing suite --- *Built with ❤️ by Edwin Noorlander*