Skip to content

Commit

Permalink
Merge branch 'master' into fixing-post-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Nov 20, 2016
2 parents 8899b24 + 0ecaff5 commit 8502aa7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
4 changes: 3 additions & 1 deletion CHANGES.txt
Expand Up @@ -4,8 +4,10 @@ New in master
Bugfixes
--------

* Make "data" from global context available to templated shortcodes (Issue #2488)
* Make ``data`` from global context available to templated shortcodes
as ``global_data`` (Issue #2488)
* Don't crash if plugins is a file (Issue #2539)
* Don't mangle bare ``#`` links (Issue #2553)

Features
--------
Expand Down
9 changes: 6 additions & 3 deletions docs/manual.txt
Expand Up @@ -1086,9 +1086,10 @@ In that case, the template engine used will be your theme's and the arguments yo
as well as the global context from your ``conf.py``, are available to the template you
are creating.

You can use anything defined in your confguration's ``GLOBAL_CONTEXT`` as variables in your
shortcode template, with a caveat: Because of an unfortunate implementation detail, data is called
"global_data" when used in a shortcode.
You can use anything defined in your confguration's ``GLOBAL_CONTEXT`` as
variables in your shortcode template, with a caveat: Because of an unfortunate
implementation detail (a name conflict), ``data`` is called ``global_data``
when used in a shortcode.

The Global Context and Data files
---------------------------------
Expand Down Expand Up @@ -1119,6 +1120,8 @@ JSON/YAML/TOML files and Nikola generates a large page with data from all data
files. (This is especially useful with some automatic rebuild feature, like
those documented in `Deployment`_)

Data files are also available as ``global_data``, to avoid name conflicts in
shortcodes. (``global_data`` works everywhere.)

Redirections
------------
Expand Down
11 changes: 8 additions & 3 deletions nikola/nikola.py
Expand Up @@ -1165,6 +1165,8 @@ def _set_global_context_from_data(self):
data = utils.load_data(fname)
key = os.path.splitext(fname.split(os.sep, 1)[1])[0]
self._GLOBAL_CONTEXT['data'][key] = data
# Offer global_data as an alias for data (Issue #2488)
self._GLOBAL_CONTEXT['global_data'] = self._GLOBAL_CONTEXT['data']

def _activate_plugins_of_category(self, category):
"""Activate all the plugins of a given category and return them."""
Expand Down Expand Up @@ -1379,6 +1381,10 @@ def url_replacer(self, src, dst, lang=None, url_type=None):
lang is used for language-sensitive URLs in link://
url_type is used to determine final link appearance, defaulting to URL_TYPE from config
"""
# Avoid mangling links within the page
if dst.startswith('#'):
return dst

parsed_src = urlsplit(src)
src_elems = parsed_src.path.split('/')[1:]
dst_url = urlparse(dst)
Expand Down Expand Up @@ -1492,13 +1498,12 @@ def _make_renderfunc(self, t_data, fname=None):
Global context keys are made available as part of the context,
respecting locale.
As a special quirk, the "data" key from global_context is made
available as "global_data" because of name clobbering.
As a special quirk, the "data" key from global_context is
available only as "global_data" because of name clobbering.
"""
def render_shortcode(*args, **kw):
context = self.GLOBAL_CONTEXT.copy()
context['global_data'] = context['data']
context.update(kw)
context['_args'] = args
context['lang'] = utils.LocaleBorg().current_lang
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/command/new_post.py
Expand Up @@ -262,7 +262,7 @@ def _execute(self, options, args):
self.site.config['post_pages'])

if content_format not in compiler_names:
LOGGER.error("Unknown {0} format {1}, maybe you need to install a plugin?".format(content_type, content_format))
LOGGER.error("Unknown {0} format {1}, maybe you need to install a plugin or enable an existing one?".format(content_type, content_format))
self.print_compilers()
return
compiler_plugin = self.site.plugin_manager.getPluginByName(
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/task/py3_switch.py
Expand Up @@ -36,12 +36,12 @@
from nikola.utils import get_logger, STDERR_HANDLER
from nikola.plugin_categories import LateTask

PY2_AND_NO_PY3_WARNING = """Nikola is going to deprecate Python 2 support in 2016. Your current
PY2_AND_NO_PY3_WARNING = """Nikola is going to deprecate Python 2 support in 2016 (or 2017). Your current
version will continue to work, but please consider upgrading to Python 3.
Please check http://bit.ly/1FKEsiX for details.
"""
PY2_WARNING = """Nikola is going to deprecate Python 2 support in 2016. You already have Python 3
PY2_WARNING = """Nikola is going to deprecate Python 2 support in 2016 (or 2017). You already have Python 3
available in your system. Why not switch?
Please check http://bit.ly/1FKEsiX for details.
Expand Down
4 changes: 2 additions & 2 deletions requirements-tests.txt
@@ -1,8 +1,8 @@
-r requirements-extras.txt
mock==2.0.0
coverage==4.2
pytest==3.0.3
pytest==3.0.4
pytest-cov==2.4.0
freezegun==0.3.7
freezegun==0.3.8
python-coveralls==2.9.0
colorama>=0.3.4

0 comments on commit 8502aa7

Please sign in to comment.