Skip to content
This repository was archived by the owner on Mar 19, 2023. It is now read-only.

Commit d0492f9

Browse files
committed
Merge branch 'amalfra-patch-1' into develop
2 parents 4445a4a + 6477054 commit d0492f9

File tree

2 files changed

+54
-36
lines changed

2 files changed

+54
-36
lines changed

README.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,19 @@ You can use this Facade anywhere in your application
4747
<head>
4848
...
4949
{{ Minify::stylesheet('/css/main.css') }}
50-
//or by passing multiple files
50+
// or by passing multiple files
5151
{{ Minify::stylesheet(array('/css/main.css', '/css/bootstrap.css')) }}
52-
//add custom attributes
52+
// add custom attributes
5353
{{ Minify::stylesheet(array('/css/main.css', '/css/bootstrap.css'), array('foo' => 'bar')) }}
5454
// add full uri of the resource
55-
{{ Minify::stylesheet(array('/css/main.css', '/css/bootstrap.css'))->withFullUrl() }}
56-
// Minify and combine all stylesheet files in given folder
55+
{{ Minify::stylesheet(array('/css/main.css', '/css/bootstrap.css'))->withFullUrl() }}
56+
57+
// minify and combine all stylesheet files in given folder
5758
{{ Minify::stylesheetDir('/css/') }}
59+
// add custom attributes to minify and combine all stylesheet files in given folder
60+
{{ Minify::stylesheetDir('/css/', array('foo' => 'bar')) }}
61+
// minify and combine all stylesheet files in given folder with full uri
62+
{{ Minify::stylesheetDir('/css/')->withFullUrl() }}
5863
</head>
5964
...
6065
</html>
@@ -70,14 +75,19 @@ You can use this Facade anywhere in your application
7075
...
7176
</body>
7277
{{ Minify::javascript('/js/jquery.js') }}
73-
//or by passing multiple files
78+
// or by passing multiple files
7479
{{ Minify::javascript(array('/js/jquery.js', '/js/jquery-ui.js')) }}
75-
//add custom attributes
80+
// add custom attributes
7681
{{ Minify::javascript(array('/js/jquery.js', '/js/jquery-ui.js'), array('bar' => 'baz')) }}
7782
// add full uri of the resource
7883
{{ Minify::javascript(array('/js/jquery.js', '/js/jquery-ui.js'))->withFullUrl() }}
79-
// Minify and combine all javascript files in given folder
84+
85+
// minify and combine all javascript files in given folder
8086
{{ Minify::javascriptDir('/js/') }}
87+
// add custom attributes to minify and combine all javascript files in given folder
88+
{{ Minify::javascriptDir('/js/', array('bar' => 'baz')) }}
89+
// minify and combine all javascript files in given folder with full uri
90+
{{ Minify::javascriptDir('/js/')->withFullUrl() }}
8191
</html>
8292

8393
```
@@ -106,10 +116,10 @@ return array(
106116
| CSS path and CSS build path
107117
|--------------------------------------------------------------------------
108118
|
109-
| Minify is an extention that can minify your css files into one build file.
119+
| Minify is an extension that can minify your css files into one build file.
110120
| The css_path property is the location where your CSS files are located
111121
| The css_builds_path property is the location where the builded files are
112-
| stored. THis is relative to the css_path property.
122+
| stored. This is relative to the css_path property.
113123
|
114124
*/
115125

@@ -120,10 +130,10 @@ return array(
120130
| JS path and JS build path
121131
|--------------------------------------------------------------------------
122132
|
123-
| Minify is an extention that can minify your JS files into one build file.
133+
| Minify is an extension that can minify your JS files into one build file.
124134
| The JS_path property is the location where your JS files are located
125135
| The JS_builds_path property is the location where the builded files are
126-
| stored. THis is relative to the css_path property.
136+
| stored. This is relative to the css_path property.
127137
|
128138
*/
129139

src/CeesVanEgmond/Minify/Minify.php

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -84,26 +84,30 @@ public function stylesheet($file, $attributes = array())
8484

8585
/**
8686
* @param $dir
87+
* @param array $attributes
8788
* @return string
8889
*/
89-
public function stylesheetDir($dir)
90+
public function stylesheetDir($dir, $attributes = array())
9091
{
91-
$this->provider = new StyleSheet(public_path());
92-
$this->buildPath = $this->config['css_build_path'];
93-
94-
return $this->assetDirHelper('css', $dir);
92+
$this->provider = new StyleSheet(public_path());
93+
$this->buildPath = $this->config['css_build_path'];
94+
$this->attributes = $attributes;
95+
96+
return $this->assetDirHelper('css', $dir);
9597
}
9698

9799
/**
98100
* @param $dir
101+
* @param array $attributes
99102
* @return string
100103
*/
101-
public function javascriptDir($dir)
104+
public function javascriptDir($dir, $attributes = array())
102105
{
103-
$this->provider = new JavaScript(public_path());
104-
$this->buildPath = $this->config['js_build_path'];
105-
106-
return $this->assetDirHelper('js', $dir);
106+
$this->provider = new JavaScript(public_path());
107+
$this->buildPath = $this->config['js_build_path'];
108+
$this->attributes = $attributes;
109+
110+
return $this->assetDirHelper('js', $dir);
107111
}
108112

109113
/**
@@ -113,23 +117,27 @@ public function javascriptDir($dir)
113117
*/
114118
private function assetDirHelper($ext, $dir)
115119
{
116-
$files = array();
117-
118-
$dir_obj = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(public_path().$dir));
119-
foreach ($dir_obj as $fileinfo)
120-
{
121-
if (!$fileinfo->isDir() && ($filename = $fileinfo->getFilename()) && (pathinfo($filename, PATHINFO_EXTENSION) == $ext) && (strlen($fileinfo->getFilename()) < 30))
120+
$files = array();
121+
122+
$itr_obj = new RecursiveDirectoryIterator(public_path().$dir);
123+
$itr_obj->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
124+
$dir_obj = new RecursiveIteratorIterator($itr_obj);
125+
126+
foreach ($dir_obj as $fileinfo)
122127
{
123-
$files[] = str_replace(public_path(), '', $fileinfo);
128+
if (!$fileinfo->isDir() && ($filename = $fileinfo->getFilename()) && (pathinfo($filename, PATHINFO_EXTENSION) == $ext) && (strlen($fileinfo->getFilename()) < 30))
129+
{
130+
$files[] = str_replace(public_path(), '', $fileinfo);
131+
}
124132
}
125-
}
126-
127-
if (count($files) > 0)
128-
{
129-
$this->process($files);
130-
}
131-
132-
return $this;
133+
134+
if (count($files) > 0)
135+
{
136+
rsort($files);
137+
$this->process($files);
138+
}
139+
140+
return $this;
133141
}
134142

135143
/**

0 commit comments

Comments
 (0)