Skip to content

Commit

Permalink
docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
da2x committed Aug 5, 2015
1 parent 90f2992 commit 25b3f94
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nikola/plugins/command/auto/__init__.py
Expand Up @@ -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

Expand Down

0 comments on commit 25b3f94

Please sign in to comment.