Apptrian_Minify_HTML_CSS_JS - Version 2.0.1

Version Notes

* Small bug fixed

Download this release

Release Info

Developer Apptrian
Extension Apptrian_Minify_HTML_CSS_JS
Version 2.0.1
Comparing to
See all releases


Code changes from version 2.0.0 to 2.0.1

app/code/community/Apptrian/Minify/etc/config.xml CHANGED
@@ -11,7 +11,7 @@
11
  <config>
12
  <modules>
13
  <Apptrian_Minify>
14
- <version>2.0.0</version>
15
  </Apptrian_Minify>
16
  </modules>
17
  <global>
11
  <config>
12
  <modules>
13
  <Apptrian_Minify>
14
+ <version>2.0.1</version>
15
  </Apptrian_Minify>
16
  </modules>
17
  <global>
lib/Apptrian/Minify/Css.php CHANGED
@@ -7,8 +7,6 @@
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License
8
  */
9
 
10
- // @codingStandardsIgnoreFile
11
-
12
  /**
13
  * This class is taken from tubalmartin/cssmin library and modified into Magento
14
  * compatible class. Some additional features are added to it for seamless
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License
8
  */
9
 
 
 
10
  /**
11
  * This class is taken from tubalmartin/cssmin library and modified into Magento
12
  * compatible class. Some additional features are added to it for seamless
lib/Apptrian/Minify/Html.php CHANGED
@@ -7,8 +7,6 @@
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License
8
  */
9
 
10
- // @codingStandardsIgnoreFile
11
-
12
  /**
13
  * This class is taken from mrclay/minify library and modified into Magento
14
  * compatible class. Some additional features are added to it for seamless
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License
8
  */
9
 
 
 
10
  /**
11
  * This class is taken from mrclay/minify library and modified into Magento
12
  * compatible class. Some additional features are added to it for seamless
lib/Apptrian/Minify/Js.php CHANGED
@@ -7,8 +7,6 @@
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License
8
  */
9
 
10
- // @codingStandardsIgnoreFile
11
-
12
  /**
13
  * This class is taken from tedivm/jshrink library and modified into Magento
14
  * compatible class. Some additional features are added to it for seamless
@@ -46,6 +44,11 @@
46
 
47
  class Apptrian_Minify_Js
48
  {
 
 
 
 
 
49
  /**
50
  * The input javascript to be minified.
51
  *
@@ -106,6 +109,22 @@ class Apptrian_Minify_Js
106
  */
