function onAfterWrite()
 {
     $urls = array();
     $urls[] = "";
     // Homepage
     $sp = new FilesystemPublisher();
     $sp->publishPages($urls);
     parent::onAfterWrite();
 }
コード例 #2
0
 function testUrlsToPathsWithDomainBasedCaching()
 {
     $origDomainBasedCaching = FilesystemPublisher::$domain_based_caching;
     FilesystemPublisher::$domain_based_caching = true;
     $fsp = new FilesystemPublisher('.', 'html');
     $url = 'http://domain1.com/';
     $this->assertEquals($fsp->urlsToPaths(array($url)), array($url => 'domain1.com/index.html'), 'Root URL path mapping');
     $url = 'http://domain1.com/about-us';
     $this->assertEquals($fsp->urlsToPaths(array($url)), array($url => 'domain1.com/about-us.html'), 'URLsegment path mapping');
     $url = 'http://domain2.com/parent/child';
     $this->assertEquals($fsp->urlsToPaths(array($url)), array($url => 'domain2.com/parent/child.html'), 'Nested URLsegment path mapping');
     FilesystemPublisher::$domain_based_caching = $origDomainBasedCaching;
 }
 public function testUrlsToPathsWithDomainBasedCaching()
 {
     $origDomainBasedCaching = Config::inst()->get('FilesystemPublisher', 'domain_based_caching');
     Config::inst()->update('FilesystemPublisher', 'domain_based_caching', true);
     $fsp = new FilesystemPublisher('.', 'html');
     $url = 'http://domain1.com/';
     $this->assertEquals($fsp->urlsToPaths(array($url)), array($url => 'domain1.com/index.html'), 'Root URL path mapping');
     $url = 'http://domain1.com/about-us';
     $this->assertEquals($fsp->urlsToPaths(array($url)), array($url => 'domain1.com/about-us.html'), 'URLsegment path mapping');
     $url = 'http://domain2.com/parent/child';
     $this->assertEquals($fsp->urlsToPaths(array($url)), array($url => 'domain2.com/parent/child.html'), 'Nested URLsegment path mapping');
     Config::inst()->update('FilesystemPublisher', 'domain_based_caching', $origDomainBasedCaching);
 }
コード例 #4
0
 function publishPages($urls)
 {
     parent::publishPages($urls);
     $base = Director::baseFolder();
     $framework = FRAMEWORK_DIR;
     // Get variable that can turn off the rsync component of publication
     if (isset($_GET['norsync']) && $_GET['norsync']) {
         return;
     }
     $extraArg = "";
     if (self::$excluded_folders) {
         foreach (self::$excluded_folders as $folder) {
             $extraArg .= " --exclude " . escapeshellarg($folder);
         }
     }
     foreach (self::$targets as $target) {
         // Transfer non-PHP content from everything to the target; that will ensure that we have all the JS/CSS/etc
         $rsyncOutput = `cd {$base}; rsync -av -e ssh --exclude /.htaccess --exclude /web.config --exclude '*.php' --exclude '*.svn' --exclude '*.git' --exclude '*~' {$extraArg} --delete . {$target}`;
         // Then transfer "safe" PHP from the cache/ directory
         $rsyncOutput .= `cd {$base}; rsync -av -e ssh --exclude '*.svn' --exclude '*~' {$extraArg} --delete cache {$target}`;
         // Transfer framework/static-main.php to the target
         $rsyncOutput .= `cd {$base}; rsync -av -e ssh --delete {$framework}/static-main.php {$target}/{$framework}`;
         if (StaticPublisher::echo_progress()) {
             echo $rsyncOutput;
         }
     }
 }
 function tearDown()
 {
     parent::tearDown();
     Object::remove_extension("SiteTree", "FilesystemPublisher('assets/HomepageForDomainTest-static-folder/')");
     HomepageForDomainExtension::$write_homepage_map = true;
     FilesystemPublisher::$domain_based_caching = $this->orig['domain_based_caching'];
     if (file_exists(BASE_PATH . '/assets/HomepageForDomainTest-static-folder')) {
         Filesystem::removeFolder(BASE_PATH . '/assets/HomepageForDomainTest-static-folder');
     }
 }
コード例 #6
0
 function publishPages($urls)
 {
     parent::publishPages($urls);
     $base = Director::baseFolder();
     // Get variable that can turn off the rsync component of publication
     if (isset($_GET['norsync']) && $_GET['norsync']) {
         return;
     }
     foreach (self::$targets as $target) {
         // Transfer non-PHP content from everything to the target; that will ensure that we have all the JS/CSS/etc
         $rsyncOutput = `cd {$base}; rsync -av -e ssh --exclude /.htaccess --exclude '*.php' --exclude '*.svn' --exclude '*~' --delete . {$target}`;
         // Then transfer "safe" PHP from the cache/ directory
         $rsyncOutput .= `cd {$base}; rsync -av -e ssh --exclude '*.svn' --exclude '*~' --delete cache {$target}`;
         if (StaticPublisher::echo_progress()) {
             echo $rsyncOutput;
         }
     }
 }
コード例 #7
0
 /**
  * Set a different base URL for the static copy of the site.
  * This can be useful if you are running the CMS on a different domain from the website.
  */
 static function set_static_base_url($url)
 {
     self::$static_base_url = $url;
 }
 function onAfterWrite()
 {
     $sp = new FilesystemPublisher();
     $sp->publishPages(Page::get()->first()->allPagesToCache());
     parent::onAfterWrite();
 }
コード例 #9
0
 /**
  * @ignore
  */
 public function __construct()
 {
     parent::__construct(null, 'html');
 }