File tree Expand file tree Collapse file tree 5 files changed +65
-0
lines changed Expand file tree Collapse file tree 5 files changed +65
-0
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
":count Incident" : " :count Incident|:count Incidents" ,
3
+ ":name RSS Feed" : " :name RSS Feed" ,
3
4
"Admin" : " Admin" ,
4
5
"Always Hidden" : " Always Hidden" ,
5
6
"Always collapsed" : " Always collapsed" ,
Original file line number Diff line number Diff line change
1
+ <?=
2
+ ' <?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL
3
+ ? >
4
+ <rss version =" 2.0" >
5
+ <channel >
6
+ <title ><![CDATA[ {{ __ (' :name RSS Feed' , [' name' => $statusPageName ]) } } ]] ></title >
7
+ <link ><![CDATA[ {{ route (' cachet.rss' ) } } ]] ></link >
8
+ @if ($statusAbout )
9
+ <description ><![CDATA[ {{ $statusAbout } } ]] ></description >
10
+ @endif
11
+ <language >{{ config (' app.locale' ) } } </language >
12
+ <pubDate >{{ now ()-> toRssString () } } </pubDate >
13
+
14
+ @foreach ($incidents as $incident )
15
+ <item >
16
+ <title >{{ $incident -> name } } </title >
17
+ <link >{{ route (' cachet.status-page.incident' , $incident ) } } </link >
18
+ <description ><![CDATA[{!! $incident -> message ! !} ]] ></description >
19
+ <guid >{{ $incident -> guid } } </guid >
20
+ <pubDate >{{ $incident -> created_at -> toRssString () } } </pubDate >
21
+ </item >
22
+ @endforeach
23
+ </channel >
24
+ </rss >
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Cachet \Http \Controllers ;
4
+
5
+ use Cachet \Models \Incident ;
6
+ use Cachet \Settings \AppSettings ;
7
+ use Illuminate \Http \Response ;
8
+
9
+ class RssController
10
+ {
11
+ /**
12
+ * Returns the RSS feed of all incidents.
13
+ */
14
+ public function __invoke (AppSettings $ appSettings ): Response
15
+ {
16
+ return response ()->view ('cachet::rss ' , [
17
+ 'statusPageName ' => $ appSettings ->name ,
18
+ 'statusAbout ' => $ appSettings ->about ,
19
+ 'incidents ' => Incident::query ()
20
+ ->guests ()
21
+ ->with ('incidentUpdates ' )
22
+ ->orderByDesc ('created_at ' )
23
+ ->get (),
24
+ ])->header ('Content-Type ' , 'application/rss+xml ' );
25
+ }
26
+ }
Original file line number Diff line number Diff line change 3
3
namespace Cachet ;
4
4
5
5
use Cachet \Http \Controllers \HealthController ;
6
+ use Cachet \Http \Controllers \RssController ;
6
7
use Cachet \Http \Controllers \Setup \SetupController ;
7
8
use Cachet \Http \Controllers \StatusPage \StatusPageController ;
8
9
use Illuminate \Routing \Router ;
@@ -37,6 +38,8 @@ public function register(): void
37
38
// @todo subscription routes... subscribe, manage subscriptions, unsubscribe
38
39
39
40
$ router ->get ('/health ' , HealthController::class)->name ('health ' );
41
+
42
+ $ router ->get ('/rss ' , RssController::class)->name ('rss ' );
40
43
});
41
44
}
42
45
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Cachet \Models \Incident ;
4
+
5
+ it ('can get the rss feed ' , function () {
6
+ $ incident = Incident::factory ()->create ();
7
+
8
+ $ this ->get ('/status/rss ' )
9
+ ->assertOk ()
10
+ ->assertSee ($ incident ->name );
11
+ });
You can’t perform that action at this time.
0 commit comments