Skip to content

Commit

Permalink
Merge branch 'master' into persistent-state
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Jan 25, 2016
2 parents 9b964c1 + f915421 commit 0f174e6
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Expand Up @@ -15,6 +15,9 @@ Features
Bugfixes
--------

* Don’t attempt to create redirects for URLs with query strings in
WordPress imports if the site is in a subdirectory (Issue #2224)
* Avoid some random file rebuilds (Issue #2220)
* Honor ``MATHJAX_CONFIG``
* Display tags and archives in a unified format, with the date on the
left, instead of a misplaced dash in tags (Issue #2212)
Expand Down
14 changes: 10 additions & 4 deletions docs/manual.txt
Expand Up @@ -2146,7 +2146,13 @@ Nikola is released under the `MIT license <https://getnikola.com/license.html>`_
components shipped along with Nikola, or required by it are released under
other licenses.

If you are not familiar with free software licensing: In general, you should be able to
do pretty much anything you want, unless you modify Nikola. If you modify it, and share
it with someone else, that someone else should get all your modifications under the same
license you got it.

If you are not familiar with free software licensing, here is a brief
explanation (this is NOT legal advice): In general, you can do pretty much
anything you want — including modifying Nikola, using and redistributing the
original version or the your modified version. However, if you redistribute
Nikola to someone else, either a modified version or the original version, the
full copyright notice and license text must be included in your distribution.
Nikola is provided “as is”, and the Nikola contributors are not liable for any
damage caused by the software. Read the `full license text
<https://getnikola.com/license.html>`_ for details.
8 changes: 5 additions & 3 deletions nikola/plugins/basic_import.py
Expand Up @@ -76,8 +76,11 @@ def get_channel_from_file(cls, filename):
return channel

@staticmethod
def configure_redirections(url_map):
def configure_redirections(url_map, base_dir=''):
"""Configure redirections from an url_map."""
index = base_dir + 'index.html'
if index.startswith('/'):
index = index[1:]
redirections = []
for k, v in url_map.items():
if not k[-1] == '/':
Expand All @@ -86,11 +89,10 @@ def configure_redirections(url_map):
# remove the initial "/" because src is a relative file path
src = (urlparse(k).path + 'index.html')[1:]
dst = (urlparse(v).path)
if src == 'index.html':
if src == index:
utils.LOGGER.warn("Can't do a redirect for: {0!r}".format(k))
else:
redirections.append((src, dst))

return redirections

def generate_base_site(self):
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/command/github_deploy.py
Expand Up @@ -53,7 +53,7 @@ def check_ghp_import_installed():
except OSError:
# req_missing defaults to `python=True` — and it’s meant to be like this.
# `ghp-import` is installed via pip, but the only way to use it is by executing the script it installs.
req_missing(['ghp-import'], 'deploy the site to GitHub Pages')
req_missing(['ghp-import2'], 'deploy the site to GitHub Pages')


class CommandGitHubDeploy(Command):
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/command/import_wordpress.py
Expand Up @@ -334,7 +334,7 @@ def show_info_about_mising_module(modulename):
self.context['TRANSLATIONS'] = format_default_translations_config(
self.extra_languages)
self.context['REDIRECTIONS'] = self.configure_redirections(
self.url_map)
self.url_map, self.base_dir)
if self.timezone:
self.context['TIMEZONE'] = self.timezone
if self.export_categories_as_categories:
Expand Down
2 changes: 2 additions & 0 deletions nikola/plugins/compile/html.py
Expand Up @@ -33,6 +33,7 @@

from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, write_metadata
from nikola.shortcodes import apply_shortcodes


class CompileHtml(PageCompiler):
Expand All @@ -49,6 +50,7 @@ def compile_html(self, source, dest, is_two_file=True):
data = in_file.read()
if not is_two_file:
_, data = self.split_metadata(data)
data = apply_shortcodes(data, self.site.shortcode_registry, self.site, source)
out_file.write(data)
return True

Expand Down
5 changes: 4 additions & 1 deletion nikola/plugins/compile/ipynb.py
Expand Up @@ -62,6 +62,7 @@

from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, req_missing, get_logger, STDERR_HANDLER
from nikola.shortcodes import apply_shortcodes


class CompileIPynb(PageCompiler):
Expand Down Expand Up @@ -93,7 +94,9 @@ def compile_html(self, source, dest, is_two_file=True):
"""Compile source file into HTML and save as dest."""
makedirs(os.path.dirname(dest))
with io.open(dest, "w+", encoding="utf8") as out_file:
out_file.write(self.compile_html_string(source, is_two_file))
output = self.compile_html_string(source, is_two_file)
output = apply_shortcodes(output, self.site.shortcode_registry, self.site, source)
out_file.write()

def read_metadata(self, post, file_metadata_regexp=None, unslugify_titles=False, lang=None):
"""Read metadata directly from ipynb file.
Expand Down
5 changes: 5 additions & 0 deletions nikola/plugins/compile/pandoc.py
Expand Up @@ -37,6 +37,7 @@

from nikola.plugin_categories import PageCompiler
from nikola.utils import req_missing, makedirs, write_metadata
from nikola.shortcodes import apply_shortcodes


class CompilePandoc(PageCompiler):
Expand All @@ -55,6 +56,10 @@ def compile_html(self, source, dest, is_two_file=True):
makedirs(os.path.dirname(dest))
try:
subprocess.check_call(['pandoc', '-o', dest, source] + self.site.config['PANDOC_OPTIONS'])
with open(dest, 'r', encoding='utf-8') as inf:
output = apply_shortcodes(inf.read(), self.site.shortcode_registry, self.site, source)
with open(dest, 'w', encoding='utf-8') as outf:
outf.write(output)
except OSError as e:
if e.strreror == 'No such file or directory':
req_missing(['pandoc'], 'build this site (compile with pandoc)', python=False)
Expand Down
2 changes: 2 additions & 0 deletions nikola/plugins/compile/rest/__init__.py
Expand Up @@ -39,6 +39,7 @@

from nikola.plugin_categories import PageCompiler
from nikola.utils import unicode_str, get_logger, makedirs, write_metadata, STDERR_HANDLER
from nikola.shortcodes import apply_shortcodes


class CompileRest(PageCompiler):
Expand Down Expand Up @@ -97,6 +98,7 @@ def compile_html(self, source, dest, is_two_file=True):
with io.open(source, "r", encoding="utf8") as in_file:
data = in_file.read()
output, error_level, deps = self.compile_html_string(data, source, is_two_file)
output = apply_shortcodes(output, self.site.shortcode_registry, self.site, source)
out_file.write(output)
deps_path = dest + '.dep'
if deps.list:
Expand Down
13 changes: 10 additions & 3 deletions nikola/plugins/task/authors.py
Expand Up @@ -35,6 +35,8 @@
from urllib.parse import urljoin # NOQA
from collections import defaultdict

from blinker import signal

from nikola.plugin_categories import Task
from nikola import utils

Expand All @@ -47,13 +49,20 @@ class RenderAuthors(Task):

def set_site(self, site):
"""Set Nikola site."""
self.generate_author_pages = False
if site.config["ENABLE_AUTHOR_PAGES"]:
site.register_path_handler('author_index', self.author_index_path)
site.register_path_handler('author', self.author_path)
site.register_path_handler('author_atom', self.author_atom_path)
site.register_path_handler('author_rss', self.author_rss_path)
signal('scanned').connect(self.posts_scanned)
return super(RenderAuthors, self).set_site(site)

def posts_scanned(self, event):
"""Called after posts are scanned via signal."""
self.generate_author_pages = self.site.config["ENABLE_AUTHOR_PAGES"] and len(self._posts_per_author()) > 1
self.site.GLOBAL_CONTEXT["author_pages_generated"] = self.generate_author_pages

def gen_tasks(self):
"""Render the author pages and feeds."""
kw = {
Expand Down Expand Up @@ -81,9 +90,7 @@ def gen_tasks(self):
yield self.group_task()
self.site.scan_posts()

generate_author_pages = self.site.config["ENABLE_AUTHOR_PAGES"] and len(self._posts_per_author()) > 1
self.site.GLOBAL_CONTEXT["author_pages_generated"] = generate_author_pages
if generate_author_pages:
if self.generate_author_pages:
yield self.list_authors_page(kw)

if not self._posts_per_author(): # this may be self.site.posts_per_author
Expand Down
4 changes: 2 additions & 2 deletions requirements-tests.txt
@@ -1,8 +1,8 @@
-r requirements-extras.txt
mock==1.3.0
coverage==4.0.3
pytest==2.8.5
pytest==2.8.7
pytest-cov==2.2.0
freezegun==0.3.5
freezegun==0.3.6
python-coveralls==2.6.0
colorama>=0.3.4

0 comments on commit 0f174e6

Please sign in to comment.