TemplateToolkit
1

[% IF count == 1 and posts.size == 1 -%]
  [%- INCLUDE template.header title = posts.0.title -%]
[% ELSE -%]
  [%- INCLUDE template.header title = app.name -%]
[% END -%]

[%- USE date -%]

[%- INCLUDE log.header -%]

  <div class="log">

[%- IF order > 0 -%]
[%- SET posts = posts.reverse -%]
[%- END -%]

[%- FOREACH post = posts %]
   <div class="post">
    <h[% app.topHeaderLevel %] title="[% post.age WRAPPER dictionary section="age" | html %]">
     <a href="?start=[% post.stamp | uriparameter | html %]&amp;count=1" rel="bookmark">[% date.format(post.stamp, '%Y-%m-%d %H:%M UTC') | html %]</a>
     [% post.title | html %]
    </h[% app.topHeaderLevel %]>
[% post.content %]
[% IF post.pingbacks.size > 0 -%]
    <p class="pingbacks">
     Pingbacks: 
[% SET pingbackIndex = 0 -%]
[% FOREACH pingback = post.pingbacks -%]
[% SET pingbackIndex = pingbackIndex + 1 -%]
     <span>
      <a href="[% pingback.uri | uri | html %]" title="[% pingback.title | html %]">[% pingbackIndex | html %]</a>
[% IF session.right.poster and count == 1 -%]
      (<a href="?command=showTemplate&amp;string=log.pingbackDelete.confirmation&amp;pingback.uri=[% pingback.uri | uriparameter | html %]&amp;pingback.title=[% pingback.title | uriparameter | html %]&amp;pingback.id=[% pingback.id | uriparameter | html %]&amp;post.title=[% post.title | uriparameter | html %]&amp;post.stamp=[% post.stamp | uriparameter | html %]">delete</a>)
[% END -%]
     </span>
[% END -%]
    </p>
[% END -%]
    <!-- [% FILTER htmlcomment %] RDF for trackback autodiscovery:
       <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:tb="http://madskills.com/public/xml/rss/module/trackback/">
       <rdf:Description
           about="[% app.canonicalURI | xml %]?start=[% post.stamp | uriparameter | xml %]&amp;count=1"
           dc:identifier="[% app.canonicalURI | xml %]?start=[% post.stamp | uriparameter | xml %]&amp;count=1"
           dc:title="[% post.title | xml %]"
           dc:date="[% post.ISOtimestamp | xml %]"
           tb:ping="[% FILTER xml %]http://software.hixie.ch/utilities/cgi/pingback-proxy/trackback-to-pingback/[% FILTER uriparameter %][% app.canonicalURI | uriparameter %],[% FILTER uriparameter %][% app.canonicalURI %]?start=[% post.stamp | uriparameter %]&count=1[% END %][% END %][% END # ok, by my count some of those characters are going to be TRIPPLE escaped. %]"/>
       </rdf:RDF>
    [% END %] -->
[% IF session.right.poster and count == 1 -%]
    <p><a href="http://validator.w3.org/check/referer">Validate</a></p>
[% END -%]
   </div>
[% END -%]

[%- IF session.right.poster %]
   <form action="./" method="POST" enctype="multipart/form-data" class="post">
[%- IF count == 1 %]
    <h[% app.topHeaderLevel %]><a rel="bookmark">[% date.format(post.stamp, '%Y-%m-%d %H:%M UTC') | html %]</a> <input type="text" name="title" value="[% post.title | html %]"></h[% app.topHeaderLevel %]>
    <p><textarea name="content" cols="80" rows="8">[% post.originalContent | html %]</textarea></p>
    <p><input type="hidden" name="command" value="editLog"><input type="hidden" name="id" value="[% post.postID | html%]"><input type="submit" value="Repost"></p>
[%- ELSE %]
    <h[% app.topHeaderLevel %]><a rel="bookmark">[% date.format(now, '%Y-%m-%d %H:%M UTC') | html %]</a> <input type="text" name="title" value="Untitled"></h[% app.topHeaderLevel %]>
    <p><textarea name="content" cols="80" rows="8">&lt;p&gt;&lt;/p&gt;</textarea></p>
    <p><input type="hidden" name="command" value="addLog"><input type="submit" value="Post"></p>
