-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Steven Peercy
committed
Feb 19, 2019
1 parent
d5e8f72
commit 518e9a1
Showing
9 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace Statamic\Addons\CacheTidy; | ||
|
||
use Illuminate\Support\Facades\Artisan; | ||
use Statamic\Extend\Controller; | ||
|
||
class CacheTidyController extends Controller | ||
{ | ||
/** | ||
* Maps to your route definition in routes.yaml | ||
* | ||
* @return mixed | ||
*/ | ||
public function index() | ||
{ | ||
return $this->view('index'); | ||
} | ||
|
||
public function cache() | ||
{ | ||
$command = 'clear:cache'; | ||
|
||
try { | ||
Artisan::call($command); | ||
$call = trim(Artisan::output()); | ||
return back()->with('success', $call); | ||
} catch (\Exception $e) { | ||
Log::error('Problem running command: ' . $command); | ||
return back()->withErrors('error', ' There was a problem' . $e); | ||
} | ||
} | ||
|
||
public function glide() | ||
{ | ||
$command = 'clear:glide'; | ||
|
||
try { | ||
Artisan::call($command); | ||
$call = trim(Artisan::output()); | ||
return back()->with('success', $call); | ||
} catch (\Exception $e) { | ||
Log::error('Problem running command: ' . $command); | ||
return back()->withErrors('error', ' There was a problem' . $e); | ||
} | ||
} | ||
|
||
public function stache() | ||
{ | ||
$command = 'clear:stache'; | ||
|
||
try { | ||
Artisan::call($command); | ||
$call = trim(Artisan::output()); | ||
return back()->with('success', $call); | ||
} catch (\Exception $e) { | ||
Log::error('Problem running command: ' . $command); | ||
return back()->withErrors('error', ' There was a problem' . $e); | ||
} | ||
} | ||
|
||
public function staticCache() | ||
{ | ||
$command = 'clear:static'; | ||
|
||
try { | ||
Artisan::call($command); | ||
$call = trim(Artisan::output()); | ||
return back()->with('success', $call); | ||
} catch (\Exception $e) { | ||
Log::error('Problem running command: ' . $command); | ||
return back()->withErrors('error', ' There was a problem' . $e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Statamic\Addons\CacheTidy; | ||
|
||
use Statamic\API\Nav; | ||
use Statamic\Extend\Listener; | ||
|
||
class CacheTidyListener extends Listener | ||
{ | ||
/** | ||
* The events to be listened for, and the methods to call. | ||
* | ||
* @var array | ||
*/ | ||
public $events = [ | ||
'cp.nav.created' => 'addNavItems' | ||
]; | ||
|
||
public function addNavItems($nav) | ||
{ | ||
$tidy = Nav::item('Cache Tidy')->route('addons.cache_tidy')->icon('flat-brush'); | ||
|
||
$nav->addTo('tools', $tidy); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "pattern/cache-tidy", | ||
"require": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name: 'Cache Tidy' | ||
version: '1.0' | ||
description: 'Clear caches from within the CP' | ||
url: 'https://github.com/pttrnco/cache-tidy' | ||
developer: Pattern | ||
developer_url: 'https://pttrn.co' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
@extends('layout') | ||
|
||
@section('content') | ||
<div class="flexy mb-3"> | ||
<h1>Cache Tidy</h1> | ||
</div> | ||
<div class="card flush dossier-for-mobile"> | ||
<div class="dossier-table-wrapper"> | ||
<table class="dossier"> | ||
<tbody> | ||
<tr> | ||
<td class="cell-name first-cell" style="width:200px;"> | ||
<span class="column-label">Name</span> <a href="{{ route('addons.clear_cache') }}">Clear Cache</a> | ||
</td> | ||
<td class="cell-description"> | ||
<span class="column-label">Description</span> Clear the application cache. | ||
</td> | ||
<td class="column-actions"></td> | ||
</tr> | ||
<tr> | ||
<td class="cell-name first-cell"> | ||
<span class="column-label">Name</span> <a href="{{ route('addons.clear_glide') }}">Clear Glide</a> | ||
</td> | ||
<td class="cell-description"> | ||
<span class="column-label">Description</span> Clear the Glide image cache. | ||
</td> | ||
<td class="column-actions"></td> | ||
</tr> | ||
<tr> | ||
<td class="cell-name first-cell"> | ||
<span class="column-label">Name</span> <a href="{{ route('addons.clear_stache') }}">Clear Stache</a> | ||
</td> | ||
<td class="cell-description"> | ||
<span class="column-label">Description</span> Clear the "Stache" cache. | ||
</td> | ||
<td class="column-actions"></td> | ||
</tr> | ||
<tr> | ||
<td class="cell-name first-cell"> | ||
<span class="column-label">Name</span> <a href="{{ route('addons.clear_static') }}">Clear Static</a> | ||
</td> | ||
<td class="cell-description"> | ||
<span class="column-label">Description</span> Clear the Static Page Cache. | ||
</td> | ||
<td class="column-actions"></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
routes: | ||
/: | ||
as: addons.cache_tidy | ||
uses: index | ||
cache: | ||
as: addons.clear_cache | ||
uses: cache | ||
glide: | ||
as: addons.clear_glide | ||
uses: glide | ||
stache: | ||
as: addons.clear_stache | ||
uses: stache | ||
static: | ||
as: addons.clear_static | ||
uses: staticCache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Cache Tidy | ||
|
||
Gives Statamic control panel users the ability to clear Statamic's caches. | ||
|
||
## Installation | ||
|
||
Unzip and place the `CacheTidy` directory in your `site/addons` directory. Then run `php please update:addons`. | ||
|
||
After installation, you can find Cache Tidy in the 'Tools' section of the CP nav. |