107
  public $locks = array();
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  /**
110
  * Takes a string containing javascript and removes unneeded characters in
111
  * order to shrink the code without altering it's functionality.
@@ -118,15 +137,14 @@ class Apptrian_Minify_Js
118
  public static function minify($js, $options = array())
119
  {
120
  try {
121
- ob_start();
122
-
123
  $jshrink = new Apptrian_Minify_Js();
124
  $js = $jshrink->lock($js);
125
  $jshrink->minifyDirectToOutput($js, $options);
126
 
127
  // Sometimes there's a leading new line, so we trim that out here.
128
- $js = ltrim(ob_get_clean());
129
  $js = $jshrink->unlock($js);
 
130
  unset($jshrink);
131
 
132
  return $js;
@@ -135,11 +153,10 @@ class Apptrian_Minify_Js
135
  // Since the breakdownScript function probably wasn't finished
136
  // we clean it out before discarding it.
137
  $jshrink->clean();
 
138
  unset($jshrink);
139
  }
140
 
141
- // without this call things get weird, with partially outputted js.
142
- ob_end_clean();
143
  throw $e;
144
  }
145
  }
@@ -196,7 +213,7 @@ class Apptrian_Minify_Js
196
  // if the next line is something that can't stand alone
197
  // preserve the newline
198
  if (strpos('(-+{[@', $this->b) !== false) {
199
- echo $this->a;
200
  $this->saveString();
201
  break;
202
  }
@@ -212,7 +229,7 @@ class Apptrian_Minify_Js
212
 
213
  case ' ':
214
  if (static::isAlphaNumeric($this->b)) {
215
- echo $this->a;
216
  }
217
 
218
  $this->saveString();
@@ -222,12 +239,12 @@ class Apptrian_Minify_Js
222
  switch ($this->b) {
223
  case "\n":
224
  if (strpos('}])+-"\'', $this->a) !== false) {
225
- echo $this->a;
226
  $this->saveString();
227
  break;
228
  } else {
229
  if (static::isAlphaNumeric($this->a)) {
230
- echo $this->a;
231
  $this->saveString();
232
  }
233
  }
@@ -248,7 +265,7 @@ class Apptrian_Minify_Js
248
  continue;
249
  }
250
 
251
- echo $this->a;
252
  $this->saveString();
253
  break;
254
  }
@@ -394,21 +411,21 @@ class Apptrian_Minify_Js
394
  && $thirdCommentString === '!')
395
  || ($thirdCommentString === '@') ) {
396
  // If conditional comments or flagged comments are not the first
397
- // thing in the script we need to echo a and fill it with
398
  // a space before moving on.
399
  if ($startIndex > 0) {
400
- echo $this->a;
401
  $this->a = " ";
402
 
403
  // If the comment started on a new line we let it stay on
404
  // the new line
405
  if ($this->input[($startIndex - 1)] === "\n") {
406
- echo "\n";
407
  }
408
  }
409
 
410
  $endPoint = ($this->index - 1) - $startIndex;
411
- echo substr($this->input, $startIndex, $endPoint);
412
 
413
  return $char;
414
  }
@@ -477,8 +494,8 @@ class Apptrian_Minify_Js
477
  // String type is the quote used, " or '
478
  $stringType = $this->a;
479
 
480
- // Echo out that starting quote
481
- echo $this->a;
482
 
483
  // Loop until the string is done
484
  while (true) {
@@ -516,14 +533,14 @@ class Apptrian_Minify_Js
516
  break;
517
  }
518
 
519
- // echo out the escaped character and restart the loop.
520
- echo $this->a . $this->b;
521
  break;
522
 
523
  // Since we're not dealing with any special cases we simply
524
  // output the character and continue our loop.
525
  default:
526
- echo $this->a;
527
  }
528
  }
529
  }
@@ -536,7 +553,7 @@ class Apptrian_Minify_Js
536
  */
537
  public function saveRegex()
538
  {
539
- echo $this->a . $this->b;
540
 
541
  while (($this->a = $this->getChar()) !== false) {
542
  if ($this->a === '/') {
@@ -544,7 +561,7 @@ class Apptrian_Minify_Js
544
  }
545
 
546
  if ($this->a === '\\') {
547
- echo $this->a;
548
  $this->a = $this->getChar();
549
  }
550
 
@@ -554,7 +571,7 @@ class Apptrian_Minify_Js
554
  );
555
  }
556
 
557
- echo $this->a;
558
  }
559
 
560
  $this->b = $this->getReal();
7
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License
8
  */
9
 
 
 
10
  /**
11
  * This class is taken from tedivm/jshrink library and modified into Magento
12
  * compatible class. Some additional features are added to it for seamless
44
 
45
  class Apptrian_Minify_Js
46
  {
47
+ /**
48
+ * @var string
49
+ */
50
+ public $buffer = '';
51
+
52
  /**
53
  * The input javascript to be minified.
54
  *
109
  */
110
  public $locks = array();
111
 
