/** * Returns the rendered Blade templates. * * @return \Illuminate\View\View */ public function showIndex() { $components = Component::orderBy('order')->orderBy('created_at')->get(); $allIncidents = []; $incidentDays = Setting::get('app_incident_days') ?: 7; foreach (range(0, $incidentDays) as $i) { $date = Carbon::now()->subDays($i); $incidents = Incident::whereBetween('created_at', [$date->format('Y-m-d') . ' 00:00:00', $date->format('Y-m-d') . ' 23:59:59'])->orderBy('created_at', 'desc')->get(); $allIncidents[] = ['date' => $date->format('jS F Y'), 'incidents' => $incidents]; } return View::make('index', ['components' => $components, 'allIncidents' => $allIncidents, 'pageTitle' => Setting::get('app_name'), 'aboutApp' => Markdown::render(Setting::get('app_about'))]); }
/** * Run the allowed domains filter. * * @param \Illuminate\Routing\Route $route * @param \Illuminate\Http\Request $request * @param \Symfony\Component\HttpFoundation\Response $response * * @return \Symfony\Component\HttpFoundation\Response */ public function filter(Route $route, Request $request, Response $response) { // Always allow our own domain. $ourDomain = Setting::get('app_domain'); $response->headers->set('Access-Control-Allow-Origin', $ourDomain); // Should we allow anyone else? if ($setting = Setting::get('allowed_domains')) { $domains = explode(',', $setting); foreach ($domains as $domain) { $response->headers->set('Access-Control-Allow-Origin', $domain); } } return $response; }
/** * Generates an RSS feed of all incidents. * * @return \Illuminate\Http\Response */ public function feedAction() { $feed = RssFacade::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) { if ($incident->component) { $componentName = $incident->component->name; } else { $componentName = null; } $feed->item(['title' => $incident->name, 'message' => $incident->message, 'component' => $componentName, 'status' => $incident->humanStatus, 'created_at' => $incident->created_at, 'updated_at' => $incident->updated_at]); }); return Response::make($feed, 200, ['Content-Type' => 'text/xml']); }
/** * 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'); }