Compare commits

...

3 Commits

@ -1,4 +1,5 @@
APP_DEBUG=false
APP_LOCALE=en
DIRECTUS_API_URL=
DIRECTUS_API_TOKEN=

@ -1,4 +1,4 @@
# Super Gear Directus 1.0.0-rc2
# Super Gear Directus 1.0.0-rc3
Project to using a Directus Instance as CMS. Structure is inspired by Laravel, using [FlightPHP](https://github.com/mikecao/flight)
for handle Request.
@ -25,36 +25,4 @@ DIRECTUS_API_TOKEN=
## Repositories
For getting Data use **App\\Respositories\\RepositoryAbstract** to create Repository-Classes.
This is the default class to handle
```PHP
class PageRepository extends RepositoryAbstract
{
/** endpoint */
protected $endpoint = 'pages';
/**
* find single page with a slug,
* page must be published
*
* @param string $slug
* @return array
*/
public function findOneBySlug($slug)
{
if (!$slug) {
$slug = [ '_null' => 'true' ];
}
return $this->queryBuilder
->fields(['title', 'slug', 'content', 'view', 'meta', 'media_teaser.*', 'media_hero.*'])
->aliases('view', 'template')
->filter([
'status' => 'published',
'slug' => $slug
])
->findOne();
}
}
```

@ -0,0 +1,53 @@
<?php
namespace App\Controllers;
use App\Controllers\DirectusControllerAbstract;
use App\Repositories\SiteRepository;
use App\Repositories\PostRepository;
/**
* controller for render feed of posts
*
*
* @author Björn Hase, Tentakelfabrik
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.tentakelfabrik.de/Tentakelfabrik/super-gear-directus
*
*/
class FeedController extends DirectusControllerAbstract
{
private $limit = 20;
/**
*
*/
protected $page = [
'data' => [
'view' => 'rss'
]
];
/**
* get single page from slug
*
*
* @param string $slug
*/
public function indexAction()
{
$siteRepository = new SiteRepository();
$site = $siteRepository->findOne();
$postRepository = new PostRepository();
$posts = $postRepository->find($this->limit);
// change type
header('Content-Type: text/xml');
$this->render($this->page, [
'site' => $site,
'posts' => $posts
]);
}
}

@ -3,7 +3,7 @@
namespace App\Controllers;
use App\Controllers\DirectusControllerAbstract;
use App\Repositories\Manager;
use App\Repositories\PageRepository;
/**
* controller for page items from directus
@ -36,11 +36,11 @@ class PageController extends DirectusControllerAbstract
*/
public function getAction($slug = NULL)
{
$repository = Manager::get('Page');
$page = $repository->findOneBySlug($slug);
$pageRepository = new PageRepository();
$page = $pageRepository->findOneBySlug($slug);
if (count($page['data']) === 0) {
$this->app->redirect('/404', 301);
$this->app->redirect('/404');
} else {
$this->render($page);
}

@ -0,0 +1,36 @@
<?php
namespace App\Controllers;
use App\Controllers\DirectusControllerAbstract;
use App\Repositories\PostRepository;
/**
* controller for page items from directus
*
*
* @author Björn Hase, Tentakelfabrik
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.tentakelfabrik.de/Tentakelfabrik/super-gear-directus
*
*/
class PostController extends DirectusControllerAbstract
{
/**
* get single page from slug
*
*
* @param string $slug
*/
public function getAction($slug)
{
$repository = new PostRepository();
$post = $repository->findOneBySlug($slug);
if (count($post['data']) === 0) {
$this->app->redirect('/404');
} else {
$this->render($post);
}
}
}

@ -1,51 +0,0 @@
<?php
namespace App\Repositories;
use Exception;
/**
* Manager Class to create Repository Objects that
* are located in App\Repositories\
*
*
* @author Björn Hase, Tentakelfabrik
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.tentakelfabrik.de/Tentakelfabrik/super-gear-directus
*
*/
class Manager
{
/**
* naming of Repository
* @var string
*/
const NAMESPACE = 'App\Repositories\\';
/**
* naming of Repository
* @var string
*/
const REPOSITORY_SUFFIX = 'Repository';
/**
* getting repository object
*
* @param string $repositoryClass
* @return AbstractRepository
*/
public static function get($repositoryName)
{
$repositoryClass = self::NAMESPACE.$repositoryName.self::REPOSITORY_SUFFIX;
if (!class_exists($repositoryClass)) {
throw new Exception('Repository Class '.$repositoryClass.' not exists!');
}
// create respository object
$repository = new $repositoryClass();
return $repository;
}
}

@ -40,7 +40,7 @@ class PageRepository extends RepositoryAbstract
'media_teaser.*',
'media_hero.*'
])
->aliases('view', 'template')
->aliases('template', 'view')
->filter([
'status' => 'published',
'slug' => $slug

@ -0,0 +1,83 @@
<?php
namespace App\Repositories;
use App\Repositories\RepositoryAbstract;
/**
* request pages items from directus
*
* @author Björn Hase, Tentakelfabrik
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.tentakelfabrik.de/Tentakelfabrik/super-gear-directus
*
*/
class PostRepository extends RepositoryAbstract
{
/** endpoint */
protected $endpoint = 'posts';
/**
*
*/
public function find($limit = 20)
{
return $this->queryBuilder
->fields([
'title',
'slug',
'lead',
'content',
'view',
'date_created',
'published_at',
'media_teaser.id',
'media_teaser.description'
])
->aliases('template', 'view')
->filter([
'status' => 'published',
'published_at' => [
'_nnull' => 'true'
]
])
->sort(['published_at'])
->find();
}
/**
* find single page with a slug,
* page must be published
*
* @param string $slug
* @return array
*/
public function findOneBySlug($slug)
{
return $this->queryBuilder
->fields([
'title',
'slug',
'lead',
'content',
'view',
'meta',
'date_created',
'published_at',
'media_teaser.id',
'media_teaser.description',
'media_hero.id',
'media_hero.description',
])
->aliases('template', 'view')
->filter([
'status' => 'published',
'published_at' => [
'_nnull' => 'true'
],
'slug' => $slug
])
->findOne();
}
}

@ -29,11 +29,11 @@ class SiteRepository extends RepositoryAbstract
{
return $this->queryBuilder
->fields([
'title',
'title',
'description',
'logo'
])
->aliases('logo[id]', 'logo')
->aliases('logo', 'logo[id]')
->findOne();
}
}

@ -25,19 +25,20 @@ class SnippetRepository extends RepositoryAbstract
* @param string $slug
* @return array
*/
public function findByType($type)
public function findByName($name)
{
$results = $this->queryBuilder
->fields([
'title',
'content',
'name',
'view',
'blocks',
'files.directus_files_id'
'file.id',
'file.description'
])
->aliases('template', 'view')
->filter([
'type' => $type
'name' => $name
])
->find();

@ -1,6 +1,6 @@
{
"name": "tentakelfabrik/super-gear-directus",
"version": "1.0.0-rc2",
"version": "1.0.0-rc3",
"type": "project",
"license": "MIT",
"authors": [
@ -16,8 +16,10 @@
"erusev/parsedown": "1.7.*",
"vlucas/phpdotenv": "5.3.*",
"jenssegers/blade": "1.4.*",
"tentakelfabrik/pirectus": "^0.1.2",
"cocur/slugify": "^4.0"
"tentakelfabrik/pirectus": "^0.1.3",
"cocur/slugify": "^4.0",
"nesbot/carbon": "^2.54",
"mtownsend/read-time": "^2.0"
},
"autoload": {
"psr-4": {

297
composer.lock generated

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "fcd79dd392240661e898bba640146723",
"content-hash": "a83db35a0da974bc28038b8ae4581142",
"packages": [
{
"name": "cocur/slugify",
@ -82,34 +82,30 @@
},
{
"name": "doctrine/inflector",
"version": "2.0.3",
"version": "2.0.4",
"source": {
"type": "git",
"url": "https://github.com/doctrine/inflector.git",
"reference": "9cf661f4eb38f7c881cac67c75ea9b00bf97b210"
"reference": "8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/9cf661f4eb38f7c881cac67c75ea9b00bf97b210",
"reference": "9cf661f4eb38f7c881cac67c75ea9b00bf97b210",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89",
"reference": "8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^7.0",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan-strict-rules": "^0.11",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
"doctrine/coding-standard": "^8.2",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"vimeo/psalm": "^4.10"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Inflector\\": "lib/Doctrine/Inflector"
@ -157,7 +153,7 @@
],
"support": {
"issues": "https://github.com/doctrine/inflector/issues",
"source": "https://github.com/doctrine/inflector/tree/2.0.x"
"source": "https://github.com/doctrine/inflector/tree/2.0.4"
},
"funding": [
{
@ -173,7 +169,7 @@
"type": "tidelift"
}
],
"time": "2020-05-29T15:13:26+00:00"
"time": "2021-10-22T20:16:43+00:00"
},
{
"name": "erusev/parsedown",
@ -227,16 +223,16 @@
},
{
"name": "graham-campbell/result-type",
"version": "v1.0.2",
"version": "v1.0.3",
"source": {
"type": "git",
"url": "https://github.com/GrahamCampbell/Result-Type.git",
"reference": "84afea85c6841deeea872f36249a206e878a5de0"
"reference": "296c015dc30ec4322168c5ad3ee5cc11dae827ac"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/84afea85c6841deeea872f36249a206e878a5de0",
"reference": "84afea85c6841deeea872f36249a206e878a5de0",
"url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/296c015dc30ec4322168c5ad3ee5cc11dae827ac",
"reference": "296c015dc30ec4322168c5ad3ee5cc11dae827ac",
"shasum": ""
},
"require": {
@ -272,7 +268,7 @@
],
"support": {
"issues": "https://github.com/GrahamCampbell/Result-Type/issues",
"source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.0.2"
"source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.0.3"
},
"funding": [
{
@ -284,28 +280,29 @@
"type": "tidelift"
}
],
"time": "2021-08-28T21:34:50+00:00"
"time": "2021-10-17T19:48:54+00:00"
},
{
"name": "guzzlehttp/guzzle",
"version": "7.3.0",
"version": "7.4.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "7008573787b430c1c1f650e3722d9bba59967628"
"reference": "868b3571a039f0ebc11ac8f344f4080babe2cb94"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/7008573787b430c1c1f650e3722d9bba59967628",
"reference": "7008573787b430c1c1f650e3722d9bba59967628",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/868b3571a039f0ebc11ac8f344f4080babe2cb94",
"reference": "868b3571a039f0ebc11ac8f344f4080babe2cb94",
"shasum": ""
},
"require": {
"ext-json": "*",
"guzzlehttp/promises": "^1.4",
"guzzlehttp/psr7": "^1.7 || ^2.0",
"guzzlehttp/promises": "^1.5",
"guzzlehttp/psr7": "^1.8.3 || ^2.1",
"php": "^7.2.5 || ^8.0",
"psr/http-client": "^1.0"
"psr/http-client": "^1.0",
"symfony/deprecation-contracts": "^2.2"
},
"provide": {
"psr/http-client-implementation": "1.0"
@ -315,7 +312,7 @@
"ext-curl": "*",
"php-http/client-integration-tests": "^3.0",
"phpunit/phpunit": "^8.5.5 || ^9.3.5",
"psr/log": "^1.1"
"psr/log": "^1.1 || ^2.0 || ^3.0"
},
"suggest": {
"ext-curl": "Required for CURL handler support",
@ -325,7 +322,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "7.3-dev"
"dev-master": "7.4-dev"
}
},
"autoload": {
@ -341,19 +338,43 @@
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Jeremy Lindblom",
"email": "jeremeamia@gmail.com",
"homepage": "https://github.com/jeremeamia"
},
{
"name": "George Mponos",
"email": "gmponos@gmail.com",
"homepage": "https://github.com/gmponos"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https://github.com/Nyholm"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://sagikazarmark.hu"
"homepage": "https://github.com/sagikazarmark"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https://github.com/Tobion"
}
],
"description": "Guzzle is a PHP HTTP client library",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
"curl",
@ -367,7 +388,7 @@
],
"support": {
"issues": "https://github.com/guzzle/guzzle/issues",
"source": "https://github.com/guzzle/guzzle/tree/7.3.0"
"source": "https://github.com/guzzle/guzzle/tree/7.4.0"
},
"funding": [
{
@ -379,28 +400,24 @@
"type": "github"
},
{
"url": "https://github.com/alexeyshockov",
"type": "github"
},
{
"url": "https://github.com/gmponos",
"type": "github"
"url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle",
"type": "tidelift"
}
],
"time": "2021-03-23T11:33:13+00:00"
"time": "2021-10-18T09:52:00+00:00"
},
{
"name": "guzzlehttp/promises",
"version": "1.5.0",
"version": "1.5.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "136a635e2b4a49b9d79e9c8fee267ffb257fdba0"
"reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/136a635e2b4a49b9d79e9c8fee267ffb257fdba0",
"reference": "136a635e2b4a49b9d79e9c8fee267ffb257fdba0",
"url": "https://api.github.com/repos/guzzle/promises/zipball/fe752aedc9fd8fcca3fe7ad05d419d32998a06da",
"reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da",
"shasum": ""
},
"require": {
@ -455,7 +472,7 @@
],
"support": {
"issues": "https://github.com/guzzle/promises/issues",
"source": "https://github.com/guzzle/promises/tree/1.5.0"
"source": "https://github.com/guzzle/promises/tree/1.5.1"
},
"funding": [
{
@ -471,7 +488,7 @@
"type": "tidelift"
}
],
"time": "2021-10-07T13:05:22+00:00"
"time": "2021-10-22T20:56:57+00:00"
},
{
"name": "guzzlehttp/psr7",
@ -590,16 +607,16 @@
},
{
"name": "illuminate/bus",
"version": "v8.63.0",
"version": "v8.70.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/bus.git",
"reference": "a222094903c473b6b0ade0b0b0e20b83ae1472b6"
"reference": "be400399687b97d5558a224e970060fd5d5f2735"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/bus/zipball/a222094903c473b6b0ade0b0b0e20b83ae1472b6",
"reference": "a222094903c473b6b0ade0b0b0e20b83ae1472b6",
"url": "https://api.github.com/repos/illuminate/bus/zipball/be400399687b97d5558a224e970060fd5d5f2735",
"reference": "be400399687b97d5558a224e970060fd5d5f2735",
"shasum": ""
},
"require": {
@ -639,20 +656,20 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2021-09-15T14:32:50+00:00"
"time": "2021-10-21T19:19:36+00:00"
},
{
"name": "illuminate/collections",
"version": "v8.63.0",
"version": "v8.70.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/collections.git",
"reference": "8e6c29c49f28b90e9de0cac1c14290feb99202c5"
"reference": "05f286ec5fd2dd286e8384577047efc375c8954c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/collections/zipball/8e6c29c49f28b90e9de0cac1c14290feb99202c5",
"reference": "8e6c29c49f28b90e9de0cac1c14290feb99202c5",
"url": "https://api.github.com/repos/illuminate/collections/zipball/05f286ec5fd2dd286e8384577047efc375c8954c",
"reference": "05f286ec5fd2dd286e8384577047efc375c8954c",
"shasum": ""
},
"require": {
@ -693,11 +710,11 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2021-09-30T15:04:19+00:00"
"time": "2021-10-22T18:01:46+00:00"
},
{
"name": "illuminate/container",
"version": "v8.63.0",
"version": "v8.70.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/container.git",
@ -748,16 +765,16 @@
},
{
"name": "illuminate/contracts",
"version": "v8.63.0",
"version": "v8.70.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/contracts.git",
"reference": "ab4bb4ec3b36905ccf972c84f9aaa2bdd1153913"
"reference": "e76f4bce73a2a1656add24bd5210ebc4b8af49c0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/contracts/zipball/ab4bb4ec3b36905ccf972c84f9aaa2bdd1153913",
"reference": "ab4bb4ec3b36905ccf972c84f9aaa2bdd1153913",
"url": "https://api.github.com/repos/illuminate/contracts/zipball/e76f4bce73a2a1656add24bd5210ebc4b8af49c0",
"reference": "e76f4bce73a2a1656add24bd5210ebc4b8af49c0",
"shasum": ""
},
"require": {
@ -792,11 +809,11 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2021-09-08T12:09:40+00:00"
"time": "2021-10-22T18:01:46+00:00"
},
{
"name": "illuminate/events",
"version": "v8.63.0",
"version": "v8.70.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/events.git",
@ -851,16 +868,16 @@
},
{
"name": "illuminate/filesystem",
"version": "v8.63.0",
"version": "v8.70.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/filesystem.git",
"reference": "f33219e5550f8f280169e933b91a95250920de06"
"reference": "a7bc30dac4e27dbeb37b026f3dbaee13bd578861"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/filesystem/zipball/f33219e5550f8f280169e933b91a95250920de06",
"reference": "f33219e5550f8f280169e933b91a95250920de06",
"url": "https://api.github.com/repos/illuminate/filesystem/zipball/a7bc30dac4e27dbeb37b026f3dbaee13bd578861",
"reference": "a7bc30dac4e27dbeb37b026f3dbaee13bd578861",
"shasum": ""
},
"require": {
@ -909,11 +926,11 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2021-07-20T13:46:01+00:00"
"time": "2021-10-22T13:20:42+00:00"
},
{
"name": "illuminate/macroable",
"version": "v8.62.0",
"version": "v8.70.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/macroable.git",
@ -959,7 +976,7 @@
},
{
"name": "illuminate/pipeline",
"version": "v8.63.0",
"version": "v8.70.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/pipeline.git",
@ -1007,16 +1024,16 @@
},
{
"name": "illuminate/support",
"version": "v8.63.0",
"version": "v8.70.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/support.git",
"reference": "259993e2119e99be17c10486f66c5a13b7fe4a70"
"reference": "1ed88eed1d179e5a27171324e57692366449eca0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/support/zipball/259993e2119e99be17c10486f66c5a13b7fe4a70",
"reference": "259993e2119e99be17c10486f66c5a13b7fe4a70",
"url": "https://api.github.com/repos/illuminate/support/zipball/1ed88eed1d179e5a27171324e57692366449eca0",
"reference": "1ed88eed1d179e5a27171324e57692366449eca0",
"shasum": ""
},
"require": {
@ -1026,7 +1043,7 @@
"illuminate/collections": "^8.0",
"illuminate/contracts": "^8.0",
"illuminate/macroable": "^8.0",
"nesbot/carbon": "^2.31",
"nesbot/carbon": "^2.53.1",
"php": "^7.3|^8.0",
"voku/portable-ascii": "^1.4.8"
},
@ -1071,20 +1088,20 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2021-10-04T13:02:25+00:00"
"time": "2021-11-09T17:40:38+00:00"
},
{
"name": "illuminate/view",
"version": "v8.63.0",
"version": "v8.70.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/view.git",
"reference": "875ca9f548b17e1a225469e0b0f8bae3c9e4ff71"
"reference": "5e497ed2bf3452201a992bba7552306e49b17978"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/view/zipball/875ca9f548b17e1a225469e0b0f8bae3c9e4ff71",
"reference": "875ca9f548b17e1a225469e0b0f8bae3c9e4ff71",
"url": "https://api.github.com/repos/illuminate/view/zipball/5e497ed2bf3452201a992bba7552306e49b17978",
"reference": "5e497ed2bf3452201a992bba7552306e49b17978",
"shasum": ""
},
"require": {
@ -1125,7 +1142,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2021-09-20T14:39:52+00:00"
"time": "2021-11-06T15:10:53+00:00"
},
{
"name": "jenssegers/blade",
@ -1236,18 +1253,83 @@
},
"time": "2021-04-05T01:36:59+00:00"
},
{
"name": "mtownsend/read-time",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://github.com/mtownsend5512/read-time.git",
"reference": "b43f178095383bda3cdf606c8a288bf8cacf537e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mtownsend5512/read-time/zipball/b43f178095383bda3cdf606c8a288bf8cacf537e",
"reference": "b43f178095383bda3cdf606c8a288bf8cacf537e",
"shasum": ""
},
"require": {
"php": "^7.4|^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Mtownsend\\ReadTime\\Providers\\ReadTimeServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Mtownsend\\ReadTime\\": "src"
},
"files": [
"src/helpers.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Townsend",
"email": "mtownsend5512@gmail.com",
"role": "Developer"
}
],
"description": "A PHP package to show users how long it takes to read content.",
"keywords": [
"Minutes",
"article",
"blog",
"content",
"medium",
"min",
"read",
"reading",
"time"
],
"support": {
"issues": "https://github.com/mtownsend5512/read-time/issues",
"source": "https://github.com/mtownsend5512/read-time/tree/2.0.0"
},
"time": "2021-01-11T13:46:58+00:00"
},
{
"name": "nesbot/carbon",
"version": "2.53.1",
"version": "2.54.0",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "f4655858a784988f880c1b8c7feabbf02dfdf045"
"reference": "eed83939f1aed3eee517d03a33f5ec587ac529b5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/f4655858a784988f880c1b8c7feabbf02dfdf045",
"reference": "f4655858a784988f880c1b8c7feabbf02dfdf045",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/eed83939f1aed3eee517d03a33f5ec587ac529b5",
"reference": "eed83939f1aed3eee517d03a33f5ec587ac529b5",
"shasum": ""
},
"require": {
@ -1258,6 +1340,7 @@
"symfony/translation": "^3.4 || ^4.0 || ^5.0"
},
"require-dev": {
"doctrine/dbal": "^2.0 || ^3.0",
"doctrine/orm": "^2.7",
"friendsofphp/php-cs-fixer": "^3.0",
"kylekatarnls/multi-tester": "^2.0",
@ -1328,7 +1411,7 @@
"type": "tidelift"
}
],
"time": "2021-09-06T09:29:23+00:00"
"time": "2021-11-01T21:22:20+00:00"
},
{
"name": "phpoption/phpoption",
@ -1401,20 +1484,20 @@
},
{
"name": "psr/container",
"version": "1.1.1",
"version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
"reference": "513e0666f7216c7459170d56df27dfcefe1689ea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
"reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
"url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea",
"reference": "513e0666f7216c7459170d56df27dfcefe1689ea",
"shasum": ""
},
"require": {
"php": ">=7.2.0"
"php": ">=7.4.0"
},
"type": "library",
"autoload": {
@ -1443,9 +1526,9 @@
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
"source": "https://github.com/php-fig/container/tree/1.1.1"
"source": "https://github.com/php-fig/container/tree/1.1.2"
},
"time": "2021-03-05T17:36:06+00:00"
"time": "2021-11-05T16:50:12+00:00"
},
{
"name": "psr/http-client",
@ -2075,16 +2158,16 @@
},
{
"name": "symfony/translation",
"version": "v5.3.9",
"version": "v5.3.10",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "6e69f3551c1a3356cf6ea8d019bf039a0f8b6886"
"reference": "6ef197aea2ac8b9cd63e0da7522b3771714035aa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/6e69f3551c1a3356cf6ea8d019bf039a0f8b6886",
"reference": "6e69f3551c1a3356cf6ea8d019bf039a0f8b6886",
"url": "https://api.github.com/repos/symfony/translation/zipball/6ef197aea2ac8b9cd63e0da7522b3771714035aa",
"reference": "6ef197aea2ac8b9cd63e0da7522b3771714035aa",
"shasum": ""
},
"require": {
@ -2150,7 +2233,7 @@
"description": "Provides tools to internationalize your application",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/translation/tree/v5.3.9"
"source": "https://github.com/symfony/translation/tree/v5.3.10"
},
"funding": [
{
@ -2166,7 +2249,7 @@
"type": "tidelift"
}
],
"time": "2021-08-26T08:22:53+00:00"
"time": "2021-10-10T06:43:24+00:00"
},
{
"name": "symfony/translation-contracts",
@ -2248,16 +2331,16 @@
},
{
"name": "tentakelfabrik/pirectus",
"version": "0.1.1",
"version": "0.1.3",
"source": {
"type": "git",
"url": "https://github.com/tentakelfabrik/pirectus.git",
"reference": "64d168bb3d5e4c4d8eec3faa7cdcaba22fdd9ca0"
"reference": "58ed57814f1851b05aeec3ddc3717e087e07f7d8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tentakelfabrik/pirectus/zipball/64d168bb3d5e4c4d8eec3faa7cdcaba22fdd9ca0",
"reference": "64d168bb3d5e4c4d8eec3faa7cdcaba22fdd9ca0",
"url": "https://api.github.com/repos/tentakelfabrik/pirectus/zipball/58ed57814f1851b05aeec3ddc3717e087e07f7d8",
"reference": "58ed57814f1851b05aeec3ddc3717e087e07f7d8",
"shasum": ""
},
"require": {
@ -2282,9 +2365,9 @@
],
"support": {
"issues": "https://github.com/tentakelfabrik/pirectus/issues",
"source": "https://github.com/tentakelfabrik/pirectus/tree/v0.1.1"
"source": "https://github.com/tentakelfabrik/pirectus/tree/v0.1.3"
},
"time": "2021-10-11T07:32:53+00:00"
"time": "2021-10-15T09:39:24+00:00"
},
{
"name": "vlucas/phpdotenv",

@ -9,11 +9,20 @@ $flight->route('GET /@slug:[a-z0-9\-]+/$', function() use ($flight) {
// getting position and build route
$position = strlen($flight->request()->url) - 1;
$route = substr_replace($flight->request()->url, '', $position, 1);
$flight->redirect($route);
$flight->redirect($route, 301);
});
$flight->route('GET /404', array(new App\Controllers\PageController, 'notFoundAction'));
$flight->route('GET /feed', array(new App\Controllers\FeedController, 'indexAction'));
$flight->route('GET /blog/@slug:[a-z0-9\-]+$', array(new App\Controllers\PostController, 'getAction'));
$flight->route('GET /(@slug:[a-z0-9\-]+$)', array(new App\Controllers\PageController, 'getAction'));
$flight->start();
try {
$flight->start();
} catch (\Exception $exception) {
echo $exception->getMessage();
}

@ -2,8 +2,6 @@
@inject('siteRepository', 'App\Repositories\SiteRepository')
@inject('menuRepository', 'App\Repositories\MenuRepository')
@inject('markdownHelper', 'App\Helpers\MarkdownHelper')
@php
$site = $siteRepository->findOne();
$menuItems = $menuRepository->findByName('main');

@ -0,0 +1,53 @@
@extends('layout')
{{-- pretend duplicate content --}}
@push('head')
<meta name="robots" content="noindex,follow" />
@endpush
{{-- inject helper for content & repositories --}}
@inject('markdownHelper', 'App\Helpers\MarkdownHelper')
@inject('postRepository', 'App\Repositories\PostRepository')
@php
$posts = $postRepository->find();
@endphp
@section('content')
<h1>
{{ $page['data']['title'] }}
</h1>
<div class="content">
{!! $markdownHelper->parse($page['data']['content']) !!}
</div>
@if (count($posts) > 0)
@foreach($posts['data'] as $post)
<a class="post" href="/blog/{{ $post['slug'] }}">
<header class="post__header">
<h2 class="post__title">
{{ $post['title'] }}
</h2>
@include('partials.date', ['post' => $post])
@include('partials.readtime', ['post' => $post])
@if (isset($post['media_teaser']['id']))
<div class="post__teaser">
<img src="{{ assetsUrl($post['media_teaser']['id']) }}" alt="{{ $post['media_teaser']['description'] }}" />
</div>
@endif
</header>
<div class="content post__lead">
{!! $markdownHelper->parse($post['lead']) !!}
</div>
</div>
@endforeach
@else
<div class="post">
<p>
Nothing!
</p>
</div>
@endif
@endsection

@ -1,12 +1,29 @@
@extends('layout')
@inject('markdownHelper', 'App\Helpers\MarkdownHelper')
@inject('snippetRepository', 'App\Repositories\SnippetRepository')
@section('content')
<h1>
{{ $page['data']['title'] }}
</h1>
<div class="content">
{!! $markdownHelper->parse($page['data']['content']) !!}
</div>
@foreach($snippetRepository->findByName('default')['data'] as $snippet)
<div class="snippet">
<h3>
{{ $snippet['title'] }}
</h3>
<div class="snippet__media">
<img src="{{ assetsUrl($snippet['file']['id']) }}" alt="{{ $snippet['file']['description'] }}" />
</div>
<div class="snippet__content content">
{!! $markdownHelper->parse($snippet['content']) !!}
</div>
</div>
@endforeach
@endsection

@ -0,0 +1,5 @@
<div class="post__date">
<time datetime="{{ $post['published_at'] }}">
{{ Carbon\Carbon::parse($post['published_at'])->diffForHumans() }}
</time>
</div>

@ -0,0 +1,10 @@
@php
$content = $post['lead'].$post['content'];
$readtime = (new \Mtownsend\ReadTime\ReadTime($content))->timeOnly(true)->setTranslation([
'minute' => ''
])->get();
@endphp
<div class="post__readtime">
Reading time {{ $readtime }} Minutes
</div>

@ -0,0 +1,17 @@
@extends('layout')
@inject('markdownHelper', 'App\Helpers\MarkdownHelper')
@section('content')
<h1>
{{ $page['data']['title'] }}
</h1>
<div class="content content--lead">
{!! $markdownHelper->parse($page['data']['lead']) !!}
</div>
<div class="content">
{!! $markdownHelper->parse($page['data']['content']) !!}
</div>
@endsection

@ -0,0 +1,38 @@
@inject('markdownHelper', 'App\Helpers\MarkdownHelper')
@php
if (isset($_SERVER['HTTPS'])) {
$http = 'https';
} else {
$http = 'http';
}
$base_url = $http.'://'.$_SERVER['SERVER_NAME'];
@endphp
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ $site['data']['title'] }}</title>
<atom:link href="{{ $base_url }}/feed" rel="self" type="application/rss+xml" />
<link>{{ $base_url }}/blog</link>
<description>{{ $site['data']['description'] }}</description>
<lastBuildDate>{{ date(DATE_RSS) }}</lastBuildDate>
<language>{{ $_ENV['APP_LOCALE'] }}-{{ strtoupper($_ENV['APP_LOCALE']) }}</language>
@foreach($posts['data'] as $post)
<item>
<title>{{ $post['title'] }}</title>
<link>{{ $base_url.'/blog/'.$post['slug'] }}</link>
<pubDate>{{ date(DATE_RSS, strtotime($post['published_at'])) }}</pubDate>
<description>
<![CDATA[
{!! $markdownHelper->parse($post['lead']) !!}
{!! $markdownHelper->parse($post['content']) !!}
]]>
</description>
<guid isPermaLink="false">{{ $post['slug'] }}</guid>
</item>
@endforeach
</channel>
</rss>

