Repository: getnikola/nikola

Issue:
Bug in taxonomy link handler
Steps to reproduce:

* checkout from master
* nikola init -q foo
* cd foo
* nikola new_post foo

Change navigation_links to contain

        ("link://category", "Tags"),

And voilá:

```
TaskError - taskid:render_taxonomies:output/index.html
PythonAction Error
Traceback (most recent call last):
  File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/doit/action.py", line 403, in execute
    returned_value = self.py_callable(*self.args, **kwargs)
  File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/nikola.py", line 1426, in render_template
    self.rewrite_links(doc, src, context['lang'], url_type)
  File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/nikola.py", line 1440, in rewrite_links
    doc.rewrite_links(lambda dst: self.url_replacer(src, dst, lang, url_type), resolve_base_href=False)
  File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/lxml/html/__init__.py", line 622, in rewrite_links
    new_link = link_repl_func(link.strip())
  File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/nikola.py", line 1440, in <lambda>
    doc.rewrite_links(lambda dst: self.url_replacer(src, dst, lang, url_type), resolve_base_href=False)
  File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/nikola.py", line 1489, in url_replacer
    dst = self.link(dst_url.netloc, dst_url.path.lstrip('/'), lang, **link_kwargs)
  File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/nikola.py", line 1879, in link
    url = self.path(*args, is_link=True, **kwargs)
  File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/nikola.py", line 1798, in path
    path = self.path_handlers[kind](name, lang, **kwargs)
  File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/plugins/misc/taxonomies_classifier.py", line 282, in _taxonomy_path
    result = taxonomy.get_path(taxonomy.extract_hierarchy(name), lang, dest_type=dest_type)
  File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/plugins/task/categories.py", line 132, in get_path
    return [_f for _f in [self.site.config['CATEGORY_PATH'](lang)] if _f] + self.slugify_category_name(classification, lang), 'auto'
  File "/home/ralsina/.virtualenvs/nikola/lib/python3.5/site-packages/nikola/plugins/task/categories.py", line 125, in slugify_category_name
    result[0] = self.site.config['CATEGORY_PREFIX'] + result[0]
IndexError: list index out of range
```


Discussion:
So, the problem seems to be that the categories taxonomy doesn't support "link://category" but I should use "link://category_index".

In any case the way it flames out is pretty impressive, so adding a small error handler there.

Resolving patch:
diff --git a/nikola/plugins/task/categories.py b/nikola/plugins/task/categories.py
--- a/nikola/plugins/task/categories.py
+++ b/nikola/plugins/task/categories.py
@@ -116,6 +116,9 @@ def slugify_tag_name(self, name, lang):
 
     def slugify_category_name(self, path, lang):
         """Slugify a category name."""
+        if not path:  # Probably used link://category
+            utils.LOGGER.error('Invalid link to a category without passing a category name. Probably meant to use category_index?')
+            raise ValueError()
         if lang is None:  # TODO: remove in v8
             utils.LOGGER.warn("ClassifyCategories.slugify_category_name() called without language!")
             lang = ''


Test patch: