Skip to content

Commit

Permalink
0.4.0.alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
d4s6 committed Feb 25, 2020
1 parent e4c5179 commit 8ad75b7
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 123 deletions.
5 changes: 3 additions & 2 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ RewriteEngine on

RewriteBase /

RewriteRule ^asset/ - [L]
RewriteRule ^ html.php [L]
RewriteRule ^favicon.ico$ - [L]
RewriteRule ^asset/ - [L]
RewriteRule ^ genug.php [L]

</IfModule>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ a file-based CMS
under development

## requirements
- PHP 7.0
- PHP 7.4
- Apache, .htaccess, rewrite_module (mod_rewrite)

## installation
Expand Down
19 changes: 3 additions & 16 deletions asset/css/style.css
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
@CHARSET "UTF-8";
@charset "UTF-8";

.is_requested::before {
content: '\2192\A0';
nav a[aria-current="page"]::before {
content: "\2192\A0";
}

time,
[data-category] {
font-style: italic;
}

[data-category=site] {
color: green;
}

[data-category=news] {
color: red;
}
51 changes: 51 additions & 0 deletions genug.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
*
* @author David Ringsdorf http://davidringsdorf.de
* @license MIT License
*/

(function () {
try {
\ob_start();

(function (){
$bootstrapFile = __DIR__ . '/genug_core/genug/bootstrap.php';
if (! \is_readable($bootstrapFile)) {
throw new \Error("Failed opening required '" . $bootstrapFile . "'");
}
require_once $bootstrapFile;
})();

spl_autoload_register('\genug\autoloader');

\header('Content-Type: ' . \genug\Setting\CONTENT_TYPE);
\http_response_code(200);

try {
\genug\Api::requestedPage();

if (! \is_readable(\genug\Setting\VIEW_INDEX_FILE)) {
throw new \Error("Failed opening required '" . \genug\Setting\VIEW_INDEX_FILE . "'");
}
require_once \genug\Setting\VIEW_INDEX_FILE;
} catch (\genug\throwable_RequestedPageNotFound $t) {
\ob_clean();
\http_response_code(404);

if (\is_readable(\genug\Setting\VIEW_404_FILE)) {
require_once \genug\Setting\VIEW_404_FILE;
} else {
echo '404 Not Found';
}
}
} catch (\Throwable $t) {
\ob_clean();
\http_response_code(500);

echo '500 Internal Server Error';
throw $t;
} finally {
\ob_end_flush();
}
})();
20 changes: 20 additions & 0 deletions genug_core/genug/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
namespace genug\Setting
{

if (! \defined(__NAMESPACE__ . '\CONTENT_TYPE')) {

\define(__NAMESPACE__ . '\CONTENT_TYPE', 'text/html; charset=UTF-8');
}

if (! \defined(__NAMESPACE__ . '\MAIN_CATEGORY_ID')) {

\define(__NAMESPACE__ . '\MAIN_CATEGORY_ID', 'site');
Expand Down Expand Up @@ -55,6 +60,21 @@

\define(__NAMESPACE__ . '\CONTENT_DIR', namespace\USER_DIR . '/content');
}

if (! \defined(__NAMESPACE__ . '\VIEW_DIR')) {

\define(__NAMESPACE__ . '\VIEW_DIR', namespace\USER_DIR . '/view');
}

if (! \defined(__NAMESPACE__ . '\VIEW_INDEX_FILE')) {

\define(__NAMESPACE__ . '\VIEW_INDEX_FILE', namespace\VIEW_DIR . '/index.php');
}

if (! \defined(__NAMESPACE__ . '\VIEW_404_FILE')) {

\define(__NAMESPACE__ . '\VIEW_404_FILE', namespace\VIEW_DIR . '/404.php');
}
}
namespace genug
{
Expand Down
13 changes: 0 additions & 13 deletions genug_user/template/error404.html.php

This file was deleted.

59 changes: 0 additions & 59 deletions genug_user/template/main.html.php

This file was deleted.

13 changes: 13 additions & 0 deletions genug_user/view/404.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Not Found (404)</title>
</head>
<body>
<h1>Not Found (404)</h1>
<nav>
<a href="<?= genug\Api::homepage()->id() ?>">homepage</a>
</nav>
</body>
</html>
25 changes: 25 additions & 0 deletions genug_user/view/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php use genug\Api as g; ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><?= g::requestedPage()->title()?></title>
<link rel="stylesheet" href="/asset/css/style.css" />
</head>
<body>
<h1><?= g::requestedPage()->title() ?></h1>
<p><time datetime="<?= g::requestedPage()->date() ?>"><?= g::requestedPage()->date()->format(DATE_RFC1123) ?></time></p>
<?= g::requestedPage()->content()?>

<nav>
<h1>all pages</h1>
<ul>
<?php foreach (g::pages() as $page): ?>
<li>
<a href="<?= $page->id() ?>"<?php if ($page === g::requestedPage()) echo ' aria-current="page"' ?>><?= $page->title() ?></a>
</li>
<?php endforeach; ?>
</ul>
</nav>
</body>
</html>
32 changes: 0 additions & 32 deletions html.php

This file was deleted.

0 comments on commit 8ad75b7

Please sign in to comment.