Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2372fef

Browse files
committedMar 9, 2016
merged master
2 parents 4015aee + 6e46b1a commit 2372fef

33 files changed

+313
-123
lines changed
 

‎CHANGES.txt

+31
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,41 @@
11
New in master
22
=============
33

4+
Features
5+
--------
6+
7+
* New ``--one-file`` option to wordpress importer (Issue #2262)
8+
* New Pygal-based chart shortcode (Issue #2170)
9+
* Add ``post_type`` to post-list directive (Issue #2272)
10+
* Use ``sys.executable`` for launching pip in ``plugin`` (Issue #2275)
11+
412
Bugfixes
513
--------
614

15+
* Fix a JSON conversion bug in the WordPress importer (Issue #2264)
16+
* Don’t create download directories when not downloading WordPress
17+
attachments (Issue #2260)
18+
* Don’t display “Good link” messages in ``nikola check -l`` by default,
19+
can be re-enabled with ``-v`` option (Issue #2268)
20+
* Fix a format string in ``nikola check`` (Issue #2267)
21+
* Don't crash wordpress importer when posts are "empty" (Issue #2263)
22+
* Don't put untranslated and nonexistant posts in sitemap (Issue #2289)
723
* Mark as failed tasks when filters fail (Issue #2169)
824

25+
New in v7.7.6
26+
=============
27+
28+
Features
29+
--------
30+
31+
* Add ``FRONT_INDEX_HEADER`` setting to allow adding greeting notices
32+
to the main index page (Issue #2249)
33+
34+
Bugfixes
35+
--------
36+
37+
* Make Jupyter posts build (Issues #2248, #2252)
38+
939
New in v7.7.5
1040
=============
1141

@@ -24,6 +54,7 @@ Features
2454
if ``GITHUB_COMMIT_SOURCE`` is set to True (Issue #2186)
2555
* Hugo-like shortcodes (Issue #1707)
2656
* New Galician translation
57+
* New PRESERVE_EXIF_DATA option to copy EXIF when resizing images (Issue #2204)
2758
* New facilities for data persistence and data caching (Issues #2209 and #2009)
2859
* (internal) allow ``scripts/jinjify.py`` usage with scripts (Issue #2240)
2960

‎docs/extending.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Extending Nikola
1010
================
1111

12-
:Version: 7.7.5
12+
:Version: 7.7.6
1313
:Author: Roberto Alsina <ralsina@netmanagers.com.ar>
1414

1515
.. class:: alert alert-info pull-right

‎docs/man/nikola.1.gz

1 Byte
Binary file not shown.

‎docs/man/nikola.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Nikola
66
A Static Site and Blog Generator
77
--------------------------------
88

9-
:Version: Nikola v7.7.5
9+
:Version: Nikola v7.7.6
1010
:Manual section: 1
1111
:Manual group: User Commands
1212

‎docs/manual.txt

+31-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
The Nikola Handbook
1010
===================
1111

12-
:Version: 7.7.5
12+
:Version: 7.7.6
1313

1414
.. class:: alert alert-info pull-right
1515

@@ -813,28 +813,49 @@ To use them from plugins, please see `Extending Nikola <https://getnikola.com/ex
813813
Using a shortcode
814814
~~~~~~~~~~~~~~~~~
815815

816-
In your content files, a shortcode can be called by using the ``{{% name parameters %}}`` form. Shortcode parameters are space delimited. Parameters with spaces can be quoted (or backslash escaped).
816+
In your content files, a shortcode can be called by using the {{% raw %}}{{% name parameters %}}{{% /raw %}} form. Shortcode parameters are space delimited. Parameters with spaces can be quoted (or backslash escaped).
817817

818818
The first word is always the name of the shortcode. Parameters follow the name. Depending upon how the shortcode is defined, the parameters may be named, positional or both. The format for named parameters models that of HTML with the format name="value".
819819

820820
Some shortcodes use or require closing shortcodes. Like HTML, the opening and closing shortcodes match (name only), the closing being prepended with a slash.
821821

822822
Example of a paired shortcode (note that we don't have a highlight shortcode yet ;-)::
823823

824-
{{% highlight python %}} A bunch of code here {{% /highlight %}}
825-
824+
{{% raw %}}{{% highlight python %}} A bunch of code here {{% /highlight %}}{{% /raw %}}
825+
826826
Built-in shortcodes
827827
~~~~~~~~~~~~~~~~~~~
828828

829829
post-list
830830
Will show a list of posts, see the `Post List directive for details <#post-list>`__
831-
831+
832+
media
833+
Display media embedded from a URL, for example, this will embed a youtube video::
834+
835+
{{% raw %}}{{% media url="https://www.youtube.com/watch?v=Nck6BZga7TQ" %}}{{% /raw %}}
836+
837+
In reStructuredText this shortcode will fail because docutils turns that URL to a link and everything breaks, use the `media directive <#media>`__ instead.
838+
839+
chart
840+
Create charts via PyGal. This is similar to the `chart directive <#chart>`__ except the syntax is adapted to
841+
shortcodes. This is an example::
842+
843+
{{% raw %}}{{% chart Bar title='Browser usage evolution (in %)' %}}
844+
x_labels='["2002","2003","2004","2005","2006","2007","2008","2009","2010","2011","2012"]'%}}
845+
'Firefox', [None, None, 0, 16.6, 25, 31]
846+
'Chrome', [None, None, None, None, None, None]
847+
'IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6]
848+
'Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4]
849+
{{% /chart %}}{{% /raw %}}
850+
851+
In reStructuredText the quoting needed to pass arguments gets insane really fast, use the chart directive
852+
instead (the syntax is nicer anyway)
832853

833854
Template-based shortcodes
834855
~~~~~~~~~~~~~~~~~~~~~~~~~
835856

836857
If you put a template in ``shortcodes/`` called ``mycode.tmpl`` then Nikola will create a shortcode
837-
called ``mycode`` you can use. Any options you pass to the shortcode will be available as variables
858+
called ``mycode`` you can use. Any options you pass to the shortcode will be available as variables
838859
for that template. If you use the shortcode as paired, then the contents between the paired tags will
839860
be available in the ``data`` variable.
840861

@@ -846,7 +867,7 @@ For example, if your ``shortcodes/foo.tmpl`` contains this::
846867

847868
And your post contains this::
848869

849-
{{% foo bar=bla %}}
870+
{{% raw %}}{{% foo bar=bla %}}{{% /raw %}}
850871

851872
Then the output file will contain::
852873

@@ -1388,13 +1409,14 @@ The currently available filters are:
13881409
.. sidebar:: Creating your own filters
13891410

13901411
You can use any program name that works in place as a filter, like ``sed -i``
1391-
and you can use arbitrary python functions as filters, too.
1412+
and you can use arbitrary Python functions as filters, too.
13921413

1393-
If your program doesn't run in-place, then you can use Nikola's runinplace function.
1414+
If your program doesn't run in-place, then you can use Nikola's ``runinplace`` function (from the ``filters`` module).
13941415
For example, this is how the yui_compressor filter is implemented:
13951416

13961417
.. code-block:: python
13971418

1419+
from nikola.filters import runinplace
13981420
def yui_compressor(infile):
13991421
return runinplace(r'yui-compressor --nomunge %1 -o %2', infile)
14001422

‎docs/path_handlers.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
.. slug: path-handlers
33
.. author: The Nikola Team
44

5-
Nikola supports special links with the syntax ``link://kind/name``. Here is
6-
the description for all the supported kinds.
5+
Nikola supports special links with the syntax ``link://kind/name``. In the templates you can also
6+
use ``_link(kind, name)`` Here is the description for all the supported kinds.
77

88
.. class:: dl-horizontal
99

@@ -204,7 +204,7 @@ slug
204204

205205
Example:
206206

207-
links://slug/yellow-camaro => /posts/cars/awful/yellow-camaro/index.html
207+
link://slug/yellow-camaro => /posts/cars/awful/yellow-camaro/index.html
208208

209209

210210
tag

‎docs/social_buttons.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Using Alternative Social Buttons with Nikola
1010
============================================
1111

12-
:Version: 7.7.5
12+
:Version: 7.7.6
1313

1414
.. class:: alert alert-info pull-right
1515

‎docs/sphinx/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@
5454
# built documents.
5555
#
5656
# The short X.Y version.
57-
version = '7.7.5'
57+
version = '7.7.6'
5858
# The full version, including alpha/beta/rc tags.
59-
release = '7.7.5'
59+
release = '7.7.6'
6060

6161
# The language for content autogenerated by Sphinx. Refer to documentation
6262
# for a list of supported languages.

‎docs/theming.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Theming Nikola
1010
==============
1111

12-
:Version: 7.7.5
12+
:Version: 7.7.6
1313
:Author: Roberto Alsina <ralsina@netmanagers.com.ar>
1414

1515
.. class:: alert alert-info pull-right

‎nikola/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from __future__ import absolute_import
3030
import os
3131

32-
__version__ = "7.7.5"
32+
__version__ = "7.7.6"
3333
DEBUG = bool(os.getenv('NIKOLA_DEBUG'))
3434

3535
from .nikola import Nikola # NOQA

‎nikola/conf.py.in

+11
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,12 @@ HIDDEN_AUTHORS = ['Guest']
391391
# output / TRANSLATION[lang] / INDEX_PATH / index-*.html
392392
# INDEX_PATH = ""
393393

394+
# Optional HTML that displayed on “main” blog index.html files.
395+
# May be used for a greeting. (translatable)
396+
FRONT_INDEX_HEADER = {
397+
DEFAULT_LANG: ''
398+
}
399+
394400
# Create per-month archives instead of per-year
395401
# CREATE_MONTHLY_ARCHIVE = False
396402
# Create one large archive instead of per-year
@@ -562,6 +568,11 @@ GITHUB_COMMIT_SOURCE = True
562568
#
563569
# If set to False, it will sort by filename instead. Defaults to True
564570
# GALLERY_SORT_BY_DATE = True
571+
572+
# If set to True, EXIF data will be copied when an image is thumbnailed or
573+
# resized.
574+
# PRESERVE_EXIF_DATA = False
575+
565576
#
566577
# Folders containing images to be used in normal posts or pages. Images will be
567578
# scaled down according to IMAGE_THUMBNAIL_SIZE and MAX_IMAGE_SIZE options, but

‎nikola/data/themes/base-jinja/templates/index.tmpl

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
{% block content %}
1414
{% block content_header %}{% endblock %}
15+
{% if 'main_index' in pagekind %}
16+
{{ front_index_header }}
17+
{% endif %}
1518
<div class="postindex">
1619
{% for post in posts %}
1720
<article class="h-entry post-{{ post.meta('type') }}">

‎nikola/data/themes/base/templates/index.tmpl

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
<%block name="content">
1414
<%block name="content_header"></%block>
15+
% if 'main_index' in pagekind:
16+
${front_index_header}
17+
% endif
1518
<div class="postindex">
1619
% for post in posts:
1720
<article class="h-entry post-${post.meta('type')}">

‎nikola/image_processing.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ImageProcessor(object):
5252

5353
image_ext_list_builtin = ['.jpg', '.png', '.jpeg', '.gif', '.svg', '.bmp', '.tiff']
5454

55-
def resize_image(self, src, dst, max_size, bigger_panoramas=True):
55+
def resize_image(self, src, dst, max_size, bigger_panoramas=True, preserve_exif_data=False):
5656
"""Make a copy of the image in the requested size."""
5757
if not Image or os.path.splitext(src)[1] in ['.svg', '.svgz']:
5858
self.resize_svg(src, dst, max_size, bigger_panoramas)
@@ -70,6 +70,7 @@ def resize_image(self, src, dst, max_size, bigger_panoramas=True):
7070
exif = im._getexif()
7171
except Exception:
7272
exif = None
73+
_exif = im.info.get('exif')
7374
if exif is not None:
7475
for tag, value in list(exif.items()):
7576
decoded = ExifTags.TAGS.get(tag, tag)
@@ -84,7 +85,10 @@ def resize_image(self, src, dst, max_size, bigger_panoramas=True):
8485
break
8586
try:
8687
im.thumbnail(size, Image.ANTIALIAS)
87-
im.save(dst)
88+
if _exif is not None and preserve_exif_data:
89+
im.save(dst, exif=_exif)
90+
else:
91+
im.save(dst)
8892
except Exception as e:
8993
self.logger.warn("Can't thumbnail {0}, using original "
9094
"image as thumbnail ({1})".format(src, e))

‎nikola/nikola.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ def __init__(self, **config):
412412
'FILES_FOLDERS': {'files': ''},
413413
'FILTERS': {},
414414
'FORCE_ISO8601': False,
415+
'FRONT_INDEX_HEADER': '',
415416
'GALLERY_FOLDERS': {'galleries': 'galleries'},
416417
'GALLERY_SORT_BY_DATE': True,
417418
'GLOBAL_CONTEXT_FILLER': [],
@@ -454,6 +455,7 @@ def __init__(self, **config):
454455
'POSTS_SECTION_FROM_META': False,
455456
'POSTS_SECTION_NAME': "",
456457
'POSTS_SECTION_TITLE': "{name}",
458+
'PRESERVE_EXIF_DATA': False,
457459
'PAGES': (("stories/*.txt", "stories", "story.tmpl"),),
458460
'PANDOC_OPTIONS': [],
459461
'PRETTY_URLS': False,
@@ -554,6 +556,7 @@ def __init__(self, **config):
554556
'BODY_END',
555557
'EXTRA_HEAD_DATA',
556558
'NAVIGATION_LINKS',
559+
'FRONT_INDEX_HEADER',
557560
'INDEX_READ_MORE_LINK',
558561
'FEED_READ_MORE_LINK',
559562
'INDEXES_TITLE',
@@ -587,6 +590,7 @@ def __init__(self, **config):
587590
'posts_section_descriptions',
588591
'posts_section_name',
589592
'posts_section_title',
593+
'front_index_header',
590594
)
591595
# WARNING: navigation_links SHOULD NOT be added to the list above.
592596
# Themes ask for [lang] there and we should provide it.
@@ -866,7 +870,7 @@ def init_plugins(self, commands_only=False):
866870
# FIXME TemplateSystem should not be needed
867871
if p[-1].details.get('Nikola', 'PluginCategory') not in {'Command', 'Template'}:
868872
bad_candidates.add(p)
869-
else: # Not commands-only
873+
elif self.configured: # Not commands-only, and configured
870874
# Remove compilers we don't use
871875
if p[-1].name in self.bad_compilers:
872876
bad_candidates.add(p)
@@ -954,6 +958,7 @@ def _set_global_context(self):
954958
self._GLOBAL_CONTEXT['show_blog_title'] = self.config.get('SHOW_BLOG_TITLE')
955959
self._GLOBAL_CONTEXT['logo_url'] = self.config.get('LOGO_URL')
956960
self._GLOBAL_CONTEXT['blog_description'] = self.config.get('BLOG_DESCRIPTION')
961+
self._GLOBAL_CONTEXT['front_index_header'] = self.config.get('FRONT_INDEX_HEADER')
957962
self._GLOBAL_CONTEXT['color_hsl_adjust_hex'] = utils.color_hsl_adjust_hex
958963
self._GLOBAL_CONTEXT['colorize_str_from_base_color'] = utils.colorize_str_from_base_color
959964

@@ -1331,7 +1336,7 @@ def render_shortcode(t_data=template_data, **kw):
13311336
def register_shortcode(self, name, f):
13321337
"""Register function f to handle shortcode "name"."""
13331338
if name in self.shortcode_registry:
1334-
utils.LOGGER.warn('Shortcode name conflict: %s', name)
1339+
utils.LOGGER.warn('Shortcode name conflict: {}', name)
13351340
return
13361341
self.shortcode_registry[name] = f
13371342

@@ -1508,7 +1513,7 @@ def slug_path(self, name, lang):
15081513
15091514
Example:
15101515
1511-
links://slug/yellow-camaro => /posts/cars/awful/yellow-camaro/index.html
1516+
link://slug/yellow-camaro => /posts/cars/awful/yellow-camaro/index.html
15121517
"""
15131518
results = [p for p in self.timeline if p.meta('slug') == name]
15141519
if not results:

‎nikola/plugins/basic_import.py

+24-3
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,37 @@ def transform_content(cls, content):
127127
def write_content(cls, filename, content, rewrite_html=True):
128128
"""Write content to file."""
129129
if rewrite_html:
130-
doc = html.document_fromstring(content)
131-
doc.rewrite_links(replacer)
132-
content = html.tostring(doc, encoding='utf8')
130+
try:
131+
doc = html.document_fromstring(content)
132+
doc.rewrite_links(replacer)
133+
content = html.tostring(doc, encoding='utf8')
134+
except etree.ParserError:
135+
content = content.encode('utf-8')
133136
else:
134137
content = content.encode('utf-8')
135138

136139
utils.makedirs(os.path.dirname(filename))
137140
with open(filename, "wb+") as fd:
138141
fd.write(content)
139142

143+
@classmethod
144+
def write_post(cls, filename, content, headers, compiler, rewrite_html=True):
145+
"""Ask the specified compiler to write the post to disk."""
146+
if rewrite_html:
147+
try:
148+
doc = html.document_fromstring(content)
149+
doc.rewrite_links(replacer)
150+
content = html.tostring(doc, encoding='utf8')
151+
except etree.ParserError:
152+
pass
153+
if isinstance(content, utils.bytes_str):
154+
content = content.decode('utf-8')
155+
compiler.create_post(
156+
filename,
157+
content=content,
158+
onefile=True,
159+
**headers)
160+
140161
@staticmethod
141162
def write_metadata(filename, title, slug, post_date, description, tags, **kwargs):
142163
"""Write metadata to meta file."""

0 commit comments

Comments
 (0)
Please sign in to comment.