-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(code): initial code base commit
- Loading branch information
Showing
5 changed files
with
90 additions
and
3 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,2 @@ | ||
# v1.0.0, 2021-01-11 | ||
* Initial release |
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
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,64 @@ | ||
<?php | ||
|
||
use Psr\Http\Message\ResponseInterface as Response; | ||
use Psr\Http\Message\ServerRequestInterface as Request; | ||
|
||
$feed = flextype('registry')->get('plugins.feed.settings.feed'); | ||
|
||
if (isset($feed) and count($feed) > 0) { | ||
foreach (flextype('registry')->get('plugins.feed.settings.feed') as $item) { | ||
|
||
$cacheID = strings('feed-collection-' . $item['id'])->hash()->toString(); | ||
|
||
flextype('emitter')->addListener('onEntriesCreate', function () use ($cacheID) { | ||
flextype('cache')->delete($cacheID); | ||
}); | ||
|
||
flextype('emitter')->addListener('onEntriesDelete', function () use ($cacheID) { | ||
flextype('cache')->delete($cacheID); | ||
}); | ||
|
||
flextype('emitter')->addListener('onEntriesMove', function () use ($cacheID) { | ||
flextype('cache')->delete($cacheID); | ||
}); | ||
|
||
flextype('emitter')->addListener('onEntriesCopy', function () use ($cacheID) { | ||
flextype('cache')->delete($cacheID); | ||
}); | ||
|
||
flextype('emitter')->addListener('onEntriesUpdate', function () use ($cacheID) { | ||
flextype('cache')->delete($cacheID); | ||
}); | ||
|
||
flextype()->get($item['options']['route'], function (Request $request, Response $response, array $args) use ($item, $cacheID) { | ||
|
||
if (flextype('cache')->has($cacheID)) { | ||
$entries = flextype('cache')->get($cacheID); | ||
} else { | ||
$entries = flextype('entries') | ||
->fetch($item['id'], $item['options']) | ||
->sortBy('published_at', 'DESC'); | ||
|
||
flextype('cache')->set($cacheID, $entries); | ||
} | ||
|
||
switch ($item['options']['format']) { | ||
case 'rss': | ||
$response = $response->withHeader('Content-Type', 'application/rss+xml'); | ||
$template = 'plugins/feed/templates/feed.rss.html'; | ||
break; | ||
case 'atom': | ||
$response = $response->withHeader('Content-Type', 'application/atom+xml'); | ||
$template = 'plugins/feed/templates/feed.atom.html'; | ||
break; | ||
case 'json': | ||
default: | ||
$response = $response->withHeader('Content-Type', 'application/json'); | ||
$template = 'plugins/feed/templates/feed.json.html'; | ||
break; | ||
} | ||
|
||
return flextype('twig')->render($response, $template, ['entries' => $entries, 'item' => $item]); | ||
}); | ||
} | ||
} |
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,19 @@ | ||
name: Feed | ||
version: 1.0.0 | ||
description: Feed plugin for Flextype | ||
author: | ||
name: Sergey Romanenko | ||
email: [email protected] | ||
url: https://flextype.org | ||
homepage: https://github.com/flextype-plugins/feed | ||
documentation: https://github.com/flextype-plugins/feed | ||
changelog: https://github.com/flextype-plugins/feed/blob/master/CHANGELOG.md | ||
bugs: https://github.com/flextype-plugins/feed/issues | ||
icon: | ||
name: map-marked-alt | ||
set: "fontawesome|solid" | ||
license: MIT | ||
|
||
dependencies: | ||
flextype: 0.9.15 | ||
twig: '>=2.0.0' |
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,3 @@ | ||
enabled: true | ||
priority: 100 | ||
feed: [] |