Add Patreon link and latest Cachet blog posts to dashboard

This commit is contained in:
James Brooks
2016-05-31 19:12:23 +01:00
parent 0190813012
commit f53075ec4f
5 changed files with 50 additions and 13 deletions

View File

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

View File

@@ -15,6 +15,11 @@ use GuzzleHttp\Client;
use Illuminate\Contracts\Cache\Repository;
use SimpleXmlElement;
/**
* This is the feed class.
*
* @author James Brooks <james@alt-three.com>
*/
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));
});
}
}

View File

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

View File

@@ -249,6 +249,14 @@ return [
'whoops' => 'Whoops.',
],
// Widgets
'widgets' => [
'support' => 'Support Cachet',
'support_subtitle' => 'Check out our <strong><a href="https://patreon.com/jbrooksuk" target="_blank">Patreon</a></strong> page!',
'news' => 'Latest News',
'news_subtitle' => 'Get the latest updates',
],
// Welcome modal
'welcome' => [
'welcome' => 'Welcome to your new status page!',

View File

@@ -79,8 +79,8 @@
<div class="col-sm-12 col-lg-6">
<div class="stats-widget">
<div class='stats-top'>
<span class='stats-value'>Support Cachet</span>
<span class='stats-label'>Check out our <a href="https://patreon.com/jbrooksuk" target="_blank">Patreon</a> page!</span>
<span class='stats-value'>{{ trans('dashboard.widgets.support') }}</span>
<span class='stats-label'>{!! trans('dashboard.widgets.support_subtitle') !!}</span>
</div>
</div>
</div>
@@ -88,15 +88,15 @@
<div class="col-sm-12 col-lg-6">
<div class="stats-widget">
<div class='stats-top'>
<span class='stats-value'>Support Cachet</span>
<span class='stats-label'>Check out our <a href="https://patreon.com/jbrooksuk" target="_blank">Patreon</a> page!</span>
<span class='stats-value'>{{ trans('dashboard.widgets.news') }}</span>
<span class='stats-label'>{{ trans('dashboard.widgets.news_subtitle') }}</span>
</div>
<div class='stats-chart'>
<ul class="list-group">
@foreach($feed->entries()['channel']['item'] as $item)
<a class="list-group-item" href="{{ $item['link'] }}" target="_blank"></a>
<div class='stats-body'>
<div class="list-group">
@foreach($entries as $entry)
<a class="list-group-item" href="{{ $entry->link }}" target="_blank">{{ $entry->title }}, <small>{{ $entry->pubDate }}</small></a>
@endforeach
</ul>
</div>
</div>
</div>
</div>