Skip to content

Commit 402a62e

Browse files
committedSep 21, 2015
minifyjson filter
1 parent 47de6c4 commit 402a62e

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed
 

Diff for: ‎CHANGES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ New in master
44
Features
55
--------
66

7+
* New ```jsonmnify``` filter for minifying JSON files.
78
* New option ``FEED_PREVIEWIMAGE`` includes the ``post.meta.previewimage``
89
image in Atom and RSS feeds. (Issue #2095)
910

Diff for: ‎docs/manual.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,9 @@ cssminify
13811381
jsminify
13821382
Minify JS using http://javascript-minifier.com/ (requires internet access)
13831383

1384+
jsonminify
1385+
Minify JSON files (strips whitespace and use minimal separators).
1386+
13841387
You can apply filters to specific posts or pages by using the ``filters`` metadata field:
13851388

13861389
.. code:: restructuredtext

Diff for: ‎nikola/filters.py

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from functools import wraps
3030
import os
3131
import io
32+
import json
3233
import shutil
3334
import subprocess
3435
import tempfile
@@ -307,6 +308,12 @@ def jsminify(data):
307308
return data
308309

309310

311+
@apply_to_text_file
312+
def jsonminify(data):
313+
data = json.dumps(json.loads(data), indent=None, separators=(',', ':'))
314+
return data
315+
316+
310317
def _normalize_html(data):
311318
"""Pass HTML through LXML to clean it up, if possible."""
312319
try:

0 commit comments

Comments
 (0)
Please sign in to comment.