Skip to content

Commit

Permalink
完善 assets-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
breath-co2 committed Jan 5, 2014
1 parent 892ba75 commit 33c37d4
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions libraries/myqee/develop/controllers/assets-dev.controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Library_MyQEE_Develop_Controller_Assets_Dev extends Controller
*
* @var string
*/
protected $allow_suffix = 'js|css|jpg|jpeg|png|gif|bmp|pdf|html|htm|mp4|swf|eot|svg|ttf|woff';
protected $allow_suffix = 'js|css|jpg|jpeg|png|gif|bmp|pdf|html|htm|mp4|swf|eot|svg|ttf|woff|map';

/**
* 文件名
Expand Down Expand Up @@ -63,7 +63,7 @@ public function before()
# 移除.min的后缀
if (substr($this->file, -4)=='.min')
{
$this->file = substr($this->file, 0, -4);
$this->file = substr($this->file, 0, -4);
$this->is_min = true;
}
}
Expand Down Expand Up @@ -177,7 +177,7 @@ protected function output_by_file($file)
$out_dir = DIR_ASSETS . Core::$project .'/';

# 输出文件
$out_file = $out_dir . $this->file . '.' . $this->type;
$out_file = $out_dir . $this->file . ($this->is_min?'.min':'') . '.' . $this->type;

if (is_file($out_file))
{
Expand All @@ -191,22 +191,30 @@ protected function output_by_file($file)
}
else
{
File::create_dir(dirname($out_file));
copy($file, $out_file);
touch($out_file, filemtime($file));
// symlink($this->relative_path($file, $out_file), $out_file);
if (File::create_dir(dirname($out_file)))
{
copy($file, $out_file);
touch($out_file, filemtime($file));
}
}

$fun = 'apache_get_modules';
if (function_exists($fun))
{
if (in_array('mod_xsendfile', $fun()))
{
$slen = strlen(DIR_SYSTEM);
if (substr($file, 0, $slen)==DIR_SYSTEM)
$root_dir = $_SERVER["DOCUMENT_ROOT"];
$root_len = strlen($root_dir);

if (IS_WIN)
{
$root_dir = str_replace('\\', '/', $root_dir);
$file = str_replace('\\', '/', $file);
}
if (substr($file, 0, $root_len)==$root_dir)
{
# 采用xsendfile发送文件
header('X-Sendfile: '.substr($file, $slen));
header('X-Sendfile: '.substr($file, $root_len));
exit();
}
}
Expand Down Expand Up @@ -427,15 +435,16 @@ protected function output_css_js_file()
*/
protected function output_other_file()
{
$found_file = Core::find_file('assets', $this->file, '.'. $this->type);
$file_name = $this->file . ($this->is_min?'.min':'');
$found_file = Core::find_file('assets', $file_name, '.'. $this->type);

if ($found_file)
{
$this->output_by_file($found_file);
}
else
{
Core::show_404(__('Assets files : %s not found.', array('%s'=>$this->file .'.'. $this->type)));
Core::show_404(__('Assets files : %s not found.', array('%s'=>$file_name .'.'. $this->type)));
}
}

Expand Down Expand Up @@ -677,14 +686,15 @@ protected function prease_css($out_file, $type, &$content)
$assets_path = array();

$tmp_dir = dirname($this->file);
if ($tmp_dir && $dir!='.')
if ($tmp_dir && $tmp_dir!='.')
{
$tmp_dir .= '/';
}
else
{
$tmp_dir = '';
}

# 循环include path
foreach ($include_path as $path)
{
Expand Down

0 comments on commit 33c37d4

Please sign in to comment.