Skip to content

Commit

Permalink
Merge pull request #2544 from getnikola/per_post_url_type
Browse files Browse the repository at this point in the history
Allow overriding URL_TYPE via meta
  • Loading branch information
Kwpolska committed Oct 23, 2016
2 parents fd273fd + 836d805 commit 926bcc8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Bugfixes
Features
--------

* Allow posts to set custom ``URL_TYPE`` by using the ``url_type``
meta tag (useful for HTML fragments inserted using JavaScript)
* Plugins can depend on other plugins being installed (Issue #2533)
* The destination folder in ``POSTS`` and ``PAGES`` can now be
translated (Issue #2116)
Expand Down
3 changes: 2 additions & 1 deletion nikola/nikola.py
Original file line number Diff line number Diff line change
Expand Up @@ -2086,7 +2086,8 @@ def generic_page_renderer(self, lang, post, filters, context=None):
uptodate_deps=uptodate_deps,
context=context,
context_deps_remove=['post'],
post_deps_dict=deps_dict)
post_deps_dict=deps_dict,
url_type=post.url_type)

def generic_post_list_renderer(self, lang, posts, output_name, template_name, filters, extra_context):
"""Render pages with lists of posts."""
Expand Down
4 changes: 4 additions & 0 deletions nikola/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ def __init__(
self.use_in_feeds = use_in_feeds and not is_draft and not is_private \
and not self.publish_later

# Allow overriding URL_TYPE via meta
# The check is done here so meta dicts won’t change inside of
# generic_post_rendere
self.url_type = self.meta('url_type') or None
# Register potential extra dependencies
self.compiler.register_extra_dependencies(self)

Expand Down
21 changes: 9 additions & 12 deletions tests/test_rss_feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
from __future__ import unicode_literals, absolute_import

import os
import sys


from collections import defaultdict
from io import StringIO
import os
import re
import unittest

Expand Down Expand Up @@ -50,15 +47,15 @@ def setUp(self):

with mock.patch('nikola.post.get_meta',
mock.Mock(return_value=(
({'title': 'post title',
'slug': 'awesome_article',
'date': '2012-10-01 22:41',
'author': None,
'tags': 'tags',
'link': 'link',
'description': 'description',
'enclosure': 'http://www.example.org/foo.mp3',
'enclosure_length': '5'},
(defaultdict(str, {'title': 'post title',
'slug': 'awesome_article',
'date': '2012-10-01 22:41',
'author': None,
'tags': 'tags',
'link': 'link',
'description': 'description',
'enclosure': 'http://www.example.org/foo.mp3',
'enclosure_length': '5'}),
True)
))):
with mock.patch('nikola.nikola.utils.os.path.isdir',
Expand Down

0 comments on commit 926bcc8

Please sign in to comment.