init
This commit is contained in:
143
user/plugins/feed/CHANGELOG.md
Normal file
143
user/plugins/feed/CHANGELOG.md
Normal file
@@ -0,0 +1,143 @@
|
||||
# v1.8.5
|
||||
## 06/09/2021
|
||||
|
||||
1. [](#improved)
|
||||
* Rolled back the URL check functionality as it caused more issues than it solved.
|
||||
|
||||
# v1.8.4
|
||||
## 06/07/2021
|
||||
|
||||
1. [](#improved)
|
||||
* Added a configurable `enable_url_check` (default `true`) to disable the URL checking if you run into an issue.
|
||||
1. [](#bugfix)
|
||||
* More robust URL checking including multi-lang versions [#62](https://github.com/getgrav/grav-plugin-feed/issues/62)
|
||||
|
||||
# v1.8.3
|
||||
## 05/28/2021
|
||||
|
||||
1. [](#bugfix)
|
||||
* Fixed issue with feeds at the root of a site [#61](https://github.com/getgrav/grav-plugin-feed/issues/61)
|
||||
|
||||
# v1.8.2
|
||||
## 05/21/2021
|
||||
|
||||
1. [](#bugfix)
|
||||
* Fixed issue with json feed type corrupting other json requests [getgrav/grav-premium-issues#102](https://github.com/getgrav/grav-premium-issues/issues/102)
|
||||
* Fixed issue with modular pages showing up in feed
|
||||
|
||||
|
||||
# v1.8.1
|
||||
## 05/21/2021
|
||||
|
||||
1. [](#bugfix)
|
||||
* Provide a default language if multi-language not enabled
|
||||
|
||||
# v1.8.0
|
||||
## 12/02/2020
|
||||
|
||||
1. [](#new)
|
||||
* Require Grav v1.6
|
||||
* Pass phpstan level 1 tests
|
||||
1. [](#improved)
|
||||
* Major plugin overhaul [#57](https://github.com/getgrav/grav-plugin-feed/pull/57)
|
||||
* Bumped the default image sizes in atom/rss
|
||||
|
||||
# v1.7.1
|
||||
## 05/09/2019
|
||||
|
||||
1. [](#bugfix)
|
||||
* Fix issue with Feed Options not showing up in Quark (and other themes) [#46](https://github.com/getgrav/grav-plugin-feed/issues/46)
|
||||
|
||||
# v1.7.0
|
||||
## 04/15/2019
|
||||
|
||||
1. [](#improved)
|
||||
* Use `safe_truncate_html` [#41](https://github.com/getgrav/grav-plugin-feed/pull/41)
|
||||
* Allow full-text feeds [#37](https://github.com/getgrav/grav-plugin-feed/pull/37)
|
||||
* Dynamic json feed header and image file support [#32](https://github.com/getgrav/grav-plugin-feed/pull/32)
|
||||
* Added `json` link example to `README.md`
|
||||
1. [](#bugfix)
|
||||
* Changed type `text` to `range` to prevent validation errors [#45](https://github.com/getgrav/grav-plugin-feed/issues/45)
|
||||
* Always show route in url for self-link [#38](https://github.com/getgrav/grav-plugin-feed/pull/38)
|
||||
|
||||
# v1.6.2
|
||||
## 06/06/2017
|
||||
|
||||
1. [](#bugfix)
|
||||
* Fix issue with feeds not rendering with cache enabled [#27](https://github.com/getgrav/grav-plugin-feed/pull/27)
|
||||
|
||||
# v1.6.1
|
||||
## 05/30/2017
|
||||
|
||||
1. [](#improved)
|
||||
* Improved JSON template to `json_encode()` all output
|
||||
1. [](#bugfix)
|
||||
* Optimized logic to disable JSON feeds by default and only set the template when there's a collection
|
||||
|
||||
# v1.6.0
|
||||
## 05/25/2017
|
||||
|
||||
1. [](#new)
|
||||
* Added support for new JSON feed format by @RosemaryOrchard [#21](https://github.com/getgrav/grav-plugin-feed/pull/21)
|
||||
|
||||
# v1.5.3
|
||||
## 04/12/2017
|
||||
|
||||
1. [](#bugfix)
|
||||
* Fix a truncate issue [#16](https://github.com/getgrav/grav-plugin-feed/pull/16)
|
||||
|
||||
# v1.5.2
|
||||
## 02/17/2017
|
||||
|
||||
1. [](#bugfix)
|
||||
* Fix issue on non-collection pages [#14](https://github.com/getgrav/grav-plugin-feed/pull/14)
|
||||
|
||||
# v1.5.1
|
||||
## 01/24/2017
|
||||
|
||||
1. [](#bugfix)
|
||||
* Add support for Twig `Autoescape variables` mode
|
||||
|
||||
# v1.5.0
|
||||
## 07/14/2016
|
||||
|
||||
1. [](#improved)
|
||||
* Make Feeds 'language-safe'
|
||||
|
||||
# v1.4.1
|
||||
## 10/07/2015
|
||||
|
||||
1. [](#bugfix)
|
||||
* Avoid duplicated routes
|
||||
|
||||
# v1.4.0
|
||||
## 08/26/2015
|
||||
|
||||
1. [](#improved)
|
||||
* Added blueprints for Grav Admin plugin
|
||||
|
||||
# v1.3.3
|
||||
## 03/24/2015
|
||||
|
||||
1. [](#improved)
|
||||
* Feed will now skip pages with `feed: skip: true` in frontmatter
|
||||
1. [](#bugfix)
|
||||
* Fixed page overrides for configuration
|
||||
|
||||
# v1.3.2
|
||||
## 02/19/2015
|
||||
|
||||
1. [](#bugfix)
|
||||
* Fixed couple of RSS validation issues
|
||||
|
||||
# v1.3.1
|
||||
## 12/26/2014
|
||||
|
||||
1. [](#bugfix)
|
||||
* Fixed issue with default configuration not being loaded yet
|
||||
|
||||
# v1.3.0
|
||||
## 11/30/2014
|
||||
|
||||
1. [](#new)
|
||||
* ChangeLog started...
|
||||
21
user/plugins/feed/LICENSE
Normal file
21
user/plugins/feed/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Grav
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
146
user/plugins/feed/README.md
Normal file
146
user/plugins/feed/README.md
Normal file
@@ -0,0 +1,146 @@
|
||||
# Grav Syndication Feed Plugin
|
||||
|
||||

|
||||
|
||||
`feed` is a [Grav](http://github.com/getgrav/grav) plugin and allows Grav to generate feeds of your pages.
|
||||
|
||||
This plugin supports __Atom 1.0__, __RSS__ and __JSON__ feed types. Enabling is very simple. just install this plugin in the `/user/plugins/` folder in your Grav install. By default, the plugin is enabled and provides some default values.
|
||||
|
||||
| NOTE: JSON feeds must be enabled manually in the plugin configuration as the `.json` extension is commonly used and this can conflict with other plugins.
|
||||
|
||||
If you do enable the JSON feed, you will want to edit `feed.json.twig`. Replace the placeholder data on lines 2 and 3 (`feed_url` and `author:url`) with your own data. You may also want to change the formatting of the date on lines 8 and 9.
|
||||
|
||||
# Installation
|
||||
|
||||
Installing the Feed plugin can be done in one of two ways. Our GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file.
|
||||
|
||||
## GPM Installation (Preferred)
|
||||
|
||||
The simplest way to install this plugin is via the [Grav Package Manager (GPM)](http://learn.getgrav.org/advanced/grav-gpm) through your system's Terminal (also called the command line). From the root of your Grav install type:
|
||||
|
||||
bin/gpm install feed
|
||||
|
||||
This will install the Feed plugin into your `/user/plugins` directory within Grav. Its files can be found under `/your/site/grav/user/plugins/feed`.
|
||||
|
||||
## Manual Installation
|
||||
|
||||
To install this plugin, just download the zip version of this repository and unzip it under `/your/site/grav/user/plugins`. Then, rename the folder to `feed`. You can find these files either on [GitHub](https://github.com/getgrav/grav-plugin-feed) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras).
|
||||
|
||||
You should now have all the plugin files under
|
||||
|
||||
/your/site/grav/user/plugins/feed
|
||||
|
||||
>> NOTE: This plugin is a modular component for Grav which requires [Grav](http://github.com/getgrav/grav), the [Error](https://github.com/getgrav/grav-plugin-error) and [Problems](https://github.com/getgrav/grav-plugin-problems) plugins, and a theme to be installed in order to operate.
|
||||
|
||||
# Usage
|
||||
|
||||
The feeds work for pages that have sub-pages, for example a blog list view. If your page has a `content`, then the RSS plugin will automatically be enabled. Simply append either `.atom`, `.rss` or `.json` to the url. For example, if you have a blog page that defines a `content` header to display a list of blog pages in a list, and the URL is `http://www.mysite.com/blog` then the feed would simply be:
|
||||
|
||||
```
|
||||
http://www.mysite.com/blog.atom
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
http://www.mysite.com/blog.rss
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
http://www.mysite.com/blog.json
|
||||
```
|
||||
|
||||
## Autodiscovery
|
||||
|
||||
To let feed readers discover the feed automatically, add a link to your HTML `<head>` tag:
|
||||
|
||||
```
|
||||
<link rel="alternate" type="application/atom+xml" title="My Feed" href="{{ base_url }}.atom" />
|
||||
<link rel="alternate" type="application/rss+xml" title="My Feed" href="{{ base_url }}.rss" />
|
||||
<link rel="alternate" type="application/json" title="My Feed" href="{{ base_url }}.json" />
|
||||
```
|
||||
|
||||
## Creating Feed Buttons in Your Pages
|
||||
|
||||
Just having the plugin loaded and activated is enough to get it working, but you can help users find your feeds by creating buttons in the body of your page users can easily discover and click on to access the feeds.
|
||||
|
||||
In our [Blog Skeleton] demo, you will see these buttons located in the sidebar under the heading `Syndicate`. This was done very easily by adding the following information to the `sidebar.html.twig` template file found under `/user/themes/antimatter/templates/partials/`.
|
||||
|
||||
```
|
||||
<a class="button" href="{{ base_url }}.atom"><i class="fa fa-rss-square"></i> Atom 1.0</a>
|
||||
<a class="button" href="{{ base_url }}.rss"><i class="fa fa-rss-square"></i> RSS</a>
|
||||
```
|
||||
|
||||
The first line adds the **Atom** feed by simply adding `.atom` to the base URL of the site, while the second handles RSS. This a very simple way to add a useful feature to your site that your visitors will enjoy.
|
||||
|
||||
# Config Defaults
|
||||
|
||||
```
|
||||
enabled: true
|
||||
limit: 10
|
||||
title: 'My Feed Title'
|
||||
description: 'My Feed Description'
|
||||
length: 500
|
||||
enable_json_feed: false
|
||||
show_last_modified: false
|
||||
```
|
||||
|
||||
You can override any of the default values by setting one or more of these in your blog list page where `sub_pages` is defined. For example:
|
||||
|
||||
```
|
||||
title: Sample Blog
|
||||
content:
|
||||
items: @self.children
|
||||
limit: 5
|
||||
pagination: true
|
||||
feed:
|
||||
limit: 15
|
||||
description: Sample Blog Description
|
||||
```
|
||||
|
||||
You can ensure a particular page is skipped from the feed by adding the following in the frontmatter header:
|
||||
|
||||
```
|
||||
title: Sample Blog
|
||||
feed:
|
||||
skip: true
|
||||
```
|
||||
|
||||
# Updating
|
||||
|
||||
As development for the Feed plugin continues, new versions may become available that add additional features and functionality, improve compatibility with newer Grav releases, and generally provide a better user experience. Updating Feed is easy, and can be done through Grav's GPM system, as well as manually.
|
||||
|
||||
## GPM Update (Preferred)
|
||||
|
||||
The simplest way to update this plugin is via the [Grav Package Manager (GPM)](http://learn.getgrav.org/advanced/grav-gpm). You can do this with this by navigating to the root directory of your Grav install using your system's Terminal (also called command line) and typing the following:
|
||||
|
||||
bin/gpm update feed
|
||||
|
||||
This command will check your Grav install to see if your Feed plugin is due for an update. If a newer release is found, you will be asked whether or not you wish to update. To continue, type `y` and hit enter. The plugin will automatically update and clear Grav's cache.
|
||||
|
||||
## Manual Update
|
||||
|
||||
Manually updating Feed is pretty simple. Here is what you will need to do to get this done:
|
||||
|
||||
* Delete the `your/site/user/plugins/feed` directory.
|
||||
* Downalod the new version of the Feed plugin from either [GitHub](https://github.com/getgrav/grav-plugin-feed) or [GetGrav.org](http://getgrav.org/downloads/plugins#extras).
|
||||
* Unzip the zip file in `your/site/user/plugins` and rename the resulting folder to `feed`.
|
||||
* Clear the Grav cache. The simplest way to do this is by going to the root Grav directory in terminal and typing `bin/grav clear-cache`.
|
||||
|
||||
> Note: Any changes you have made to any of the files listed under this directory will also be removed and replaced by the new set. Any files located elsewhere (for example a YAML settings file placed in `user/config/plugins`) will remain intact.
|
||||
|
||||
## Nginx Note:
|
||||
|
||||
If you are having trouble with 404s with Nginx, it might be related to your configuration. You may need to remove the feed extensions from the list of types to cache as static files: `.xml`, `.rss`, and `.atom`. For example:
|
||||
|
||||
```nginx
|
||||
# Cache static files
|
||||
location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf)$ {
|
||||
add_header "Access-Control-Allow-Origin" "*";
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
expires max;
|
||||
}
|
||||
```
|
||||
BIN
user/plugins/feed/assets/readme_1.png
Normal file
BIN
user/plugins/feed/assets/readme_1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 291 KiB |
78
user/plugins/feed/blueprints.yaml
Normal file
78
user/plugins/feed/blueprints.yaml
Normal file
@@ -0,0 +1,78 @@
|
||||
name: Feed
|
||||
type: plugin
|
||||
slug: feed
|
||||
version: 1.8.5
|
||||
description: The **Feed** plugin is a simple yet powerful add-on that lets you view a Grav Collection as **JSON**, **RSS** or **Atom** news feed.
|
||||
icon: rss
|
||||
author:
|
||||
name: Team Grav
|
||||
email: devs@getgrav.org
|
||||
url: http://getgrav.org
|
||||
homepage: https://github.com/getgrav/grav-plugin-feed
|
||||
demo: http://demo.getgrav.org/blog-skeleton
|
||||
keywords: feed, plugin, rss, atom, collection, json
|
||||
bugs: https://github.com/getgrav/grav-plugin-feed/issues
|
||||
license: MIT
|
||||
dependencies:
|
||||
- { name: grav, version: '>=1.6.0' }
|
||||
|
||||
form:
|
||||
validation: strict
|
||||
fields:
|
||||
enabled:
|
||||
type: toggle
|
||||
label: Plugin status
|
||||
highlight: 1
|
||||
default: 0
|
||||
options:
|
||||
1: Enabled
|
||||
0: Disabled
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
limit:
|
||||
type: range
|
||||
label: Feed count
|
||||
validate:
|
||||
type: number
|
||||
min: 10
|
||||
max: 1000
|
||||
|
||||
title:
|
||||
type: text
|
||||
label: Title
|
||||
|
||||
description:
|
||||
type: textarea
|
||||
label: Description
|
||||
|
||||
length:
|
||||
type: range
|
||||
label: Feed Length (0 for full-text feed)
|
||||
validate:
|
||||
type: number
|
||||
min: 0
|
||||
max: 10000
|
||||
|
||||
enable_json_feed:
|
||||
type: toggle
|
||||
label: JSON feed support
|
||||
highlight: 0
|
||||
default: 0
|
||||
options:
|
||||
1: Enabled
|
||||
0: Disabled
|
||||
validate:
|
||||
type: bool
|
||||
|
||||
show_last_modified:
|
||||
type: toggle
|
||||
label: Show last modified date
|
||||
help: If enabled, file modification date will be used for computing "last updated" times in feeds
|
||||
highlight: 0
|
||||
default: 0
|
||||
options:
|
||||
1: Enabled
|
||||
0: Disabled
|
||||
validate:
|
||||
type: bool
|
||||
22
user/plugins/feed/blueprints/feed.yaml
Normal file
22
user/plugins/feed/blueprints/feed.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
form:
|
||||
fields:
|
||||
tabs:
|
||||
fields:
|
||||
blog:
|
||||
type: tab
|
||||
|
||||
fields:
|
||||
header.feed.limit:
|
||||
type: text
|
||||
label: Feed count
|
||||
default: 10
|
||||
validate:
|
||||
type: int
|
||||
|
||||
header.feed.title:
|
||||
type: text
|
||||
label: Feed title
|
||||
|
||||
header.feed.description:
|
||||
type: text
|
||||
label: Feed description
|
||||
36
user/plugins/feed/composer.json
Normal file
36
user/plugins/feed/composer.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "getgrav/grav-plugin-feed",
|
||||
"type": "grav-plugin",
|
||||
"description": "Feed plugin for Grav CMS",
|
||||
"keywords": ["feed", "plugin"],
|
||||
"homepage": "https://github.com/getgrav/grav-plugin-feed",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Team Grav",
|
||||
"email": "devs@getgrav.org",
|
||||
"homepage": "https://getgrav.org",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/getgrav/grav-plugin-feed/issues",
|
||||
"irc": "https://chat.getgrav.org",
|
||||
"forum": "https://getgrav.org/forum",
|
||||
"docs": "https://github.com/getgrav/grav-plugin-feed/blob/master/README.md"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"feed.php"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "7.1.3"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vendor/bin/codecept run unit",
|
||||
"test-windows": "vendor\\bin\\codecept run unit"
|
||||
}
|
||||
}
|
||||
21
user/plugins/feed/composer.lock
generated
Normal file
21
user/plugins/feed/composer.lock
generated
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "76fd53c3c430250c751e8cb0d82e5308",
|
||||
"packages": [],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": [],
|
||||
"platform-overrides": {
|
||||
"php": "7.1.3"
|
||||
},
|
||||
"plugin-api-version": "2.0.0"
|
||||
}
|
||||
162
user/plugins/feed/feed.php
Normal file
162
user/plugins/feed/feed.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
namespace Grav\Plugin;
|
||||
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use Grav\Common\Data;
|
||||
use Grav\Common\Page\Collection;
|
||||
use Grav\Common\Page\Interfaces\PageInterface;
|
||||
use Grav\Common\Plugin;
|
||||
use Grav\Common\Uri;
|
||||
use RocketTheme\Toolbox\Event\Event;
|
||||
|
||||
class FeedPlugin extends Plugin
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $active = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $feed_config;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $valid_types = array('rss','atom');
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
'onPluginsInitialized' => [
|
||||
['autoload', 100000],
|
||||
['onPluginsInitialized', 0],
|
||||
],
|
||||
'onBlueprintCreated' => ['onBlueprintCreated', 0]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* [onPluginsInitialized:100000] Composer autoload.
|
||||
*
|
||||
* @return ClassLoader
|
||||
*/
|
||||
public function autoload()
|
||||
{
|
||||
return require __DIR__ . '/vendor/autoload.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate feed plugin only if feed was requested for the current page.
|
||||
*
|
||||
* Also disables debugger.
|
||||
*/
|
||||
public function onPluginsInitialized()
|
||||
{
|
||||
if ($this->isAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->feed_config = (array) $this->config->get('plugins.feed');
|
||||
|
||||
if ($this->feed_config['enable_json_feed']) {
|
||||
$this->valid_types[] = 'json';
|
||||
}
|
||||
|
||||
/** @var Uri $uri */
|
||||
$uri = $this->grav['uri'];
|
||||
$this->type = $uri->extension();
|
||||
|
||||
if ($this->type && in_array($this->type, $this->valid_types)) {
|
||||
|
||||
$this->enable([
|
||||
'onPageInitialized' => ['onPageInitialized', 0],
|
||||
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize feed configuration.
|
||||
*/
|
||||
public function onPageInitialized()
|
||||
{
|
||||
$page = $this->grav['page'];
|
||||
|
||||
// Overwrite regular content with feed config, so you can influence the collection processing with feed config
|
||||
if (property_exists($page->header(), 'content')) {
|
||||
if (isset($page->header()->feed)) {
|
||||
$this->feed_config = array_merge($this->feed_config, $page->header()->feed);
|
||||
}
|
||||
|
||||
$page->header()->content = array_merge($page->header()->content, $this->feed_config);
|
||||
|
||||
$this->grav['twig']->template = 'feed.' . $this->type . '.twig';
|
||||
|
||||
$this->enable([
|
||||
'onCollectionProcessed' => ['onCollectionProcessed', 0],
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Feed consists of all sub-pages.
|
||||
*
|
||||
* @param Event $event
|
||||
*/
|
||||
public function onCollectionProcessed(Event $event)
|
||||
{
|
||||
/** @var Collection $collection */
|
||||
$collection = $event['collection']->nonModular();
|
||||
|
||||
foreach ($collection as $slug => $page) {
|
||||
$header = $page->header();
|
||||
if (isset($header->feed) && !empty($header->feed['skip'])) {
|
||||
$collection->remove($page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add current directory to twig lookup paths.
|
||||
*/
|
||||
public function onTwigTemplatePaths()
|
||||
{
|
||||
$this->grav['twig']->twig_paths[] = __DIR__ . '/templates';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extend page blueprints with feed configuration options.
|
||||
*
|
||||
* @param Event $event
|
||||
*/
|
||||
public function onBlueprintCreated(Event $event)
|
||||
{
|
||||
static $inEvent = false;
|
||||
|
||||
/** @var Data\Blueprint $blueprint */
|
||||
$blueprint = $event['blueprint'];
|
||||
$form = $blueprint->form();
|
||||
|
||||
$blog_tab_exists = isset($form['fields']['tabs']['fields']['blog']);
|
||||
|
||||
if (!$inEvent && $blog_tab_exists) {
|
||||
$inEvent = true;
|
||||
$blueprints = new Data\Blueprints(__DIR__ . '/blueprints/');
|
||||
$extends = $blueprints->get('feed');
|
||||
$blueprint->extend($extends, true);
|
||||
$inEvent = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
7
user/plugins/feed/feed.yaml
Normal file
7
user/plugins/feed/feed.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
enabled: true
|
||||
limit: 10
|
||||
title: 'My Feed Title'
|
||||
description: 'My Feed Description'
|
||||
length: 500
|
||||
enable_json_feed: false
|
||||
show_last_modified: false
|
||||
15
user/plugins/feed/hebe.json
Normal file
15
user/plugins/feed/hebe.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"project":"grav-plugin-feed",
|
||||
"platforms":{
|
||||
"grav":{
|
||||
"nodes":{
|
||||
"plugin":[
|
||||
{
|
||||
"source":"/",
|
||||
"destination":"/user/plugins/feed"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
user/plugins/feed/templates/feed.atom.twig
Normal file
45
user/plugins/feed/templates/feed.atom.twig
Normal file
@@ -0,0 +1,45 @@
|
||||
{# Format specification: https://tools.ietf.org/html/rfc4287 #}
|
||||
{% set collection = collection|default(page.collection) %}
|
||||
{% set feed_updated = 0 %}
|
||||
{% for page in collection %}
|
||||
{%- set feed_updated = max(feed_updated, page.date) %}
|
||||
{%- if collection.params.show_last_modified %}
|
||||
{%- set feed_updated = max(feed_updated, page.modified) %}
|
||||
{%- endif %}
|
||||
{% endfor %}
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
<title>{{ collection.params.title }}</title>
|
||||
<link href="{{ uri.rootUrl(true)~uri.uri() }}" rel="self" />
|
||||
<subtitle>{{ collection.params.description }}</subtitle>
|
||||
<updated>{{ feed_updated|date("Y-m-d\\TH:i:sP") }}</updated>
|
||||
<author>
|
||||
<name>{{ site.author.name }}</name>
|
||||
</author>
|
||||
<id>{{ page.url(true) }}</id>
|
||||
{% for item in collection %}
|
||||
{% set banner = item.media.images|first %}
|
||||
<entry>
|
||||
<title>{{ item.title|e }}</title>
|
||||
<id>{{ item.url(true) }}</id>
|
||||
{% if collection.params.show_last_modified %}
|
||||
<updated>{{ item.modified|date("Y-m-d\\TH:i:sP") }}</updated>
|
||||
{% else %}
|
||||
<updated>{{ item.date|date("Y-m-d\\TH:i:sP") }}</updated>
|
||||
{% endif %}
|
||||
<published>{{ item.date|date("Y-m-d\\TH:i:sP") }}</published>
|
||||
<link href="{{ item.url(true) }}"/>
|
||||
{% for tag in item.taxonomy.tag %}
|
||||
<category term="{{ tag|e }}" />
|
||||
{% endfor %}
|
||||
<content type="html">
|
||||
<![CDATA[
|
||||
{% if banner %}
|
||||
{{ banner.cropZoom(1200,800).html|raw }}
|
||||
{% endif %}
|
||||
{{ item.content|safe_truncate_html(collection.params.length)|raw }}
|
||||
]]>
|
||||
</content>
|
||||
</entry>
|
||||
{% endfor %}
|
||||
</feed>
|
||||
43
user/plugins/feed/templates/feed.json.twig
Normal file
43
user/plugins/feed/templates/feed.json.twig
Normal file
@@ -0,0 +1,43 @@
|
||||
{# Format specification: https://www.jsonfeed.org/version/1/ #}
|
||||
{% set collection = collection|default(page.collection) %}
|
||||
{% set jsonfeed = {
|
||||
"version" : "https://jsonfeed.org/version/1",
|
||||
"title": collection.params.title,
|
||||
"home_page_url": page.url(true),
|
||||
"feed_url": uri.rootUrl(true)~uri.uri(),
|
||||
"description": collection.params.description,
|
||||
"author": {"name": site.author.name}
|
||||
} %}
|
||||
|
||||
{% set itemList = [] %}
|
||||
{% for item in collection %}
|
||||
{%- set post = {
|
||||
"title": item.title|e,
|
||||
"date_published": item.date|date('Y-m-d\\TH:i:sP'),
|
||||
"id": item.url(true),
|
||||
"url": item.url(true),
|
||||
"content_html": item.content|safe_truncate_html(collection.params.length)
|
||||
} %}
|
||||
{% set banner = item.media.images|first %}
|
||||
|
||||
{% if item.header.metadata.description %}
|
||||
{%- set post = post|merge({"summary": item.header.metadata.description|e}) %}
|
||||
{% endif %}
|
||||
|
||||
{% if collection.params.show_last_modified %}
|
||||
{%- set post = post|merge({"date_modified": item.modified|date('Y-m-d\\TH:i:sP')}) %}
|
||||
{% endif %}
|
||||
|
||||
{% if item.taxonomy.tag %}
|
||||
{%- set post = post|merge({"tags": item.taxonomy.tag}) %}
|
||||
{% endif %}
|
||||
|
||||
{% set image = item.media.images|first %}
|
||||
{% if image %}
|
||||
{%- set post = post|merge({"image": image.url(true)}) %}
|
||||
{% endif %}
|
||||
{%- set itemList = itemList|merge([post]) %}
|
||||
{% endfor %}
|
||||
|
||||
{% set jsonfeed = jsonfeed|merge({"items": itemList}) %}
|
||||
{{- jsonfeed|json_encode|raw }}
|
||||
40
user/plugins/feed/templates/feed.rss.twig
Normal file
40
user/plugins/feed/templates/feed.rss.twig
Normal file
@@ -0,0 +1,40 @@
|
||||
{# Format specification: https://www.rssboard.org/rss-specification #}
|
||||
{% set collection = collection|default(page.collection) %}
|
||||
{% set lastBuildDate = 0 %}
|
||||
{% for page in collection %}
|
||||
{%- set lastBuildDate = max(lastBuildDate, page.date) %}
|
||||
{%- if collection.params.show_last_modified %}
|
||||
{%- set lastBuildDate = max(feed_updated, page.modified) %}
|
||||
{%- endif %}
|
||||
{% endfor %}
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
|
||||
<channel>
|
||||
<title>{{ collection.params.title }}</title>
|
||||
<link>{{ page.url(true) }}</link>
|
||||
<atom:link href="{{ uri.rootUrl(true)~uri.uri() }}" rel="self" type="application/rss+xml"/>
|
||||
<description>{{ collection.params.description }}</description>
|
||||
<language>{{ grav.language.getLanguage|default(config.system.language.default_lang)|default('en') }}</language>
|
||||
<lastBuildDate>{{ lastBuildDate|date('D, d M Y H:i:s O') }}</lastBuildDate>
|
||||
{% for item in collection %}
|
||||
{% set banner = item.media.images|first %}
|
||||
<item>
|
||||
<title>{{ item.title|e }}</title>
|
||||
<link>{{ item.url(true) }}</link>
|
||||
<guid>{{ item.url(true) }}</guid>
|
||||
<pubDate>{{ item.date|date('D, d M Y H:i:s O') }}</pubDate>
|
||||
<description>
|
||||
<![CDATA[
|
||||
{% if banner %}
|
||||
{{ banner.cropZoom(1200,800).html|absolute_url|raw }}
|
||||
{% endif %}
|
||||
{{ item.content|safe_truncate_html(collection.params.length)|raw }}
|
||||
]]>
|
||||
</description>
|
||||
{% for tag in item.taxonomy.tag %}
|
||||
<category>{{ tag|e }}</category>
|
||||
{% endfor %}
|
||||
</item>
|
||||
{% endfor %}
|
||||
</channel>
|
||||
</rss>
|
||||
7
user/plugins/feed/vendor/autoload.php
vendored
Normal file
7
user/plugins/feed/vendor/autoload.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitd512066232734940b99b34ad4f8603bc::getLoader();
|
||||
445
user/plugins/feed/vendor/composer/ClassLoader.php
vendored
Normal file
445
user/plugins/feed/vendor/composer/ClassLoader.php
vendored
Normal file
@@ -0,0 +1,445 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see https://www.php-fig.org/psr/psr-0/
|
||||
* @see https://www.php-fig.org/psr/psr-4/
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
// PSR-4
|
||||
private $prefixLengthsPsr4 = array();
|
||||
private $prefixDirsPsr4 = array();
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
private $prefixesPsr0 = array();
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
private $useIncludePath = false;
|
||||
private $classMap = array();
|
||||
private $classMapAuthoritative = false;
|
||||
private $missingClasses = array();
|
||||
private $apcuPrefix;
|
||||
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $classMap Class to filename map
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
if ($this->classMap) {
|
||||
$this->classMap = array_merge($this->classMap, $classMap);
|
||||
} else {
|
||||
$this->classMap = $classMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
// Register directories for a new namespace.
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 base directories
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr0 = (array) $paths;
|
||||
} else {
|
||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setPsr4($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr4 = (array) $paths;
|
||||
} else {
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns off searching the prefix and fallback directories for classes
|
||||
* that have not been registered with the class map.
|
||||
*
|
||||
* @param bool $classMapAuthoritative
|
||||
*/
|
||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||
{
|
||||
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should class lookup fail if not found in the current class map?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isClassMapAuthoritative()
|
||||
{
|
||||
return $this->classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||
*
|
||||
* @param string|null $apcuPrefix
|
||||
*/
|
||||
public function setApcuPrefix($apcuPrefix)
|
||||
{
|
||||
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The APCu prefix in use, or null if APCu caching is not enabled.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getApcuPrefix()
|
||||
{
|
||||
return $this->apcuPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return bool|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
includeFile($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|false The path if found, false otherwise
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
// class map lookup
|
||||
if (isset($this->classMap[$class])) {
|
||||
return $this->classMap[$class];
|
||||
}
|
||||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
||||
return false;
|
||||
}
|
||||
if (null !== $this->apcuPrefix) {
|
||||
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
||||
if ($hit) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
$file = $this->findFileWithExtension($class, '.php');
|
||||
|
||||
// Search for Hack files if we are running on HHVM
|
||||
if (false === $file && defined('HHVM_VERSION')) {
|
||||
$file = $this->findFileWithExtension($class, '.hh');
|
||||
}
|
||||
|
||||
if (null !== $this->apcuPrefix) {
|
||||
apcu_add($this->apcuPrefix.$class, $file);
|
||||
}
|
||||
|
||||
if (false === $file) {
|
||||
// Remember that this class does not exist.
|
||||
$this->missingClasses[$class] = true;
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||
$subPath = $class;
|
||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||
$subPath = substr($subPath, 0, $lastPos);
|
||||
$search = $subPath . '\\';
|
||||
if (isset($this->prefixDirsPsr4[$search])) {
|
||||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||
if (file_exists($file = $dir . $pathEnd)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-4 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 lookup
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||
}
|
||||
|
||||
if (isset($this->prefixesPsr0[$first])) {
|
||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 include paths.
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*/
|
||||
function includeFile($file)
|
||||
{
|
||||
include $file;
|
||||
}
|
||||
209
user/plugins/feed/vendor/composer/InstalledVersions.php
vendored
Normal file
209
user/plugins/feed/vendor/composer/InstalledVersions.php
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
namespace Composer;
|
||||
|
||||
use Composer\Semver\VersionParser;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class InstalledVersions
|
||||
{
|
||||
private static $installed = array (
|
||||
'root' =>
|
||||
array (
|
||||
'pretty_version' => 'dev-develop',
|
||||
'version' => 'dev-develop',
|
||||
'aliases' =>
|
||||
array (
|
||||
),
|
||||
'reference' => '8f9e4fdbb1ae743f788767897571f175fcdc4e27',
|
||||
'name' => 'getgrav/grav-plugin-feed',
|
||||
),
|
||||
'versions' =>
|
||||
array (
|
||||
'getgrav/grav-plugin-feed' =>
|
||||
array (
|
||||
'pretty_version' => 'dev-develop',
|
||||
'version' => 'dev-develop',
|
||||
'aliases' =>
|
||||
array (
|
||||
),
|
||||
'reference' => '8f9e4fdbb1ae743f788767897571f175fcdc4e27',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getInstalledPackages()
|
||||
{
|
||||
return array_keys(self::$installed['versions']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function isInstalled($packageName)
|
||||
{
|
||||
return isset(self::$installed['versions'][$packageName]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||
{
|
||||
$constraint = $parser->parseConstraints($constraint);
|
||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||
|
||||
return $provided->matches($constraint);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getVersionRanges($packageName)
|
||||
{
|
||||
if (!isset(self::$installed['versions'][$packageName])) {
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
$ranges = array();
|
||||
if (isset(self::$installed['versions'][$packageName]['pretty_version'])) {
|
||||
$ranges[] = self::$installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
if (array_key_exists('aliases', self::$installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']);
|
||||
}
|
||||
if (array_key_exists('replaced', self::$installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']);
|
||||
}
|
||||
if (array_key_exists('provided', self::$installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']);
|
||||
}
|
||||
|
||||
return implode(' || ', $ranges);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getVersion($packageName)
|
||||
{
|
||||
if (!isset(self::$installed['versions'][$packageName])) {
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
if (!isset(self::$installed['versions'][$packageName]['version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return self::$installed['versions'][$packageName]['version'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getPrettyVersion($packageName)
|
||||
{
|
||||
if (!isset(self::$installed['versions'][$packageName])) {
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return self::$installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getReference($packageName)
|
||||
{
|
||||
if (!isset(self::$installed['versions'][$packageName])) {
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
if (!isset(self::$installed['versions'][$packageName]['reference'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return self::$installed['versions'][$packageName]['reference'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getRootPackage()
|
||||
{
|
||||
return self::$installed['root'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getRawData()
|
||||
{
|
||||
return self::$installed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function reload($data)
|
||||
{
|
||||
self::$installed = $data;
|
||||
}
|
||||
}
|
||||
21
user/plugins/feed/vendor/composer/LICENSE
vendored
Normal file
21
user/plugins/feed/vendor/composer/LICENSE
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
11
user/plugins/feed/vendor/composer/autoload_classmap.php
vendored
Normal file
11
user/plugins/feed/vendor/composer/autoload_classmap.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||
'Grav\\Plugin\\FeedPlugin' => $baseDir . '/feed.php',
|
||||
);
|
||||
9
user/plugins/feed/vendor/composer/autoload_namespaces.php
vendored
Normal file
9
user/plugins/feed/vendor/composer/autoload_namespaces.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
||||
9
user/plugins/feed/vendor/composer/autoload_psr4.php
vendored
Normal file
9
user/plugins/feed/vendor/composer/autoload_psr4.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
||||
55
user/plugins/feed/vendor/composer/autoload_real.php
vendored
Normal file
55
user/plugins/feed/vendor/composer/autoload_real.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitd512066232734940b99b34ad4f8603bc
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Composer\Autoload\ClassLoader
|
||||
*/
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitd512066232734940b99b34ad4f8603bc', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitd512066232734940b99b34ad4f8603bc', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitd512066232734940b99b34ad4f8603bc::getInitializer($loader));
|
||||
} else {
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
|
||||
$map = require __DIR__ . '/autoload_psr4.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->setPsr4($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
}
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
21
user/plugins/feed/vendor/composer/autoload_static.php
vendored
Normal file
21
user/plugins/feed/vendor/composer/autoload_static.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
// autoload_static.php @generated by Composer
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitd512066232734940b99b34ad4f8603bc
|
||||
{
|
||||
public static $classMap = array (
|
||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||
'Grav\\Plugin\\FeedPlugin' => __DIR__ . '/../..' . '/feed.php',
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->classMap = ComposerStaticInitd512066232734940b99b34ad4f8603bc::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
}
|
||||
5
user/plugins/feed/vendor/composer/installed.json
vendored
Normal file
5
user/plugins/feed/vendor/composer/installed.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"packages": [],
|
||||
"dev": true,
|
||||
"dev-package-names": []
|
||||
}
|
||||
24
user/plugins/feed/vendor/composer/installed.php
vendored
Normal file
24
user/plugins/feed/vendor/composer/installed.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php return array (
|
||||
'root' =>
|
||||
array (
|
||||
'pretty_version' => 'dev-develop',
|
||||
'version' => 'dev-develop',
|
||||
'aliases' =>
|
||||
array (
|
||||
),
|
||||
'reference' => '8f9e4fdbb1ae743f788767897571f175fcdc4e27',
|
||||
'name' => 'getgrav/grav-plugin-feed',
|
||||
),
|
||||
'versions' =>
|
||||
array (
|
||||
'getgrav/grav-plugin-feed' =>
|
||||
array (
|
||||
'pretty_version' => 'dev-develop',
|
||||
'version' => 'dev-develop',
|
||||
'aliases' =>
|
||||
array (
|
||||
),
|
||||
'reference' => '8f9e4fdbb1ae743f788767897571f175fcdc4e27',
|
||||
),
|
||||
),
|
||||
);
|
||||
Reference in New Issue
Block a user