Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Added suport for absolute include url #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ all:
params: # optimizer class configuration
driver: JSMin # driver name (JSMin, JSMinPlus, etc.)
destination: /js/optimized.js # destination path for optimized .js file
absolute_url: false # use absolute url
timestamp: true # add a timestamp to the combined file url
files: [] # list of js files to optimize and combine
stylesheet: # stylesheets configuration section
Expand All @@ -17,6 +18,7 @@ all:
params: # optimizer class configuration
driver: Cssmin # driver name
destination: /css/optimized.css # destination path for optimized .css file
absolute_url: false # use absolute url
timestamp: true # add a timestamp to the combined file url
files: [] # list of css files to optimize and combine
png_image: # PNG images configuration section
Expand Down
10 changes: 7 additions & 3 deletions lib/service/npAssetsOptimizerService.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ public function replaceJavascripts(sfWebResponse $response)
$response->removeJavascript($file);
}

$response->addJavascript($javascriptOptimizer->getOptimizedFileWebPath(), 'first');
$options = ($this->configuration['javascript']['params']['absolute_url']) ? array("absolute" => true) : array();

$response->addJavascript($javascriptOptimizer->getOptimizedFileWebPath(), 'first', $options);
}

/**
Expand All @@ -138,8 +140,10 @@ public function replaceStylesheets(sfWebResponse $response)
{
$response->removeStylesheet($file);
}

$options = ($this->configuration['stylesheet']['params']['absolute_url']) ? array("absolute" => true) : array();

$response->addStylesheet($stylesheetOptimizer->getOptimizedFileWebPath(), 'first');
$response->addStylesheet($stylesheetOptimizer->getOptimizedFileWebPath(), 'first', $options);
}

/**
Expand Down Expand Up @@ -172,4 +176,4 @@ public function getOptimizer($type)

return new $className($this->dispatcher, $this->configuration[$type]['params'], $this->baseAssetsDir);
}
}
}