<rdf:Description rdf:about="http://snarfed.org/space/pyblosxom%20history">
  <dc:title> history.py </dc:title>
  <dc:creator> Ryan Barrett &lt;snarfed at ryanb dot org&gt; </dc:creator>
  <dc:date> 2006-10-09T06:07:00Z </dc:date>
  <dc:language> en </dc:language>
  <dc:format> text/html </dc:format>
  <dc:rights> Copyright 2002-2009 Ryan Barrett </dc:rights>

  <content>
    <p><img src="/space/clock_icon.jpg" alt="clock_icon.jpg" title="" /></p>

<p>For the impatient: <br />
&nbsp; Download <a href="/space/history.py">history.py 0.5</a> <br />
&nbsp; Download <a href="/space/history-0.5.tar.gz">history-0.5.tar.gz</a> (includes templates) <br />
&nbsp; <a href="http://pyblosxom.sf.net/">PyBlosxom home page</a> <br />
&nbsp; <a href="http://pyblosxom.sf.net/blog/registry?sortby=path">PyBlosxom plugin registry</a> <br />
&nbsp; <a href="http://www.baus.net/svnpyblosxom">svnpyblosxom</a>
  (<a href="http://0pointer.de/blog/projects/pyblosxom-svn.html">simplified</a>),
  a related plugin</p>

<p><em>Updated 2009-02-24.</em></p>

<p><a href="/space/history.py">history.py</a> is a <a href="http://pyblosxom.sf.net/">PyBlosxom</a>
plugin that displays change history for entries. The change history must
already exist, either in a version control system, database, or another form.
This plugin just uses that backend to display change history, previous
versions of entries, and textual diffs for changes.</p>

<p>As an example, you can see the
<a href="?history=1">change history for this page</a>.</p>

<h3>Version Control Backends</h3>

<p>This plugin is designed to support different version control backends.
Currently the only backend is Subversion, but the backend code has been
abstracted to make it easy to add new backends.</p>

<p>The <code>history_backend</code> config parameter specifies the version control backend
to use. For now, only <code>subversion</code> is supported. Add this line to your
config.py:</p>

<div class='p-shadow'><pre><code>py['history_backend'] = 'subversion'
</code></pre></div>

<p><br class='clearing' />To use the Subversion backend, the <a href="http://pysvn.tigris.org/">pysvn</a> module
must be installed somewhere in your PYTHONPATH.</p>

<h3>Config Parameters</h3>

<p>In addition to the <code>history_backend</code> parameter, you may also optionally
specify a limit on the number of changes to fetch and display in the change
history page. This is set via the <code>history_num_changes</code> parameter, e.g.:</p>

<div class='p-shadow'><pre><code>py['history_num_changes'] = 20
</code></pre></div>

<p><br class='clearing' /><h3>New Urls</h3></p>

<p>There are three new types of pages: past versions, change history, and diffs.
They are accessed by adding these parameters to entry URLs:</p>

<div class='p-shadow'><pre><code>?history=1
</code></pre></div>

<p><br class='clearing' />Shows the entry's change history as a series of diffs, one for each change.</p>

<div class='p-shadow'><pre><code>?version=X
</code></pre></div>

<p><br class='clearing' />Shows version X of the entry. Depending on your backend, X may be a revision
number, a date, a tag, or something else entirely. The Subversion backend
supports revision numbers.</p>

<div class='p-shadow'><pre><code>?version=X&amp;raw=1
</code></pre></div>

<p><br class='clearing' />Shows the raw text of version X of the entry.</p>

<div class='p-shadow'><pre><code>?diff=1&amp;version1=X&amp;version2=Y
</code></pre></div>

<p><br class='clearing' />For example, if an entry is located at
<a href="/space/filekicker">http://snarfed.org/space/filekicker</a>,
you'd use
<a href="/space/filekicker?history=1">http://snarfed.org/space/filekicker?history=1</a>
to show its change history.</p>

<p>Note that all of the URL parameters require a value. The values for history,
diff, and raw can be anything, but they <em>must</em> be present. URLs that omit the
value, e.g.
<a href="/space/filekicker?history">http://snarfed.org/space/filekicker?history</a>,
will not work.</p>

<h3>Templates</h3>

<p>The history plugin uses a few new templates, and provides new template
variables for them. Template files for the html flavour are provided with this
plugin.</p>

<ul>
<li><p><code>history-diff</code>: a diff between two versions of an entry. The text of the
diff is provided in the <code>$diff</code> template variable. It's in
<a href="http://www.gnu.org/software/diffutils/manual/html_node/Unified-Format.html">unified format</a>.</p></li>
<li><p><code>history-version</code>: a previous version of an entry. This will usually be
similar to your story template, with minor modifications. For example, you
might not provide links to the entry's comments. All template variables
available in the story template are also available here.</p></li>
<li><p><code>history-head</code> and <code>history-foot</code>: These are displayed around the change
history page. <code>history-head</code> is displayed at the beginning, <code>history-foot</code>
is displayed at the end. The body of the page is a series of diffs, one
for each change to the entry, rendered with the <code>history-diff</code> template.</p></li>
</ul>

<h3>Template Variables</h3>

<p>These new template variables are provided in the <code>history-diff</code> and
<code>history-version</code> templates:</p>

<div class='p-shadow'><pre><code>history-diff:
  $diff      The text of the diff, in unified format.
  $version1  The base version of the diff.
  $version2  The ending version of the diff.
history-version:
  $version   The displayed version of the entry.
both:
  $author    The person who made the last change.
  $message   The changelog of the last change.
  $date      The date of the last change.
</code></pre></div>

<p><br class='clearing' />Diffs should usually be displayed in a fixed-width font, so surrounding
<code>$diff</code> with <code>&lt;code&gt;</code> and/or <code>&lt;pre&gt;</code> is strongly suggested.</p>

<p>Some lines will be surrounded with <code>&lt;span class="..."&gt;</code>. The class will
be <code>diff-added</code>, <code>diff-removed</code>, <code>diff-changed</code>, or <code>diff-line-number</code>,
depending on the type of change that the line represents.</p>

<p>history.py is copyright 2006 <a href="/space/about">Ryan Barrett</a>, and is distributed
under the <a href="http://www.gnu.org/licenses/gpl.html">GPL</a>.</p>

<p>See also:</p>

<ul>
<li><a href="/space/photogallery">photogallery</a></li>
<li><a href="/space/hardcodedates">hardcodedates</a></li>
<li><a href="/space/filekicker">filekicker</a></li>
<li><a href="/space/pyblosxom ajax comments">pyblosxom ajax comments</a></li>
<li><a href="/space/pyblosxom rdf flavour">pyblosxom rdf flavour</a></li>
<li><a href="/space/2006-08-23">migrating to pyblosxom</a></li>
</ul>

  </content>

  <rdf:Seq>

<rdf:li>
<rdf:Description rdf:about="#1158514133.65">
  <dc:source> http://snarfed.org/ </dc:source>
  <dc:title> history.py </dc:title>
  <dc:creator> christopher baus </dc:creator>
  <dc:date> cmt_pubDate </dc:date>
  <dc:format> text/html </dc:format>

  <content>
    Good idea.&nbsp; This is something I thought about when I did the original svnpyblosxom.
  </content>
</rdf:Description>
</rdf:li>

  </rdf:Seq>
</rdf:Description>
</rdf:RDF>
