mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-29 11:08:53 +01:00
Added credits
This commit is contained in:
parent
ab0ed775e1
commit
c03f01ca44
@ -14,7 +14,8 @@ namespace CachetHQ\Cachet\Foundation\Providers;
|
||||
use AltThree\Bus\Dispatcher;
|
||||
use CachetHQ\Cachet\Bus\Middleware\UseDatabaseTransactions;
|
||||
use CachetHQ\Cachet\Dates\DateFactory;
|
||||
use CachetHQ\Cachet\GitHub\Release;
|
||||
use CachetHQ\Cachet\Integrations\Credits;
|
||||
use CachetHQ\Cachet\Integrations\Releases;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@ -53,7 +54,8 @@ class AppServiceProvider extends ServiceProvider
|
||||
public function register()
|
||||
{
|
||||
$this->registerDateFactory();
|
||||
$this->registerRelease();
|
||||
$this->registerCredits();
|
||||
$this->registerReleases();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,18 +73,31 @@ class AppServiceProvider extends ServiceProvider
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the credits class.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerCredits()
|
||||
{
|
||||
$this->app->singleton(Credits::class, function ($app) {
|
||||
$cache = $app['cache.store'];
|
||||
|
||||
return new Credits($cache);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Register the releases class.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerRelease()
|
||||
protected function registerReleases()
|
||||
{
|
||||
$this->app->singleton(Release::class, function ($app) {
|
||||
$this->app->singleton(Releases::class, function ($app) {
|
||||
$cache = $app['cache.store'];
|
||||
$token = $app['config']->get('services.github.token');
|
||||
|
||||
return new Release($cache, $token);
|
||||
return new Releases($cache, $token);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
|
||||
|
||||
use CachetHQ\Cachet\GitHub\Release;
|
||||
use CachetHQ\Cachet\Integrations\Releases;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
use CachetHQ\Cachet\Models\IncidentTemplate;
|
||||
@ -99,7 +99,7 @@ class ApiController extends Controller
|
||||
*/
|
||||
public function checkVersion()
|
||||
{
|
||||
$latest = app(Release::class)->latest();
|
||||
$latest = app(Releases::class)->latest();
|
||||
|
||||
return Response::json([
|
||||
'cachet_version' => CACHET_VERSION,
|
||||
|
@ -82,6 +82,12 @@ class SettingsController extends Controller
|
||||
'icon' => 'ion-stats-bars',
|
||||
'active' => false,
|
||||
],
|
||||
'credits' => [
|
||||
'title' => trans('dashboard.settings.credits.credits'),
|
||||
'url' => route('dashboard.settings.credits'),
|
||||
'icon' => 'ion-ios-list',
|
||||
'active' => false,
|
||||
],
|
||||
'about' => [
|
||||
'title' => CACHET_VERSION,
|
||||
'url' => 'javascript: void(0);',
|
||||
@ -212,6 +218,30 @@ class SettingsController extends Controller
|
||||
->withSubMenu($this->subMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the credits view.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function showCreditsView()
|
||||
{
|
||||
$this->subMenu['credits']['active'] = true;
|
||||
|
||||
$credits = app(Credits::class)->latest();
|
||||
|
||||
$backers = $credits['backers'];
|
||||
$contributors = $credits['contributors'];
|
||||
|
||||
shuffle($backers);
|
||||
shuffle($contributors);
|
||||
|
||||
return View::make('dashboard.settings.credits')
|
||||
->withPageTitle(trans('dashboard.settings.credits.credits').' - '.trans('dashboard.dashboard'))
|
||||
->withBackers($backers)
|
||||
->withContributors($contributors)
|
||||
->withSubMenu($this->subMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the status page settings.
|
||||
*
|
||||
|
@ -25,7 +25,7 @@ class Timezone
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Creates a new release instance.
|
||||
* Creates a new timezone middleware instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Config\Repository $config
|
||||
*
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Routes;
|
||||
|
||||
use CachetHQ\Cachet\Integrations\Credits;
|
||||
use Illuminate\Contracts\Routing\Registrar;
|
||||
|
||||
/**
|
||||
@ -211,6 +212,10 @@ class DashboardRoutes
|
||||
'as' => 'customization',
|
||||
'uses' => 'SettingsController@showCustomizationView',
|
||||
]);
|
||||
$router->get('credits', [
|
||||
'as' => 'credits',
|
||||
'uses' => 'SettingsController@showCreditsView',
|
||||
]);
|
||||
$router->post('/', 'SettingsController@postSettings');
|
||||
});
|
||||
|
||||
|
67
app/Integrations/Credits.php
Normal file
67
app/Integrations/Credits.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Integrations;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Contracts\Cache\Repository;
|
||||
|
||||
class Credits
|
||||
{
|
||||
/**
|
||||
* The default url.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const URL = 'https://cachethq.io/credits';
|
||||
|
||||
/**
|
||||
* The cache repository instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Cache\Repository
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* The url to use.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* Creates a new credits instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Cache\Repository $cache
|
||||
* @param string|null $url
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Repository $cache, $url = null)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->url = $url ?: static::URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest credits.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function latest()
|
||||
{
|
||||
return $this->cache->remember('version', 2880, function () {
|
||||
return json_decode((new Client())->get($this->url, [
|
||||
'headers' => ['Accept' => 'application/json'],
|
||||
])->getBody(), true);
|
||||
});
|
||||
}
|
||||
}
|
@ -9,13 +9,20 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\GitHub;
|
||||
namespace CachetHQ\Cachet\Integrations;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Contracts\Cache\Repository as CacheRepository;
|
||||
use Illuminate\Contracts\Cache\Repository;
|
||||
|
||||
class Release
|
||||
class Releases
|
||||
{
|
||||
/**
|
||||
* The default url.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const URL = 'https://api.github.com/repos/cachethq/cachet/releases/latest';
|
||||
|
||||
/**
|
||||
* The cache repository instance.
|
||||
*
|
||||
@ -26,26 +33,35 @@ class Release
|
||||
/**
|
||||
* The github authentication token.
|
||||
*
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $token;
|
||||
|
||||
/**
|
||||
* Creates a new release instance.
|
||||
* The url to use.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* Creates a new releases instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Cache\Repository $cache
|
||||
* @param string $token
|
||||
* @param string|null $token
|
||||
* @param string|null $url
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(CacheRepository $cache, $token)
|
||||
public function __construct(Repository $cache, $token = null, $url = null)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->token = $token;
|
||||
$this->url = $url ?: static::URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest GitHub release.
|
||||
* Returns the latest release.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -54,12 +70,11 @@ class Release
|
||||
$release = $this->cache->remember('version', 720, function () {
|
||||
$headers = ['Accept' => 'application/vnd.github.v3+json'];
|
||||
|
||||
// We can re-use the Emoji token here, if we have it.
|
||||
if ($this->token) {
|
||||
$headers['OAUTH-TOKEN'] = $this->token;
|
||||
}
|
||||
|
||||
return json_decode((new Client())->get('https://api.github.com/repos/cachethq/cachet/releases/latest', [
|
||||
return json_decode((new Client())->get($this->url, [
|
||||
'headers' => $headers,
|
||||
])->getBody(), true);
|
||||
});
|
@ -219,6 +219,13 @@ return [
|
||||
'success' => 'Settings saved.',
|
||||
'failure' => 'Settings could not be saved.',
|
||||
],
|
||||
'credits' => [
|
||||
'credits' => 'Credits',
|
||||
'license' => 'Cachet is a BSD-3-licensed open source project, released by <a href="https://alt-three.com/?utm_source=cachet&utm_medium=credits&utm_campaign=Cachet%20Credit%20Dashboard" target="_blank">Alt Three Services Limited</a>.',
|
||||
'backers-title' => 'Backers & Sponsors',
|
||||
'backers' => 'If you\'d like to support future development, check out the <a href="https://patreon.com/jbrooksuk" target="_blank">Cachet Patreon</a> campaign.',
|
||||
'thank-you' => 'Thank you to each and every one of the :count contributors.',
|
||||
],
|
||||
],
|
||||
|
||||
// Login
|
||||
|
51
resources/views/dashboard/settings/credits.blade.php
Normal file
51
resources/views/dashboard/settings/credits.blade.php
Normal file
@ -0,0 +1,51 @@
|
||||
@extends('layout.dashboard')
|
||||
|
||||
@section('content')
|
||||
<div class="content-panel">
|
||||
@if(isset($sub_menu))
|
||||
@include('dashboard.partials.sub-sidebar')
|
||||
@endif
|
||||
<div class="content-wrapper">
|
||||
<div class="header sub-header" id="application-setup">
|
||||
<span class="uppercase">
|
||||
{{ trans('dashboard.settings.credits.credits') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<h4>Cachet</h4>
|
||||
|
||||
<p>{!! trans('dashboard.settings.credits.license') !!}</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h4>{{ trans('dashboard.settings.credits.backers-title') }}</h4>
|
||||
|
||||
<p>{!! trans('dashboard.settings.credits.backers') !!}</p>
|
||||
|
||||
<ul>
|
||||
@foreach($backers as $backer)
|
||||
<li>{{ $backer['name'] }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
|
||||
<h4>{{ trans('dashboard.settings.credits.contributors') }}</h4>
|
||||
|
||||
<p>{{ trans('dashboard.settings.credits.thank-you', ['count' => count($contributors)]) }}</p>
|
||||
|
||||
<ul class="list-inline">
|
||||
@foreach($contributors as $contributor)
|
||||
<li>
|
||||
<img src="{{ $contributor['avatar'] }}" class="img-rounded img-responsive" title="{{ $contributor['name'] }}" data-toggle="tooltip">
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
@ -13,7 +13,8 @@ namespace CachetHQ\Tests\Cachet\Foundation\Providers;
|
||||
|
||||
use AltThree\TestBench\ServiceProviderTrait;
|
||||
use CachetHQ\Cachet\Dates\DateFactory;
|
||||
use CachetHQ\Cachet\GitHub\Release;
|
||||
use CachetHQ\Cachet\Integrations\Credits;
|
||||
use CachetHQ\Cachet\Integrations\Releases;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
@ -30,8 +31,13 @@ class AppServiceProviderTest extends AbstractTestCase
|
||||
$this->assertIsInjectable(DateFactory::class);
|
||||
}
|
||||
|
||||
public function testReleaseIsInjectable()
|
||||
public function testCreditsIsInjectable()
|
||||
{
|
||||
$this->assertIsInjectable(Release::class);
|
||||
$this->assertIsInjectable(Credits::class);
|
||||
}
|
||||
|
||||
public function testReleasesIsInjectable()
|
||||
{
|
||||
$this->assertIsInjectable(Releases::class);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user