Skip to content

Commit

Permalink
Site 1.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Dec 30, 2020
1 parent 74ad071 commit 3e52d63
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 57 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<a name="1.8.0"></a>
# [1.8.0](https://github.com/flextype-plugins/site/compare/v1.7.0...v1.8.0) (2020-12-30)

### Features

* **core** update code base for new Flextype 0.9.14
* **core** Moving to PHP 7.4
* **core** use new TWIG Plugin 1.7.0
* **routes** use new `onFlextypeBeforeRun` event for site routing.

BREAKING CHANGES

* removed `$entry` property, use entries storage functionality instead.
* removed even `onSiteEntryAfterInitialized`, use event `onEntriesFetchSingleHasResult` instead.
* removed template variable `query` and `uri`, use an full power of new `$request` variable.

<a name="1.7.0"></a>
# [1.7.0](https://github.com/flextype-plugins/site/compare/v1.6.1...v1.7.0) (2020-12-23)

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1 align="center">Site Plugin for <a href="http://flextype.org/">Flextype</a></h1>
<h1 align="center">Site Plugin for <a href="https://flextype.org/">Flextype</a></h1>

<p align="center">
<a href="https://github.com/flextype-plugins/site/releases"><img alt="Version" src="https://img.shields.io/github/release/flextype-plugins/site.svg?label=version&color=black"></a> <a href="https://github.com/flextype-plugins/site"><img src="https://img.shields.io/badge/license-MIT-blue.svg?color=black" alt="License"></a> <a href="https://github.com/flextype-plugins/site"><img src="https://img.shields.io/github/downloads/flextype-plugins/site/total.svg?color=black" alt="Total downloads"></a> <a href="https://github.com/flextype/flextype"><img src="https://img.shields.io/badge/Flextype-0.9.13-green.svg" alt="Flextype"></a> <a href=""><img src="https://img.shields.io/discord/423097982498635778.svg?logo=discord&color=black&label=Discord%20Chat" alt="Discord"></a>
<a href="https://github.com/flextype-plugins/site/releases"><img alt="Version" src="https://img.shields.io/github/release/flextype-plugins/site.svg?label=version&color=black"></a> <a href="https://github.com/flextype-plugins/site"><img src="https://img.shields.io/badge/license-MIT-blue.svg?color=black" alt="License"></a> <a href="https://github.com/flextype-plugins/site"><img src="https://img.shields.io/github/downloads/flextype-plugins/site/total.svg?color=black" alt="Total downloads"></a> <a href="https://github.com/flextype/flextype"><img src="https://img.shields.io/badge/Flextype-0.9.14-green.svg" alt="Flextype"></a> <a href=""><img src="https://img.shields.io/discord/423097982498635778.svg?logo=discord&color=black&label=Discord%20Chat" alt="Discord"></a>
</p>

Site plugin to display entries content on the website frontend.
Expand All @@ -14,7 +14,7 @@ The following dependencies need to be downloaded and installed for Site Plugin.

