Merge pull request #3368 from CachetHQ/drop-feeds

Drop support for RSS & Atom feeds
This commit is contained in:
James Brooks
2018-12-27 23:27:19 +00:00
committed by GitHub
9 changed files with 0 additions and 310 deletions

View File

@@ -1,124 +0,0 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Cachet\Http\Controllers;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\Incident;
use GrahamCampbell\Markdown\Facades\Markdown;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Str;
use McCool\LaravelAutoPresenter\Facades\AutoPresenter;
use Roumen\Feed\Feed;
/**
* This is the feed controller.
*
* @author James Brooks <james@alt-three.com>
*/
class FeedController extends Controller
{
/**
* Feed facade.
*
* @var \Roumen\Feed\Feed
*/
protected $feed;
/**
* Create a new feed controller instance.
*
* @return void
*/
public function __construct(Feed $feed)
{
$this->feed = $feed;
$this->feed->title = Config::get('setting.app_name');
$this->feed->description = trans('cachet.feed');
$this->feed->link = Str::canonicalize(Config::get('setting.app_domain'));
$this->feed->ctype = 'text/xml';
$this->feed->setDateFormat('datetime');
}
/**
* Generates an Atom feed of all incidents.
*
* @param \CachetHQ\Cachet\Models\ComponentGroup|null $group
*
* @return \Illuminate\Http\Response
*/
public function atomAction(ComponentGroup $group = null)
{
return $this->feedAction($group, false);
}
/**
* Generates a Rss feed of all incidents.
*
* @param \CachetHQ\Cachet\Models\ComponentGroup|null $group
*
* @return \Illuminate\Http\Response
*/
public function rssAction(ComponentGroup $group = null)
{
$this->feed->lang = Config::get('setting.app_locale');
return $this->feedAction($group, true);
}
/**
* Generates a Rss feed of all incidents.
*
* @param \CachetHQ\Cachet\Models\ComponentGroup|null $group
* @param bool $isRss
*
* @return \Illuminate\Http\Response
*/
private function feedAction(ComponentGroup $group = null, $isRss = true)
{
if ($group) {
$group->components->map(function ($component) use ($isRss) {
$component->incidents()->visible()->orderBy('occurred_at', 'desc')->get()->map(function ($incident) use ($isRss) {
$this->feedAddItem($incident, $isRss);
});
});
} else {
Incident::visible()->orderBy('occurred_at', 'desc')->get()->map(function ($incident) use ($isRss) {
$this->feedAddItem($incident, $isRss);
});
}
return $this->feed->render($isRss ? 'rss' : 'atom');
}
/**
* Adds an item to the feed.
*
* @param \CachetHQ\Cachet\Models\Incident $incident
* @param bool $isRss
*/
private function feedAddItem(Incident $incident, $isRss)
{
$incident = AutoPresenter::decorate($incident);
$this->feed->add(
$incident->name,
Config::get('setting.app_name'),
Str::canonicalize(cachet_route('incident', [$incident->id])),
$isRss ? $incident->getWrappedObject()->occurred_at->toRssString() : $incident->getWrappedObject()->occurred_at->toAtomString(),
Markdown::convertToHtml($incident->message),
null,
[],
$isRss ? $incident->human_status : null
);
}
}

View File

@@ -1,53 +0,0 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Cachet\Http\Routes;
use Illuminate\Contracts\Routing\Registrar;
/**
* This is the feed routes class.
*
* @author James Brooks <james@alt-three.com>
*/
class FeedRoutes
{
/**
* Defines if these routes are for the browser.
*
* @var bool
*/
public static $browser = true;
/**
* Define the status page routes.
*
* @param \Illuminate\Contracts\Routing\Registrar $router
*
* @return void
*/
public function map(Registrar $router)
{
$router->group([
'middleware' => ['ready'],
], function (Registrar $router) {
$router->get('/atom/{component_group?}', [
'as' => 'get:feed.atom',
'uses' => 'FeedController@atomAction',
]);
$router->get('/rss/{component_group?}', [
'as' => 'get:feed.rss',
'uses' => 'FeedController@rssAction',
]);
});
}
}

