Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
POC of handling filter failures
  • Loading branch information
ralsina committed Feb 14, 2016
1 parent 7638ac8 commit c05cb99
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGES.txt
@@ -1,3 +1,11 @@
New in master
=============

Bugfixes
--------

* Mark as out-of-date tasks when filters fail (Issue #2169)

New in v7.7.5
=============

Expand Down
13 changes: 8 additions & 5 deletions nikola/filters.py
Expand Up @@ -75,8 +75,11 @@ def f_in_file(fname):
with io.open(fname, 'r', encoding='utf-8') as inf:
data = inf.read()
data = f(data)
with io.open(fname, 'w+', encoding='utf-8') as outf:
outf.write(data)
if data is not False:
with io.open(fname, 'w+', encoding='utf-8') as outf:
outf.write(data)
else:
return False

return f_in_file

Expand Down Expand Up @@ -287,16 +290,16 @@ def php_template_injection(data):
def cssminify(data):
"""Minify CSS using http://cssminifier.com/."""
try:
url = 'http://cssminifier.com/raw'
url = 'http://cssminifier.comFOO/raw'
_data = {'input': data}
response = requests.post(url, data=_data)
if response.status_code != 200:
LOGGER.error("can't use cssminifier.com: HTTP status {}", response.status_code)
return data
return False
return response.text
except Exception as exc:
LOGGER.error("can't use cssminifier.com: {}", exc)
return data
return False


@apply_to_text_file
Expand Down
2 changes: 1 addition & 1 deletion nikola/utils.py
Expand Up @@ -903,7 +903,7 @@ def filter_matches(ext):
def unlessLink(action, target):
if not os.path.islink(target):
if isinstance(action, Callable):
action(target)
return action(target)
else:
subprocess.check_call(action % target, shell=True)

Expand Down

0 comments on commit c05cb99

Please sign in to comment.