diff --git a/app/config/app.php b/app/config/app.php index c2ceb1663..6d41ae0cc 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -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', diff --git a/app/routes/app.php b/app/routes/app.php index 496cab35f..5ab59d246 100644 --- a/app/routes/app.php +++ b/app/routes/app.php @@ -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'); }); diff --git a/composer.json b/composer.json index 36d17a7aa..9c981b50f 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/composer.lock b/composer.lock index 9337ba0f5..f40568cd7 100644 --- a/composer.lock +++ b/composer.lock @@ -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", diff --git a/src/Http/Controllers/AtomController.php b/src/Http/Controllers/AtomController.php new file mode 100644 index 000000000..f89a7b0c8 --- /dev/null +++ b/src/Http/Controllers/AtomController.php @@ -0,0 +1,46 @@ +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'); + } +}