View File

@@ -55,7 +55,6 @@
"nexmo/client": "^1.5",
"pragmarx/google2fa": "^0.7.1",
"predis/predis": "^1.1",
"roumen/feed": "^2.10",
"twig/twig": "^1.35"
},
"require-dev": {

View File

@@ -187,7 +187,6 @@ return [
Laravolt\Avatar\ServiceProvider::class,
McCool\LaravelAutoPresenter\AutoPresenterServiceProvider::class,
PragmaRX\Google2FA\Vendor\Laravel\ServiceProvider::class,
Roumen\Feed\FeedServiceProvider::class,
/*
* Application Service Providers...

View File

@@ -7,9 +7,6 @@
<meta name="env" content="{{ app('env') }}">
<meta name="token" content="{{ csrf_token() }}">
<link rel="alternate" type="application/atom+xml" href="{{ cachet_route('feed.atom') }}" title="{{ $siteTitle }} - Atom Feed">
<link rel="alternate" type="application/rss+xml" href="{{ cachet_route('feed.rss') }}" title="{{ $siteTitle }} - RSS Feed">
<!-- Mobile friendliness -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">

View File

@@ -26,12 +26,6 @@
<a class="btn btn-link" href="{{ cachet_route('auth.logout') }}">{{ trans('dashboard.logout') }}</a>
</li>
@endif
<li>
<a class="btn btn-link" href="{{ cachet_route('feed.rss') }}">{{ trans('cachet.rss-feed') }}</a>
</li>
<li>
<a class="btn btn-link" href="{{ cachet_route('feed.atom') }}">{{ trans('cachet.atom-feed') }}</a>
</li>
@if($enableSubscribers)
<li>
<a class="btn btn-success btn-outline" href="{{ cachet_route('subscribe') }}">{{ trans('cachet.subscriber.button') }}</a>

View File

@@ -1,29 +0,0 @@
{!! '<'.'?'.'xml version="1.0" encoding="UTF-8" ?>' !!}
<feed xmlns="http://www.w3.org/2005/Atom"<?php foreach($namespaces as $n) echo " ".$n; ?>>
<title type="text">{!! $channel['title'] !!}</title>
<subtitle type="html"><![CDATA[{!! $channel['description'] !!}]]></subtitle>
<link href="{{ Request::url() }}"></link>
<id>{{ $channel['link'] }}</id>
<link rel="alternate" type="text/html" href="{{ Request::url() }}" ></link>
<link rel="self" type="application/atom+xml" href="{{ $channel['link'] }}" ></link>
@if (!empty($channel['logo']))
<logo>{{ $channel['logo'] }}</logo>
@endif
@if (!empty($channel['icon']))
<icon>{{ $channel['icon'] }}</icon>
@endif
<updated>{{ $channel['pubdate'] }}</updated>
@foreach($items as $item)
<entry>
<author>
<name>{{ $item['author'] }}</name>
</author>
<title type="text"><![CDATA[{!! $item['title'] !!}]]></title>
<link rel="alternate" type="text/html" href="{{ $item['link'] }}"></link>
<id>{{ $item['link'] }}</id>
<summary type="html"><![CDATA[{!! $item['description'] !!}]]></summary>
<content type="html"><![CDATA[{!! $item['content'] !!}]]></content>
<updated>{{ $item['pubdate'] }}</updated>
</entry>
@endforeach
</feed>

View File

@@ -1,89 +0,0 @@
{!! '<'.'?'.'xml version="1.0" encoding="UTF-8" ?>' !!}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:webfeeds="http://webfeeds.org/rss/1.0" xmlns:media="http://search.yahoo.com/mrss/"<?php foreach($namespaces as $n) echo " ".$n; ?>>
<channel>
<title>{!! $channel['title'] !!}</title>
<link>{{ Request::url() }}</link>
<description><![CDATA[{!! $channel['description'] !!}]]></description>
<atom:link href="{{ $channel['link'] }}" rel="self"></atom:link>
@if (!empty($channel['copyright']))
<copyright>{{ $channel['copyright'] }}</copyright>
@endif
@if (!empty($channel['color']))
<webfeeds:accentColor>{{ $channel['color'] }}</webfeeds:accentColor>
@endif
@if (!empty($channel['cover']))
<webfeeds:cover image="{{ $channel['cover'] }}">
@endif
@if (!empty($channel['icon']))
<webfeeds:icon>{{ $channel['icon'] }}</webfeeds:icon>
@endif
@if (!empty($channel['logo']))
<webfeeds:logo>{{ $channel['logo'] }}</webfeeds:logo>
<image>
<url>{{ $channel['logo'] }}</url>
<title>{{ $channel['title'] }}</title>
<link>{{ Request::url() }}</link>
</image>
@endif
@if (!empty($channel['related']))
<webfeeds:related layout="card" target="browser">
@endif
@if (!empty($channel['ga']))
<webfeeds:analytics id="{{ $channel['ga'] }}" engine="GoogleAnalytics">
@endif
<language>{{ $channel['lang'] }}</language>
<lastBuildDate>{{ $channel['pubdate'] }}</lastBuildDate>
@foreach($items as $item)
<item>
<title><![CDATA[{!! $item['title'] !!}]]></title>
@if (!empty($item['category']))
<category>{{ $item['category'] }}</category>
@endif
<link>{{ $item['link'] }}</link>
<guid isPermaLink="true">{{ $item['link'] }}</guid>
<description><![CDATA[{!! $item['description'] !!}]]></description>
@if (!empty($item['content']))
<content:encoded><![CDATA[{!! $item['content'] !!}]]></content:encoded>
@endif
<dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">{{ $item['author'] }}</dc:creator>
<pubDate>{{ $item['pubdate'] }}</pubDate>
@if (!empty($item['enclosure']))
<enclosure
@foreach ($item['enclosure'] as $k => $v)
{!! $k.'="'.$v.'" ' !!}
@endforeach
/>
@endif
@if (!empty($item['media:content']))
<media:content
@foreach ($item['media:content'] as $k => $v)
{!! $k.'="'.$v.'" ' !!}
@endforeach
/>
@endif
@if (!empty($item['media:thumbnail']))
<media:thumbnail
@foreach ($item['media:thumbnail'] as $k => $v)
{!! $k.'="'.$v.'" ' !!}
@endforeach
/>
@endif
@if (!empty($item['media:title']))
<media:title type="plain">{{ $item['media:title'] }}</media:title>
@endif
@if (!empty($item['media:description']))
<media:description type="plain">{{ $item['media:description'] }}</media:description>
@endif
@if (!empty($item['media:keywords']))
<media:keywords>{{ $item['media:title'] }}</media:keywords>
@endif
@if (!empty($item['media:rating']))
<media:rating>{{ $item['media:rating'] }}</media:rating>
@endif
@if (!empty($item['creativeCommons:license']))
<creativeCommons:license>{{ $item['creativeCommons:license'] }}</creativeCommons:license>
@endif
</item>
@endforeach
</channel>
</rss>

View File

@@ -126,8 +126,6 @@ class RouteServiceProviderTest extends AbstractTestCase
'core::get:schedule',
'core::get:metric',
'core::get:component_shield',
'core::get:feed.atom',
'core::get:feed.rss',
'core::get:subscribe',
'core::post:subscribe',
'core::get:subscribe.manage',
@@ -151,8 +149,6 @@ class RouteServiceProviderTest extends AbstractTestCase
'core::get:schedule',
'core::get:metric',
'core::get:component_shield',
'core::get:feed.atom',
'core::get:feed.rss',
'core::get:subscribe',
'core::post:subscribe',
'core::get:subscribe.manage',