Skip to content
Permalink
Browse files

docstrings

  • Loading branch information...
da2x committed Aug 5, 2015
1 parent 90f2992 commit 25b3f94ab7b948308c6e963dc4f0d6754e00b283
Showing with 3 additions and 3 deletions.
  1. +3 −3 nikola/plugins/command/auto/__init__.py
@@ -309,22 +309,22 @@ def serve_static(self, environ, start_response):
start_response('404 ERR', [])
return [self.file_filter('text/html', ERROR_N.format(404).format(uri).encode('utf-8'))]

"""Apply necessary changes to document before serving."""
def file_filter(self, mimetype, data):
"""Apply necessary changes to document before serving."""
if mimetype == 'text/html':
data = data.decode('utf8')
data = self.remove_base_tag(data)
data = self.inject_js(data)
data = data.encode('utf8')
return data

"""Inject livereload.js."""
def inject_js(self, data):
"""Inject livereload.js."""
data = re.sub('</head>', self.snippet, data, 1, re.IGNORECASE)
return data

"""Comment out any <base> to allow local resolution of relative URLs."""
def remove_base_tag(self, data):
"""Comment out any <base> to allow local resolution of relative URLs."""
data = re.sub(r'<base\s([^>]*)>', '<!--base \g<1>-->', data, re.IGNORECASE)
return data

0 comments on commit 25b3f94

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