Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0b6ae50

Browse files
committedMay 30, 2022
v3.1.0: Added ReportWidget with convenient path clearer.
1 parent e6e7794 commit 0b6ae50

File tree

6 files changed

+122
-6
lines changed

6 files changed

+122
-6
lines changed
 

‎Plugin.php

+18-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
use Illuminate\Contracts\Http\Kernel;
66

77
use BizMark\Quicksilver\Console\Clear;
8-
use BizMark\Quicksilver\Models\Settings;
98
use BizMark\Quicksilver\Classes\Caches\StorageCache;
109
use BizMark\Quicksilver\Classes\Contracts\Quicksilver;
1110
use BizMark\Quicksilver\Classes\Middlewares\QuicksilverMiddleware;
1211

12+
use BizMark\Quicksilver\Models\Settings;
13+
use BizMark\Quicksilver\ReportWidgets\QuicksilverClear;
14+
1315
/**
1416
* Quicksilver Plugin Information File
1517
* @package BizMark\Quicksilver
@@ -63,6 +65,21 @@ public function boot()
6365
$this->app[Kernel::class]->prependMiddleware(QuicksilverMiddleware::class);
6466
}
6567

68+
/**
69+
* registerReportWidgets registers any report widgets provided by this plugin.
70+
*
71+
* @return array
72+
*/
73+
public function registerReportWidgets()
74+
{
75+
return [
76+
QuicksilverClear::class => [
77+
'label' => 'bizmark.quicksilver::lang.reportwidget.label',
78+
'context' => 'dashboard'
79+
],
80+
];
81+
}
82+
6683
/**
6784
* registerSettings registers any back-end configuration links used by this plugin.
6885
*

‎lang/en/lang.php

+14
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,19 @@
2323
'label' => 'Enable query strings support',
2424
'comment' => 'Quicksilver will cache page with different query strings as separate entities.'
2525
],
26+
],
27+
'reportwidget' => [
28+
'label' => 'Quicksilver cache clearer',
29+
'clear_specific' => 'Cache of :path successfully cleared.',
30+
'clear_all_paths' => 'Cache of all pages successfully cleared.',
31+
'clear_all' => 'System cache and all pages successfully cleared.',
32+
'title' => 'Quicksilver cache',
33+
'clearing_path' => 'Path to clear',
34+
'clearing_example' => 'Example: /path, /path/something, /path/*',
35+
'clear_path' => 'Clear pages cache at specified path',
36+
'clear_all_pages' => 'Clear all pages cache',
37+
'clear_all_pages_confirm' => 'Are you sure you want to delete all cached pages?',
38+
'clear_all_caches' => 'Clear system cache and all cached pages',
39+
'clear_all_caches_confirm' => 'Are you sure you want to clear all caches?',
2640
]
2741
];

‎lang/ru/lang.php

+19-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
return [
44
'plugin' => [
55
'name' => 'Quicksilver',
6-
'description' => 'Супербыстрый кеш для вашего статичного сайта.',
6+
'description' => 'Супербыстрый кэш для вашего статичного сайта.',
77
],
88
'settings' => [
99
'label' => 'Quicksilver',
10-
'description' => 'Различные настройки системы статичного кеша',
10+
'description' => 'Различные настройки системы статичного кэша',
1111
],
1212
'tab' => [
1313
'general' => 'Основное',
@@ -16,12 +16,26 @@
1616
'field' => [
1717
'excluded' => [
1818
'label' => 'Исключенные пути',
19-
'comment' => 'Пример: acme/demo, acme/* and etc.',
19+
'comment' => 'Пример: acme/demo, acme/* и т.д.',
2020
'path' => 'Путь'
2121
],
2222
'enable_query_strings' => [
23-
'label' => 'Включить кеширование вместе с query параметрами.',
24-
'comment' => 'Quicksilver будет кешировать страницы с query параметрами как отдельные файлы.'
23+
'label' => 'Включить кэширование вместе с query параметрами.',
24+
'comment' => 'Quicksilver будет кэшировать страницы с query параметрами как отдельные файлы.'
2525
],
26+
],
27+
'reportwidget' => [
28+
'label' => 'Очистка кэша Quicksilver',
29+
'clear_specific' => 'Кэш :path успешно очищен.',
30+
'clear_all_paths' => 'Кэш страниц успешно очищен.',
31+
'clear_all' => 'Системный кэш и страницы успешно очищены.',
32+
'title' => 'Quicksilver кэш',
33+
'clearing_path' => 'Очищаемый путь',
34+
'clearing_example' => 'Например: /path, /path/something, /path/*',
35+
'clear_path' => 'Очистить страницы по указанному пути',
36+
'clear_all_pages' => 'Очистить все страницы',
37+
'clear_all_pages_confirm' => 'Уверены что хотите удалить все страницы?',
38+
'clear_all_caches' => 'Очистить системный кеш и страницы',
39+
'clear_all_caches_confirm' => 'Очистить системный кеш и страницы',
2640
]
2741
];

‎reportwidgets/QuicksilverClear.php

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php namespace BizMark\Quicksilver\ReportWidgets;
2+
3+
use Artisan, Flash, Input, Lang;
4+
use Backend\Classes\ReportWidgetBase;
5+
6+
/**
7+
* Quicksilver Plugin Information File
8+
* @package BizMark\Quicksilver\ReportWidgets
9+
* @author Nick Khaetsky, Biz-Mark
10+
*/
11+
class QuicksilverClear extends ReportWidgetBase
12+
{
13+
public function render()
14+
{
15+
return $this->makePartial('widget');
16+
}
17+
18+
public function onClearSpecificQuicksilverPath()
19+
{
20+
$specificPath = Input::get('path');
21+
Artisan::call('quicksilver:clear', ['path' => $specificPath]);
22+
23+
Flash::success(Lang::get('bizmark.quicksilver::lang.reportwidget.clear_specific', ['path' => $specificPath]));
24+
}
25+
26+
public function onClearQuicksilver()
27+
{
28+
Artisan::call('quicksilver:clear');
29+
30+
Flash::success(Lang::get('bizmark.quicksilver::lang.reportwidget.clear_all_paths'));
31+
}
32+
33+
public function onClearAll()
34+
{
35+
Artisan::call('cache:clear');
36+
Artisan::call('quicksilver:clear');
37+
38+
Flash::success(Lang::get('bizmark.quicksilver::lang.reportwidget.clear_all'));
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<div class="report-widget">
2+
<h3><?= e(trans('bizmark.quicksilver::lang.reportwidget.title')) ?></h3>
3+
4+
<div class="form-group">
5+
<label for="quicksilverPathInput"><?= e(trans('bizmark.quicksilver::lang.reportwidget.clearing_path')) ?></label>
6+
<input type="text" name="path" class="form-control" id="quicksilverPathInput">
7+
<small><?= e(trans('bizmark.quicksilver::lang.reportwidget.clearing_example')) ?></small>
8+
</div>
9+
<div class="form-group" style="display: flex; justify-content: space-between">
10+
<div class="left">
11+
<button class="btn btn-primary"
12+
data-request="onClearSpecificQuicksilverPath"
13+
onclick="$(this).data('request-data', {path: $('#quicksilverPathInput').val()})">
14+
<?= e(trans('bizmark.quicksilver::lang.reportwidget.clear_path')) ?>
15+
</button>
16+
<button class="btn btn-link"
17+
data-request="onClearQuicksilver"
18+
data-request-confirm="<?= e(trans('bizmark.quicksilver::lang.reportwidget.clear_all_pages_confirm')) ?>">
19+
<?= e(trans('bizmark.quicksilver::lang.reportwidget.clear_all_pages')) ?>
20+
</button>
21+
</div>
22+
<div class="right">
23+
<button class="btn btn-danger"
24+
data-request="onClearAll"
25+
data-request-confirm="<?= e(trans('bizmark.quicksilver::lang.reportwidget.clear_all_caches_confirm')) ?>">
26+
<?= e(trans('bizmark.quicksilver::lang.reportwidget.clear_all_caches')) ?>
27+
</button>
28+
</div>
29+
</div>
30+
</div>

‎updates/version.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ v3.0.0: Complete refactoring. Read UPGRADE.md.
1414
v3.0.1: Reintroduced support for PHP >=7.4
1515
v3.0.2: Added query params check in has() method.
1616
v3.0.3: Add Cache-control header to cached responses.
17+
v3.1.0: Added ReportWidget with convenient path clearer.

0 commit comments

Comments
 (0)
Please sign in to comment.