[%- END %]
   </form>
[%- END -%]

   <div class="navigation">
    <div class="jump">
     <form action="./" method="GET">
      <p>
       <label>
        Jump to
        <select name="start">
         <option value="0">Latest</option>
[%- SET last = times.size - 1 %]
[%- SET positionMinusCount = 0 %]
[%- SET positionPlusCount = times.$last.time %]
[%- FOREACH time = times %]
[%- IF time.position == (0-count) %]
[%- SET positionMinusCount = time.time %]
[%- ELSIF time.position == (0+count) %]
[%- SET positionPlusCount = time.time %]
[%- ENDIF %]
[%- END %]
[%- IF time.position > -20 and time.position < 20 %]
         <option value="[% time.time | html %]"[% ' selected="selected"' IF time.position == 0 %]>[% date.format(time.time, '%Y-%m-%d %H:%M UTC') | html %] - [% time.title | html %]</option>
[%- END %][% END %]
[% IF times.$last.position != 0 -%]
         <option value="[% times.$last.time | html %]">Start</option>
[% END -%]
        </select>
       </label>
       <input type="hidden" name="order" value="[% order | html %]">
       <input type="hidden" name="count" value="[% count | html %]">
       <input type="submit" value="Go &#x21A0;">
      </p>
     </form>
    </div>
    <div class="options">
[% IF order < 0 -%]
     <form action="./" method="GET">
      <p>
       <input type="hidden" name="start" value="[% positionMinusCount | html %]">
       <input type="hidden" name="order" value="[% order | html %]">
       <input type="hidden" name="count" value="[% count | html %]">
       <input type="submit" value="Newer &#x21A9;"[% ' disabled="disabled"' IF times.0.position == 0 %]>
      </p>
     </form>
     <form action="./" method="GET">
      <p>
       <input type="hidden" name="start" value="[% positionPlusCount | html %]">
       <input type="hidden" name="order" value="[% order | html %]">
       <input type="hidden" name="count" value="[% count | html %]">
       <input type="submit" value="Older &#x21AA;"[% ' disabled="disabled"' IF times.$last.position == 0 %]>
      </p>
     </form>
[% ELSE -%]
     <form action="./" method="GET">
      <p>
       <input type="hidden" name="start" value="[% positionPlusCount | html %]">
       <input type="hidden" name="order" value="[% order | html %]">
       <input type="hidden" name="count" value="[% count | html %]">
       <input type="submit" value="Older &#x21A9;"[% ' disabled="disabled"' IF times.$last.position == 0 %]>
      </p>
     </form>
     <form action="./" method="GET">
      <p>
       <input type="hidden" name="start" value="[% positionMinusCount | html %]">
       <input type="hidden" name="order" value="[% order | html %]">
       <input type="hidden" name="count" value="[% count | html %]">
       <input type="submit" value="Newer &#x21AA;"[% ' disabled="disabled"' IF times.0.position == 0 %]>
      </p>
     </form>
[% END -%]
     <form action="./" method="GET">
      <p>
       <input type="hidden" name="start" value="[% start | html %]">
       <input type="hidden" name="order" value="[% 0-order | html %]">
       <input type="hidden" name="count" value="[% count | html %]">
[% IF order < -0 -%]
       <input type="submit" value="Reverse &#x21A5;">
[% ELSE -%]
       <input type="submit" value="Reverse &#x21A7;">
[% END -%]
      </p>
     </form>
     <form action="./" method="GET">
      <p>
       <input type="hidden" name="start" value="[% start | html %]">
       <input type="hidden" name="order" value="[% order | html %]">
       <label>
        Show up to
        <input type="text" name="count" value="[% count | html %]" size="3">
        posts
       </label>
       <input type="submit" value="Update">
      </p>
     </form>
    </div>
   </div>
  </div>

[% INCLUDE template.footer %]