[Rest2web-develop] rest2web & Another terrible Idea
Brought to you by:
mjfoord
From: <fuz...@vo...> - 2006-01-28 10:56:43
|
{emo;waffle} As I mentioned I've been hacking on `rest2web </python/rest2web/>`_ a bit. I've started to add the functionality that will make *Next* and *Previous* links possible for pages. Some of what I'd like to do, specifically auto-building contents pages that include the directories *below* the current one, would require changing **rest2web** to a two pass build system. In the first pass accumulate all the data & metadata for pages, *then* build them all. It occurs to me that this would be an opportunity to savagely refactor. Currently **rest2web** builds datastructures that represent the directories / section / site. These are all built with nested list and dictionary datatypes. When generating the {acro;HTML} output it has to regenerate these data structures virtually for every page. This is because each page can have a target location that is actually outside of the directory being built. **rest2web** needs to recalculate relative links from the current page to every other location. (It also handles making sure that the information about each page is available in the *output encoding* of the page being handled. This means you can use several different output encodings throughout your site.) This has the great advantage that you aren't tied to the directory structure that **rest2web** uses to represent sites. `Voidspace </index2.shtml>`_ uses this facility. It allows you to include in indexes, pages that are actually somewhere else in the site. For example the `Library Pages </library/index.shtml>`_ are included in the `Cyberpunk </cyberpunk/index.shtml>`_ section. The template code for the index page is trivially simple. Recalculating these each time is expensive, and makes the code very fiddly (i.e. difficult to understand). It would be better to generate a tree structure for the site, with custom objects representing the pages and indexes. It would make the code simpler, but it would mean replacing the `indextree data structure </rest2web/reference/indextree.html>`_ with something more useful. Hmm...... {sm;:neutral:} This of course is a *terrible idea*. Making the code more readable, and more useful, is *good* - but it's a lot of work. .. note:: In practise it may not have that much effect. The relative paths would *still* need to be calculated. A custom object could *possibly* do this conversion on demand though. |