From f53075ec4fade183084c575201855b6958ef7bbc Mon Sep 17 00:00:00 2001 From: James Brooks Date: Tue, 31 May 2016 19:12:23 +0100 Subject: [PATCH] Add Patreon link and latest Cachet blog posts to dashboard --- .../Dashboard/DashboardController.php | 4 ++-- app/Integrations/Feed.php | 11 ++++++++-- resources/assets/sass/modules/_stats.scss | 22 +++++++++++++++++++ resources/lang/en/dashboard.php | 8 +++++++ resources/views/dashboard/index.blade.php | 18 +++++++-------- 5 files changed, 50 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/Dashboard/DashboardController.php b/app/Http/Controllers/Dashboard/DashboardController.php index 952fb090..dcb60c92 100644 --- a/app/Http/Controllers/Dashboard/DashboardController.php +++ b/app/Http/Controllers/Dashboard/DashboardController.php @@ -69,14 +69,14 @@ class DashboardController extends Controller $subscribers = $this->getSubscribers(); $feed = $this->feed->entries(); - dd($feed); + $entries = array_slice($feed->channel->item, 0, 5); return View::make('dashboard.index') ->withPageTitle(trans('dashboard.dashboard')) ->withComponents($components) ->withIncidents($incidents) ->withSubscribers($subscribers) - ->withFeed($feed); + ->withEntries($entries); } /** diff --git a/app/Integrations/Feed.php b/app/Integrations/Feed.php index 53136628..474ca522 100644 --- a/app/Integrations/Feed.php +++ b/app/Integrations/Feed.php @@ -15,6 +15,11 @@ use GuzzleHttp\Client; use Illuminate\Contracts\Cache\Repository; use SimpleXmlElement; +/** + * This is the feed class. + * + * @author James Brooks + */ class Feed { /** @@ -60,9 +65,11 @@ class Feed public function entries() { return $this->cache->remember('feeds', 2880, function () { - return new SimpleXmlElement((new Client())->get($this->url, [ + $xml = simplexml_load_string((new Client())->get($this->url, [ 'headers' => ['Accept' => 'application/rss+xml', 'User-Agent' => defined('CACHET_VERSION') ? 'cachet/'.constant('CACHET_VERSION') : 'cachet'], - ])->getBody()->getContents()); + ])->getBody()->getContents(), null, LIBXML_NOCDATA); + + return json_decode(json_encode($xml)); }); } } diff --git a/resources/assets/sass/modules/_stats.scss b/resources/assets/sass/modules/_stats.scss index 160ddf56..da60616f 100644 --- a/resources/assets/sass/modules/_stats.scss +++ b/resources/assets/sass/modules/_stats.scss @@ -40,6 +40,28 @@ padding-top: 10px; } + .stats-body { + margin-top: -20px; + padding-top: 10px; + + .list-group { + border: none; + padding-bottom: 0; + margin-bottom: 0; + + .list-group-item { + border-right: none; + border-left: none; + + border-color: #eee; + + &:last-child { + border-bottom: none; + } + } + } + } + .stats-bottom { border-top: #eee 1px solid; color: #777; diff --git a/resources/lang/en/dashboard.php b/resources/lang/en/dashboard.php index 54270b24..0078d64f 100755 --- a/resources/lang/en/dashboard.php +++ b/resources/lang/en/dashboard.php @@ -249,6 +249,14 @@ return [ 'whoops' => 'Whoops.', ], + // Widgets + 'widgets' => [ + 'support' => 'Support Cachet', + 'support_subtitle' => 'Check out our Patreon page!', + 'news' => 'Latest News', + 'news_subtitle' => 'Get the latest updates', + ], + // Welcome modal 'welcome' => [ 'welcome' => 'Welcome to your new status page!', diff --git a/resources/views/dashboard/index.blade.php b/resources/views/dashboard/index.blade.php index 874e4a93..cbc07663 100644 --- a/resources/views/dashboard/index.blade.php +++ b/resources/views/dashboard/index.blade.php @@ -79,8 +79,8 @@
- Support Cachet - Check out our Patreon page! + {{ trans('dashboard.widgets.support') }} + {!! trans('dashboard.widgets.support_subtitle') !!}
@@ -88,15 +88,15 @@
- Support Cachet - Check out our Patreon page! + {{ trans('dashboard.widgets.news') }} + {{ trans('dashboard.widgets.news_subtitle') }}
-
- +