112
+ /**
113
+ * Accessor method
114
+ */
115
+ public function getBuffer()
116
+ {
117
+ return $this->buffer;
118
+ }
119
+
120
+ /**
121
+ * Empty the baffer.
122
+ */
123
+ public function emptyBuffer()
124
+ {
125
+ $this->buffer = '';
126
+ }
127
+
128
  /**
129
  * Takes a string containing javascript and removes unneeded characters in
130
  * order to shrink the code without altering it's functionality.
137
  public static function minify($js, $options = array())
138
  {
139
  try {
 
 
140
  $jshrink = new Apptrian_Minify_Js();
141
  $js = $jshrink->lock($js);
142
  $jshrink->minifyDirectToOutput($js, $options);
143
 
144
  // Sometimes there's a leading new line, so we trim that out here.
145
+ $js = ltrim($jshrink->getBuffer());
146
  $js = $jshrink->unlock($js);
147
+ $jshrink->emptyBuffer();
148
  unset($jshrink);
149
 
150
  return $js;
153
  // Since the breakdownScript function probably wasn't finished
154
  // we clean it out before discarding it.
155
  $jshrink->clean();
156
+ $jshrink->emptyBuffer();
157
  unset($jshrink);
158
  }
159
 
 
 
160
  throw $e;
161
  }
162
  }
213
  // if the next line is something that can't stand alone
214
  // preserve the newline
215
  if (strpos('(-+{[@', $this->b) !== false) {
216
+ $this->buffer .= $this->a;
217
  $this->saveString();
218
  break;
219
  }
229
 
230
  case ' ':
231
  if (static::isAlphaNumeric($this->b)) {
232
+ $this->buffer .= $this->a;
233
  }
234
 
235
  $this->saveString();
239
  switch ($this->b) {
240
  case "\n":
241
  if (strpos('}])+-"\'', $this->a) !== false) {
242
+ $this->buffer .= $this->a;
243
  $this->saveString();
244
  break;
245
  } else {
246
  if (static::isAlphaNumeric($this->a)) {
247
+ $this->buffer .= $this->a;
248
  $this->saveString();
249
  }
250
  }
265
  continue;
266
  }
267
 
268
+ $this->buffer .= $this->a;
269
  $this->saveString();
270
  break;
271
  }
411
  && $thirdCommentString === '!')
412
  || ($thirdCommentString === '@') ) {
413
  // If conditional comments or flagged comments are not the first
414
+ // thing in the script we need to concat a and fill it with
415
  // a space before moving on.
416
  if ($startIndex > 0) {
417
+ $this->buffer .= $this->a;
418
  $this->a = " ";
419
 
420
  // If the comment started on a new line we let it stay on
421
  // the new line
422
  if ($this->input[($startIndex - 1)] === "\n") {
423
+ $this->buffer .= "\n";
424
  }
425
  }
426
 
427
  $endPoint = ($this->index - 1) - $startIndex;
428
+ $this->buffer .= substr($this->input, $startIndex, $endPoint);
429
 
430
  return $char;
431
  }
494
  // String type is the quote used, " or '
495
  $stringType = $this->a;
496
 
497
+ // Concat that starting quote
498
+ $this->buffer .= $this->a;
499
 
500
  // Loop until the string is done
501
  while (true) {
533
  break;
534
  }
535
 
536
+ // Concat the escaped character and restart the loop.
537
+ $this->buffer .= $this->a . $this->b;
538
  break;
539
 
540
  // Since we're not dealing with any special cases we simply
541
  // output the character and continue our loop.
542
  default:
543
+ $this->buffer .= $this->a;
544
  }
545
  }
546
  }
553
  */
554
  public function saveRegex()
555
  {
556
+ $this->buffer .= $this->a . $this->b;
557
 
558
  while (($this->a = $this->getChar()) !== false) {
559
  if ($this->a === '/') {
561
  }
562
 
563
  if ($this->a === '\\') {
564
+ $this->buffer .= $this->a;
565
  $this->a = $this->getChar();
566
  }
567
 
571
  );
572
  }
573
 
574
+ $this->buffer .= $this->a;
575
  }
576
 
577
  $this->b = $this->getReal();
package.xml CHANGED
@@ -1,22 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Apptrian_Minify_HTML_CSS_JS</name>
4
- <version>2.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Minify HTML CSS JS including inline CSS/JS and speed up your site. Works with default Magento CSS/JS merger.</summary>
10
  <description>Apptrian Minify HTML CSS JS is a very small and efficient extension. It will minify HTML including inline CSS and JS code. Minification of CSS and JS files is compatible with default Magento CSS and JS file merger. There are no complex setups nor query strings on minified CSS and JS files. Extension is very easy to install and use. Compatible with FPC and Varnish cache extensions. If there is a serious error in some page code that page will not be minified. Extension will log the error and url of the page where this error occurs so developers can track it down and fix the code.</description>
11
- <notes>* Complete rewrite from the ground up&#xD;
12
- + Support for Knockout JavaScript library comments&#xD;
13
- + Support for script tags of type="text/x-magento-template"&#xD;
14
- + Logging of errors with url where errors occur&#xD;
15
- + Compliance with Magento's Extension Quality Program (EQP)</notes>
16
  <authors><author><name>Apptrian</name><user>apptrian</user><email>apptrian@yahoo.com</email></author></authors>
