Skip to content

Commit

Permalink
Show the timezone in the footer.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrooksuk committed Jul 11, 2016
1 parent e2da8ee commit 5298ad2
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 2 deletions.
22 changes: 22 additions & 0 deletions app/Composers/AppComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,32 @@

namespace CachetHQ\Cachet\Composers;

use CachetHQ\Cachet\Dates\DateFactory;
use GrahamCampbell\Markdown\Facades\Markdown;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Config;

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.
*
Expand Down Expand Up @@ -45,6 +65,8 @@ public function compose(View $view)
$view->withShowSupport(Config::get('setting.show_support'));
$view->withAutomaticLocalization(Config::get('setting.automatic_localization'));
$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->withFontSubset(Config::get('langs.'.Config::get('app.locale').'.subset', 'latin'));
}
Expand Down
13 changes: 13 additions & 0 deletions app/Dates/DateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace CachetHQ\Cachet\Dates;

use DateTimeZone;
use Jenssegers\Date\Date;

class DateFactory
Expand Down Expand Up @@ -88,4 +89,16 @@ public function make($time = null)
{
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');
}
}
10 changes: 10 additions & 0 deletions config/setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,14 @@

'enable_external_dependencies' => true,

/*
|--------------------------------------------------------------------------
| Show the timezone
|--------------------------------------------------------------------------
|
| Whether to show the status page timezone in the footer.
|
*/

'show_timezone' => false,
];
1 change: 1 addition & 0 deletions resources/lang/en/cachet.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
'home' => 'Home',
'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>.',
'timezone' => 'Times are shown in :timezone.',
'about_this_site' => 'About This Site',
'rss-feed' => 'RSS',
'atom-feed' => 'Atom',
Expand Down
3 changes: 2 additions & 1 deletion resources/lang/en/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

// Settings
'settings' => [
/// Application setup
// Application setup
'app-setup' => [
'site-name' => 'Site Name',
'site-url' => 'Site URL',
Expand All @@ -111,6 +111,7 @@
'subscribers' => 'Allow people to signup to email notifications?',
'automatic_localization' => 'Automatically localise your status page to your visitor\'s language?',
'enable_external_dependencies' => 'Enable Third Party Dependencies (Google Fonts, Trackers, etc...)',
'show_timezone' => 'Show the timezone the status page is running in.',
],
'analytics' => [
'analytics_google' => 'Google Analytics code',
Expand Down
11 changes: 11 additions & 0 deletions resources/views/dashboard/settings/app-setup.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@
</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>

<div class="row">
Expand Down
7 changes: 6 additions & 1 deletion resources/views/partials/footer.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
<div class="row">
<div class="col-sm-5">
@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
</div>
<div class="col-sm-7">
Expand Down

0 comments on commit 5298ad2

Please sign in to comment.