mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 21:49:01 +01:00
Added Atom Support #149
This commit is contained in:
parent
110ae5060d
commit
6cd489a20a
@ -126,6 +126,7 @@ return [
|
||||
'GrahamCampbell\Throttle\ThrottleServiceProvider',
|
||||
'GrahamCampbell\Markdown\MarkdownServiceProvider',
|
||||
'Thujohn\Rss\RssServiceProvider',
|
||||
'Roumen\Feed\FeedServiceProvider',
|
||||
|
||||
'CachetHQ\Cachet\Providers\RepositoryServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\RoutingServiceProvider',
|
||||
|
@ -13,4 +13,5 @@ Route::group(['before' => 'is_setup', 'namespace' => 'CachetHQ\Cachet\Http\Contr
|
||||
|
||||
Route::group(['namespace' => 'CachetHQ\Cachet\Http\Controllers'], function () {
|
||||
Route::get('/rss', 'RssController@feedAction');
|
||||
Route::get('/atom', 'AtomController@feedAction');
|
||||
});
|
||||
|
@ -20,7 +20,8 @@
|
||||
"graham-campbell/throttle": "~2.0",
|
||||
"guzzlehttp/guzzle": "~5.0",
|
||||
"thujohn/rss": "~1.0",
|
||||
"watson/validating": "0.10.*"
|
||||
"watson/validating": "0.10.*",
|
||||
"roumen/feed": "~2.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.3",
|
||||
|
55
composer.lock
generated
55
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "10cd158111365c98b217fc244a6c3a6e",
|
||||
"hash": "18f348e602f5894b0f1fd1189da5ba29",
|
||||
"packages": [
|
||||
{
|
||||
"name": "classpreloader/classpreloader",
|
||||
@ -1858,6 +1858,59 @@
|
||||
"description": "A lightweight implementation of CommonJS Promises/A for PHP",
|
||||
"time": "2014-12-30 13:32:42"
|
||||
},
|
||||
{
|
||||
"name": "roumen/feed",
|
||||
"version": "v2.8.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/RoumenDamianoff/laravel-feed.git",
|
||||
"reference": "7b6ef68081a4aa16f1c43cea23a3a55235ea6698"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/RoumenDamianoff/laravel-feed/zipball/7b6ef68081a4aa16f1c43cea23a3a55235ea6698",
|
||||
"reference": "7b6ef68081a4aa16f1c43cea23a3a55235ea6698",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/support": "~4|~5",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"orchestra/testbench": "2.2.*",
|
||||
"phpunit/phpunit": "3.7.*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.8-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Roumen\\Feed": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Roumen Damianoff",
|
||||
"email": "roumen@dawebs.com",
|
||||
"homepage": "https://roumen.it",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "A simple feed generator for Laravel.",
|
||||
"homepage": "https://roumen.it/projects/laravel-feed",
|
||||
"keywords": [
|
||||
"feed",
|
||||
"laravel"
|
||||
],
|
||||
"time": "2014-12-09 14:53:34"
|
||||
},
|
||||
{
|
||||
"name": "stack/builder",
|
||||
"version": "v1.0.3",
|
||||
|
46
src/Http/Controllers/AtomController.php
Normal file
46
src/Http/Controllers/AtomController.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Cachet\Models\Setting;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Roumen\Feed\Facades\Feed;
|
||||
|
||||
class AtomController extends Controller
|
||||
{
|
||||
/**
|
||||
* Generates an Atom feed of all incidents.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function feedAction()
|
||||
{
|
||||
$feed = Feed::make();
|
||||
$feed->title = Setting::get('app_name');
|
||||
$feed->description = 'Status Feed';
|
||||
$feed->link = Setting::get('app_domain');
|
||||
|
||||
$feed->setDateFormat('datetime');
|
||||
|
||||
Incident::get()->map(function ($incident) use ($feed) {
|
||||
if ($incident->component) {
|
||||
$componentName = $incident->component->name;
|
||||
} else {
|
||||
$componentName = null;
|
||||
}
|
||||
|
||||
$feed->add(
|
||||
$incident->name,
|
||||
Setting::get('app_name'),
|
||||
Setting::get('app_domain'),
|
||||
$incident->created_at,
|
||||
($componentName===null ? $incident->humanStatus : $componentName." ".$incident->humanStatus),
|
||||
$incident->message
|
||||
);
|
||||
});
|
||||
|
||||
return $feed->render('atom');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user