-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feature/reintegrate-blog
# Conflicts: # composer.json # composer.lock # src/system/Environment.php # src/system/Router.php # src/system/Template.php
- Loading branch information
Showing
21 changed files
with
564 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# ADR | ||
|
||
An Architectural Decision (AD) is a software design choice that addresses a functional or non-functional requirement that is architecturally significant. An Architecturally Significant Requirement (ASR) is a requirement that has a measurable effect on a software system’s architecture and quality. An Architectural Decision Record (ADR) captures a single AD, such as often done when writing personal notes or meeting minutes; the collection of ADRs created and maintained in a project constitute its decision log. All these are within the topic of Architectural Knowledge Management (AKM). | ||
|
||
## Overall goals | ||
|
||
A) Strive to simplify. | ||
B) Everyone contributes. | ||
|
||
|
||
# Decision Record | ||
|
||
Decision IDs are auto incremented. IDs not in the document no longer apply. | ||
|
||
- 003 Cuttlefish only generates static websites. | ||
- 004 A content project consists of content assets and a php configuration file. All other code is in this project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?php | ||
|
||
namespace Cuttlefish\Blog; | ||
|
||
use Cuttlefish\Controller; | ||
use Cuttlefish\Html; | ||
use Cuttlefish\App; | ||
|
||
class ControllerAdmin extends Controller | ||
{ | ||
public array $allowed_methods = array( | ||
'index' => 'Overview', | ||
'clearCache' => 'Clear cache', | ||
'generateSite' => 'Generate static site', | ||
'logout' => 'Logout', | ||
); | ||
|
||
// admin section does not use content files | ||
protected string $contents; | ||
|
||
protected function isAllowedMethod($action): bool | ||
{ | ||
return array_key_exists($action, $this->allowed_methods); | ||
} | ||
|
||
protected function showTasks(): string | ||
{ | ||
$output = '<ul>'; | ||
$am = $this->allowed_methods; | ||
array_shift($am); | ||
foreach ($am as $key => $value) : | ||
$Url = new Cuttlefish\Url("/admin/$key"); | ||
$output .= sprintf('<li><a href="%s">%s</a></li>', $Url->url_absolute, $value); | ||
endforeach; | ||
|
||
$output .= '</ul>'; | ||
|
||
return $output; | ||
} | ||
|
||
protected function showLogin(): string | ||
{ | ||
return App::getInstance()->Security->login(); | ||
} | ||
|
||
protected function clearCache() | ||
{ | ||
$App = App::getInstance(); | ||
$App->Security->maybeLoginRedirect(); | ||
|
||
return $App->Cache->clear(); | ||
} | ||
|
||
protected function generateSite(): void | ||
{ | ||
$App = App::getInstance(); | ||
$App->Security->maybeLoginRedirect(); | ||
echo $App->Cache->generateSite(); | ||
} | ||
|
||
|
||
/** | ||
* @return void | ||
*/ | ||
public function init() | ||
{ | ||
App::getInstance()->Cache->abort(); | ||
|
||
$action = ( isset($this->args[0]) ) ? $this->args[0] : 'index'; | ||
if ($this->isAllowedMethod($action)) { | ||
$this->contents = $this->$action(); | ||
} else { | ||
exit("Method $action is not allowed"); | ||
} | ||
|
||
parent::init(); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function view() | ||
{ | ||
parent::view(); | ||
|
||
$this->View = new Html($this->contents, array( | ||
'layout' => 'layout.php', | ||
'controller' => 'admin', | ||
'model' => 'page', | ||
)); | ||
} | ||
|
||
public function index(): string | ||
{ | ||
if (App::getInstance()->Security->isLoggedIn()) { | ||
return $this->showTasks(); | ||
} | ||
|
||
return $this->showLogin(); | ||
} | ||
|
||
public function logout() | ||
{ | ||
$App = App::getInstance(); | ||
$App->Security->maybeLoginRedirect(); | ||
|
||
return $App->Security->logout(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Cuttlefish\Blog; | ||
|
||
use Configuration; | ||
use Cuttlefish\Controller; | ||
use Cuttlefish\Files; | ||
use Cuttlefish\Html; | ||
|
||
class ControllerArchive extends Controller | ||
{ | ||
/** | ||
* @return void | ||
*/ | ||
public function records() | ||
{ | ||
$content_dir = Configuration::CONTENT_FOLDER . '/posts'; | ||
$Files = new Files(array( 'url' => $content_dir ), $this->ext); | ||
$this->records = $Files->files(); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function model() | ||
{ | ||
$this->Model = new ModelPost($this->records); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function view() | ||
{ | ||
parent::view(); | ||
$this->View = new Html($this->Model->contents, array( | ||
'layout' => 'layout.php', | ||
'controller' => 'archive', | ||
'model' => 'post', | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Cuttlefish\Blog; | ||
|
||
use Configuration; | ||
use Cuttlefish\Controller; | ||
use Cuttlefish\Filesystem; | ||
use Cuttlefish\Html; | ||
|
||
class ControllerError extends Controller | ||
{ | ||
// single errors page | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function records() | ||
{ | ||
$content_dir = Configuration::CONTENT_FOLDER . '/errors/'; | ||
$url = $content_dir . implode("/", $this->args) . '.' . $this->ext; | ||
$this->records = [ Filesystem::convertUrlToPath($url) ]; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function model() | ||
{ | ||
$this->Model = new ModelPage($this->records); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function view() | ||
{ | ||
parent::view(); | ||
|
||
$this->View = new Html($this->Model->contents, array( | ||
'layout' => 'layout.php', | ||
'controller' => 'errors', | ||
'model' => 'page', | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Cuttlefish\Blog; | ||
|
||
use Configuration; | ||
use Cuttlefish\Controller; | ||
use Cuttlefish\Feed; | ||
use Cuttlefish\Files; | ||
|
||
class ControllerFeed extends Controller | ||
{ | ||
// single feed | ||
/** | ||
* @return void | ||
*/ | ||
public function records() | ||
{ | ||
$limit = Configuration::POSTS_HOMEPAGE; | ||
$content_dir = Configuration::CONTENT_FOLDER . '/posts'; | ||
$Records = new Files(array( 'url' => $content_dir ), $this->ext); | ||
$this->records = $Records->limit($limit + 5); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function model() | ||
{ | ||
$Model = new ModelPost($this->records); | ||
$this->Model = $Model->limit(10); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function view() | ||
{ | ||
parent::view(); | ||
$this->View = new Feed($this->Model->contents); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Cuttlefish\Blog; | ||
|
||
use Configuration; | ||
use Cuttlefish\Controller; | ||
use Cuttlefish\Files; | ||
use Cuttlefish\Html; | ||
|
||
class ControllerHome extends Controller | ||
{ | ||
// list of recent posts | ||
/** | ||
* @return void | ||
*/ | ||
public function records() | ||
{ | ||
$limit = Configuration::POSTS_HOMEPAGE; | ||
$content_dir = Configuration::CONTENT_FOLDER . '/posts'; | ||
$Files = new Files(array( 'url' => $content_dir ), $this->ext); | ||
$this->records = $Files->limit($limit + 5); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function model() | ||
{ | ||
$Model = new ModelPost($this->records); | ||
$this->Model = $Model->limit(Configuration::POSTS_HOMEPAGE); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function view() | ||
{ | ||
parent::view(); | ||
$this->View = new Html($this->Model->contents, array( | ||
'layout' => 'layout.php', | ||
'controller' => 'home', | ||
'model' => 'post', | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Cuttlefish\Blog; | ||
|
||
use Configuration; | ||
use Cuttlefish\Controller; | ||
use Cuttlefish\File; | ||
use Cuttlefish\Filesystem; | ||
|
||
// single image | ||
class ControllerImage extends Controller | ||
{ | ||
/** | ||
* @return void | ||
*/ | ||
public function records() | ||
{ | ||
$content_dir = Configuration::CONTENT_FOLDER . '/images/'; | ||
$this->records = [ Filesystem::convertUrlToPath($content_dir . implode('/', $this->args)) ]; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function model() | ||
{ | ||
$this->Model = new ModelFile($this->records); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function view() | ||
{ | ||
parent::view(); | ||
$this->View = new File($this->Model->contents[0]); | ||
$this->View->render(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Cuttlefish\Blog; | ||
|
||
use Configuration; | ||
use Cuttlefish\Controller; | ||
use Cuttlefish\Filesystem; | ||
use Cuttlefish\Html; | ||
|
||
// single page | ||
class ControllerPage extends Controller | ||
{ | ||
/** | ||
* @return void | ||
*/ | ||
public function records() | ||
{ | ||
$content_dir = Configuration::CONTENT_FOLDER . '/pages/'; | ||
$url = $content_dir . implode('/', $this->args) . '.' . $this->ext; | ||
$this->records = [ Filesystem::convertUrlToPath($url) ]; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function model() | ||
{ | ||
$this->Model = new ModelPage($this->records); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function view() | ||
{ | ||
parent::view(); | ||
|
||
$this->View = new Html($this->Model->contents, array( | ||
'layout' => 'layout.php', | ||
'controller' => 'pages', | ||
'model' => 'page', | ||
)); | ||
} | ||
} |
Oops, something went wrong.