Added Atom Support #149

This commit is contained in:
Matt Clements 2015-01-02 14:27:51 +00:00
parent 110ae5060d
commit 6cd489a20a
5 changed files with 104 additions and 2 deletions

View File

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

View File

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

View File

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

55
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": "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",

View File

@ -0,0 +1,46 @@
<?php
namespace CachetHQ\Cachet\Http\Controllers;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\Setting;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Response;
use Roumen\Feed\Facades\Feed;
class AtomController extends Controller
{
/**
* Generates an Atom feed of all incidents.
*
* @return \Illuminate\Http\Response
*/
public function feedAction()
{
$feed = Feed::make();
$feed->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');
}
}