Skip to content
Permalink
Browse files

fix #1999

  • Loading branch information
ralsina committed Sep 2, 2015
1 parent 50bf2cb commit fe4663c1fc10ccaa4d06ec0eaf60894c34a6564d
Showing with 34 additions and 0 deletions.
  1. +1 −0 CHANGES.txt
  2. +5 −0 docs/manual.txt
  3. +28 −0 nikola/filters.py
@@ -4,6 +4,7 @@ New in master
Features
--------

* New support for online CSS and JS minifying services (Issue #1999)
* Make <base> tag optional with USE_BASE_TAG flag (Issue #1985)
* Render author pages (Issue #1972)
* Atom feeds for tag lists (Issue #1686)
@@ -1350,6 +1350,11 @@ optipng
jpegoptim
Compress JPEG files using `jpegoptim <http://www.kokkonen.net/tjko/projects.html>`_

cssminify
Minify CSS using http://cssminifier.com/ (requires internet access)

jsminify
Minify JS using http://javascript-minifier.com/ (requires internet access)

You can apply filters to specific posts or pages by using the ``filters`` metadata field:

@@ -39,7 +39,9 @@
import typogrify.filters as typo
except ImportError:
typo = None # NOQA
import requests

from utils import LOGGER

def apply_to_binary_file(f):
"""Apply a filter to a binary file.
@@ -274,3 +276,29 @@ def php_template_injection(data):
return phpdata
else:
return data


@apply_to_text_file
def cssminify(data):
"""Minify CSS using http://cssminifier.com/"""
try:
url = 'http://cssminifier.com/raw'
_data = {'input': data}
response = requests.post(url, data=_data)
return response.text
except Exception as exc:
LOGGER.error("can't use cssminifier.com: {}", exc)
return data


@apply_to_text_file
def jsminify(data):
"""Minify JS using http://javascript-minifier.com/"""
try:
url = 'http://javascript-minifier.com/raw'
_data = {'input': data}
response = requests.post(url, data=_data)
return response.text
except Exception as exc:
LOGGER.error("can't use javascript-minifier.com: {}", exc)
return data

0 comments on commit fe4663c

Please sign in to comment.
You can’t perform that action at this time.