Skip to content

Commit

Permalink
Feed 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Jan 15, 2021
1 parent b7ceed7 commit b813ab3
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 32 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# v1.0.0, 2021-01-11
# v1.0.0, 2021-01-15
* Initial release
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1 align="center">Feed Plugin for <a href="https://flextype.org/">Flextype</a></h1>

<p align="center">
<a href="https://github.com/flextype-plugins/feed/releases"><img alt="Version" src="https://img.shields.io/github/release/flextype-plugins/feed.svg?label=version&color=black"></a> <a href="https://github.com/flextype-plugins/feed"><img src="https://img.shields.io/badge/license-MIT-blue.svg?color=black" alt="License"></a> <a href="https://github.com/flextype-plugins/feed"><img src="https://img.shields.io/github/downloads/flextype-plugins/feed/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.15-green.svg?color=black" 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/feed/releases"><img alt="Version" src="https://img.shields.io/github/release/flextype-plugins/feed.svg?label=version&color=black"></a> <a href="https://github.com/flextype-plugins/feed"><img src="https://img.shields.io/badge/license-MIT-blue.svg?color=black" alt="License"></a> <a href="https://github.com/flextype-plugins/feed"><img src="https://img.shields.io/github/downloads/flextype-plugins/feed/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.16-green.svg?color=black" 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>

Feed plugin for Flextype supports Atom 1.0, RSS and JSON feed types and allows you to generate feeds for entries.
Expand All @@ -12,7 +12,7 @@ The following dependencies need to be downloaded and installed for Feed Plugin.

| Item | Version | Download |
|---|---|---|
| [flextype](https://github.com/flextype/flextype) | 0.9.15 | [download](https://github.com/flextype/flextype/releases) |
| [flextype](https://github.com/flextype/flextype) | 0.9.16 | [download](https://github.com/flextype/flextype/releases) |
| [twig](https://github.com/flextype-plugins/twig) | >=2.0.0 | [download](https://github.com/flextype-plugins/twig/releases) |

## Installation
Expand All @@ -33,7 +33,7 @@ The following dependencies need to be downloaded and installed for Feed Plugin.

### Usage

Inside `project/config/plugins/feed/settings.yaml` you may create unlimited feed for you entries.
In `project/config/plugins/feed/settings.yaml` you may create unlimited feed for you entries.

Lets create RSS, ATOM and JSON feed for blog collection:

Expand All @@ -45,7 +45,6 @@ feed:
title: Blog
description: Blog description
collection: true
length: 400
format: rss
route: '/blog.rss'
blog-atom:
Expand All @@ -54,7 +53,6 @@ feed:
title: Blog
description: Blog description
collection: true
length: 400
format: json
route: '/blog.atom'
blog-json:
Expand All @@ -63,7 +61,6 @@ feed:
title: Blog
description: Blog description
collection: true
length: 400
format: json
route: '/blog.json'
```
Expand Down
26 changes: 6 additions & 20 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,15 @@
$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) {
foreach ($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('emitter')->addListener('onEntriesCreate', fn () => flextype('cache')->delete($cacheID));
flextype('emitter')->addListener('onEntriesDelete', fn () => flextype('cache')->delete($cacheID));
flextype('emitter')->addListener('onEntriesMove', fn () => flextype('cache')->delete($cacheID));
flextype('emitter')->addListener('onEntriesCopy', fn () => flextype('cache')->delete($cacheID));
flextype('emitter')->addListener('onEntriesUpdate', fn () => flextype('cache')->delete($cacheID));

flextype()->get($item['options']['route'], function (Request $request, Response $response, array $args) use ($item, $cacheID) {

Expand Down
4 changes: 2 additions & 2 deletions plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 1.0.0
description: Feed plugin for Flextype
author:
name: Sergey Romanenko
email: awilum@yandex.ru
email: sergey.romanenko@flextype.org
url: https://flextype.org
homepage: https://github.com/flextype-plugins/feed
documentation: https://github.com/flextype-plugins/feed
Expand All @@ -15,5 +15,5 @@ icon:
license: MIT

dependencies:
flextype: 0.9.15
flextype: 0.9.16
twig: '>=2.0.0'
2 changes: 1 addition & 1 deletion templates/feed.atom.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<link href="{{ url() }}/{{ entry.id }}"/>
<content type="html">
<![CDATA[
{{ strings(entry.content).limit(item.options.length).toString()|shortcode|markdown|raw }}
{{ entry.content|shortcode|markdown|raw }}
]]>
</content>
</entry>
Expand Down
2 changes: 1 addition & 1 deletion templates/feed.json.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

{% set itemList = [] %}
{% for entry in entries %}
{%- set content_html = strings(entry.content).limit(item.options.length).toString()|shortcode|markdown|raw -%}
{%- set content_html = entry.content|shortcode|markdown|raw -%}
{%- set post = {
"title": entry.title|e,
"date_published": entry.published_at|date('Y-m-d\\TH:i:sP'),
Expand Down
2 changes: 1 addition & 1 deletion templates/feed.rss.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<pubDate>{{ entry.published_at|date('D, d M Y H:i:s O') }}</pubDate>
<description>
<![CDATA[
{{ strings(entry.content).limit(item.options.length).toString()|shortcode|markdown|raw }}
{{ entry.content|shortcode|markdown|raw }}
]]>
</description>
</item>
Expand Down

0 comments on commit b813ab3

Please sign in to comment.