diff --git a/README.md b/README.md index 0a5b4c1..c3bb4e7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# Static +# StaticPublisher ## Introduction -Static provides several extensions for exporting a SilverStripe application to -both local or remote file systems. +This module provides an extension for exporting a SilverStripe application as +static files to both a local or remote server for increased site performance. ## Maintainer Contact @@ -17,6 +17,6 @@ both local or remote file systems. ## Documentation -See docs/ +See the docs folder. Note this is untested on Windows. \ No newline at end of file diff --git a/code/CachedPHPPage.tmpl b/code/CachedPHPPage.tmpl index 6b5b468..36c66cc 100644 --- a/code/CachedPHPPage.tmpl +++ b/code/CachedPHPPage.tmpl @@ -4,7 +4,7 @@ * This is a system-generated PHP script that performs header management for * the statically cached content given below. * - * @package static + * @package staticpublisher */ define('MAX_AGE', '**MAX_AGE**'); diff --git a/code/CachedPHPRedirection.tmpl b/code/CachedPHPRedirection.tmpl index 990bb77..29e1627 100644 --- a/code/CachedPHPRedirection.tmpl +++ b/code/CachedPHPRedirection.tmpl @@ -4,7 +4,7 @@ * This is a system-generated PHP script that performs header management for * a 301 redirection. * - * @package static + * @package staticpublisher */ define('DESTINATION', '**DESTINATION**'); diff --git a/code/controllers/StaticExporter.php b/code/controllers/StaticExporter.php index 9bf125d..88d8d1d 100644 --- a/code/controllers/StaticExporter.php +++ b/code/controllers/StaticExporter.php @@ -12,7 +12,7 @@ * * @see StaticPublisher * - * @package static + * @package staticpublisher */ class StaticExporter extends Controller { diff --git a/code/extensions/FilesystemPublisher.php b/code/extensions/FilesystemPublisher.php index 5919503..b6d7712 100644 --- a/code/extensions/FilesystemPublisher.php +++ b/code/extensions/FilesystemPublisher.php @@ -1,19 +1,7 @@ pagesAffectedByUnpublishing() to return other URLS - * that should be de-cached if $page is unpublished. - * - * @see http://doc.silverstripe.com/doku.php?id=staticpublisher - * - * @package cms - * @subpackage publishers + * @package staticpublisher */ class FilesystemPublisher extends StaticPublisher { diff --git a/code/extensions/RsyncMultiHostPublisher.php b/code/extensions/RsyncMultiHostPublisher.php index 1838316..705cbf9 100644 --- a/code/extensions/RsyncMultiHostPublisher.php +++ b/code/extensions/RsyncMultiHostPublisher.php @@ -1,17 +1,20 @@ republish($original); } /** - * Called after link assets have been renamed, and the live site has been updated, without - * an actual publish event. + * Called after link assets have been renamed, and the live site has been + * updated, without an actual publish event. * * Only called if the published content exists and has been modified. */ - function onRenameLinkedAsset($original) { + public function onRenameLinkedAsset($original) { $this->republish($original); } - function republish($original) { + public function republish($original) { if (self::$disable_realtime) return; $urls = array(); @@ -99,10 +123,9 @@ abstract class StaticPublisher extends DataExtension { } /** - * On after unpublish, get changes and hook into underlying - * functionality + * Get changes and hook into underlying functionality. */ - function onAfterUnpublish($page) { + public function onAfterUnpublish($page) { if (self::$disable_realtime) return; // Get the affected URLs @@ -125,12 +148,11 @@ abstract class StaticPublisher extends DataExtension { /** * Get all external references to CSS, JS, */ - function externalReferencesFor($content) { + public function externalReferencesFor($content) { $CLI_content = escapeshellarg($content); $tidy = `echo $CLI_content | tidy -numeric -asxhtml`; $tidy = preg_replace('/xmlns="[^"]+"/','', $tidy); $xContent = new SimpleXMLElement($tidy); - //Debug::message($xContent->asXML()); $xlinks = array( "//link[@rel='stylesheet']/@href" => false, @@ -140,6 +162,7 @@ abstract class StaticPublisher extends DataExtension { ); $urls = array(); + foreach($xlinks as $xlink => $assetsOnly) { $matches = $xContent->xpath($xlink); if($matches) foreach($matches as $item) { @@ -152,6 +175,4 @@ abstract class StaticPublisher extends DataExtension { return $urls; } - -} - +} \ No newline at end of file diff --git a/docs/en/StaticPublisher.md b/docs/en/StaticPublisher.md index 4a3a1ea..0fa2933 100644 --- a/docs/en/StaticPublisher.md +++ b/docs/en/StaticPublisher.md @@ -177,7 +177,7 @@ your dev environment). RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$ RewriteCond %{REQUEST_URI} ^(.*)$ RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule .* static/code/main.php?url=%1&%{QUERY_STRING} [L] + RewriteRule .* staticpublisher/code/main.php?url=%1&%{QUERY_STRING} [L] ### SILVERSTRIPE END ### @@ -190,7 +190,7 @@ Just look for this line: And change the PHP script from main.php to static-main.php: - RewriteRule .* static/code/main.php?url=%1&%{QUERY_STRING} [L] + RewriteRule .* staticpublisher/code/main.php?url=%1&%{QUERY_STRING} [L] ## Using Static Publisher With Subsites Module diff --git a/docs/en/index.md b/docs/en/index.md index 84a41d6..01809db 100644 --- a/docs/en/index.md +++ b/docs/en/index.md @@ -1,10 +1,10 @@ -# Static +# StaticPublisher -Static is a module providing extensions to SilverStripe to allow developers to -generate static exports of their SilverStripe sites either for performance or -as a backup system. +StaticPublisher is a module providing an extension to SilverStripe to allow +developers to generate static exports of their SilverStripe sites either +for performance or as a backup system. -There are two main parts to the module +There are two extensions provided by the module: ## Static Publisher diff --git a/main.php b/main.php index c8d320f..a3760f8 100644 --- a/main.php +++ b/main.php @@ -2,7 +2,7 @@ /** * This file is designed to be the new 'server' of sites using StaticPublisher. * to use this, you need to modify your .htaccess to point all requests to - * static/main.php, rather than framework/main.php. This file also allows for + * staticpublisher/main.php, rather than framework/main.php. This file also allows for * using static publisher with the subsites module. * * If you are using StaticPublisher+Subsites, set the following in _config.php: @@ -18,7 +18,7 @@ * automatically generated by the Subsites module) and the cache will default * to no subdirectory. * - * @package static + * @package staticpublisher */ $cacheEnabled = true; @@ -48,7 +48,7 @@ if ( ) { // Define system paths (copied from Core.php) if(!defined('BASE_PATH')) { - // Assuming that this file is static/main.php we can then determine the base path + // Assuming that this file is staticpublisher/main.php we can then determine the base path define('BASE_PATH', rtrim(dirname(dirname(__FILE__))), DIRECTORY_SEPARATOR); } if(!defined('BASE_URL')) { diff --git a/tasks/RebuildStaticCacheTask.php b/tasks/RebuildStaticCacheTask.php index 650c7b5..2e9a9fc 100644 --- a/tasks/RebuildStaticCacheTask.php +++ b/tasks/RebuildStaticCacheTask.php @@ -1,6 +1,6 @@