Adding a page list ============================================ Most wikis have a feature that lets you view an index of the pages. To add one, we'll start with a new template, ``pagelist.html``. We'll copy ``page.html`` so that we don't have to write the boilerplate. .. code-block:: bash cd wiki20/templates cp page.html pagelist.html After editing, our ``pagelist.html`` looks like: .. literalinclude:: ../../project_code/wiki_root/snapshots/9/wiki20/templates/pagelist.html :linenos: :language: html **19-22** This section represents the Genshi code of interest. You can guess that the ``py:for`` is a python ``for`` loop, modified to fit into Genshi's XML. It iterates through each of the ``pages`` (which we'll send in via the controller, using a modification you'll see next). For each one, ``Page Name Here`` is replaced by ``pagename``, as is the URL. We must also modify ``controller/root.py`` to implement ``pagelist`` and to create and pass ``pages`` to our template: .. literalinclude:: ../../project_code/wiki_root/snapshots/8/wiki20/controllers/root.py :linenos: :language: python **45-47** We select all of the ``Page`` objects from the database, and order them by pagename. We can also modify ``page.html`` so that the link to the page list is available on every page (line 28): .. literalinclude:: ../../project_code/wiki_root/snapshots/9/wiki20/templates/page.html :linenos: :language: html You can see your pagelist by clicking the link on a page or by going directly to http://localhost:8080/pagelist.