| Item | Version | Download |
|---|---|---|
| [flextype](https://github.com/flextype/flextype) | 0.9.13 | [download](https://github.com/flextype/flextype/releases) |
| [flextype](https://github.com/flextype/flextype) | 0.9.14 | [download](https://github.com/flextype/flextype/releases) |
| [twig](https://github.com/flextype-plugins/twig) | >=1.0.0 | [download](https://github.com/flextype-plugins/twig/releases) |
| [noir](https://github.com/flextype-themes/noir) | >=1.0.0 | [download](https://github.com/flextype-themes/noir/releases) |

Expand Down Expand Up @@ -76,8 +76,8 @@ You can reach any of these items via registry `themes` by using the standard dot
Usage:

```twig
Theme name: {{ registry.get('themes.noir.manifest.name') }}
Theme version: {{ registry.get('themes.noir.manifest.version') }}
Theme name: {{ flextype.registry.get('themes.noir.manifest.name') }}
Theme version: {{ flextype.registry.get('themes.noir.manifest.version') }}
```

Result:
Expand Down Expand Up @@ -118,7 +118,7 @@ highlight: red
Then in your theme templates you can access these variable using the `themes.noir` object:

```twig
<h1 style="color:{{ registry.get('themes.noir.settings.highlight') }}">
<h1 style="color:{{ flextype.registry.get('themes.noir.settings.highlight') }}">
BUILD FAST, FLEXIBLE, EASIER TO MANAGE WEBSITES WITH FLEXTYPE.
</h1>
```
Expand Down
30 changes: 7 additions & 23 deletions app/Controllers/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@

class SiteController
{
/**
* Current entry data array
*
* @var array
* @access private
*/
public $entry = [];

/**
* Index page
*
Expand Down Expand Up @@ -70,36 +62,28 @@ public function index(Request $request, Response $response, array $args) : Respo
$entry = $entry_body;
}
} else {
$entry = $this->error404();
$entry = $this->error404();
$isEntryNotFound = true;
}

// Set entry
$this->entry = $entry;

// Run event onSiteEntryAfterInitialized
flextype('emitter')->emit('onSiteEntryAfterInitialized');

// Return in JSON Format
if ($isJson) {
if ($isEntryNotFound) {
return $response->withJson($this->entry, 404);
return $response->withJson($entry, 404);
}

return $response->withJson($this->entry);
return $response->withJson($entry);
}

// Set template path for current entry
$path = 'themes/' . flextype('registry')->get('plugins.site.settings.theme') . '/' . (empty($this->entry['template']) ? 'templates/default' : 'templates/' . $this->entry['template']) . '.html';
$path = 'themes/' . flextype('registry')->get('plugins.site.settings.theme') . '/' . (empty($entry['template']) ? 'templates/default' : 'templates/' . $entry['template']) . '.html';

if (! Filesystem::has(PATH['project'] . '/' . $path)) {
return $response->write("Template {$this->entry['template']} not found");
return $response->write("Template {$entry['template']} not found");
}

$data = ['entry' => $this->entry,
'query' => $query,
'uri' => $uri,
'args' => $args,
$data = ['entry' => $entry,
'args' => $args,
'request' => $request];

if ($isEntryNotFound) {
Expand Down
12 changes: 1 addition & 11 deletions app/Models/Themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

/**
* Flextype (http://flextype.org)
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/

Expand All @@ -20,16 +20,6 @@

class Themes
{
/**
* Private construct method to enforce singleton behavior.
*
* @access private
*/
public function __construct()
{

}

/**
* Init themes
*/
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"issues": "https://github.com/flextype-plugins/site/issues"
},
"require": {
"php": ">=7.3.0",
"php": ">=7.4.0",
"ext-json": "*",
"middlewares/trailing-slash": "~1.1.0",
"flextype-components/arrays" : "3.0.1",
Expand All @@ -26,7 +26,7 @@
"apcu-autoloader": true,
"optimize-autoloader": true,
"platform": {
"php": "7.3.0"
"php": "7.4.0"
}
},
"autoload": {
Expand Down
12 changes: 4 additions & 8 deletions dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
/**
* Add themes service to Flextype container
*/
flextype()->container()['themes'] = static function () {
return new Themes();
};
flextype()->container()['themes'] = fn() => new Themes();

/**
* Init themes
Expand All @@ -29,9 +27,7 @@
/**
* Add site controller to Flextype container
*/
flextype()->container()['SiteController'] = static function () {
return new SiteController();
};
flextype()->container()['SiteController'] = fn() => new SiteController();

$bootstrapPath = PATH['project']. '/themes/' . flextype('registry')->get('plugins.site.settings.theme') . '/bootstrap.php';
filesystem()->file($bootstrapPath)->exists() and include_once $bootstrapPath;
$themeBootstrapPath = PATH['project']. '/themes/' . flextype('registry')->get('plugins.site.settings.theme') . '/theme.php';
filesystem()->file($themeBootstrapPath)->exists() and include_once $themeBootstrapPath;
2 changes: 1 addition & 1 deletion lang/en_US.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
site_title: Site
site_description: Site plugin to display entries content on the website frontend.
site_powered_by_flextype: Build fast, flexible, easier to manage websites with <a href="http://flextype.org" target="_blank">Flextype</a>.
site_powered_by_flextype: Build fast, flexible, easier to manage websites with <a href="https://flextype.org" target="_blank">Flextype</a>.
2 changes: 1 addition & 1 deletion lang/ru_RU.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
site_title: Site
site_description: Site plugin to display entries content on the website frontend.
site_powered_by_flextype: Создавайте быстрые и легкие в управлении веб-сайты c <a href="http://flextype.org/ru" target="_blank">Flextype</a>.
site_powered_by_flextype: Создавайте быстрые и легкие в управлении веб-сайты c <a href="https://flextype.org/ru" target="_blank">Flextype</a>.
4 changes: 2 additions & 2 deletions plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Site
version: 1.7.0
version: 1.8.0
description: Site plugin to display entries content on the website frontend.
icon: fas fa-globe
author:
Expand All @@ -11,5 +11,5 @@ bugs: https://github.com/flextype-plugins/site/issues
license: MIT

dependencies:
flextype: 0.9.13
flextype: 0.9.14
twig: '>=1.0.0'
5 changes: 3 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Slim\Http\Environment;
use Slim\Http\Uri;

if (! flextype()->isApiRequest()) {

flextype('emitter')->addListener('onFlextypeBeforeRun', static function (): void {
flextype()->get('{uri:.+}', 'SiteController:index')->setName('site.index')->add('csrf');
}
});
2 changes: 1 addition & 1 deletion settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
enabled: true

# Site plugin priority
priority: 0
priority: 10000

# The title of the website
title: Flextype
Expand Down

0 comments on commit 3e52d63

Please sign in to comment.