/usr/share/doc/rest2web/html/reference/indextree.html is in rest2web-doc 0.5.2~alpha+svn-r248-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>indextree and thispage</title>
<link rel="stylesheet" href="../stylesheets/rest2web.css" type="text/css" />
<link rel="stylesheet" href="../stylesheets/voidspace_docutils2.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="rest2web - build websites with Python and docutils." />
<meta name="author" content="Michael Foord" />
<meta name="copyright" content="© 2003-2006 Michael Foord, subject to BSD License" />
<meta name="keywords" content="rest2web - build websites with Python and docutils,
rest, restructured text, text, website, internet, web, net, web builder, site,
site builder, docutils, i18n, internationalization, templates, templating,
python, " />
</head>
<body style="background: url(../images/logos/img_background.gif) top center repeat-y;">
<div id="wrap">
<div id="header-section">
<a href="http://www.voidspace.org.uk/python/index.shtml" title="Voidspace"><img src="../images/logos/header760.gif" alt="Voidspace"/></a>
<p align="center" class="headertitle"><span style="font-size:130%">rest2web:</span> Building Websites Across the Known Universe</p>
</div>
<div id="header">
<ul>
<li><a href="../index.html">rest2web</a></li>
<li>></li>
<li><a href="index.html">Reference</a></li>
<li>></li>
<li>indextree</li>
</ul>
</div>
<table>
<tr>
<td><img src="../images/logos/1.gif" width="1" height="1" alt="" /></td>
<!-- main content cell first, with rowspan=2 -->
<td valign="top" align="left" rowspan="2">
<div id="middle-column">
<a name="startcontent" id="startcontent"></a>
<div id="gallery">
<div class="document" id="indextree-and-thispage">
<h1 class="title">indextree and thispage</h1>
<h2 class="subtitle" id="representing-site-structure">Representing Site Structure</h2>
<p><strong>rest2web</strong> provides your templates with three variables that give you information about the site structure. The first is called <strong>sections</strong>. This gives you information about all the pages in the same directory as the one that is being rendered. See the <a class="reference external" href="../templating.html">templating</a> page for the description of that data structure.</p>
<p>The other two variables are called <strong>indextree</strong> and <strong>thispage</strong>. <strong>indextree</strong> is a data structure that represents more of the whole site than <strong>sections</strong>. <strong>thispage</strong> is a pointer to a specific part of <strong>indextree</strong>.</p>
<p><strong>indextree</strong> itself represents the top level page. It has members representing the pages inside the top level directory. Any index pages for sub-directories will be represented here, and will themselves have pages.</p>
<p>Because of the order that sites are processed in, any page can know that every directory above it will have been <em>fully</em> processed. This means that <strong>indextree</strong> can be used to construct 'sidebar' type links that look a bit like the following :</p>
<pre class="literal-block">
(root directory)
index page <- indextree
|
|
section1
| (a sub-directory)
|
section 2 - Index Page
| |
| |
section 3 |
| sub-section 1
| |
section 4 sub-section 2 (another sub-directory)
|
sub-section 3 - Index Page
|
|
**This Page** <- thispage
|
Another Page
|
And Another One
</pre>
<p>This allows a sidebar that is a set of links to all the sections above the current page. It doesn't yet allow you to know what pages might be in <tt class="docutils literal"><span class="pre">section</span> <span class="pre">3</span></tt> or <tt class="docutils literal"><span class="pre">section</span> <span class="pre">4</span></tt> of the root directory - but it would be unusual to need to put that amount of links just in a sidebar <a class="footnote-reference" href="#id3" id="id1">[1]</a> !</p>
<p>You can see an example of using <strong>sections</strong> for sidebar information in the <a class="reference external" href="../index.html">rest2web docs</a>. The <a class="reference external" href="../test_site/index.html">test site</a> is an example of a site using <strong>indextree</strong> for the sidebar. You can use the <a class="reference external" href="../functions.html">standard function</a> <tt class="docutils literal"><span class="pre">sidebar</span></tt> to generate these sidebars from indextree.</p>
<p>The actual data structure <strong>indextree</strong> is a dictionary that represents the index page for the top level directory. The dictionary contains links to dictionaries that represent the other pages and indexes. <tt class="docutils literal"><span class="pre">indextree</span></tt> is actually just part of the whole tree - it only contains the branches needed to get from the root directory to the current page that is being rendered.</p>
<p>The dictionaries in <strong>indextree</strong> all follow the same pattern <a class="footnote-reference" href="#id4" id="id2">[2]</a> and contain the following members :</p>
<ol class="arabic">
<li><p class="first"><strong>parent</strong> : a reference to the parent directory (also a dictionary like this).</p>
<blockquote>
<p>If this is the top level directory, then this member is <tt class="docutils literal"><span class="pre">None</span></tt>.</p>
</blockquote>
</li>
<li><p class="first"><strong>sectionlist</strong> : a list of sections for this directory. This retains the order that the sections are listed in the <tt class="docutils literal"><span class="pre">sectionlist</span></tt> value of the restindex.</p>
</li>
<li><p class="first"><strong>sections</strong> : this is actually a dictionary keyed by section name. Each value is a tuple <tt class="docutils literal"><span class="pre">(section_title,</span> <span class="pre">section_description)</span></tt></p>
</li>
<li><p class="first"><strong>pages</strong> : a <em>list</em> of pages that are in this section. For pages that don't represent subsections this will be the value <tt class="docutils literal"><span class="pre">None</span></tt>. For pages that do represent subsections, this list will only be populated if our page is somewhere down this tree.</p>
<blockquote>
<p>If the page currently being rendered (<strong>thispage</strong>) is not further down this branch, then this will be an empty list <tt class="docutils literal"><span class="pre">[]</span></tt>.</p>
<p>Each <em>page</em> in this list is also a dictionary like this one.</p>
</blockquote>
</li>
<li><p class="first"><strong>subdir</strong> : This will be <tt class="docutils literal"><span class="pre">True</span></tt> for pages that are index pages (i.e. represent sub-directories). It is <tt class="docutils literal"><span class="pre">False</span></tt> for pages that aren't index pages for sections.</p>
</li>
<li><p class="first"><strong>target</strong> : A relative link from the current page to the one that this dictionary represents.</p>
</li>
<li><p class="first"><strong>section</strong> : What section this page is in. For an index page, this section will refer to what section in the <em>directory above</em> this index belongs to.</p>
</li>
<li><p class="first"><strong>link-title</strong></p>
</li>
<li><p class="first"><strong>crumb</strong></p>
</li>
<li><p class="first"><strong>page-description</strong></p>
</li>
<li><p class="first"><strong>thispage</strong> : <tt class="docutils literal"><span class="pre">True</span></tt> if this page represents the one currently being rendered, <tt class="docutils literal"><span class="pre">False</span></tt> otherwise.</p>
</li>
<li><p class="first"><strong>uservalues</strong> : The uservalues for this page.</p>
</li>
<li><p class="first"><strong>restindex</strong> : The restindex for the page.</p>
</li>
<li><p class="first"><em>current_dir</em> - The directory the page was rendered in, relative to the top level directory. You can turn this into an absolute path using <tt class="docutils literal"><span class="pre">os.path.join(os.getcwd(),</span> <span class="pre">current_dir)</span></tt>.</p>
</li>
<li><p class="first"><em>source_file</em> - The source filepath for the page.</p>
</li>
<li><p class="first"><em>target_dir</em> - The target file directory (as an absolute file path) being rendered into. Note: if the file has a target specified it may not be put in this directory. Use <tt class="docutils literal"><span class="pre">os.path.dirname(target_file)</span></tt> instead.</p>
</li>
<li><p class="first"><em>full_page_url</em> - The full url (starting with '/') for the page. Using this means that your pages may not work from the filesystem. <img src="../images/smilies/smile.gif" alt="Smile" /> </p>
</li>
<li><p class="first"><em>target_file</em> - The full output filepath of the page.</p>
</li>
</ol>
<p>As well as <strong>indextree</strong>, templates also have access to a value called <strong>thispage</strong>. <strong>thispage</strong> is an entry in the <strong>indextree</strong> structure, but it points to the current page. If you like <strong>indextree</strong> is the top of the tree, and <strong>thispage</strong> is the bottom.</p>
<div class="note">
<p class="first admonition-title">Note</p>
<p class="last">Pages that have 'include' set to 'No' aren't in indextree. For those pages the value <em>thispage</em> will be <tt class="docutils literal"><span class="pre">None</span></tt>.</p>
</div>
<p>All string values in the <strong>indextree</strong> structure are encoded using the appropriate encoding for the page being rendered (as determined by the value <tt class="docutils literal"><span class="pre">final_encoding</span></tt>).</p>
<table class="docutils footnote" frame="void" id="id3" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>It would be possible to do this by generating the site in two passes. On the first pass we'd generate the link structure and on the second pass actually render the pages. This would take longer, mean keeping the whole site in memory, and mean parsing the whole site before basic errors in the template are discovered !</td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="id4" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id2">[2]</a></td><td>They follow as closely as possible the pattern for pages in the <em>sections</em> variable that is also passed to templates. See <em>sections</em> in the <a class="reference external" href="../templating.html">templating</a> page.</td></tr>
</tbody>
</table>
</div>
</div>
<div id="end">
<p><a href="#startcontent">Return to Top</a><br />
<small>Part of the <a href="http://www.voidspace.org.uk/python/rest2web/">rest2web Docs</a></small><br />
<small>Page last modified <strong>Sun Aug 6 18:29:38 2006</strong>.</small>
</p>
</div>
</div></td>
</tr>
<tr>
<td valign="top" align="left" width="25%">
<div id="left-column">
<div id="sidie">
<ul>
<li class="left-navheader-first">
<a href="index.html" class="left-navheader">Index Page</a>
</li>
<li class="left-navheader">Pages</li>
<li><a href="todo.html">TODO/ISSUES</a></li>
<li><a href="uservalues.html">uservalues</a></li>
<li><a href="encodings.html">Encodings</a></li>
<li><a href="indextree.html">indextree</a></li>
<li><a href="changelog.html">changelog</a></li>
<li><a href="smilies.html">Smilies</a></li>
<li><a href="plugins.html">Plugins</a></li>
<li><a href="gallery.html">Gallery</a></li>
</ul>
</div>
<p class="sidieimg">
<a href="http://www.python.org">
<img src="../images/logos/new_python.gif" width="88"
height="103" border="0" alt="Powered by Python" />
</a>
</p>
<p class="sidieimg">
<a href="http://sourceforge.net/donate/index.php?group_id=138579">
<img src="http://images.sourceforge.net/images/project-support.jpg" width="100"
height="32" border="0" alt="Support This Project" />
</a>
</p>
<p class="sidieimg">
<a href="http://www.voidspace.org.uk/python/rest2web/"><img
src="../images/logos/rest2web140x62.gif" width="142" height="62"
alt="Site Built with rest2web" /></a><br />
</p>
</div>
</td>
</tr>
</table>
<hr />
<p class="sidieimg">
<a href="http://www.voidspace.org.uk/python/rest2web/"><img src="../images/logos/rest2web200x80.gif" width="200" height="80" alt="Site Built with rest2web" /></a>
<a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=138579&type=5" width="210" height="62" alt="SourceForge.net Logo" /></a>
<a href="http://www.opensource.org"><img src="../images/logos/osi-certified-120x100.gif" width="120" height="100" alt="Certified Open Source" border="1" /></a>
</p>
<p class="sidieimg">
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-203625-1";
urchinTracker();
</script>
</p>
<p class="sidieimg">
<a href="http://www.voidspace.org.uk/python/index.shtml"><img
src="../images/logos/pythonbanner.gif" width="468" height="60"
alt="Python on Voidspace" /></a>
</p>
<div id="footer">
Copyright © Voidspace<br />Design by <a href="http://www.fuchsiashockz.co.uk">Fuchsiashockz</a> | <a href="http://validator.w3.org/check?uri=referer" title="Validate code as W3C XHTML 1.1 Strict Compliant">W3C XHTML 1.1</a> | <a href="http://jigsaw.w3.org/css-validator/check?uri=referer" title="Validate Style Sheet as W3C CSS 2.0 Compliant">W3C CSS 2.0</a>
</div>
</div>
</body>
</html>
|