From 4160bf6640274b90aaca439f47b3c6b3d628ee2c Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sat, 10 Jan 2015 19:45:25 +0000 Subject: [PATCH] Do not add hashes to asset directory --- src/ClientSide/FileOrganiser.php | 15 +++++++-------- src/ClientSide/PageManifest.php | 11 +++++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/ClientSide/FileOrganiser.php b/src/ClientSide/FileOrganiser.php index 951c23e7..3fbc54a7 100644 --- a/src/ClientSide/FileOrganiser.php +++ b/src/ClientSide/FileOrganiser.php @@ -127,7 +127,6 @@ public function purgeStaticWwwFiles() { foreach(new \DirectoryIterator(Path::get(Path::WWW)) as $item) { $filename = $item->getFilename(); - if($filename === $assetDirName || strpos($filename, $scriptDirName . "-") === 0 || strpos($filename, $styleDirName . "-") === 0) { @@ -233,13 +232,6 @@ public function copyAsset() { return $copyCount; } -private function writeStaticFingerprint($fingerprint) { - if(!is_dir(dirname($this->staticFingerprintFile))) { - mkdir(dirname($this->staticFingerprintFile), 0775, true); - } - file_put_contents($this->staticFingerprintFile, $fingerprint); -} - /** * */ @@ -260,6 +252,13 @@ public function copyAssetCallback($file, $iterator, &$out) { } } +private function writeStaticFingerprint($fingerprint) { + if(!is_dir(dirname($this->staticFingerprintFile))) { + mkdir(dirname($this->staticFingerprintFile), 0775, true); + } + file_put_contents($this->staticFingerprintFile, $fingerprint); +} + /** * Recursively iterate over all files within given directories and build up a * hash of their contents and file names. diff --git a/src/ClientSide/PageManifest.php b/src/ClientSide/PageManifest.php index b29bd91f..47dcb55e 100644 --- a/src/ClientSide/PageManifest.php +++ b/src/ClientSide/PageManifest.php @@ -63,6 +63,17 @@ public function __construct(Node $domHead, $request, $response) { public function generatePathDetails() { $this->nodeList = $this->domHead->xpath(self::$xpathQuery); + // Do not add nodes that reference the asset directory. + foreach ($this->nodeList->nodeArray as $i => $node) { + $source = $node->getAttribute( + $this->sourceAttribute[$node->tagName]); + $source = strtolower($source); + if(strpos($source, "/asset") === 0) { + unset($this->nodeList->nodeArray[$i]); + } + } + $this->nodeList->nodeArray = array_values($this->nodeList->nodeArray); + $pathDetails = new PathDetails($this->nodeList); return $pathDetails; }