Skip to content

Commit

Permalink
Adding in support to run Munee in a sub-directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
meenie committed Oct 18, 2013
1 parent 03e2552 commit 7aafc64
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

use Munee\Asset\Registry;

// DIRECTORY_SEPARATOR alias
defined('DS') || define('DS' , DIRECTORY_SEPARATOR);
// Define Sub-Folder the Munee Dispatcher file is in
$subFolder = dirname($_SERVER['SCRIPT_NAME']);
defined('SUB_FOLDER') || define('SUB_FOLDER', '/' === $subFolder ? '' : $subFolder);
// Define Webroot if hasn't already been defined
defined('WEBROOT') || define('WEBROOT', str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['SCRIPT_FILENAME']));
defined('WEBROOT') || define('WEBROOT', str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['SCRIPT_FILENAME']) . SUB_FOLDER);
// Folder where Munee is located
defined('MUNEE_FOLDER') || define('MUNEE_FOLDER', dirname(__DIR__));
// Define the cache path
Expand Down
2 changes: 1 addition & 1 deletion src/Munee/Asset/Type/Css.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ protected function fixRelativeImagePaths($content, $originalFile)
$filePath = trim($match[2]);
// Skip conversion if the first character is a '/' since it's already an absolute path
if ($filePath[0] !== '/') {
$basePath = str_replace($webroot, '', dirname($originalFile));
$basePath = SUB_FOLDER . str_replace($webroot, '', dirname($originalFile));
$basePathParts = array_reverse(array_filter(explode('/', $basePath)));
$numOfRecursiveDirs = substr_count($filePath, '../');
if ($numOfRecursiveDirs > count($basePathParts)) {
Expand Down

0 comments on commit 7aafc64

Please sign in to comment.