Show the timezone in the footer.

This commit is contained in:
James Brooks
2016-07-11 21:33:07 +01:00
parent e2da8ee1fa
commit 5298ad241a
7 changed files with 65 additions and 2 deletions

View File

@@ -11,12 +11,32 @@
namespace CachetHQ\Cachet\Composers; namespace CachetHQ\Cachet\Composers;
use CachetHQ\Cachet\Dates\DateFactory;
use GrahamCampbell\Markdown\Facades\Markdown; use GrahamCampbell\Markdown\Facades\Markdown;
use Illuminate\Contracts\View\View; use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
class AppComposer class AppComposer
{ {
/**
* The date factory instance.
*
* @var \CachetHQ\Cachet\Dates\DateFactory
*/
protected $dates;
/**
* Create a new app composer instance.
*
* @param \CachetHQ\Cachet\Dates\DateFactory $dates
*
* @return void
*/
public function __construct(DateFactory $dates)
{
$this->dates = $dates;
}
/** /**
* Index page view composer. * Index page view composer.
* *
@@ -45,6 +65,8 @@ class AppComposer
$view->withShowSupport(Config::get('setting.show_support')); $view->withShowSupport(Config::get('setting.show_support'));
$view->withAutomaticLocalization(Config::get('setting.automatic_localization')); $view->withAutomaticLocalization(Config::get('setting.automatic_localization'));
$view->withEnableExternalDependencies(Config::get('setting.enable_external_dependencies')); $view->withEnableExternalDependencies(Config::get('setting.enable_external_dependencies'));
$view->withShowTimezone(Config::get('setting.show_timezone'));
$view->withTimezone($this->dates->getTimezone());
$view->withSiteTitle(Config::get('setting.app_name')); $view->withSiteTitle(Config::get('setting.app_name'));
$view->withFontSubset(Config::get('langs.'.Config::get('app.locale').'.subset', 'latin')); $view->withFontSubset(Config::get('langs.'.Config::get('app.locale').'.subset', 'latin'));
} }

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Dates; namespace CachetHQ\Cachet\Dates;
use DateTimeZone;
use Jenssegers\Date\Date; use Jenssegers\Date\Date;
class DateFactory class DateFactory
@@ -88,4 +89,16 @@ class DateFactory
{ {
return (new Date($time))->setTimezone($this->cachetTimezone); return (new Date($time))->setTimezone($this->cachetTimezone);
} }
/**
* Return the abbreviated timezone.
*
* @return string
*/
public function getTimezone()
{
$dateTime = new Date();
$dateTime->setTimeZone(new DateTimeZone($this->cachetTimezone));
return $dateTime->format('T');
}
} }

View File

@@ -67,4 +67,14 @@ return [
'enable_external_dependencies' => true, 'enable_external_dependencies' => true,
/*
|--------------------------------------------------------------------------
| Show the timezone
|--------------------------------------------------------------------------
|
| Whether to show the status page timezone in the footer.
|
*/
'show_timezone' => false,
]; ];

View File

@@ -136,6 +136,7 @@ return [
'home' => 'Home', 'home' => 'Home',
'description' => 'Stay up to date with the latest service updates from :app.', 'description' => 'Stay up to date with the latest service updates from :app.',
'powered_by' => 'Powered by <a href="https://cachethq.io" class="links">Cachet</a>.', 'powered_by' => 'Powered by <a href="https://cachethq.io" class="links">Cachet</a>.',
'timezone' => 'Times are shown in :timezone.',
'about_this_site' => 'About This Site', 'about_this_site' => 'About This Site',
'rss-feed' => 'RSS', 'rss-feed' => 'RSS',
'atom-feed' => 'Atom', 'atom-feed' => 'Atom',

View File

@@ -99,7 +99,7 @@ return [
// Settings // Settings
'settings' => [ 'settings' => [
/// Application setup // Application setup
'app-setup' => [ 'app-setup' => [
'site-name' => 'Site Name', 'site-name' => 'Site Name',
'site-url' => 'Site URL', 'site-url' => 'Site URL',
@@ -111,6 +111,7 @@ return [
'subscribers' => 'Allow people to signup to email notifications?', 'subscribers' => 'Allow people to signup to email notifications?',
'automatic_localization' => 'Automatically localise your status page to your visitor\'s language?', 'automatic_localization' => 'Automatically localise your status page to your visitor\'s language?',
'enable_external_dependencies' => 'Enable Third Party Dependencies (Google Fonts, Trackers, etc...)', 'enable_external_dependencies' => 'Enable Third Party Dependencies (Google Fonts, Trackers, etc...)',
'show_timezone' => 'Show the timezone the status page is running in.',
], ],
'analytics' => [ 'analytics' => [
'analytics_google' => 'Google Analytics code', 'analytics_google' => 'Google Analytics code',

View File

@@ -95,6 +95,17 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row">
<div class="col-xs-12">
<div class="checkbox">
<label>
<input type="hidden" value="0" name="show_timezone">
<input type="checkbox" value="1" name="show_timezone" {{ $show_timezone ? 'checked' : null }}>
{{ trans('forms.settings.app-setup.show_timezone') }}
</label>
</div>
</div>
</div>
</fieldset> </fieldset>
<div class="row"> <div class="row">

View File

@@ -6,7 +6,12 @@
<div class="row"> <div class="row">
<div class="col-sm-5"> <div class="col-sm-5">
@if($show_support) @if($show_support)
<p>{!! trans('cachet.powered_by') !!}</p> <p>
{!! trans('cachet.powered_by') !!}
@if($show_timezone)
{{ trans('cachet.timezone', ['timezone' => $timezone]) }}
@endif
</p>
@endif @endif
</div> </div>
<div class="col-sm-7"> <div class="col-sm-7">