Skip to content

Commit

Permalink
merged master
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Mar 2, 2016
2 parents 041b19d + 6c30cd6 commit 17c9775
Show file tree
Hide file tree
Showing 22 changed files with 96 additions and 31 deletions.
17 changes: 16 additions & 1 deletion CHANGES.txt
@@ -1,12 +1,26 @@
New in master
=============
============

Features
--------

* New Oembed-based media shortcode (Issue #2170)
* New Pygal-based chart shortcode (Issue #2170)

New in v7.7.6
=============

Features
--------

* Add ``FRONT_INDEX_HEADER`` setting to allow adding greeting notices
to the main index page (Issue #2249)

Bugfixes
--------

* Make Jupyter posts build (Issues #2248, #2252)

New in v7.7.5
=============

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

Expand Down
2 changes: 1 addition & 1 deletion docs/extending.txt
Expand Up @@ -9,7 +9,7 @@
Extending Nikola
================

:Version: 7.7.5
:Version: v7.7.6
:Author: Roberto Alsina <ralsina@netmanagers.com.ar>

.. class:: alert alert-info pull-right
Expand Down
Binary file modified docs/man/nikola.1.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/man/nikola.rst
Expand Up @@ -6,7 +6,7 @@ Nikola
A Static Site and Blog Generator
--------------------------------

:Version: Nikola v7.7.5
:Version: Nikola vv7.7.6
:Manual section: 1
:Manual group: User Commands

Expand Down
7 changes: 4 additions & 3 deletions docs/manual.txt
Expand Up @@ -9,7 +9,7 @@
The Nikola Handbook
===================

:Version: 7.7.5
:Version: v7.7.6

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

Expand Down Expand Up @@ -1409,13 +1409,14 @@ The currently available filters are:
.. sidebar:: Creating your own filters

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

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

.. code-block:: python

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

Expand Down
2 changes: 1 addition & 1 deletion docs/path_handlers.txt
Expand Up @@ -204,7 +204,7 @@ slug

Example:

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


tag
Expand Down
2 changes: 1 addition & 1 deletion docs/social_buttons.txt
Expand Up @@ -9,7 +9,7 @@
Using Alternative Social Buttons with Nikola
============================================

:Version: 7.7.5
:Version: v7.7.6

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

Expand Down
4 changes: 2 additions & 2 deletions docs/sphinx/conf.py
Expand Up @@ -54,9 +54,9 @@
# built documents.
#
# The short X.Y version.
version = '7.7.5'
version = 'v7.7.6'
# The full version, including alpha/beta/rc tags.
release = '7.7.5'
release = 'v7.7.6'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion docs/theming.txt
Expand Up @@ -9,7 +9,7 @@
Theming Nikola
==============

:Version: 7.7.5
:Version: v7.7.6
:Author: Roberto Alsina <ralsina@netmanagers.com.ar>

.. class:: alert alert-info pull-right
Expand Down
2 changes: 1 addition & 1 deletion nikola/__init__.py
Expand Up @@ -29,7 +29,7 @@
from __future__ import absolute_import
import os

__version__ = "7.7.5"
__version__ = "v7.7.6"
DEBUG = bool(os.getenv('NIKOLA_DEBUG'))

from .nikola import Nikola # NOQA
Expand Down
11 changes: 11 additions & 0 deletions nikola/conf.py.in
Expand Up @@ -391,6 +391,12 @@ HIDDEN_AUTHORS = ['Guest']
# output / TRANSLATION[lang] / INDEX_PATH / index-*.html
# INDEX_PATH = ""

# Optional HTML that displayed on “main” blog index.html files.
# May be used for a greeting. (translatable)
FRONT_INDEX_HEADER = {
DEFAULT_LANG: ''
}

# Create per-month archives instead of per-year
# CREATE_MONTHLY_ARCHIVE = False
# Create one large archive instead of per-year
Expand Down Expand Up @@ -562,6 +568,11 @@ GITHUB_COMMIT_SOURCE = True
#
# If set to False, it will sort by filename instead. Defaults to True
# GALLERY_SORT_BY_DATE = True

# If set to True, EXIF data will be copied when an image is thumbnailed or
# resized.
# PRESERVE_EXIF_DATA = False

#
# Folders containing images to be used in normal posts or pages. Images will be
# scaled down according to IMAGE_THUMBNAIL_SIZE and MAX_IMAGE_SIZE options, but
Expand Down
3 changes: 3 additions & 0 deletions nikola/data/themes/base-jinja/templates/index.tmpl
Expand Up @@ -12,6 +12,9 @@

{% block content %}
{% block content_header %}{% endblock %}
{% if 'main_index' in pagekind %}
{{ front_index_header }}
{% endif %}
<div class="postindex">
{% for post in posts %}
<article class="h-entry post-{{ post.meta('type') }}">
Expand Down
3 changes: 3 additions & 0 deletions nikola/data/themes/base/templates/index.tmpl
Expand Up @@ -12,6 +12,9 @@

<%block name="content">
<%block name="content_header"></%block>
% if 'main_index' in pagekind:
${front_index_header}
% endif
<div class="postindex">
% for post in posts:
<article class="h-entry post-${post.meta('type')}">
Expand Down
8 changes: 6 additions & 2 deletions nikola/image_processing.py
Expand Up @@ -52,7 +52,7 @@ class ImageProcessor(object):

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

def resize_image(self, src, dst, max_size, bigger_panoramas=True):
def resize_image(self, src, dst, max_size, bigger_panoramas=True, preserve_exif_data=False):
"""Make a copy of the image in the requested size."""
if not Image or os.path.splitext(src)[1] in ['.svg', '.svgz']:
self.resize_svg(src, dst, max_size, bigger_panoramas)
Expand All @@ -70,6 +70,7 @@ def resize_image(self, src, dst, max_size, bigger_panoramas=True):
exif = im._getexif()
except Exception:
exif = None
_exif = im.info.get('exif')
if exif is not None:
for tag, value in list(exif.items()):
decoded = ExifTags.TAGS.get(tag, tag)
Expand All @@ -84,7 +85,10 @@ def resize_image(self, src, dst, max_size, bigger_panoramas=True):
break
try:
im.thumbnail(size, Image.ANTIALIAS)
im.save(dst)
if _exif is not None and preserve_exif_data:
im.save(dst, exif=_exif)
else:
im.save(dst)
except Exception as e:
self.logger.warn("Can't thumbnail {0}, using original "
"image as thumbnail ({1})".format(src, e))
Expand Down
7 changes: 6 additions & 1 deletion nikola/nikola.py
Expand Up @@ -412,6 +412,7 @@ def __init__(self, **config):
'FILES_FOLDERS': {'files': ''},
'FILTERS': {},
'FORCE_ISO8601': False,
'FRONT_INDEX_HEADER': '',
'GALLERY_FOLDERS': {'galleries': 'galleries'},
'GALLERY_SORT_BY_DATE': True,
'GLOBAL_CONTEXT_FILLER': [],
Expand Down Expand Up @@ -454,6 +455,7 @@ def __init__(self, **config):
'POSTS_SECTION_FROM_META': False,
'POSTS_SECTION_NAME': "",
'POSTS_SECTION_TITLE': "{name}",
'PRESERVE_EXIF_DATA': False,
'PAGES': (("stories/*.txt", "stories", "story.tmpl"),),
'PANDOC_OPTIONS': [],
'PRETTY_URLS': False,
Expand Down Expand Up @@ -554,6 +556,7 @@ def __init__(self, **config):
'BODY_END',
'EXTRA_HEAD_DATA',
'NAVIGATION_LINKS',
'FRONT_INDEX_HEADER',
'INDEX_READ_MORE_LINK',
'FEED_READ_MORE_LINK',
'INDEXES_TITLE',
Expand Down Expand Up @@ -587,6 +590,7 @@ def __init__(self, **config):
'posts_section_descriptions',
'posts_section_name',
'posts_section_title',
'front_index_header',
)
# WARNING: navigation_links SHOULD NOT be added to the list above.
# Themes ask for [lang] there and we should provide it.
Expand Down Expand Up @@ -954,6 +958,7 @@ def _set_global_context(self):
self._GLOBAL_CONTEXT['show_blog_title'] = self.config.get('SHOW_BLOG_TITLE')
self._GLOBAL_CONTEXT['logo_url'] = self.config.get('LOGO_URL')
self._GLOBAL_CONTEXT['blog_description'] = self.config.get('BLOG_DESCRIPTION')
self._GLOBAL_CONTEXT['front_index_header'] = self.config.get('FRONT_INDEX_HEADER')
self._GLOBAL_CONTEXT['color_hsl_adjust_hex'] = utils.color_hsl_adjust_hex
self._GLOBAL_CONTEXT['colorize_str_from_base_color'] = utils.colorize_str_from_base_color

Expand Down Expand Up @@ -1508,7 +1513,7 @@ def slug_path(self, name, lang):
Example:
links://slug/yellow-camaro => /posts/cars/awful/yellow-camaro/index.html
link://slug/yellow-camaro => /posts/cars/awful/yellow-camaro/index.html
"""
results = [p for p in self.timeline if p.meta('slug') == name]
if not results:
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/command/check.py
Expand Up @@ -274,7 +274,7 @@ def analyze(self, fname, find_sources=False, check_remote=False):
if self.checked_remote_targets[target] in [301, 308]:
self.logger.warn("Remote link PERMANENTLY redirected in {0}: {1} [Error {2}]".format(filename, target, self.checked_remote_targets[target]))
elif self.checked_remote_targets[target] in [302, 307]:
self.logger.debug("Remote link temporarily redirected in {1}: {2} [HTTP: {3}]".format(filename, target, self.checked_remote_targets[target]))
self.logger.debug("Remote link temporarily redirected in {0}: {1} [HTTP: {2}]".format(filename, target, self.checked_remote_targets[target]))
elif self.checked_remote_targets[target] > 399:
self.logger.error("Broken link in {0}: {1} [Error {2}]".format(filename, target, self.checked_remote_targets[target]))
continue
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/compile/ipynb.py
Expand Up @@ -96,7 +96,7 @@ def compile_html(self, source, dest, is_two_file=True):
with io.open(dest, "w+", encoding="utf8") as out_file:
output = self.compile_html_string(source, is_two_file)
output = apply_shortcodes(output, self.site.shortcode_registry, self.site, source)
out_file.write()
out_file.write(output)

def read_metadata(self, post, file_metadata_regexp=None, unslugify_titles=False, lang=None):
"""Read metadata directly from ipynb file.
Expand Down
33 changes: 27 additions & 6 deletions nikola/plugins/compile/rest/post_list.py
Expand Up @@ -62,7 +62,7 @@ class PostList(Directive):
Post List
=========
:Directive Arguments: None.
:Directive Options: lang, start, stop, reverse, sort, tags, categories, slugs, all, template, id
:Directive Options: lang, start, stop, reverse, sort, tags, categories, slugs, post_type, all, template, id
:Directive Content: None.
The posts appearing in the list can be filtered by options.
Expand Down Expand Up @@ -102,6 +102,10 @@ class PostList(Directive):
Filter posts to show only posts having at least one of the ``slugs``.
Defaults to None.
``post_type`` : string
Show only ``posts``, ``pages`` or ``all``.
Replaces ``all``. Defaults to ``posts``.
``all`` : flag
Shows all posts and pages in the post list.
Defaults to show only posts with set *use_in_feeds*.
Expand All @@ -127,6 +131,7 @@ class PostList(Directive):
'tags': directives.unchanged,
'categories': directives.unchanged,
'slugs': directives.unchanged,
'post_type': directives.unchanged,
'all': directives.flag,
'lang': directives.unchanged,
'template': directives.path,
Expand All @@ -144,20 +149,22 @@ def run(self):
categories = [c.strip().lower() for c in categories.split(',')] if categories else []
slugs = self.options.get('slugs')
slugs = [s.strip() for s in slugs.split(',')] if slugs else []
post_type = self.options.get('post_type')
show_all = self.options.get('all', False)
lang = self.options.get('lang', utils.LocaleBorg().current_lang)
template = self.options.get('template', 'post_list_directive.tmpl')
sort = self.options.get('sort')

output = _do_post_list(start, stop, reverse, tags, categories, slugs, show_all,
lang, template, sort, state=self.state, site=self.site)
output = _do_post_list(start, stop, reverse, tags, categories, slugs, post_type,
show_all, lang, template, sort, state=self.state, site=self.site)
self.state.document.settings.record_dependencies.add("####MAGIC####TIMELINE")
return [nodes.raw('', output, format='html')]


def _do_post_list(start=None, stop=None, reverse=False, tags=None, categories=None,
slugs=None, show_all=False, lang=None, template='post_list_directive.tmpl',
sort=None, id=None, data=None, state=None, site=None):
slugs=None, post_type='post', show_all=False, lang=None,
template='post_list_directive.tmpl', sort=None, id=None,
data=None, state=None, site=None):
if lang is None:
lang = utils.LocaleBorg().current_lang
if site.invariant: # for testing purposes
Expand All @@ -168,11 +175,25 @@ def _do_post_list(start=None, stop=None, reverse=False, tags=None, categories=No
filtered_timeline = []
posts = []
step = -1 if reverse is None else None

# TODO: remove in v8
if show_all is None:
timeline = [p for p in site.timeline]
else:
elif post_type == 'page':
timeline = [p for p in site.timeline if not p.use_in_feeds]
elif post_type == 'all':
timeline = [p for p in site.timeline]
else: # post
timeline = [p for p in site.timeline if p.use_in_feeds]

# TODO: replaces show_all, uncomment in v8
# if post_type == 'page':
# timeline = [p for p in site.timeline if not p.use_in_feeds]
# elif post_type == 'all':
# timeline = [p for p in site.timeline]
# else: # post
# timeline = [p for p in site.timeline if p.use_in_feeds]

if categories:
timeline = [p for p in timeline if p.meta('category', lang=lang).lower() in categories]

Expand Down
5 changes: 3 additions & 2 deletions nikola/plugins/task/galleries.py
Expand Up @@ -86,6 +86,7 @@ def set_site(self, site):
'tzinfo': site.tzinfo,
'comments_in_galleries': site.config['COMMENTS_IN_GALLERIES'],
'generate_rss': site.config['GENERATE_RSS'],
'preserve_exif_data': site.config['PRESERVE_EXIF_DATA'],
}

# Verify that no folder in GALLERY_FOLDERS appears twice
Expand Down Expand Up @@ -473,7 +474,7 @@ def create_target_images(self, img, input_path):
'targets': [thumb_path],
'actions': [
(self.resize_image,
(img, thumb_path, self.kw['thumbnail_size']))
(img, thumb_path, self.kw['thumbnail_size'], False, self.kw['preserve_exif_data']))
],
'clean': True,
'uptodate': [utils.config_changed({
Expand All @@ -488,7 +489,7 @@ def create_target_images(self, img, input_path):
'targets': [orig_dest_path],
'actions': [
(self.resize_image,
(img, orig_dest_path, self.kw['max_image_size']))
(img, orig_dest_path, self.kw['max_image_size'], False, self.kw['preserve_exif_data']))
],
'clean': True,
'uptodate': [utils.config_changed({
Expand Down
5 changes: 3 additions & 2 deletions nikola/plugins/task/scale_images.py
Expand Up @@ -71,8 +71,8 @@ def process_tree(self, src, dst):

def process_image(self, src, dst, thumb):
"""Resize an image."""
self.resize_image(src, dst, self.kw['max_image_size'], False)
self.resize_image(src, thumb, self.kw['image_thumbnail_size'], False)
self.resize_image(src, dst, self.kw['max_image_size'], False, preserve_exif_data=self.kw['preserve_exif_data'])
self.resize_image(src, thumb, self.kw['image_thumbnail_size'], False, preserve_exif_data=self.kw['preserve_exif_data'])

def gen_tasks(self):
"""Copy static files into the output folder."""
Expand All @@ -82,6 +82,7 @@ def gen_tasks(self):
'image_folders': self.site.config['IMAGE_FOLDERS'],
'output_folder': self.site.config['OUTPUT_FOLDER'],
'filters': self.site.config['FILTERS'],
'preserve_exif_data': self.site.config['PRESERVE_EXIF_DATA'],
}

self.image_ext_list = self.image_ext_list_builtin
Expand Down

0 comments on commit 17c9775

Please sign in to comment.