├── releases.json
├── translations
└── en.php
├── resources
├── icon-mask.svg
└── icon.svg
├── LICENSE.txt
├── README.md
├── services
└── CmsSpeedUpService.php
└── CmsSpeedUpPlugin.php
/releases.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "version": "1.0.0",
4 | "downloadUrl": "???",
5 | "date": "2017-11-16T16:30:12.872Z",
6 | "notes": [
7 | "[Added] Initial release"
8 | ]
9 | }
10 | ]
--------------------------------------------------------------------------------
/translations/en.php:
--------------------------------------------------------------------------------
1 | 'To this',
16 | );
17 |
--------------------------------------------------------------------------------
/resources/icon-mask.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | Copyright (c) 2017 Matt Shearing
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 |
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CMS Speed Up plugin for Craft CMS
2 |
3 | Performs a CMS Speed Up after an update is completed.
4 |
5 |
6 |
7 | ## Installation
8 |
9 | To install CMS Speed Up, follow these steps:
10 |
11 | 1. Download & unzip the file and place the `cmsspeedup` directory into your `craft/plugins` directory
12 | 2. -OR- do a `git clone ???` directly into your `craft/plugins` folder. You can then update it with `git pull`
13 | 3. Install plugin in the Craft Control Panel under Settings > Plugins
14 | 4. The plugin folder should be named `cmsspeedup` for Craft to see it. GitHub recently started appending `-master` (the branch name) to the name of the folder for zip file downloads.
15 |
16 | CMS Speed Up works on Craft 2.4.x, Craft 2.5.x and Craft 2.6.x.
17 |
18 | Please note that this plugin won't be upgraded for Craft 3. As [Andrew Welch](https://github.com/nystudio107) says that this functionality will be native:
19 | > FWIW, this is exactly how Yii2/Craft 3 work. Frontend assets get cached and served via cpresources.
20 |
21 | ## CMS Speed Up Overview
22 |
23 | This plugin has been built to follow the recommendations made in the [Speeding Up the Craft CMS Admin Dashboard](https://zacharyflower.com/tutorials/2017/02/27/speed-up-craft-admin.html) article by [Zachary Flower](https://github.com/zachflower) and also address the issue of what happens after the cms is updated.
24 |
25 | It copies our craft/app/resources folder into public/{{ cpTrigger }}/resources so that requests for these files can find their target without having to be processed by craft.
26 |
27 | ## Configuring CMS Speed Up
28 |
29 | There are no settings for this plugin, it is just a simple install.
30 |
31 | We have however experienced a redirection issue with the cpTrigger on some occasions and had to add the following rule to our .htaccess file under the public directory to resolve this:
32 |
33 | `RewriteRule ^{cpTrigger}$ https://{domain.com}/{cpTrigger}/login [R=301,L,NC]`
34 |
35 | If you experience this issue then the change to your .htaccess file should also fix this for you.
36 |
37 | ## Using CMS Speed Up
38 |
39 | You don't need to do anything as it just copies files which speeds up our control panel resource requests.
40 | If you experience redirection issues on the base cp url then there is a fix that we have found described above.
41 |
42 | ## CMS Speed Up Changelog
43 |
44 | ### 1.0.0 -- 2017.11.16
45 |
46 | * Initial release
47 |
48 | Brought to you by [Matt Shearing](https://adigital.agency)
--------------------------------------------------------------------------------
/services/CmsSpeedUpService.php:
--------------------------------------------------------------------------------
1 | cmsspeedup->copyResources()
31 | */
32 | public function copyResources()
33 | {
34 | $src = craft()->path->getAppPath()."resources";
35 | $dest = $_SERVER["DOCUMENT_ROOT"]."/".craft()->config->get('cpTrigger')."/resources";
36 | $this->recurseRemove($dest);
37 | if (!is_dir($_SERVER["DOCUMENT_ROOT"]."/".craft()->config->get('cpTrigger'))) {
38 | mkdir($_SERVER["DOCUMENT_ROOT"]."/".craft()->config->get('cpTrigger'));
39 | }
40 | $this->recurseCopy($src, $dest);
41 | return true;
42 | }
43 |
44 | public function recurseCopy($src, $dst) {
45 | $dir = opendir($src);
46 | @mkdir($dst);
47 | while(false !== ($file = readdir($dir))) {
48 | if ($file != '.' && $file != '..') {
49 | if (is_dir($src.'/'.$file)) {
50 | $this->recurseCopy($src.'/'.$file, $dst.'/'.$file);
51 | } else {
52 | copy($src.'/'.$file, $dst.'/'.$file);
53 | }
54 | }
55 | }
56 | closedir($dir);
57 | }
58 |
59 | public function removeResources()
60 | {
61 | $dest = $_SERVER["DOCUMENT_ROOT"]."/".craft()->config->get('cpTrigger')."/resources";
62 | $this->recurseRemove($dest);
63 | if (is_dir($_SERVER["DOCUMENT_ROOT"]."/".craft()->config->get('cpTrigger'))) {
64 | rmdir($_SERVER["DOCUMENT_ROOT"]."/".craft()->config->get('cpTrigger'));
65 | }
66 | return true;
67 | }
68 |
69 | public function recurseRemove($dir) {
70 | if (is_dir($dir)) {
71 | $objects = scandir($dir);
72 | foreach ($objects as $object) {
73 | if ($object != "." && $object != "..") {
74 | if (filetype($dir."/".$object) == "dir") {
75 | $this->recurseRemove($dir."/".$object);
76 | } else {
77 | unlink($dir."/".$object);
78 | }
79 | }
80 | }
81 | reset($objects);
82 | rmdir($dir);
83 | }
84 | }
85 |
86 | }
--------------------------------------------------------------------------------
/CmsSpeedUpPlugin.php:
--------------------------------------------------------------------------------
1 | on('entries.saveEntry', function(Event $event) {
32 | * // ...
33 | * });
34 | *
35 | * or loading any third party Composer packages via:
36 | *
37 | * require_once __DIR__ . '/vendor/autoload.php';
38 | *
39 | * @return mixed
40 | */
41 | public function init()
42 | {
43 | craft()->on('updates.onEndUpdate', function($event) {
44 | craft()->cmsSpeedUp->copyResources();
45 | return $event;
46 | });
47 | }
48 |
49 | /**
50 | * Returns the user-facing name.
51 | *
52 | * @return mixed
53 | */
54 | public function getName()
55 | {
56 | return Craft::t('CMS Speed Up');
57 | }
58 |
59 | /**
60 | * Plugins can have descriptions of themselves displayed on the Plugins page by adding a getDescription() method
61 | * on the primary plugin class:
62 | *
63 | * @return mixed
64 | */
65 | public function getDescription()
66 | {
67 | return Craft::t('Performs a CMS Speed Up after an update is completed');
68 | }
69 |
70 | /**
71 | * Plugins can have links to their documentation on the Plugins page by adding a getDocumentationUrl() method on
72 | * the primary plugin class:
73 | *
74 | * @return string
75 | */
76 | public function getDocumentationUrl()
77 | {
78 | return '???';
79 | }
80 |
81 | /**
82 | * Plugins can now take part in Craft’s update notifications, and display release notes on the Updates page, by
83 | * providing a JSON feed that describes new releases, and adding a getReleaseFeedUrl() method on the primary
84 | * plugin class.
85 | *
86 | * @return string
87 | */
88 | public function getReleaseFeedUrl()
89 | {
90 | return '???';
91 | }
92 |
93 | /**
94 | * Returns the version number.
95 | *
96 | * @return string
97 | */
98 | public function getVersion()
99 | {
100 | return '1.0.0';
101 | }
102 |
103 | /**
104 | * As of Craft 2.5, Craft no longer takes the whole site down every time a plugin’s version number changes, in
105 | * case there are any new migrations that need to be run. Instead plugins must explicitly tell Craft that they
106 | * have new migrations by returning a new (higher) schema version number with a getSchemaVersion() method on
107 | * their primary plugin class:
108 | *
109 | * @return string
110 | */
111 | public function getSchemaVersion()
112 | {
113 | return '1.0.0';
114 | }
115 |
116 | /**
117 | * Returns the developer’s name.
118 | *
119 | * @return string
120 | */
121 | public function getDeveloper()
122 | {
123 | return 'Matt Shearing';
124 | }
125 |
126 | /**
127 | * Returns the developer’s website URL.
128 | *
129 | * @return string
130 | */
131 | public function getDeveloperUrl()
132 | {
133 | return 'adigital.agency';
134 | }
135 |
136 | /**
137 | * Get Settings URL
138 | */
139 | public function getSettingsUrl()
140 | {
141 | }
142 |
143 | /**
144 | * Hook Register CP Routes
145 | */
146 | public function registerCpRoutes()
147 | {
148 | }
149 |
150 | /**
151 | * Returns whether the plugin should get its own tab in the CP header.
152 | *
153 | * @return bool
154 | */
155 | public function hasCpSection()
156 | {
157 | return false;
158 | }
159 |
160 | /**
161 | * Returns an array whose keys define the setting names, and values define the parameters
162 | *
163 | * @return array
164 | */
165 | protected function defineSettings()
166 | {
167 | }
168 |
169 | /**
170 | * Called right before your plugin’s row gets stored in the plugins database table, and tables have been created
171 | * for it based on its records.
172 | */
173 | public function onBeforeInstall()
174 | {
175 | }
176 |
177 | /**
178 | * Called right after your plugin’s row has been stored in the plugins database table, and tables have been
179 | * created for it based on its records.
180 | */
181 | public function onAfterInstall()
182 | {
183 | craft()->cmsSpeedUp->copyResources();
184 | }
185 |
186 | /**
187 | * Called right before your plugin’s record-based tables have been deleted, and its row in the plugins table
188 | * has been deleted.
189 | */
190 | public function onBeforeUninstall()
191 | {
192 | craft()->cmsSpeedUp->removeResources();
193 | }
194 |
195 | /**
196 | * Called right after your plugin’s record-based tables have been deleted, and its row in the plugins table
197 | * has been deleted.
198 | */
199 | public function onAfterUninstall()
200 | {
201 | }
202 | }
--------------------------------------------------------------------------------
/resources/icon.svg:
--------------------------------------------------------------------------------
1 |
197 |
--------------------------------------------------------------------------------