17
  <date>2017-01-06</date>
18
- <time>17:29:10</time>
19
- <contents><target name="magecommunity"><dir name="Apptrian"><dir name="Minify"><dir name="Block"><dir name="Adminhtml"><file name="About.php" hash="f64192564d4cf23ff796d019e6cc59fd"/><dir name="Button"><file name="Minify.php" hash="fb682754c2959e3faa976f949c1f62c2"/></dir><file name="Info.php" hash="ff8203653ffc21f22613c8a07150efb4"/></dir></dir><dir name="Helper"><file name="Data.php" hash="da081b337c9daab9ab0f0a5908adc318"/></dir><dir name="Model"><file name="Observer.php" hash="c88016f8414982f615e47d21420fa478"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Apptrian"><file name="MinifyController.php" hash="ff9d7192ade05edbf0aee65a2763cde5"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="9e667c95bf1ae3f8e9cc41876ff15822"/><file name="system.xml" hash="e356c9e13699a3550fd02955ffda675a"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Apptrian_Minify.xml" hash="c46de9988ef639ef94525ad207da6ef2"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Apptrian_Minify.csv" hash="694d5a244eeaaa7293520581b82ffcf7"/></dir></target><target name="magelib"><dir name="Apptrian"><dir name="Minify"><file name="Css.php" hash="cbfb109198d520f31033ba14110a1ba5"/><file name="Html.php" hash="1f3ce3e743530aadb78e7071dd4e49ef"/><file name="Js.php" hash="30c28af3f71c954be8fbff10228dd02b"/></dir></dir></target></contents>
20
  <compatible/>
21
  <dependencies><required><php><min>5.1.0</min><max>8.0.0</max></php></required></dependencies>
22
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Apptrian_Minify_HTML_CSS_JS</name>
4
+ <version>2.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Minify HTML CSS JS including inline CSS/JS and speed up your site. Works with default Magento CSS/JS merger.</summary>
10
  <description>Apptrian Minify HTML CSS JS is a very small and efficient extension. It will minify HTML including inline CSS and JS code. Minification of CSS and JS files is compatible with default Magento CSS and JS file merger. There are no complex setups nor query strings on minified CSS and JS files. Extension is very easy to install and use. Compatible with FPC and Varnish cache extensions. If there is a serious error in some page code that page will not be minified. Extension will log the error and url of the page where this error occurs so developers can track it down and fix the code.</description>
11
+ <notes>* Small bug fixed</notes>
 
 
 
 
12
  <authors><author><name>Apptrian</name><user>apptrian</user><email>apptrian@yahoo.com</email></author></authors>
13
  <date>2017-01-06</date>
14
+ <time>23:36:36</time>
15
+ <contents><target name="magecommunity"><dir name="Apptrian"><dir name="Minify"><dir name="Block"><dir name="Adminhtml"><file name="About.php" hash="f64192564d4cf23ff796d019e6cc59fd"/><dir name="Button"><file name="Minify.php" hash="fb682754c2959e3faa976f949c1f62c2"/></dir><file name="Info.php" hash="ff8203653ffc21f22613c8a07150efb4"/></dir></dir><dir name="Helper"><file name="Data.php" hash="da081b337c9daab9ab0f0a5908adc318"/></dir><dir name="Model"><file name="Observer.php" hash="c88016f8414982f615e47d21420fa478"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Apptrian"><file name="MinifyController.php" hash="ff9d7192ade05edbf0aee65a2763cde5"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="02612426a06ba8afa72b72a60419f862"/><file name="system.xml" hash="e356c9e13699a3550fd02955ffda675a"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Apptrian_Minify.xml" hash="c46de9988ef639ef94525ad207da6ef2"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Apptrian_Minify.csv" hash="694d5a244eeaaa7293520581b82ffcf7"/></dir></target><target name="magelib"><dir name="Apptrian"><dir name="Minify"><file name="Css.php" hash="38c36acd692f9c117bd0c90dad9712b8"/><file name="Html.php" hash="00eb1ad9230c159b7dccee91fc8e6f18"/><file name="Js.php" hash="771ac8c98a9e55246bae6859283dcb37"/></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>8.0.0</max></php></required></dependencies>
18
  </package>