Adds RSS feed. Closes #26. No link or anything, but accessible at /rss

This commit is contained in:
James Brooks
2014-11-27 14:31:33 +00:00
parent b7d49568f6
commit 252b6a1126
5 changed files with 79 additions and 6 deletions
+3 -2
View File
@@ -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',
),
+4 -1
View File
@@ -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];
}
/**
+24
View File
@@ -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'
]);
});