mirror of
https://github.com/silverstripe/silverstripe-staticpublisher
synced 2024-10-22 14:05:54 +02:00
Merge pull request #37 from dhensby/pulls/rebase-31
Removed commented code and relevant method externalReferencesFor
This commit is contained in:
commit
76ba1a8b25
@ -304,32 +304,6 @@ class FilesystemPublisher extends StaticPublisher {
|
|||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add externals
|
|
||||||
/*
|
|
||||||
$externals = $this->externalReferencesFor($content);
|
|
||||||
if($externals) foreach($externals as $external) {
|
|
||||||
// Skip absolute URLs
|
|
||||||
if(preg_match('/^[a-zA-Z]+:\/\//', $external)) continue;
|
|
||||||
// Drop querystring parameters
|
|
||||||
$external = strtok($external, '?');
|
|
||||||
|
|
||||||
if(file_exists("../" . $external)) {
|
|
||||||
// Break into folder and filename
|
|
||||||
if(preg_match('/^(.*\/)([^\/]+)$/', $external, $matches)) {
|
|
||||||
$files[$external] = array(
|
|
||||||
"Copy" => "../$external",
|
|
||||||
"Folder" => $matches[1],
|
|
||||||
"Filename" => $matches[2],
|
|
||||||
);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
user_error("Can't parse external: $external", E_USER_WARNING);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$missingFiles[$external] = true;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//return config to its previous state
|
//return config to its previous state
|
||||||
|
@ -179,39 +179,8 @@ abstract class StaticPublisher extends DataExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all external references to CSS, JS,
|
|
||||||
*/
|
|
||||||
public function externalReferencesFor($content) {
|
|
||||||
$CLI_content = escapeshellarg($content);
|
|
||||||
$tidy = `echo $CLI_content | tidy -numeric -asxhtml`;
|
|
||||||
$tidy = preg_replace('/xmlns="[^"]+"/','', $tidy);
|
|
||||||
$xContent = new SimpleXMLElement($tidy);
|
|
||||||
|
|
||||||
$xlinks = array(
|
|
||||||
"//link[@rel='stylesheet']/@href" => false,
|
|
||||||
"//script/@src" => false,
|
|
||||||
"//img/@src" => false,
|
|
||||||
"//a/@href" => true,
|
|
||||||
);
|
|
||||||
|
|
||||||
$urls = array();
|
|
||||||
|
|
||||||
foreach($xlinks as $xlink => $assetsOnly) {
|
|
||||||
$matches = $xContent->xpath($xlink);
|
|
||||||
if($matches) foreach($matches as $item) {
|
|
||||||
$url = $item . '';
|
|
||||||
if($assetsOnly && substr($url,0,7) != ASSETS_DIR . '/') continue;
|
|
||||||
|
|
||||||
$urls[] = $url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $urls;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $url
|
|
||||||
*
|
*
|
||||||
|
* @param string $url
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getMetadata($url) {
|
public function getMetadata($url) {
|
||||||
|
Loading…
Reference in New Issue
Block a user