Skip to content

Commit 39b7d31

Browse files
committedMay 19, 2015
merged master
2 parents 12a23ef + abdc591 commit 39b7d31

File tree

13 files changed

+47
-23
lines changed

13 files changed

+47
-23
lines changed
 

‎CHANGES.txt

+3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ New in master
44
Features
55
--------
66

7+
* Cleaner formatting of HTML output
78
* Allowing category hierarchies via new option CATEGORY_ALLOW_HIERARCHIES
89
(Issue #1520)
910

1011
Bugfixes
1112
--------
1213

1314
* The post-list directive only triggers rebuilds if timeline changes (Issue #1688)
15+
* Don’t check the same remote URL more than once (Issue #1732)
16+
* All remotely checked links resulted in incorrect warnings (`nikola check -lr`)
1417
* Exclude `<meta content="noindex" name="robots">` from sitemaps
1518
* new_post paths are now relative to CWD (Issue #1325)
1619

‎docs/extending.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,11 @@ Currently Nikola emits the following signals:
407407
When all the configuration file is processed. Note that plugins are activated before this is emitted.
408408
``scanned``
409409
After posts are scanned.
410-
``new_post``
411-
When a new post is created, using the ``nikola new_post`` command. The signal
410+
``new_post`` / ``new_page``
411+
When a new post is created, using the ``nikola new_post``/``nikola new_page`` commands. The signal
412412
data contains the path of the file, and the metadata file (if there is one).
413+
``existing_post`` / ``existing_page``
414+
When a new post fails to be created due to a title conflict. Contains the same data as ``new_post``.
413415
``deployed``
414416
When the ``nikola deploy`` command is run, and there is at least one new
415417
entry/post since ``last_deploy``. The signal data is of the form::

‎nikola/data/themes/bootstrap-jinja/templates/base_helper.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ lang="{{ lang }}">
6969
{% macro late_load_js() %}
7070
{% if use_bundles %}
7171
{% if use_cdn %}
72-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
72+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
7373
<script src="//maxcdn.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
7474
<script src="/assets/js/all.js"></script>
7575
{% else %}
7676
<script src="/assets/js/all-nocdn.js"></script>
7777
{% endif %}
7878
{% else %}
7979
{% if use_cdn %}
80-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
80+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
8181
<script src="//maxcdn.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
8282
{% else %}
8383
<script src="/assets/js/jquery.min.js"></script>

‎nikola/data/themes/bootstrap/templates/base_helper.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ lang="${lang}">
6969
<%def name="late_load_js()">
7070
%if use_bundles:
7171
%if use_cdn:
72-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
72+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
7373
<script src="//maxcdn.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
7474
<script src="/assets/js/all.js"></script>
7575
%else:
7676
<script src="/assets/js/all-nocdn.js"></script>
7777
%endif
7878
%else:
7979
%if use_cdn:
80-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
80+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
8181
<script src="//maxcdn.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
8282
%else:
8383
<script src="/assets/js/jquery.min.js"></script>

‎nikola/data/themes/bootstrap3-jinja/templates/base_helper.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ lang="{{ lang }}">
6868
{% macro late_load_js() %}
6969
{% if use_bundles %}
7070
{% if use_cdn %}
71-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
71+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
7272
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
7373
<script src="/assets/js/all.js"></script>
7474
{% else %}
7575
<script src="/assets/js/all-nocdn.js"></script>
7676
{% endif %}
7777
{% else %}
7878
{% if use_cdn %}
79-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
79+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
8080
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
8181
{% else %}
8282
<script src="/assets/js/jquery.min.js"></script>

‎nikola/data/themes/bootstrap3/templates/base_helper.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ lang="${lang}">
6868
<%def name="late_load_js()">
6969
%if use_bundles:
7070
%if use_cdn:
71-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
71+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
7272
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
7373
<script src="/assets/js/all.js"></script>
7474
%else:
7575
<script src="/assets/js/all-nocdn.js"></script>
7676
%endif
7777
%else:
7878
%if use_cdn:
79-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
79+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
8080
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
8181
%else:
8282
<script src="/assets/js/jquery.min.js"></script>

‎nikola/nikola.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,8 @@ def render_template(self, template_name, output_name, context):
969969
src = "/".join(src.split(os.sep))
970970

971971
utils.makedirs(os.path.dirname(output_name))
972-
doc = lxml.html.document_fromstring(data)
972+
parser = lxml.html.HTMLParser(remove_blank_text=True)
973+
doc = lxml.html.document_fromstring(data, parser)
973974
doc.rewrite_links(lambda dst: self.url_replacer(src, dst, context['lang']))
974975
data = b'<!DOCTYPE html>\n' + lxml.html.tostring(doc, encoding='utf8', method='html', pretty_print=True)
975976
with open(output_name, "wb+") as post_file:

‎nikola/plugins/command/check.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ def _execute(self, options, args):
173173
sys.exit(1)
174174

175175
existing_targets = set([])
176+
checked_remote_targets = {}
176177

177178
def analyze(self, task, find_sources=False, check_remote=False):
178179
rv = False
@@ -215,13 +216,24 @@ def analyze(self, task, find_sources=False, check_remote=False):
215216
((parsed.scheme or target.startswith('//')) and url_type in ('rel_path', 'full_path')):
216217
if not check_remote or parsed.scheme not in ["http", "https"]:
217218
continue
218-
if parsed.netloc == base_url.netloc:
219+
if parsed.netloc == base_url.netloc: # absolute URL to self.site
220+
continue
221+
if target in self.checked_remote_targets: # already checked this exact target
222+
if self.checked_remote_targets[target] > 399:
223+
self.logger.warn("Broken link in {0}: {1} [Error {2}]".format(filename, target, self.checked_remote_targets[target]))
219224
continue
220225
# Check the remote link works
221-
resp = requests.head(target)
226+
req_headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 (Nikola)'} # I’m a real boy!
227+
resp = requests.head(target, headers=req_headers)
228+
self.checked_remote_targets[target] = resp.status_code
222229
if resp.status_code > 399: # Error
223230
self.logger.warn("Broken link in {0}: {1} [Error {2}]".format(filename, target, resp.status_code))
224231
continue
232+
elif resp.status_code <= 399: # The address leads *somewhere* that is not an error
233+
self.logger.debug("Successfully checked remote link in {0}: {1} [HTTP: {2}]".format(filename, target, resp.status_code))
234+
continue
235+
self.logger.warn("Could not check remote link in {0}: {1} [Unknown problem]".format(filename, target))
236+
continue
225237

226238
if url_type == 'rel_path':
227239
target_filename = os.path.abspath(

‎nikola/plugins/command/new_post.py

+7
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,13 @@ def _execute(self, options, args):
349349

350350
if (not onefile and os.path.isfile(meta_path)) or \
351351
os.path.isfile(txt_path):
352+
353+
# Emit an event when a post exists
354+
event = dict(path=txt_path)
355+
if not onefile: # write metadata file
356+
event['meta_path'] = meta_path
357+
signal('existing_' + content_type).send(self, **event)
358+
352359
LOGGER.error("The title already exists!")
353360
exit(8)
354361

‎nikola/plugins/compile/rest/post_list.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727

2828
import os
2929
import uuid
30+
import natsort
3031

3132
from docutils import nodes
3233
from docutils.parsers.rst import Directive, directives
3334

34-
from natsort import natsorted
35-
3635
from nikola import utils
3736
from nikola.plugin_categories import RestExtension
3837

@@ -160,7 +159,7 @@ def run(self):
160159
filtered_timeline.append(post)
161160

162161
if sort:
163-
filtered_timeline = natsorted(filtered_timeline, key=lambda post: post.meta[lang][sort])
162+
filtered_timeline = natsort.natsorted(filtered_timeline, key=lambda post: post.meta[lang][sort], alg=natsort.ns.F | natsort.ns.IC)
164163

165164
for post in filtered_timeline[start:stop:step]:
166165
if slugs:

‎nikola/plugins/task/tags.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ def gen_tasks(self):
114114
if slug in categories:
115115
other_category = categories[slug]
116116
utils.LOGGER.error('You have categories that are too similar: {0} and {1}'.format(category, other_category))
117-
utils.LOGGER.error('Category {0} is used in: {1}'.format(category, ', '.join([p.source_path for p in self.posts_per_category[category]])))
118-
utils.LOGGER.error('Category {0} is used in: {1}'.format(other_category, ', '.join([p.source_path for p in self.posts_per_category[other_category]])))
117+
utils.LOGGER.error('Category {0} is used in: {1}'.format(category, ', '.join([p.source_path for p in self.site.posts_per_category[category]])))
118+
utils.LOGGER.error('Category {0} is used in: {1}'.format(other_category, ', '.join([p.source_path for p in self.site.posts_per_category[other_category]])))
119119
sys.exit(1)
120120
categories[slug] = category
121121

@@ -270,14 +270,14 @@ def page_path(i, displayed_i, num_pages, force_addition, extension=None):
270270
return utils.adjust_name_for_index_path(self.site.path(kind + feed, tag, lang), i, displayed_i, lang, self.site, force_addition, extension)
271271

272272
context_source = {}
273+
title = self._get_title(tag, is_category)
273274
if kw["generate_rss"]:
274275
# On a tag page, the feeds include the tag's feeds
275276
rss_link = ("""<link rel="alternate" type="application/rss+xml" """
276277
"""type="application/rss+xml" title="RSS for tag """
277278
"""{0} ({1})" href="{2}">""".format(
278-
tag, lang, self.site.link(kind + "_rss", tag, lang)))
279+
title, lang, self.site.link(kind + "_rss", tag, lang)))
279280
context_source['rss_link'] = rss_link
280-
title = self._get_title(tag, is_category)
281281
if is_category:
282282
context_source["category"] = tag
283283
context_source["category_path"] = self.site.parse_category_name(tag)

‎requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ docutils>=0.12
66
mako>=1.0.0
77
unidecode>=0.04.16
88
lxml>=3.3.5
9-
yapsy>=1.10.423
9+
yapsy==1.10.423
1010
PyRSS2Gen>=1.1
1111
logbook>=0.7.0
1212
blinker>=1.3

‎scripts/jinjify.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ def jinjify(in_theme, out_theme):
7878
parent = mappings[child]
7979

8080
with io.open(os.path.join(out_theme, "parent"), "w+", encoding='utf-8') as outf:
81-
outf.write(parent + '\n')
81+
outf.write(unicode(parent) + u'\n')
8282

8383
with io.open(os.path.join(out_theme, "engine"), "w+", encoding='utf-8') as outf:
84-
outf.write("jinja\n")
84+
outf.write(u"jinja\n")
8585

8686
# Copy assets
8787
# shutil.rmtree(os.path.join(out_theme, "assets"))

0 commit comments

Comments
 (0)
Please sign in to comment.