-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
161 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
================= | ||
Getting Started | ||
================= | ||
|
||
.. note:: For the purposes of this document, the implementation of | ||
`Zope Page Templates | ||
<https://docs.zope.org/zope2/zope2book/AppendixC.html#define-define-variables>`_ | ||
provided by `Chameleon | ||
<https://chameleon.readthedocs.io/>`_ | ||
working together with `z3c.pt | ||
<https://pypi.python.org/pypi/z3c.pt>`_ will simply be | ||
referred to as "page templates" or abbreviated to "ZPT." | ||
|
||
Introduction | ||
============ | ||
|
||
This package allows developing Nikola templates using Chameleon. | ||
Chameleon is a fast implementation of the Zope Page Templates | ||
specification. Unlike template systems such as Jinja2 or Mako, page | ||
templates are designed to be valid (X)HTML and may be edited in HTML | ||
editors. It's even possible to use visual design tools to produce | ||
pages that are then relatively easily turned into page templates; | ||
sometimes it's even possible to edit those templates again in the same | ||
visual design tool. | ||
|
||
Component Architecture | ||
====================== | ||
|
||
Page templates can be much more than that, though. When combined with | ||
the Zope `component architecture | ||
<https://zopecomponent.readthedocs.io/>`_ (ZCA), they can be designed | ||
to be extensible and flexible in a way that the simple template | ||
inheritance schemes of other template systems cannot match. This | ||
package is designed to embrace that, making it possible to create and | ||
extend templates and themes very easily. | ||
|
||
.. note:: | ||
|
||
Although we believe the component architecture can be used to make | ||
themes flexible and make changing and customizing them through | ||
inheritance or configuration easier, *you are not required to use | ||
these features* if you don't want to. You can build an entire theme | ||
just based on the files in the templates directory and the Chameleon | ||
``load:`` expression. | ||
|
||
For a discussion of how the ZCA can be leveraged in your themes, see :doc:`using_zca`. | ||
|
||
Prerequisites | ||
============= | ||
|
||
To create templates with this package, you'll need a basic | ||
understanding of the following: | ||
|
||
- the page templates `language <https://chameleon.readthedocs.io/en/latest/reference.html>`_ | ||
- `path expressions | ||
<https://docs.zope.org/zope2/zope2book/AppendixC.html#tales-path-expressions>`_ | ||
|
||
|
||
It may be helpful to understand object traversal, similar to what can | ||
be used in `the Pyramid web framework | ||
<https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/traversal.html>`_. | ||
We use `zope.traversing | ||
<https://pypi.python.org/pypi/zope.traversing>`_ to implement | ||
traversal, and provide several "path adapters" to make traversal in | ||
path expressions more convenient. | ||
|
||
.. todo:: Write about the standard path adapters (meta, | ||
formatted_date) and views (@@macros, @@post_text) we | ||
provide, with examples. | ||
|
||
Macros and Viewlets | ||
------------------- | ||
|
||
Most templates will also make use of `macros | ||
<https://chameleon.readthedocs.io/en/latest/reference.html#macros-metal>`_, | ||
and many will also use `viewlets | ||
<https://pypi.python.org/pypi/zope.viewlet>`_. We'll discuss how each | ||
of these can be used to develop flexible templates in :doc:`macros` | ||
and :doc:`viewlets`, respectively. Complete examples using these | ||
techniques can be found in `base-chameleon | ||
<https://github.com/NextThought/nti.nikola_themes.base-chameleon>`_, | ||
and its extension using bootstrap3, `bootstrap3-chameleon | ||
<https://github.com/NextThought/nti.nikola_themes.bootstrap3-chameleon>`_. | ||
|
||
Template Variables | ||
================== | ||
|
||
Your templates will have access to all of the `template variables | ||
Nikola defines <https://getnikola.com/template-variables.html>`_. | ||
These are made available in the ``options`` dictionary, one of `the | ||
standard names | ||
<https://docs.zope.org/zope2/zope2book/AppendixC.html#built-in-names>`_ | ||
available to page templates. The ``context`` standard name is often a | ||
Nikola post object (depending on the specific template). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
=================== | ||
Theme Inheritance | ||
=================== | ||
|
||
.. todo:: Write inheritance. | ||
|
||
Talk about how and why. Overloading bits and pieces. ZCA makes it easy. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
============== | ||
Using Macros | ||
============== | ||
|
||
.. todo:: Write macro section. | ||
|
||
- Using macros from the same template: template/macros/macro_name | ||
- Using defined templates: macro:macro_name | ||
- Automatically discovered in .macro.pt files for any triple. | ||
- Registered from ZCML for specific triples. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
======================================= | ||
Leveraging the Component Architecture | ||
======================================= | ||
|
||
.. todo:: Write ZCA section | ||
|
||
Theory of Operation | ||
=================== | ||
|
||
Talk about component lookup: context, request/layer, view and how we | ||
can register macros and viewlets for each of those things. | ||
|
||
Talk about what each represents (object in use, details about what | ||
we're asking for, how we're handling the asking). | ||
|
||
Talk about layers applied to the "request". | ||
|
||
Talk about the different page kinds. | ||
|
||
Talk about comment systems. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
================ | ||
Using Viewlets | ||
================ | ||
|
||
.. todo:: Write viewlet section. | ||
|
||
- The provider:viewlet_manager expression | ||
- Registered in ZCML | ||
- Standard viewlet manager types. | ||
- New viewlet managers in ZCML |