Coder Social home page Coder Social logo

nti.nikola_chameleon's Introduction

nti.nikola_chameleon

Latest release Supported Python versions https://travis-ci.org/NextThought/nti.nikola_chameleon.svg?branch=master https://coveralls.io/repos/github/NextThought/nti.nikola_chameleon/badge.svg?branch=master Documentation Status

An extremely flexible template system for the Nikola static blog system using Chameleon, z3c.pt and z3c.macro

A basic template using this system is available in base-chameleon, and an extension of that using bootstrap3 is available in bootstrap3-chameleon.

Documentation is hosted at https://ntinikola_chameleon.readthedocs.io/

Installation

Nikola uses a custom mechanism to find plugins instead of using the usual pkg_resources system. That makes it incredibly difficult to install plugins; it's not enough just to pip install a package from PyPI. Instead, you must also copy a .plugin file to a particular location on disk. This can be:

  • ~/.nikola/plugins/
  • The plugins directory of your Nikola site.

Beside that '.plugin' file there must also be a '.py' file of the same name that the plugin lists as a module (yes, even though the plugin file specifically requests a Python module, yapsy requires that it be a file or directory beside the plugin file---so not really a module).

It's ridiculous to require everyone to copy plugins into their plugin folder (they're not even correctly on sys.path, meaning that zope.configuration and many other tools won't work) and we don't plan to let Nikola do that automatically (we're not on the Nikola plugin index and won't be until they let us do standard installs), so the best we can do is attempt to workaround yapsy's limitations.

Into your site's plugin directory, place the following .py file:

# nti_nikola_chameleon.py
from nti.nikola_chameleon import *

Beside that, you'll need a nti.nikola_chameleon.plugin file:

# -*- mode: conf; -*-
[Core]
Name = nti.nikola_chameleon
Module = nti_nikola_chameleon

[Documentation]
Author = NextThought
Version = 1.0
Website = https://github.com/NextThought/nti.nikola_chameleon
Description = Support for Chameleon ZPT templates.

[Nikola]
PluginCategory = Template

nti.nikola_chameleon's People

Contributors

jamadden avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

jean

nti.nikola_chameleon's Issues

{{% template %}} shortcode doesn't work

As noted in #5, Nikola passes template-based shortcode contents instead of the template name. #6's solution, as I understand it, is to process template files in the shortcodes directory and set them up as template adapters.

However, this doesn't work with pages using anonymous templates enclosed by the {{% template %}} shortcode. The contents of the anonymous template are interpreted as the name of a multi-adapter instead of as TAL/TALES/METAL.

Posts for the future break; missing archiveindex.tmpl

Given a post dated in the future, things break:

[2018-05-18T18:41:13Z] NOTICE: Nikola: posts/2018/05/gevent-hub.rst is scheduled to be published in the future (2018-05-19 13:40:00-05:00)
.  render_galleries:output/galleries
.  render_galleries:output/galleries/index.html
.  render_galleries:output/galleries/rss.xml
.  render_taxonomies:output/blog/categories/index.html
.  render_taxonomies:output/blog/archives/index.html
TaskError - taskid:render_taxonomies:output/blog/archives/index.html
PythonAction Error
Traceback (most recent call last):
  File "//NIH/lib/python3.6/site-packages/doit/action.py", line 424, in execute
    returned_value = self.py_callable(*self.args, **kwargs)
  File "//NIH/lib/python3.6/site-packages/nikola/nikola.py", line 1488, in render_template
    template_name, None, local_context)
  File "//nti.nikola_chameleon/src/nti/nikola_chameleon/plugin.py", line 194, in render_template
    result = self.render_template_to_string(template_name, context)
  File "//nti.nikola_chameleon/src/nti/nikola_chameleon/plugin.py", line 254, in render_template_to_string
    template = getViewTemplate(template, view, request, context)
  File "//nti.nikola_chameleon/src/nti/nikola_chameleon/plugin.py", line 100, in getViewTemplate
    IContentTemplate, name=name)
  File "/NIH/lib/python3.6/site-packages/zope/component/_api.py", line 112, in getMultiAdapter
    raise ComponentLookupError(objects, interface, name)
zope.interface.interfaces.ComponentLookupError: ((<nti.nikola_chameleon.view.View object at 0x10f294cc0>, <nti.nikola_chameleon.request.Request object at 0x10f294da0>), <InterfaceClass z3c.template.interfaces.IContentTemplate>, 'archiveindex.tmpl')

Not compatible with Nikola 8

Specifically:

Traceback (most recent call last):
  File "//NIH/lib/python3.6/site-packages/doit/action.py", line 424, in execute
    returned_value = self.py_callable(*self.args, **kwargs)
  File "//NIH/lib/python3.6/site-packages/nikola/nikola.py", line 1390, in render_template
    template_name, None, local_context)
  File "//src/nti/nikola_chameleon/plugin.py", line 194, in render_template
    result = self.render_template_to_string(template_name, context)
  File "//src/nti/nikola_chameleon/plugin.py", line 232, in render_template_to_string
    if post.is_mathjax:
AttributeError: 'Post' object has no attribute 'is_mathjax'

Here's a document about new things in nikola 8 and here's a document about upgrading

I'm not sure there's an advantage to continuing to support nikola 7 (other than python 2.7 support).

Template-based shortcodes do not work

Template-based shortcodes fail with this plugin as the renderer.

Given a file in a site at shortcodes/foo.tmpl containing arbitrary ReST, when that shortcode is invoked, Nikola will call render_template_to_string passing the contents of foo.tmpl as the template argument. We expect the template argument to be the name of the template, which we typically derive from a filename, so we fail with a ComponentLookupError when we try to locate the template adapter.

One quick option would be to catch that error, example the template string, and if it doesn't look like a filename (e.g., contains at least on ReST directive .. ) return that string directly. That fixes the common case of using a template shortcode as a primitive "include" directive.

Alternately, we could try to examine all the files in the site's shortcodes directory and register them as page templates like everything else.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.