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

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',
),

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];
}
/**

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'
]);
});

View File

@ -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"

48
composer.lock generated
View File

@ -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": []