Adds RSS feed. Closes #26. No link or anything, but accessible at /rss
This commit is contained in:
+3
-2
@@ -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',
|
||||
|
||||
),
|
||||
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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'
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user