getnikola / plugins

Extra plugins for Nikola
https://plugins.getnikola.com/
MIT License
59 stars 95 forks source link

[sidebar] Build fails after installing sidebar plugin (again) #234

Closed KonstantinShemyak closed 7 years ago

KonstantinShemyak commented 7 years ago
(nikola)$ nikola --version
Nikola v7.8.6

The build (of the unchanged site) passes further than in #233 - gets to run sidebar, but still fails:

(nikola)$ nikola build
Scanning posts......done!
.  render_sidebar:output/sidebar-en.inc
########################################
TaskError - taskid:render_sidebar:output/sidebar-en.inc
PythonAction Error
Traceback (most recent call last):
  File "/home/user/nikola/lib/python3.5/site-packages/doit/action.py", line 403, in execute
    returned_value = self.py_callable(*self.args, **kwargs)
  File "/home/user/nikola/lib/python3.5/site-packages/nikola/nikola.py", line 1446, in render_template
    template_name, None, local_context)
  File "/home/user/nikola/lib/python3.5/site-packages/nikola/plugins/template/mako.py", line 117, in render_template
    data = template.render_unicode(**context)
  File "/home/user/nikola/lib/python3.5/site-packages/mako/template.py", line 471, in render_unicode
    as_unicode=True)
  File "/home/user/nikola/lib/python3.5/site-packages/mako/runtime.py", line 838, in _render
    **_kwargs_for_callable(callable_, data))
  File "/home/user/nikola/lib/python3.5/site-packages/mako/runtime.py", line 873, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/home/user/nikola/lib/python3.5/site-packages/mako/runtime.py", line 899, in _exec_template
    callable_(context, *args, **kwargs)
  File "/home/user/nikola/tech-notes.site/cache/.mako.tmp/sidebar.tmpl.py", line 40, in render_body
    __M_writer(str( helper.list_posts(global_posts) ))
  File "/home/user/nikola/tech-notes.site/cache/.mako.tmp/sidebar-helper.tmpl.py", line 37, in render_list_posts
    __M_writer(str( messages("Recent Posts", lang) ))
  File "/home/user/nikola/lib/python3.5/site-packages/nikola/utils.py", line 269, in __call__
    return self[lang][key]
KeyError: 'Recent Posts'
Kwpolska commented 7 years ago

This is caused by missing messages. The default templates used by the sidebar plugin expect some special messages (translations) to be added, namely:

I added a note to the README. To fix this, you can either create some custom messages files with those entries, or make it untranslatable by modifying sidebar.tmpl and sidebar-helper.tmpl.

(PS. you could have just reopened #233. I assumed this was the only problem in here, but in case an issue still occurs, or you still can’t do what you want, you can always reopen the issue.)

felixfontein commented 7 years ago

Thanks for updating the documentation (and the plugin metadata)!

p-law commented 4 years ago

I uninstalled and re-installed nikola, this time without reinstalling the sidebar plugin, and I'm still getting this same error. Started happening when I copied in a post that had a sidebar ref in the text. However, even rm-ing that post doesn't stop the error on nikola build.

Kwpolska commented 4 years ago

The posts/templates/pages might be cached, try rm -rf cache .doit.db after removing the post.

p-law commented 4 years ago

Thank you! I'll give that a whirl.

p-law commented 4 years ago

What's the conf.py tuple supposed to be for Recent Posts?

This problem arises whenever I create a first post, even for a new site (rm -rf the original site, then nikola init a new one). It even happens after I uninstall and reinstall nikola, as soon as I create a new post, and even when I haven't installed the sidebar plugin.

This is caused by missing messages. The default templates used by the sidebar plugin expect some special messages (translations) to be added, namely:

  • Recent Posts
  • Archives
  • Categories
  • Tags

I added a note to the README. To fix this, you can either create some custom messages files with those entries, or make it untranslatable by modifying sidebar.tmpl and sidebar-helper.tmpl.

Kwpolska commented 4 years ago

Localization messages are created in messages/messages_XX.py files in a theme, not conf.py.