Remove NodeJS support
This commit is contained in:
parent
dfad552ee0
commit
cb496623a4
@ -19,15 +19,6 @@ los siguientes programas instalados:
|
||||
de la página.
|
||||
* [BeautifulSoup4](https://pypi.python.org/pypi/beautifulsoup4/).
|
||||
Requerido por el complemento tipue-search.
|
||||
* [uglifycss](https://github.com/fmarcia/UglifyCSS). Compresor de código
|
||||
<abbr title="Cascading Style Sheets">CSS</abbr>.
|
||||
* [uglifyjs](http://lisperator.net/uglifyjs/). Compresor de código
|
||||
JavaScript.
|
||||
* [nodejs](https://nodejs.org/). Node.js® es un entorno de ejecución
|
||||
para JavaScript construido con el motor de JavaScript V8 de Chrome. Se
|
||||
utiliza para ejecutar uglifycss y uglifyjs.
|
||||
* [npm](https://www.npmjs.com/). Gestor de paquetes de nodejs. Utilizado
|
||||
para instalar uglifycss y uglifyjs.
|
||||
|
||||
Instalar `virtualenv` con:
|
||||
|
||||
|
@ -53,14 +53,9 @@
|
||||
{% set software = (('https://nginx.org/', 'Nginx'),
|
||||
('http://babel.pocoo.org/', 'Babel'),
|
||||
('https://pypi.org/project/beautifulsoup4/', 'BeautifulSoup4'),
|
||||
('https://nodejs.org/', 'nodejs'),
|
||||
('https://www.python.org/', 'Python'),
|
||||
('https://blog.getpelican.com/', 'Pelican'),
|
||||
('https://pypi.org/project/Markdown/', 'Markdown'),
|
||||
('https://nodejs.org/', 'nodejs'),
|
||||
('https://www.npmjs.com/', 'npm'),
|
||||
('https://github.com/fmarcia/UglifyCSS', 'uglifycss'),
|
||||
('https://github.com/mishoo/UglifyJS', 'uglifyjs'),
|
||||
('https://conocimientoslibres.tuxfamily.org/pages/librejs.html', _('Algunos programas de JavaScript'),)) %}
|
||||
<ul>
|
||||
{% for program in software %}
|
||||
|
@ -1,16 +1,16 @@
|
||||
## Descripción
|
||||
|
||||
Es un complemento para Pelican que minifica los archivos CSS y
|
||||
JavaScript usando uglifycss y uglifyjs. Preserva los archivos JavaScript
|
||||
JavaScript usando css-html-js-minify. Preserva los archivos JavaScript
|
||||
originales y añade a los archivos JavaScript minificados la cadena
|
||||
`.min` antes de la extensión `.js`.
|
||||
|
||||
## Instalación
|
||||
|
||||
Para que funcione es necesario instalar nodejs y npm. Después instala
|
||||
uglifycss y uglifyjs con la siguiente instrucción:
|
||||
Para que funcione es necesario instalar python y pip. Después instala
|
||||
css-html-js-minify con la siguiente instrucción:
|
||||
```
|
||||
npm install uglifycss uglify-js -g
|
||||
pip install css-html-js-minify
|
||||
```
|
||||
|
||||
Finalmente, añade `compressor` a `pelicanconf.py`: `PLUGINS =
|
||||
|
@ -9,31 +9,36 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
# Display command output on DEBUG and TRACE
|
||||
SHOW_OUTPUT = logger.getEffectiveLevel() <= logging.DEBUG
|
||||
PATH_CSS = 'output/theme/css/'
|
||||
PATH_JS = 'output/theme/js/'
|
||||
|
||||
"""
|
||||
Minify CSS and JS files in output path
|
||||
with uglifycss and uglifyjs.
|
||||
with css-html-js-minify.
|
||||
"""
|
||||
|
||||
|
||||
def minify(pelican):
|
||||
"""
|
||||
Minify CSS and JavaScript
|
||||
:param pelican: The Pelican instance
|
||||
"""
|
||||
for dirpath, _, filenames in os.walk(pelican.settings['OUTPUT_PATH']):
|
||||
for dirpathcss, _, filenames in os.walk(PATH_CSS):
|
||||
for name in filenames:
|
||||
if os.path.splitext(name)[1] in ('.css'):
|
||||
filepath = os.path.join(dirpath, name)
|
||||
logger.info('minifiy %s with uglifycss', filepath)
|
||||
debug = '--debug' if SHOW_OUTPUT else ''
|
||||
call('uglifycss {} --output {} {}'.format(debug, filepath, filepath),
|
||||
if os.path.splitext(name)[1] in '.css':
|
||||
filepath = os.path.join(dirpathcss, name)
|
||||
logger.info('minifiy %s with css-html-js-minify', filepath)
|
||||
call('css-html-js-minify {}'.format(filepath),
|
||||
shell=True)
|
||||
elif os.path.splitext(name)[1] in ('.js'):
|
||||
filepath = os.path.join(dirpath, name)
|
||||
logger.info('minifiy %s with uglifyjs', filepath)
|
||||
verbose = '-v' if SHOW_OUTPUT else ''
|
||||
min_filepath = filepath[:-3] + '.min' + filepath[-3:]
|
||||
call("uglifyjs {} {} -o {} --mangle".format(filepath, verbose, min_filepath),
|
||||
|
||||
for dirpathjs, _, filenames in os.walk(PATH_JS):
|
||||
for name in filenames:
|
||||
if os.path.splitext(name)[1] in '.js':
|
||||
filepath = os.path.join(dirpathjs, name)
|
||||
logger.info('minifiy %s with css-html-js-minify', filepath)
|
||||
call("css-html-js-minify {}".format(filepath),
|
||||
shell=True)
|
||||
|
||||
|
||||
def register():
|
||||
signals.finalized.connect(minify)
|
||||
|
Loading…
x
Reference in New Issue
Block a user