Vergelijk commits

..

5 Commits
v0.1 ... master

Auteur SHA1 Bericht Datum
c54a5d253d Verzeichnisse verschoben 2024-08-28 11:19:32 +02:00
b1a8800288 require auf 7.0-7.1 gesetzt 2024-08-28 11:17:44 +02:00
Ivo Bathke
d87119c53f
fixed sMetadataVersion (#6) 2020-04-02 14:01:16 +02:00
Alfred Bez
8bd8329e43
update instructions to install in oxid v5 & v6 2019-04-18 12:16:18 +02:00
Ivo Bathke
5a9f8d2111 Upgrade für OXID6 (#4)
updated module for OXID6
2019-04-18 11:39:09 +02:00
6 gewijzigde bestanden met toevoegingen van 64 en 162 verwijderingen

6
.gitignore vendored Normal file
Bestand weergeven

@ -0,0 +1,6 @@
# Created by .ignore support plugin (hsz.mobi)
vendor
composer.lock
source
.phpstorm-oxid.meta.php
ab_htmlmin.iml

Bestand weergeven

@ -1,27 +1,24 @@
<?php
/**
* ab HTML minify
* Copyright (C) 2014 Alfred Bez
*
* This program is free software;
* you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation;
* either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>
*/
class ab_htmlmin extends ab_htmlmin_parent {
protected function _fillCommonSmartyProperties($oSmarty)
{
parent::_fillCommonSmartyProperties($oSmarty);
$cfg = oxRegistry::getConfig();
$aPluginsDir = $oSmarty->plugins_dir;
$aPluginsDir[] = $cfg->getModulesDir()."/ab_htmlmin/smarty/plugins/";
$oSmarty->load_filter('output' , 'trimwhitespace');
$oSmarty->plugins_dir = $aPluginsDir;
}
}
<?php
/**
* ab HTML minify
* Copyright (C) 2014 Alfred Bez
*
* This program is free software;
* you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation;
* either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>
*/
namespace AlfredBez\HtmlMin\Modules\Core;
class UtilsView extends UtilsView_parent {
protected function _fillCommonSmartyProperties($oSmarty)
{
parent::_fillCommonSmartyProperties($oSmarty);
$oSmarty->load_filter('output' , 'trimwhitespace');
}
}

Bestand weergeven

@ -2,53 +2,35 @@ HTML minify
=============================
Enables Smarty 'trimwhitespace' Outputfilter to minify HTML Code
Versions
------------
| OXID eShop Version | Module Version |
|------|------|
| v5.x | v0.x |
| v6.x | v1.x |
Download
------------
There are several ways to download the module:
### Download-Option 1: Download via composer (recommended)
first you need [composer](https://getcomposer.org/download/)
add the module to your composer.json
* via command line ```composer.phar require alfredbez/ab_htmlmin dev-master```
* via command line ```composer require alfredbez/ab_htmlmin:"^1.0"```
* OR
* manually
```
{
"require": {
"alfredbez/ab_htmlmin": "dev-master"
"alfredbez/ab_htmlmin": "^1.0""
}
}
```
### Download-Option 2: Download using git clone
```git clone https://github.com/alfredbez/ab_htmlmin.git```
### Download-Option 3: Download ZIP
[download](https://github.com/alfredbez/ab_htmlmin/archive/master.zip) and extract zip
----
If you downloaded the module manually or via git:
* rename the folder to 'ab_htmlmin' if the folder name is 'ab_htmlmin-master'
* you have to move the folder 'ab_htmlmin' to your 'modules'-folder.
This will install the OXID-v6 module. If you need the module for an older shop just use `v0.1` instead of `v1.0`.
----
**Don't forget to activate module in the OXID backend**
----
After uploading the module, your directory should look like this:
```
├── index.php
├── bootstrap.php
├── config.inc.php
├── ...
└── modules
└── ab_htmlmin
├── README.md
├── metadata.php
└── models
```

Bestand weergeven

@ -1,9 +1,10 @@
{
"name": "alfredbez/ab_htmlmin",
"type": "oxid-module",
"type": "oxideshop-module",
"keywords": ["oxid", "modules", "eShop"],
"description": "entfernt unnötige Whitespaces aus dem HTML-Code",
"require": {
"composer/installers": "~1.0"
"oxid-esales/oxideshop-ce": "7.0 - 7.0"
},
"authors": [
{
@ -11,5 +12,11 @@
"email": "alfred.bez@gmail.com"
}
],
"extra": {},
"autoload": {
"psr-4": {
"AlfredBez\\HtmlMin\\": ""
}
},
"minimum-stability": "dev"
}

Bestand weergeven

@ -1,7 +1,7 @@
<?php
/**
* Version: 1.0
* Version: 2.0
* Author: Alfred Bez <alfred.bez@gmail.com>
* Author URI: http://www.alfredbez.de
*/
@ -9,20 +9,20 @@
/**
* Metadata version
*/
$sMetadataVersion = '1.1';
$sMetadataVersion = '2.1';
/**
* Module information
*/
$aModule = array(
'id' => 'ab_htmlmin',
'title' => 'Alfred Bez :: HTML minify',
'description' => 'entfernt unnötige Whitespaces aus dem HTML-Code',
'version' => '1.0',
'author' => 'Alfred Bez',
'url' => 'http://www.alfredbez.de',
'email' => 'alfred.bez@gmail.com',
'extend' => array(
'oxutilsview' => 'ab_htmlmin/models/ab_htmlmin'
)
);
$aModule = [
'id' => 'ab_htmlmin',
'title' => 'Alfred Bez :: HTML minify',
'description' => 'entfernt unnötige Whitespaces aus dem HTML-Code',
'version' => '2.0',
'author' => 'Alfred Bez',
'url' => 'https://www.alfredbez.de',
'email' => 'alfred.bez@gmail.com',
'extend' => [
\OxidEsales\Eshop\Core\UtilsView::class => \AlfredBez\HtmlMin\Modules\Core\UtilsView::class,
],
];

Bestand weergeven

@ -1,90 +0,0 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsFilter
*/
/**
* Smarty trimwhitespace outputfilter plugin
* Trim unnecessary whitespace from HTML markup.
*
* @author Rodney Rehm
*
* @param string $source input string
*
* @return string filtered output
* @todo substr_replace() is not overloaded by mbstring.func_overload - so this function might fail!
*/
function smarty_outputfilter_trimwhitespace($source)
{
$store = array();
$_store = 0;
$_offset = 0;
// Unify Line-Breaks to \n
$source = preg_replace("/\015\012|\015|\012/", "\n", $source);
// capture Internet Explorer Conditional Comments
if (preg_match_all('#<!--\[[^\]]+\]>.*?<!\[[^\]]+\]-->#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
foreach ($matches as $match) {
$store[] = $match[0][0];
$_length = strlen($match[0][0]);
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
$source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length);
$_offset += $_length - strlen($replace);
$_store ++;
}
}
// Strip all HTML-Comments
// yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124
$source = preg_replace('#<!--.*?-->#ms', '', $source);
// capture html elements not to be messed with
$_offset = 0;
if (preg_match_all('#<(script|pre|textarea)[^>]*>.*?</\\1>#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
foreach ($matches as $match) {
$store[] = $match[0][0];
$_length = strlen($match[0][0]);
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
$source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length);
$_offset += $_length - strlen($replace);
$_store ++;
}
}
$expressions = array(
// replace multiple spaces between tags by a single space
// can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements
'#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2',
// remove spaces between attributes (but not in attribute values!)
'#(([a-z0-9]\s*=\s*(["\'])[^\3]*?\3)|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \4',
// note: for some very weird reason trim() seems to remove spaces inside attributes.
// maybe a \0 byte or something is interfering?
'#^\s+<#Ss' => '<',
'#>\s+$#Ss' => '>',
);
$source = preg_replace(array_keys($expressions), array_values($expressions), $source);
// note: for some very weird reason trim() seems to remove spaces inside attributes.
// maybe a \0 byte or something is interfering?
// $source = trim( $source );
$_offset = 0;
if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
foreach ($matches as $match) {
$_length = strlen($match[0][0]);
$replace = $store[$match[1][0]];
$source = substr_replace($source, $replace, $match[0][1] + $_offset, $_length);
$_offset += strlen($replace) - $_length;
$_store ++;
}
}
return $source;
}