From 312f162a53bedd197cee5302d3348c946efd74c0 Mon Sep 17 00:00:00 2001 From: ysard Date: Sat, 19 Feb 2022 10:46:49 +0100 Subject: [PATCH] Refactor for Pelican 4 + inline minification (#3) * sort imports * Fix svg compress fault due to csscompressor For at least all versions under 0.9.5 of csscompressor, there is a faulty compression on the url() func of css rules; spaces are wrongly removed, thus destroying the meaning of any embedded svg file. See https://github.com/sprymix/csscompressor/issues/9 * fix typos with black * Add logger/logging * Ability to minify inline JS & CSS tags jsmin is used for JavaScript minification; csscompressor is used as for css files * fix typos * packaging: add setup.cfg * packaging: drop old setup.py (replaced by setup.cfg) * add version to __init__ * Move src files to new pelican plugins architecture * Drop python2.7 open method * Set pelican 4 dep * Add license text in src file as it should be * README: update; - simplify maintenance process by removing references to specific versions of dependencies (See setup.cfg instead) - Add jsmin dep - Add script & style related minification * Add Makefile for release & test process * Remove useless lambda * Update changelog * README: More complete plugin description * README: mention to beautifulsoup dep * packaging: add beautifulsoup dep * Fix rest typo --- CHANGELOG | 9 ++ Makefile | 14 ++ README.rst | 23 ++-- minification/__init__.py | 73 ---------- pelican/plugins/minification/__init__.py | 167 +++++++++++++++++++++++ setup.cfg | 52 +++++++ setup.py | 39 +----- 7 files changed, 257 insertions(+), 120 deletions(-) create mode 100644 Makefile delete mode 100644 minification/__init__.py create mode 100644 pelican/plugins/minification/__init__.py create mode 100644 setup.cfg diff --git a/CHANGELOG b/CHANGELOG index 4285dfb..e7ff2b5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,12 @@ +0.2 +--- + +* Ability to minify inline JS & CSS +* Refactor for Pelican 4.x +* Drop Python 2.7 support +* Fix CSS minification fail on embedded SVG in CSS rules (url() func) + + 0.1.1 ----- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c817018 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ + +# development & release cycle +fullrelease: + fullrelease + +check_setups: + pyroma . + +check_code: + prospector pelican/plugins/minification/ + check-manifest + +sdist: + python setup.py sdist diff --git a/README.rst b/README.rst index ac09c52..8a796ea 100644 --- a/README.rst +++ b/README.rst @@ -2,6 +2,7 @@ pelican-minification ==================== Content minification for the `Pelican`_ site generator. +This plugin can compress HTML & CSS files as well as inline CSS and JavaScript in HTML files. Installation and Usage @@ -9,8 +10,10 @@ Installation and Usage pelican-minification depends on the following packages that will be installed automatically, see below: -* `htmlmin >= 0.1.5`_ -* `csscompressor >= 0.9.1`_ +* `htmlmin`_ +* `csscompressor`_ +* `jsmin`_ +* `BeautifulSoup`_ * `Pelican`_ @@ -21,18 +24,20 @@ Install pelican-minification into your Python interpreter using pip: pip install pelican-minification -Then add the plugin to the PLUGINS setting within your *pelicanconf.py*: +Then add the plugin to the ``PLUGINS`` setting within your *pelicanconf.py*: .. code-block:: python PLUGINS = [ ... - 'minification', + 'pelican.plugins.minification', ] -Upon calling the *pelican* command now, all HTML and CSS files are compressed automatically. +Upon calling the *pelican* command now, all HTML and CSS files are compressed automatically; +including inline JavaScript and CSS rules in ``