diff --git a/app/config/app.php b/app/config/app.php index 69f24ac9..50751776 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -125,7 +125,7 @@ return array( 'Dingo\Api\Provider\ApiServiceProvider', 'CachetHQ\Cachet\Support\ServiceProviders\RepositoryServiceProvider', - + 'Thujohn\Rss\RssServiceProvider', ), /* @@ -194,7 +194,8 @@ return array( 'Validator' => 'Illuminate\Support\Facades\Validator', 'View' => 'Illuminate\Support\Facades\View', - 'API' => 'Dingo\Api\Facades\API' + 'API' => 'Dingo\Api\Facades\API', + 'RSS' => 'Thujohn\Rss\RssFacade', ), diff --git a/app/models/Incident.php b/app/models/Incident.php index 22973112..ea35461f 100644 --- a/app/models/Incident.php +++ b/app/models/Incident.php @@ -16,6 +16,8 @@ protected $fillable = ['component', 'name', 'status', 'message']; + protected $appends = ['humanStatus']; + /** * An incident belongs to a component. * @return Illuminate\Database\Eloquent\Relations\BelongsTo @@ -29,7 +31,8 @@ * @return string */ public function getHumanStatusAttribute() { - return Lang::get('incident.status' . $this->status); + $statuses = Lang::get('incident.status'); + return $statuses[$this->status]; } /** diff --git a/app/routes/app.php b/app/routes/app.php index bf8d6f5b..d6226c3f 100644 --- a/app/routes/app.php +++ b/app/routes/app.php @@ -20,3 +20,27 @@ // Authorization stuff. Route::get('/auth/logout', 'AuthController@logoutAction'); }); + + Route::get('/rss', function() { + $feed = RSS::feed('2.0', 'UTF-8'); + $feed->channel([ + 'title' => Setting::get('app_name'), + 'description' => 'Status Feed', + 'link' => Setting::get('app_domain'), + ]); + + Incident::get()->map(function($incident) use ($feed) { + $feed->item([ + 'title' => $incident->name, + 'message' => $incident->message, + 'component' => $incident->parent->name, + 'status' => $incident->humanStatus, + 'created_at' => $incident->created_at, + 'updated_at' => $incident->updated_at + ]); + }); + + return Response::make($feed, 200, [ + 'Content-Type' => 'text/xml' + ]); + }); diff --git a/composer.json b/composer.json index e748a2be..27e4bb29 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,8 @@ "laravel/framework": "4.2.*", "guzzlehttp/guzzle": "~5.0", "dingo/api": "0.7.*", - "watson/validating": "0.10.*" + "watson/validating": "0.10.*", + "thujohn/rss": "dev-master" }, "require-dev": { "phpunit/phpunit": "~4.3.0" diff --git a/composer.lock b/composer.lock index b9f5fb37..d51d6846 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": "0f6a2d4a8afd20da1db9127e18b3b358", + "hash": "62ab8c6b87bf3b5342d449b46df2d76b", "packages": [ { "name": "classpreloader/classpreloader", @@ -1961,6 +1961,48 @@ "homepage": "http://symfony.com", "time": "2014-10-26 07:41:27" }, + { + "name": "thujohn/rss", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/thujohn/rss-l4.git", + "reference": "8c03400062167c3f6b7340a1c964cdb3626a4e4b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thujohn/rss-l4/zipball/8c03400062167c3f6b7340a1c964cdb3626a4e4b", + "reference": "8c03400062167c3f6b7340a1c964cdb3626a4e4b", + "shasum": "" + }, + "require": { + "illuminate/support": "4.x", + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Thujohn\\Rss": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Thuau", + "email": "jonathan.thuau@gmail.com" + } + ], + "description": "RSS builder for Laravel 4", + "keywords": [ + "laravel", + "laravel4", + "rss" + ], + "time": "2014-04-07 20:15:45" + }, { "name": "watson/validating", "version": "0.10.6", @@ -2758,7 +2800,9 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "thujohn/rss": 20 + }, "prefer-stable": false, "platform": [], "platform-dev": []