nomorepanic / lektor-htmlmin Goto Github PK
View Code? Open in Web Editor NEWAutomatic HTML minifier for Lektor based on htmlmin
License: MIT License
Automatic HTML minifier for Lektor based on htmlmin
License: MIT License
Minification of files created using other encoding than UTF8 raises:
Traceback (most recent call last):
File "$LEKTOR_PATHH/devserver.py", line 45, in build
builder.build_all()
File "$LEKTOR_PATHH/builder.py", line 1111, in build_all
self.env.plugin_controller.emit('after-build-all', builder=self)
File "$LEKTOR_PATHH/pluginsystem.py", line 161, in emit
rv[plugin.id] = handler(**kwargs)
File "$LEKTOR_TMP_PATHH/lektor_htmlmin.py", line 58, in on_after_build_all self.minify_file(htmlfile)
File "$LEKTOR_TMP_PATHH/lektor_htmlmin.py", line 44, in minify_file
result = htmlmin.minify(f.read().decode('latin-1'), **self.options)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 78: ordinal not in range(128)
Following the instructions in the README and running lektor plugins add lektor-htmlmin
results in lektor-htmlmin version 0.1.10 getting installed, not 1.0, at least on my non-linux-x86_64 system. (The same outdated version gets installed when I pip install lektor-htmlmin
too.) Looking at https://pypi.python.org/pypi/lektor-htmlmin, the only source distribution available is "lektor-htmlmin-1.0.linux-x86_64.tar.gz", so I take it that the source distribution was mistakenly marked as x86_64-only, even though this package is classified as "Operating System :: OS Independent".
Getting lots of these errors:
Object allocated at (most recent call last):
File "/usr/local/lib/python3.8/site-packages/lektor_htmlmin.py", lineno 46
html = open(target, 'rb').read()
/usr/local/lib/python3.8/site-packages/lektor_htmlmin.py:46: ResourceWarning: unclosed file <_io.BufferedReader name='/srv/lektor/builds/en/.../index.html'>
html = open(target, 'rb').read()
I'm thinking that the io
read
needs to close
before continuing to the next file.
Ref: https://docs.python.org/3/library/io.html#io.IOBase.close
Thanx for this plugin.
Using the latest (=today) git version of Lektor (marked as 3.0) seems to break your plugin :
Traceback (most recent call last):
File "/Users/odeckmyn/Work/BioPredictive/IT/github/biopredictive-website/_venv/bin/lektor", line 11, in <module>
load_entry_point('Lektor==3.0', 'console_scripts', 'lektor’)()
File "/Users/odeckmyn/Work/BioPredictive/IT/github/biopredictive-website/_venv/lib/python2.7/site-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/Users/odeckmyn/Work/BioPredictive/IT/github/biopredictive-website/_venv/lib/python2.7/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/Users/odeckmyn/Work/BioPredictive/IT/github/biopredictive-website/_venv/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/odeckmyn/Work/BioPredictive/IT/github/biopredictive-website/_venv/lib/python2.7/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/odeckmyn/Work/BioPredictive/IT/github/biopredictive-website/_venv/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/Users/odeckmyn/Work/BioPredictive/IT/github/biopredictive-website/_venv/lib/python2.7/site-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/Users/odeckmyn/Work/BioPredictive/IT/github/biopredictive-website/_venv/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/Users/odeckmyn/Work/BioPredictive/IT/github/biopredictive-website/_venv/lib/python2.7/site-packages/lektor/cli.py", line 221, in build_cmd
success = _build()
File "/Users/odeckmyn/Work/BioPredictive/IT/github/biopredictive-website/_venv/lib/python2.7/site-packages/lektor/cli.py", line 214, in _build
failures = builder.build_all()
File "/Users/odeckmyn/Work/BioPredictive/IT/github/biopredictive-website/_venv/lib/python2.7/site-packages/lektor/builder.py", line 1130, in build_all
self.env.plugin_controller.emit('after-build-all', builder=self)
File "/Users/odeckmyn/Work/BioPredictive/IT/github/biopredictive-website/_venv/lib/python2.7/site-packages/lektor/pluginsystem.py", line 160, in emit
rv[plugin.id] = handler(**kwargs)
File "/Users/odeckmyn/Library/Caches/Lektor/packages/a6bc7908ecb482f98ad1094d25407fb2/lektor_htmlmin.py", line 56, in on_after_build_all
if not self.is_enabled(builder.build_flags):
AttributeError: 'Builder' object has no attribute ‘build_flags’
make: *** [build.website] Error 1
Thanx for your help
Tests are missing and should be added.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.