Skip to content

Instantly share code, notes, and snippets.

@lovett
Created November 21, 2010 20:56
Show Gist options
  • Save lovett/709140 to your computer and use it in GitHub Desktop.
Save lovett/709140 to your computer and use it in GitHub Desktop.
Phing task for revving filenames of static assets during deployment
<adhoc-task name="adhocFilehash">
<![CDATA[
class AdHocFileHash extends Task {
private $path;
private $propertyName;
function setPath($path) {
$this->path = $path;
}
function setPropertyName($name) {
$this->propertyName = $name;
}
function main() {
$this->getProject()->setProperty($this->propertyName, sha1_file($this->path));
}
}
]]>
</adhoc-task>
<adhocFilehash path="${js_root}/functions-min.js" propertyname="functions-min-hash"/>
<copy file="./${theme.path}/footer.php" tofile="${builddir}/${theme.path}/footer.php" overwrite="true">
<filterchain>
<replaceregexp>
<regexp pattern="functions\-min\.js" replace="functions-min.${master-min-hash}.js"/>
</replaceregexp>
</filterchain>
</copy>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment