Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: getnikola/nikola
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 62609d7113fc
Choose a base ref
...
head repository: getnikola/nikola
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7ba2665ada69
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jul 1, 2015

  1. response has to be bytes

    ralsina committed Jul 1, 2015

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    infinisil Silvan Mosberger
    Copy the full SHA
    13a4923 View commit details
  2. Fix #1830

    ralsina committed Jul 1, 2015
    Copy the full SHA
    7ba2665 View commit details
Showing with 11 additions and 9 deletions.
  1. +1 −0 CHANGES.txt
  2. +10 −9 nikola/plugins/command/auto/__init__.py
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ Features
Bugfixes
--------

* Nikola auto was broken in python 3 (Issue #1830)
* Read configuration when importing into an existing site (Issue #1823)
* Don’t crash on non-UTF-8 files during sitemap generation (Issue #1842)
* Unnecessary rebuilds of yearly archives (Issue #1833)
19 changes: 10 additions & 9 deletions nikola/plugins/command/auto/__init__.py
Original file line number Diff line number Diff line change
@@ -243,23 +243,24 @@ def serve_static(self, environ, start_response):
f_path = os.path.join(f_path, self.site.config['INDEX_FILE'])

if p_uri.path == '/robots.txt':
start_response('200 OK', [('Content-type', 'txt/plain')])
return '''User-Agent: *\nDisallow: /\n'''
start_response('200 OK', [('Content-type', 'text/plain')])
return ['User-Agent: *\nDisallow: /\n']
elif os.path.isfile(f_path):
with open(f_path) as fd:
with open(f_path, 'rb') as fd:
start_response('200 OK', [('Content-type', mimetype)])
return self.inject_js(mimetype, fd.read())
return [self.inject_js(mimetype, fd.read())]
elif p_uri.path == '/livereload.js':
with open(LRJS_PATH) as fd:
with open(LRJS_PATH, 'rb') as fd:
start_response('200 OK', [('Content-type', mimetype)])
return self.inject_js(mimetype, fd.read())
return [self.inject_js(mimetype, fd.read())]
start_response('404 ERR', [])
return self.inject_js('text/html', ERROR_N.format(404).format(uri))
return [self.inject_js('text/html', ERROR_N.format(404).format(uri))]

def inject_js(self, mimetype, data):
"""Inject livereload.js in HTML files."""
if mimetype == 'text/html':
data = re.sub('</head>', self.snippet, data, 1, re.IGNORECASE)
data = re.sub('</head>', self.snippet, data.decode('utf8'), 1, re.IGNORECASE)
data = data.encode('utf8')
return data


@@ -275,7 +276,7 @@ def __init__(self, *a, **kw):
super(LRSocket, self).__init__(*a, **kw)

def received_message(self, message):
message = json.loads(message.data)
message = json.loads(message.data.decode('utf8'))
self.logger.info('<--- {0}'.format(message))
response = None
if message['command'] == 'hello': # Handshake