delete rss plugin
This commit is contained in:
parent
de7cbb4b27
commit
7549856b0e
|
|
@ -1,115 +0,0 @@
|
|||
<?php namespace SoBoRed\Rss;
|
||||
|
||||
use DB;
|
||||
use DateTime;
|
||||
use File;
|
||||
use Backend;
|
||||
use Controller;
|
||||
use Event;
|
||||
use Markdown;
|
||||
use System\Classes\PluginBase;
|
||||
use SoBoRed\Rss\Models\Settings;
|
||||
|
||||
class Plugin extends PluginBase
|
||||
{
|
||||
/**
|
||||
* @var array Plugin dependencies
|
||||
*/
|
||||
public $require = ['RainLab.Blog'];
|
||||
|
||||
public function pluginDetails()
|
||||
{
|
||||
return [
|
||||
'name' => 'Blog RSS Feed',
|
||||
'description' => 'An RSS feed generator for the RainLab Blog plugin',
|
||||
'author' => 'Josh Hall',
|
||||
'icon' => 'icon-rss'
|
||||
];
|
||||
}
|
||||
|
||||
public function registerComponents()
|
||||
{
|
||||
return [
|
||||
'SoBoRed\Rss\Components\Link' => 'rssLink'
|
||||
];
|
||||
}
|
||||
|
||||
public function boot()
|
||||
{
|
||||
// Event Listeners for RainLab Blog
|
||||
Event::listen('eloquent.created: RainLab\Blog\Models\Post', function($model) {
|
||||
$this->createRss();
|
||||
});
|
||||
Event::listen('eloquent.saved: RainLab\Blog\Models\Post', function($model) {
|
||||
$this->createRss();
|
||||
});
|
||||
Event::listen('eloquent.deleted: RainLab\Blog\Models\Post', function($model) {
|
||||
$this->createRss();
|
||||
});
|
||||
|
||||
// Event Listeners for SoBoRed settings
|
||||
Event::listen('eloquent.saved: SoBoRed\Rss\Models\Settings', function($model) {
|
||||
$this->createRss();
|
||||
});
|
||||
}
|
||||
|
||||
public function registerSettings()
|
||||
{
|
||||
return [
|
||||
'settings' => [
|
||||
'label' => 'Blog RSS Settings',
|
||||
'description' => 'Manage the Blog RSS settings.',
|
||||
'category' => 'Blog',
|
||||
'icon' => 'icon-rss',
|
||||
'class' => 'SoBoRed\Rss\Models\Settings',
|
||||
'order' => 100
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
protected function createRss()
|
||||
{
|
||||
$fileContents = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" .
|
||||
"<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n".
|
||||
"\t<channel>\n".
|
||||
"\t\t<title>" . Settings::get('title') . "</title>\n" .
|
||||
"\t\t<link>" . Settings::get('link') . "</link>\n" .
|
||||
"\t\t<description>" . Settings::get('description') . "</description>\n".
|
||||
"\t\t<atom:link href=\"" . Settings::get('link') . "/rss.xml\" rel=\"self\" type=\"application/rss+xml\" />\n\n";
|
||||
|
||||
foreach($this->loadPosts() as $post)
|
||||
{
|
||||
$published = DateTime::createFromFormat('Y-m-d H:i:s', $post->published_at);
|
||||
$description = Settings::get('showFullPostContent') ? $post->content : $post->excerpt;
|
||||
$description = Markdown::parse(trim($description));
|
||||
|
||||
$fileContents .= "\t\t<item>\n" .
|
||||
"\t\t\t<title>" . htmlspecialchars($post->title, ENT_QUOTES, 'UTF-8') . "</title>\n" .
|
||||
"\t\t\t<link>" . Settings::get('link') . Settings::get('postPage') . "/" . $post->slug . "</link>\n" .
|
||||
"\t\t\t<guid isPermaLink='true'>" . Settings::get('link') . Settings::get('postPage') . "/" . $post->slug . "</guid>\n" .
|
||||
"\t\t\t<pubDate>" . $published->format(DateTime::RFC2822) . "</pubDate>\n" .
|
||||
"\t\t\t<description><![CDATA[ <img src='".Settings::get('link')."/storage/app/media/'".$post->featured_image.">"
|
||||
. htmlspecialchars($description, ENT_QUOTES, 'UTF-8') . " ]]></description>\n" .
|
||||
"\t\t</item>\n";
|
||||
|
||||
}
|
||||
|
||||
$fileContents .= "\t</channel>\n";
|
||||
$fileContents .= "</rss>\n";
|
||||
|
||||
$file = File::put('rss.xml', $fileContents);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
protected function loadPosts()
|
||||
{
|
||||
$posts = Db::table('rainlab_blog_posts')
|
||||
->select('id','title','slug','published_at','content','excerpt','featured_image')
|
||||
->orderBy('published_at', 'desc')
|
||||
->where('published', '=', '1')
|
||||
->get();
|
||||
|
||||
return $posts;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
# Blog RSS Feed Extension
|
||||
|
||||
__Blog RSS Feed extends and is therefore dependent on the [RainLab Blog](https://octobercms.com/plugin/rainlab-blog) plugin.__
|
||||
|
||||
This plugin creates and updates an rss.xml file for blog posts. It also comes with an RSS Link component. This is optional and was just included for convenience. You can link to the rss.xml file however you want. It is created at http://www.yoursite.com/rss.xml.
|
||||
|
||||
|
||||
## Installation/Setup
|
||||
|
||||
1. Install the plugin itself by either adding it to your project, or going to System > Updates and searching for **SoBoRed.Rss**
|
||||
2. Click System from the main menu of the backend.
|
||||
3. In the Settings sub-menu, click on __Blog RSS Settings__ under the Blog section.
|
||||
4. Fill out the information under the __Site Information__ and __Blog Information__ tabs.
|
||||
|
||||
The Site and Blog information is used during the creation of the RSS xml file:
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>[Title]</title>
|
||||
<link>[Link]</link>
|
||||
<description>[Description]</description>
|
||||
|
||||
<item>
|
||||
<title>[Post Title]</title>
|
||||
<link>[Link][Post Page]/[Post Slug]</link>
|
||||
<guid>[Link][Post Page]/[Post Slug]</guid>
|
||||
<pubDate>[Published Date|Format M d, Y]</pubDate>
|
||||
<description>[Post Excerpt]</description>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
### 1. Using the optional link component:
|
||||
|
||||
+ There should now be a component under the component menu for Link to RSS Feed.
|
||||
+ Add it to the page or layout just like any other component
|
||||
+ There are 3 settings for this component:
|
||||
+ Feed Burner Address - This is the address to the feedburner feed: http://feeds.feedburner.com/feed_address. If left blank, the link will just be to your RSS file: http://yourblog.com/rss.xml
|
||||
+ Default Link Text - This is the default link text. It is used for the RSS link when Icon Class(es) is empty. For example: `<a>RSS</a>`.
|
||||
+ Icon Class(es) - This is the icon class(es). It is used for the RSS link: `<a><i class="icon icon-rss"></i></a>`. If left blank, the link will just display the default link text.
|
||||
|
||||
```twig
|
||||
<a href="{{ feedBurnerAddress ? feedBurnerLink : defaultRssLink }}" target="_blank">
|
||||
{% if iconClass %}
|
||||
<i class="{{ iconClass }}"></i>
|
||||
{% else %}
|
||||
{{ defaultText }}
|
||||
{% endif %}
|
||||
</a>
|
||||
```
|
||||
|
||||
### 2. Or just put whatever you want in your layout/pages :)
|
||||
|
||||
The included component is completely optional. It is only included for convenience. You can link to the generated RSS file in any fashion that you want.
|
||||
|
||||
## Note
|
||||
> If you're using version control for your website, you may want to include the rss.xml file in your .gitignore to keep it separate from the production content.
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
<?php namespace SoBoRed\Rss\Components;
|
||||
|
||||
use DB;
|
||||
use App;
|
||||
use File;
|
||||
use Request;
|
||||
use DateTime;
|
||||
use Cms\Classes\ComponentBase;
|
||||
use SoBoRed\Rss\Models\Settings;
|
||||
|
||||
class Link extends ComponentBase
|
||||
{
|
||||
public $feedBurnerAddress;
|
||||
public $defaultText;
|
||||
public $iconCLass;
|
||||
public $posts;
|
||||
public $file;
|
||||
|
||||
public function componentDetails()
|
||||
{
|
||||
return [
|
||||
'name' => 'Link to RSS Feed',
|
||||
'description' => 'Outputs a link to the RSS feed.'
|
||||
];
|
||||
}
|
||||
|
||||
public function defineProperties()
|
||||
{
|
||||
return [
|
||||
'feedBurnerAddress' => [
|
||||
'title' => 'Feed Burner Address',
|
||||
'description' => 'This is the address to the feedburner feed: http://feeds.feedburner.com/feed_address. If left blank, the link will just be to your RSS file: http://yourblog.com/rss.xml',
|
||||
'default' => '',
|
||||
'type' => 'string'
|
||||
],
|
||||
'defaultText' => [
|
||||
'title' => 'Default Link Text',
|
||||
'description' => 'This is the default link text. It is used for the RSS link. For example: <a>RSS</a>.',
|
||||
'default' => 'RSS',
|
||||
'type' => 'string'
|
||||
],
|
||||
'iconClass' => [
|
||||
'title' => 'Icon Class(es)',
|
||||
'description' => 'This is the icon class(es). It is used for the RSS link. <a><i class="icon icon-rss"></i></a>. If left blank, the link will just display the default link text.',
|
||||
'default' => '',
|
||||
'type' => 'string'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function onRun()
|
||||
{
|
||||
$this->posts = $this->page['posts'] = $this->loadPosts();
|
||||
$this->feedBurnerAddress = $this->page['feedBurnerAddress'] = $this->property('feedBurnerAddress');
|
||||
$this->defaultText = $this->page['defaultText'] = $this->property('defaultText');
|
||||
$this->iconClass = $this->page['iconClass'] = $this->property('iconClass');
|
||||
$this->defaultRssLink = $this->page['defaultRssLink'] = Settings::get('link') . "/rss.xml";
|
||||
$this->feedBurnerLink = $this->page['feedBurnerLink'] = "http://feeds.feedburner.com/" . $this->feedBurnerAddress;
|
||||
}
|
||||
|
||||
protected function loadPosts()
|
||||
{
|
||||
$posts = Db::table('rainlab_blog_posts')
|
||||
->orderBy('published_at', 'desc')
|
||||
->where('published', '=', '1')
|
||||
->get();
|
||||
|
||||
return $posts;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<a href="{{ feedBurnerAddress ? feedBurnerLink : defaultRssLink}}" target="_blank">
|
||||
{% if iconClass %}
|
||||
<i class="{{ iconClass }}"></i>
|
||||
{% else %}
|
||||
{{ defaultText }}
|
||||
{% endif %}
|
||||
</a>
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Lamin Sanneh
|
||||
* Date: 5/19/14
|
||||
* Time: 10:35 AM
|
||||
*/
|
||||
|
||||
namespace SoBoRed\Rss\Models;
|
||||
|
||||
use Model;
|
||||
class Settings extends Model{
|
||||
|
||||
public $implement = [
|
||||
'System.Behaviors.SettingsModel'
|
||||
];
|
||||
|
||||
public $settingsCode = 'sobored_rss_settings';
|
||||
|
||||
public $settingsFields = 'fields.yaml';
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
# ===================================
|
||||
# Field Definitions
|
||||
# ===================================
|
||||
|
||||
tabs:
|
||||
fields:
|
||||
title:
|
||||
tab: Site Information
|
||||
label: Title
|
||||
span: left
|
||||
placeholder: Blog/RSS Feed Title
|
||||
comment: The <title> of your RSS feed (this will be part of the xml)
|
||||
description: The <title> of your RSS feed (this will be part of the xml)
|
||||
|
||||
link:
|
||||
tab: Site Information
|
||||
label: Link
|
||||
span: right
|
||||
placeholder: Website/Blog Link
|
||||
comment: The <link> to your blog/website (blog.example.com)
|
||||
description: The <link> to your blog/website (blog.example.com)
|
||||
|
||||
|
||||
description:
|
||||
tab: Site Information
|
||||
label: Description
|
||||
type: textarea
|
||||
size: small
|
||||
comment: A short description of your website/blog.
|
||||
description: A short description of your website/blog
|
||||
|
||||
postPage:
|
||||
tab: Blog Information
|
||||
label: Post Page
|
||||
span: left
|
||||
placeholder: /blog/post
|
||||
comment: The post page for linking in RSS
|
||||
description: The post page for linking in RSS
|
||||
|
||||
showFullPostContent:
|
||||
tab: Blog Information
|
||||
label: Show full post content?
|
||||
type: checkbox
|
||||
span: left
|
||||
default: true
|
||||
comment: Uncheck if you want only the excerpt to be displayed in the xml
|
||||
description: Uncheck if you want only the excerpt to be displayed in the xml
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
1.0.1: Initialize plugin
|
||||
1.0.2:
|
||||
- Fixed the rss.xml file to update when saving creating or deleting a blog post
|
||||
- Makes the rss.xml file update when saving the RSS Feed settings
|
||||
- Updates the conditional statement for the feed burner address
|
||||
1.0.3: Updates the generation of XML
|
||||
1.0.4: Updates pubDate to be RFC822
|
||||
1.0.5: Patch for valid RSS XML
|
||||
1.0.6: Fixes versioning
|
||||
1.0.7: Allows for full post content
|
||||
1.0.8:
|
||||
- Changed having to where to help database type compatibility
|
||||
- Updated the output to parse markdown
|
||||
1.0.9: Update to work with new RC version of October.
|
||||
1.1.0: Properly escape post title
|
||||
Loading…
Reference in New Issue