@ -421,7 +421,7 @@ fields:
display_options: null
readonly: true
hidden: true
sort: 8
sort: 9
width: half
group: null
translations: null
@ -460,13 +460,87 @@ fields:
display_options: null
readonly: true
hidden: true
sort: 10
sort: 11
width: half
group: null
translations: null
note: null
conditions: null
required: false
- collection: posts
field: media_hero
type: string
schema:
name: media_hero
table: posts
data_type: char
default_value: null
generation_expression: null
max_length: 36
numeric_precision: null
numeric_scale: null
is_generated: false
is_nullable: true
is_unique: false
is_primary_key: false
has_auto_increment: false
foreign_key_column: id
foreign_key_table: directus_files
comment: ''
meta:
collection: posts
field: media_hero
special: null
interface: file-image
options: null
display: image
display_options: null
readonly: false
hidden: false
sort: 7
width: full
group: null
translations: null
note: null
conditions: null
required: false
- collection: posts
field: media_teaser
type: string
schema:
name: media_teaser
table: posts
data_type: char
default_value: null
generation_expression: null
max_length: 36
numeric_precision: null
numeric_scale: null
is_generated: false
is_nullable: true
is_unique: false
is_primary_key: false
has_auto_increment: false
foreign_key_column: id
foreign_key_table: directus_files
comment: ''
meta:
collection: posts
field: media_teaser
special: null
interface: file-image
options: null
display: image
display_options: null
readonly: false
hidden: false
sort: 6
width: full
group: null
translations: null
note: null
conditions: null
required: false
- collection: posts
field: user_created
type: string
@ -499,7 +573,7 @@ fields:
display_options: null
readonly: true
hidden: true
sort: null
sort: 12
width: half
group: null
translations: null
@ -538,7 +612,7 @@ fields:
display_options: null
readonly: true
hidden: true
sort: null
sort: 14
width: half
group: null
translations: null
@ -654,7 +728,7 @@ fields:
circle: true
readonly: false
hidden: false
sort: 5
sort: 6
width: full
group: null
translations: null
@ -691,7 +765,7 @@ fields:
display_options: null
readonly: false
hidden: false
sort: 4
sort: 5
width: full
group: null
translations: null
@ -957,7 +1031,7 @@ fields:
display_options: null
readonly: true
hidden: true
sort: null
sort: 1
width: full
group: null
translations: null
@ -995,13 +1069,13 @@ fields:
display_options: null
readonly: false
hidden: false
sort: null
sort: 2
width: full
group: null
translations: null
note: null
conditions: null
required: false
required: true
- collection: posts
field: slug
type: string
@ -1034,13 +1108,13 @@ fields:
display_options: null
readonly: false
hidden: false
sort: null
sort: 3
width: full
group: null
translations: null
note: null
conditions: null
required: false
required: true
- collection: menus
field: id
type: uuid
@ -1506,7 +1580,7 @@ fields:
display_options: null
readonly: false
hidden: true
sort: 5
sort: 8
width: full
group: null
translations: null
@ -1545,7 +1619,7 @@ fields:
relative: true
readonly: true
hidden: true
sort: 9
sort: 10
width: half
group: null
translations: null
@ -1584,7 +1658,7 @@ fields:
relative: true
readonly: true
hidden: true
sort: 11
sort: 12
width: half
group: null
translations: null
@ -1667,13 +1741,13 @@ fields:
conditions: null
required: false
- collection: snippets
field: slug
field: name
type: string
schema:
name: slug
name: name
table: snippets
data_type: varchar
default_value: null
default_value: default
generation_expression: null
max_length: 255
numeric_precision: null
@ -1688,10 +1762,13 @@ fields:
comment: ''
meta:
collection: snippets
field: slug
field: name
special: null
interface: select-dropdown
options:
choices:
- text: Default
value: default
allowOther: true
display: raw
display_options: null
@ -1703,6 +1780,48 @@ fields:
translations: null
note: null
conditions: null
required: true
- collection: snippets
field: template
type: string
schema:
name: template
table: snippets
data_type: varchar
default_value: null
generation_expression: null
max_length: 255
numeric_precision: null
numeric_scale: null
is_generated: false
is_nullable: true
is_unique: false
is_primary_key: false
has_auto_increment: false
foreign_key_column: null
foreign_key_table: null
comment: ''
meta:
collection: snippets
field: template
special: null
interface: select-dropdown
options:
choices:
- text: Default
value: snippets/default
allowNone: true
allowOther: true
display: raw
display_options: null
readonly: false
hidden: false
sort: 5
width: full
group: null
translations: null
note: null
conditions: null
required: false
- collection: posts
field: status
@ -1749,7 +1868,7 @@ fields:
value: archived
readonly: false
hidden: false
sort: null
sort: 4
width: full
group: null
translations: null
@ -1788,7 +1907,7 @@ fields:
relative: true
readonly: true
hidden: true
sort: null
sort: 13
width: half
group: null
translations: null
@ -1827,13 +1946,232 @@ fields:
relative: true
readonly: true
hidden: true
sort: null
sort: 15
width: half
group: null
translations: null
note: null
conditions: null
required: false
- collection: posts
field: lead
type: text
schema:
name: lead
table: posts
data_type: text
default_value: null
generation_expression: null
max_length: 65535
numeric_precision: null
numeric_scale: null
is_generated: false
is_nullable: true
is_unique: false
is_primary_key: false
has_auto_increment: false
foreign_key_column: null
foreign_key_table: null
comment: ''
meta:
collection: posts
field: lead
special: null
interface: input-rich-text-md
options: null
display: raw
display_options: null
readonly: false
hidden: false
sort: 10
width: full
group: null
translations: null
note: null
conditions: null
required: false
- collection: posts
field: content
type: text
schema:
name: content
table: posts
data_type: text
default_value: null
generation_expression: null
max_length: 65535
numeric_precision: null
numeric_scale: null
is_generated: false
is_nullable: true
is_unique: false
is_primary_key: false
has_auto_increment: false
foreign_key_column: null
foreign_key_table: null
comment: ''
meta:
collection: posts
field: content
special: null
interface: input-rich-text-md
options: null
display: raw
display_options: null
readonly: false
hidden: false
sort: 11
width: full
group: null
translations: null
note: null
conditions: null
required: false
- collection: posts
field: meta
type: json
schema:
name: meta
table: posts
data_type: longtext
default_value: null
generation_expression: null
max_length: 4294967295
numeric_precision: null
numeric_scale: null
is_generated: false
is_nullable: true
is_unique: false
is_primary_key: false
has_auto_increment: false
foreign_key_column: null
foreign_key_table: null
comment: ''
meta:
collection: posts
field: meta
special:
- json
interface: list
options:
template: '{{ name }} '
addLabel: add
fields:
- field: name
name: name
type: string
meta:
field: name
type: string
interface: select-dropdown
options:
allowOther: true
allowNone: true
choices:
- text: description
value: description
- text: robots
value: robots
- text: author
value: author
- field: content
name: content
type: text
meta:
field: content
type: text
interface: input-multiline
options:
trim: true
display: raw
display_options: null
readonly: false
hidden: false
sort: 9
width: full
group: null
translations: null
note: null
conditions: null
required: false
- collection: posts
field: template
type: string
schema:
name: template
table: posts
data_type: varchar
default_value: post/default
generation_expression: null
max_length: 255
numeric_precision: null
numeric_scale: null
is_generated: false
is_nullable: false
is_unique: false
is_primary_key: false
has_auto_increment: false
foreign_key_column: null
foreign_key_table: null
comment: ''
meta:
collection: posts
field: template
special: null
interface: select-dropdown
options:
allowOther: true
choices:
- text: Default
value: post/default
display: labels
display_options: null
readonly: false
hidden: false
sort: 8
width: full
group: null
translations: null
note: null
conditions: null
required: false
- collection: posts
field: published_at
type: dateTime
schema:
name: published_at
table: posts
data_type: datetime
default_value: null
generation_expression: null
max_length: null
numeric_precision: null
numeric_scale: null
is_generated: false
is_nullable: true
is_unique: false
is_primary_key: false
has_auto_increment: false
foreign_key_column: null
foreign_key_table: null
comment: ''
meta:
collection: posts
field: published_at
special: ''
interface: datetime
options: null
display: datetime
display_options: null
readonly: false
hidden: false
sort: 5
width: full
group: null
translations: null
note: null
conditions: null
required: false
- collection: menus
field: status
type: string
@ -2009,7 +2347,7 @@ fields:
value: archived
readonly: false
hidden: false
sort: 7
sort: 4
width: full
group: null
translations: null
@ -2269,11 +2607,13 @@ fields:
value: page/default
- text: Home
value: page/home
- text: Blog
value: page/blog
display: raw
display_options: null
readonly: false
hidden: false
sort: 6
sort: 7
width: full
group: null
translations: null
@ -2494,6 +2834,48 @@ relations:
junction_field: null
sort_field: null
one_deselect_action: nullify
- collection: posts
field: media_hero
related_collection: directus_files
schema:
table: posts
column: media_hero
foreign_key_table: directus_files
foreign_key_column: id
constraint_name: posts_media_hero_foreign
on_update: RESTRICT
on_delete: RESTRICT
meta:
many_collection: posts
many_field: media_hero
one_collection: directus_files
one_field: null
one_collection_field: null
one_allowed_collections: null
junction_field: null
sort_field: null
one_deselect_action: nullify
- collection: posts
field: media_teaser
related_collection: directus_files
schema:
table: posts
column: media_teaser
foreign_key_table: directus_files
foreign_key_column: id
constraint_name: posts_media_teaser_foreign
on_update: RESTRICT
on_delete: RESTRICT
meta:
many_collection: posts
many_field: media_teaser
one_collection: directus_files
one_field: null
one_collection_field: null
one_allowed_collections: null
junction_field: null
sort_field: null
one_deselect_action: nullify
- collection: posts
field: user_created
related_collection: directus_users

Loading…
Cancel
Save