+ Quick-Summary and Quick-Archive

why the lucky stiff why at hobix.com
Sun Sep 12 11:07:15 EDT 2004


=== Again with the Daily Tip: Using Quick-Summary and Quick-Archive ===

Yesterday I ran through the basics of Quick Templates.  ERb templates 
broken into chunks inside a YAML document.
<http://rubyforge.org/pipermail/hobix-is-the-way/2004-September/000003.html>

Every Quick template inherits from that long master template.  You can 
either customize parts of it, or you can replace the whole thing by 
overriding the `page' chunk.

=== The Quick-Summary Template ===

Quick-Summary templates are useful for `index' pages.  The master 
template will display the full content of a post.  But the Quick-Summary 
template only displays the `summary' of a post, with a "Continue to full 
post" link.  If no `summary' is found, the `content' of a post will be 
displayed.

The Quick-Summary Template simply overrides the `entry_content' setting 
of the master template:

   entry_content: |
     <div class="entryContent">
       <% if entry.summary %>
         <%= entry.summary.to_html %>
         <p><a href="<%= entry.link %>">Continue to full post.</a></p>
       <% else %>
         <%= entry.content.to_html %>
       <% end %>
     </div>

To add an index page which leverages the Quick-Summary template:

   touch skel/index.html.quick-summary

=== The Quick-Archive Template ===

Quick-Archive templates display entry titles under a date header.  For 
an example: <http://bokononist.hobix.com/2004/05/>

The Quick-Archive template accomplishes this by overriding the `entry' 
and `entries' chunks:

   entry: |
     <h3 class="entryTitle"><a href="<%= entry.link %>"><%=
         entry.title %></a></h3>
   entries: |
     <div id="archives">
     <ul>
     <% entries.each_day do |day, day_entries| %>
        <li><+ day_header +></li>
        <ul>
        <% day_entries.each do |entry| %>
          <li><+ entry +></li>
        <% end %>
        </ul>
        </li>
      <% end %>
      </ul>
      </div>

_why



More information about the Hobix-is-the-way mailing list