Created a skeleton of the app
This commit is contained in:
commit
23b05394b4
7 changed files with 158 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/src/vendor/
|
23
composer.json
Normal file
23
composer.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "belle/ant-cms",
|
||||
"type": "project",
|
||||
"description": "A simple CMS built with PHP and Markdown",
|
||||
"minimum-stability": "stable",
|
||||
"require": {
|
||||
"michelf/php-markdown": "^2.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Belle\\AntCms\\": "src/"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Belle Aerni",
|
||||
"email": "belleaerni@gmail.com"
|
||||
}
|
||||
],
|
||||
"config": {
|
||||
"vendor-dir": "src/vendor"
|
||||
}
|
||||
}
|
75
composer.lock
generated
Normal file
75
composer.lock
generated
Normal file
|
@ -0,0 +1,75 @@
|
|||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "66ce6cf62e0203516b5e2e40d90fac81",
|
||||
"packages": [
|
||||
{
|
||||
"name": "michelf/php-markdown",
|
||||
"version": "2.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/michelf/php-markdown.git",
|
||||
"reference": "eb176f173fbac58a045aff78e55f833264b34e71"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/eb176f173fbac58a045aff78e55f833264b34e71",
|
||||
"reference": "eb176f173fbac58a045aff78e55f833264b34e71",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^3.0",
|
||||
"phpstan/phpstan": ">=1.0",
|
||||
"phpstan/phpstan-phpunit": ">=1.0",
|
||||
"phpunit/phpunit": "^9.5"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Michelf\\": "Michelf/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michel Fortin",
|
||||
"email": "michel.fortin@michelf.ca",
|
||||
"homepage": "https://michelf.ca/",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "John Gruber",
|
||||
"homepage": "https://daringfireball.net/"
|
||||
}
|
||||
],
|
||||
"description": "PHP Markdown",
|
||||
"homepage": "https://michelf.ca/projects/php-markdown/",
|
||||
"keywords": [
|
||||
"markdown"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/michelf/php-markdown/issues",
|
||||
"source": "https://github.com/michelf/php-markdown/tree/2.0.0"
|
||||
},
|
||||
"time": "2022-09-26T12:21:08+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.3.0"
|
||||
}
|
2
src/.htaccess
Normal file
2
src/.htaccess
Normal file
|
@ -0,0 +1,2 @@
|
|||
RewriteEngine On
|
||||
RewriteRule ^(.*)$ index.php [QSA,L]
|
35
src/AntCMS/App.php
Normal file
35
src/AntCMS/App.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
use Michelf\Markdown;
|
||||
|
||||
class AntCMS {
|
||||
public function renderPage($page, $params = null){
|
||||
$content = $this->getPage($page);
|
||||
if(!$content){
|
||||
$this->renderException("404");
|
||||
} else {
|
||||
echo Markdown::defaultTransform($content);
|
||||
}
|
||||
}
|
||||
|
||||
public function renderException($exceptionCode){
|
||||
$content = "# Error";
|
||||
$content .= "That request caused an $exceptionCode";
|
||||
echo Markdown::defaultTransform($content);
|
||||
}
|
||||
|
||||
public function getPage($page){
|
||||
$page = strtolower($page);
|
||||
$pagePath = appDir . "/Content/$page.md";
|
||||
if(file_exists($pagePath)){
|
||||
try {
|
||||
$pageContents = file_get_contents($pagePath);
|
||||
return $pageContents;
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
4
src/Content/index.md
Normal file
4
src/Content/index.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Hello World
|
||||
|
||||
This is the index.md file for my AntCMS project!
|
||||
If you see this, it works!
|
18
src/index.php
Normal file
18
src/index.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
const appDir = __DIR__;
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
require_once __DIR__ . '/AntCMS/App.php';
|
||||
|
||||
use \AntCMS;
|
||||
$antCms = new AntCMS();
|
||||
$requestedPage = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||
$indexes = ['/', '/index.php', '/index.html'];
|
||||
if (in_array($requestedPage, $indexes)) {
|
||||
$antCms->renderPage('index');
|
||||
} else {
|
||||
$antCms->renderPage($requestedPage);
|
||||
}
|
Loading…
Add table
Reference in a new issue