<?xml version="1.0" encoding="utf-8"?>
<!-- generator="Blooki/0.4803" -->
<feed version="0.3" xmlns="http://purl.org/atom/ns#"  xml:lang="en">
  <title mode="escaped" type="text/html">Blooki</title>
  <tagline mode="escaped" type="text/html">Grow what you know</tagline>
  <link rel="alternate" type="text/html" href="http://blooki.org/development/.atom/"/>
  <modified>1970-01-01T00:00:00Z</modified>
  <author><name>Paul Kulchenko</name></author>


  <entry>
    <title>Nightly builds</title>
    <content type="text/html" mode="escaped">&lt;p&gt;As Blooki now has &lt;a href="http://www.joelonsoftware.com/articles/fog0000000023.html"&gt;nightly builds&lt;/a&gt;, I'm one step closer to getting &lt;strong&gt;tolerable&lt;/strong&gt; score on &lt;a href="http://www.joelonsoftware.com/articles/fog0000000043.html"&gt;The Joel Test&lt;/a&gt;:&lt;/p&gt;


&lt;ol&gt;
&lt;li&gt;Do you use source control? &lt;strong&gt;yes&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Can you make a build in one step? &lt;strong&gt;yes&lt;/strong&gt; (now)&lt;/li&gt;
&lt;li&gt;Do you make daily builds? &lt;strong&gt;yes&lt;/strong&gt; (now)&lt;/li&gt;
&lt;li&gt;Do you have a bug database? &lt;strong&gt;yes/no&lt;/strong&gt; (I know, I know, it's either yes or no; it's not publicly available, but it exists ;))&lt;/li&gt;
&lt;li&gt;Do you fix bugs before writing new code? &lt;strong&gt;yes&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Do you have an up-to-date schedule? &lt;strong&gt;no&lt;/strong&gt; (only plans)&lt;/li&gt;
&lt;li&gt;Do you have a spec? &lt;strong&gt;no&lt;/strong&gt; (not written at least)&lt;/li&gt;
&lt;li&gt;Do programmers have quiet working conditions? &lt;strong&gt;yes&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Do you use the best tools money can buy? &lt;strong&gt;yes&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Do you have testers? &lt;strong&gt;yes&lt;/strong&gt;, one tester and one developer&lt;/li&gt;
&lt;li&gt;Do new candidates write code during their interview? &lt;strong&gt;n/a&lt;/strong&gt; (we are not hiring ;))&lt;/li&gt;
&lt;li&gt;Do you do hallway usability testing? &lt;strong&gt;yes&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;



&lt;p&gt;Nightly builds are available &lt;a href="download"&gt;here&lt;/a&gt;.&lt;/p&gt;</content>
    <link rel="alternate" type="text/html" href="http://blooki.org/development/.atom/development/nightly-builds"/>
    <id>http://blooki.org/development/.atom/development/nightly-builds</id>
    <issued>2004-10-19T05:24:26Z</issued>
    <modified>2004-10-19T05:24:26Z</modified>
    
  </entry>

  <entry>
    <title>Content negotiation</title>
    <content type="text/html" mode="escaped">&lt;p&gt;As Ian Hickson explained, &lt;a href="http://www.hixie.ch/advocacy/xhtml"&gt;Sending &lt;span class="caps"&gt;XHTML &lt;/span&gt;as text/html considered harmful&lt;/a&gt;, but it's fine "send &lt;span class="caps"&gt;XHTML &lt;/span&gt;as application/xhtml+xml to UAs that support it, and as text/html to legacy UAs."&lt;/p&gt;

&lt;p&gt;To implement this I've extended the content-type parameter in template, so that instead of &lt;code&gt;text/html&lt;/code&gt; it is now possible to write &lt;code&gt;application/xhtml+xml,text/html&lt;/code&gt;. Server will then use &lt;code&gt;Accept&lt;/code&gt; header to identify what content type should be served; it will serve &lt;code&gt;application/xhtml+xml&lt;/code&gt; to Firefox and &lt;code&gt;text/html&lt;/code&gt; to InternetExplorer. It also applies to &lt;span class="caps"&gt;RSS &lt;/span&gt;content types: Atom template has &lt;code&gt;application/atom+xml,application/xml&lt;/code&gt; as the content type.&lt;/p&gt;

&lt;p&gt;All this is done by the following lines of code (thanks to Gisle Aas for his &lt;span class="caps"&gt;HTTP&lt;/span&gt;::Negotiate):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; my @types = split /,/, $template-&amp;gt;content_type;
 my $pos = 0; # ::Negotiate sorts results by quality and then by size (asc)
 my $variants = [map {[$_, 1, $_, (undef) x 3, ++$pos]} reverse @types];
 my $headers = new HTTP::Headers Accept =&amp;gt; $request-&amp;gt;cgi-&amp;gt;http('accept');
 my $type = HTTP::Negotiate::choose($variants, $headers) || pop @types;&lt;/code&gt;&lt;/pre&gt;</content>
    <link rel="alternate" type="text/html" href="http://blooki.org/development/.atom/development/content-negotiation"/>
    <id>http://blooki.org/development/.atom/development/content-negotiation</id>
    <issued>2004-10-13T21:46:00Z</issued>
    <modified>2004-10-13T21:46:00Z</modified>
    
  </entry>

  <entry>
    <title>Dynamic Publishing: Bake or Fry?</title>
    <content type="text/html" mode="escaped">&lt;p&gt;I was reading Tim's &lt;a href="http://www.timaoutloud.org/archives/000361.html"&gt;MT 3.1 Dynamic Publishing Blues&lt;/a&gt; and it reminded me a topic I read almost two years ago -- &lt;a href="http://philringnalda.com/blog/2002/11/halfbaked_and_a_little_fried.php"&gt;Half baked and little fried&lt;/a&gt; -- about dynamic vs. static generation. The topic of Timothy's post is about controversy of recently introduced dynamic publishing in MovableType that uses &lt;span class="caps"&gt;PHP &lt;/span&gt;as its engine. While Ben Trott &lt;a href="http://groups.yahoo.com/group/mt-dev/message/580"&gt;explained their reasoning&lt;/a&gt; behind the decision I'm not sure I agree with him. &lt;/p&gt;

&lt;p&gt;In his analysis Ben describes several options and dismisses most of Perl related options as inefficient. Without considering speed of interpreters, I guess he is talking about startup penalty of perl interpreter that is called on every request. This cost is definitely there, but the solution reminds me advice to buy more hardware to solve a performance problem without looking at optimizing an algorithm that is being used. Let's look at it.&lt;/p&gt;

&lt;p&gt;The stated problem of reducing latency and server load can be solved in several ways:&lt;/p&gt;

&lt;p&gt;1. &lt;strong&gt;Expires and Last-Modified headers&lt;/strong&gt;. The script can return these headers (along with ETag) to make the page cacheable. The tricky part is to set proper Expires header. It should be long enough to minimize calls to the server and short enough to allow those calls when the content changes. This can be achieved by giving different values to different pages or even doing something similar to what google bot does visiting more often pages that change more frequently; +10% on expiration and -50% on modification may be a good start. Expires/Last-Modified also works well with static content (images, client-side scripts, and stylesheets). Expires header can be set to a fairly large value; if a file is updated, it can be served using a new &lt;span class="caps"&gt;URL.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;2. &lt;strong&gt;Handling of If-Modified-Since and If-None-Match&lt;/strong&gt;. The script should return 304 if content hasn't been modified. It doesn't even need to have a copy of the page; all it needs to know that it hasn't changed. It may be as simple as one LastModified time per blog/site for rarely updated sites that invalidates all caches; or as complex as dependency tracking to know exactly what information was used to generate a page.&lt;/p&gt;

&lt;p&gt;3. &lt;strong&gt;Local cache of generated pages&lt;/strong&gt;. The dependency check still needs to be done, but the page may already be generated and served from a local cache (likely file system). At this point most people would point out that all this can be done by saving generated pages as static pages and have them to be served by a webserver using little bit of mod_rewrite-like magic. While that's true, there are still several things that need to be addressed: &lt;/p&gt;


&lt;ul&gt;
&lt;li&gt;Expires values need to be configured and they likely to be static&lt;/li&gt;
&lt;li&gt;Any custom headers need to be configured&lt;/li&gt;
&lt;li&gt;No personalization is possible (new since the last visit and other similar things)&lt;/li&gt;
&lt;li&gt;Authentication requests may need to be handled separately&lt;/li&gt;
&lt;li&gt;No parametrized request: pagination, searches and the like.&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;Pages can be cached (they can even be compressed) along with their headers and served when necessary. While this may be a viable option in many cases, there is still a question of how this cache should be in/validated: dependencies can be checked on every request, or they can be checked when pages are added/updated/deleted.&lt;/p&gt;

&lt;p&gt;4. &lt;strong&gt;Template fragment caching&lt;/strong&gt;. While the script may not cache the entire page, it still may be feasible to cache some of page fragments, especially the most time consuming or most frequently used, as recently updated items or list of subcategories that are likely to be used across many pages. This requires tracking of what fragment uses what information, so they can, again, be properly invalidated, but this may not be as complex as it seems.&lt;/p&gt;

&lt;p&gt;5. &lt;strong&gt;File/memory cache&lt;/strong&gt;. While template fragments may not be cached, the information that is necessary for page generation can be cached in memory (applicable to mod_perl, daemon and similar server solutions) or in files (this works well for filesystem-based solutions like &lt;a href="http://blooki.org"&gt;Blooki&lt;/a&gt;, &lt;a href="http://blosxom.com"&gt;Blosxom&lt;/a&gt;, and other file I/O hungry solutions). It is not necessary to cache all the information; in most cases modification date/time, title, and some meta information is enough.&lt;/p&gt;

&lt;p&gt;6. &lt;strong&gt;Access optimization&lt;/strong&gt;. This probably doesn't apply to &lt;span class="caps"&gt;MT, &lt;/span&gt;but it definitely applies to Blooki (which uses filesystem to store its information). Even when information is not available in a cache, it's still possible to optimize a process of getting this information. Blooki is super-lazy about getting the stuff it needs. First, it's driven by templates; if it's not requested by a templates it probably won't be processed. Second, it only read directories first without even stat'ing files in them. Then it only stat files if you ask for their modification times. And then it only reads their content if you ask for title, meta, or other information.&lt;/p&gt;

&lt;p&gt;7. &lt;strong&gt;Direct access&lt;/strong&gt;. If nothing else helps, then information has to be read and page has to be regenerated from scratch.&lt;/p&gt;

&lt;p&gt;Now, back to the original question: &lt;strong&gt;was it worth it&lt;/strong&gt;? Unfortunately, it's &lt;a href="http://groups.yahoo.com/group/mt-dev/message/574"&gt;not clear from the description&lt;/a&gt; if Perl is being used at all when &lt;span class="caps"&gt;PHP&lt;/span&gt;-based rendering is used, but as far as I understand it is (please correct me if I'm wrong). Switching from Perl to &lt;span class="caps"&gt;PHP &lt;/span&gt;only addresses items 2 and 3; doing everything else still requires Perl interpreter (and hence startup penalty). Now, both 2 and 3 can be quite effectively achieved by using a local proxy/cache, which some users may already have and for those that don't it is a one-time deal and is much easier than &lt;span class="caps"&gt;PHP &lt;/span&gt;engine integration. In my opinion the asnwer is clear.&lt;/p&gt;</content>
    <link rel="alternate" type="text/html" href="http://blooki.org/development/.atom/development/dynamic-publishing-bake-or-fry"/>
    <id>http://blooki.org/development/.atom/development/dynamic-publishing-bake-or-fry</id>
    <issued>2004-09-28T20:54:00Z</issued>
    <modified>2004-09-28T20:54:00Z</modified>
    
  </entry>

  <entry>
    <title>Pagination in Blooki</title>
    <content type="text/html" mode="escaped">&lt;p&gt;&lt;a href="http://weblog.burningbird.net/archives/2004/09/20/some-gratuitous-weblog-software-writing/"&gt;Shelley has been writing&lt;/a&gt; about upcoming Wordpress 1.3 release and one of the features that will be included in the release -- pagination. I got curious about how difficult it would be to add something like this to Blooki. &lt;/p&gt;

&lt;p&gt;First, I added two template variables (&lt;code&gt;entries::prev&lt;/code&gt; and &lt;code&gt;entries::next&lt;/code&gt;) that calculate number of entries to display and &lt;span class="caps"&gt;URL &lt;/span&gt;to use.&lt;/p&gt;

&lt;p&gt;The rest was easy: update template to provide default parameters for number of entries listed and starting position:&lt;/p&gt;



&lt;pre&gt;&lt;code&gt;TemplateVar page::entries &amp;lt;&amp;lt;.
  $entries{
    start =&amp;gt; $request{args}{start} || 1,      # start from 1 by default
    display =&amp;gt; $request{args}{display} || 20, # display no more than 20 entries
    header =&amp;gt; $request{isentrypage} ? $entry::prevnext : '', # show entry prev/next
    footer =&amp;gt; q[$entries::prevnext], # show entries prev/next if necessary
  }
.
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;This code checks if &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;display&lt;/code&gt; parameters from query string available or uses 1 and 20 by default; it also sets footer to the value of &lt;code&gt;$entries::prevnext&lt;/code&gt; template variable, which is defined as follows:&lt;/p&gt;



&lt;pre&gt;&lt;code&gt;TemplateVar entries::prevnext &amp;lt;&amp;lt;.
&amp;lt;div class=&amp;quot;prevnext&amp;quot;&amp;gt;$get{join ' | ', grep {length}
  $entries::prev ? qq[&amp;lt;a href=&amp;quot;$entries::prev{url}&amp;quot;&amp;gt;&amp;amp;lt;&amp;amp;lt; Prev $entries::prev{display}&amp;lt;/a&amp;gt;] : '',
  $entries::next ? qq[&amp;lt;a href=&amp;quot;$entries::next{url}&amp;quot;&amp;gt;Next $entries::next{display} &amp;amp;gt;&amp;amp;gt;&amp;lt;/a&amp;gt;] : '', 
}&amp;lt;/div&amp;gt;
.
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;This code generates prev/next links. As parameters are not hardcoded anywhere, users can check &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;display&lt;/code&gt; values as they need (&lt;code&gt;start&lt;/code&gt; can even be negative; in this case it will display entries from the end of the list, just like &lt;code&gt;@foo[-2..-1]&lt;/code&gt; does).&lt;/p&gt;

&lt;p&gt;Excited by the ease of the change I also tried to do prev/next links on entries. This didn't required any coding at all; only a small template change:&lt;/p&gt;



&lt;pre&gt;&lt;code&gt;TemplateVar entry::prevnext &amp;lt;&amp;lt;.
&amp;lt;div class=&amp;quot;prevnext&amp;quot;&amp;gt;$get{join ' | ', grep {length}
  $entries{display =&amp;gt; 1, sort =&amp;gt; &amp;quot;-modified_on&amp;quot;, modified_on =&amp;gt; &amp;quot;&amp;lt;$entry{modified_on}&amp;quot;, q[&amp;lt;a href=&amp;quot;$entry::permalink&amp;quot;&amp;gt;&amp;amp;lt;&amp;amp;lt; $entry{title}&amp;lt;/a&amp;gt;]},
  $entries{display =&amp;gt; 1, sort =&amp;gt; &amp;quot;+modified_on&amp;quot;, modified_on =&amp;gt; &amp;quot;&amp;gt;$entry{modified_on}&amp;quot;, q[&amp;lt;a href=&amp;quot;$entry::permalink&amp;quot;&amp;gt;$entry{title} &amp;amp;gt;&amp;amp;gt;&amp;lt;/a&amp;gt;]},
}&amp;lt;/div&amp;gt;
.
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;This code displays prev/next links with titles of entries (if there is previous/next entry). It's also easy to make it display prev/next entries in a particular category, just add a category filter &lt;code&gt;category =&amp;gt; $entry{category}&lt;/code&gt;:&lt;/p&gt;



&lt;pre&gt;&lt;code&gt;TemplateVar entry::prevnext &amp;lt;&amp;lt;.
&amp;lt;div class=&amp;quot;prevnext&amp;quot;&amp;gt;$get{join ' | ', grep {length}
  $entries{display =&amp;gt; 1, category =&amp;gt; $entry{category}, sort =&amp;gt; &amp;quot;-modified_on&amp;quot;, modified_on =&amp;gt; &amp;quot;&amp;lt;$entry{modified_on}&amp;quot;, q[&amp;lt;a href=&amp;quot;$entry::permalink&amp;quot;&amp;gt;&amp;amp;lt;&amp;amp;lt; $entry{title}&amp;lt;/a&amp;gt;]},
  $entries{display =&amp;gt; 1, category =&amp;gt; $entry{category}, sort =&amp;gt; &amp;quot;+modified_on&amp;quot;, modified_on =&amp;gt; &amp;quot;&amp;gt;$entry{modified_on}&amp;quot;, q[&amp;lt;a href=&amp;quot;$entry::permalink&amp;quot;&amp;gt;$entry{title} &amp;amp;gt;&amp;amp;gt;&amp;lt;/a&amp;gt;]},
}&amp;lt;/div&amp;gt;
.
&lt;/code&gt;&lt;/pre&gt;</content>
    <link rel="alternate" type="text/html" href="http://blooki.org/development/.atom/development/pagination-in-blooki"/>
    <id>http://blooki.org/development/.atom/development/pagination-in-blooki</id>
    <issued>2004-09-26T19:11:00Z</issued>
    <modified>2004-09-26T19:11:00Z</modified>
    
  </entry>

  <entry>
    <title>Markdown Integration</title>
    <content type="text/html" mode="escaped">&lt;p&gt;Even though Blooki currently provides &lt;a href="http://search.cpan.org/~tomi/Text-Textile-0.6/"&gt;Textile&lt;/a&gt;, Tiki and ConvertBreaks filters, I've been thinking about adding &lt;a href="http://daringfireball.net/2004/08/markdown_10"&gt;Markdown&lt;/a&gt; as several people asked me about it. Markdown is a perl module, so I didn't expect any troubles integrating it with Blooki. There were few challenges though both related to the fact that Markdown is not distributed as a Perl module; instead it's distributed as a Perl script.&lt;/p&gt;

&lt;p&gt;First, since it can run as a script and as a plugin for MovableType and Blosxom it checks if either of those is avaiable and if not, it waits for input to be processed. This is easily fixable by changing &lt;code&gt;defined($blosxom::version)&lt;/code&gt; (line 184 in Markdown 1.0) to something like &lt;code&gt;(caller(0))[7]&lt;/code&gt;, which returns true if the script was called using use/require/do.&lt;/p&gt;

&lt;p&gt;Second, the old IfModule directive in a config file only processesed "real" modules/packages, and not files. So I extended it to accept files and Perl versions (as Markdown requires Perl 5.6 and later). Now the fragment that loads Markdown looks like the following: &lt;/p&gt;



&lt;pre&gt;&lt;code&gt;  &amp;lt;IfModule 5.006 Markdown.pl&amp;gt; # Markdown requires Perl 5.006
    AddModule Markdown
  &amp;lt;/IfModule&amp;gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;This goes into Blooki 0.48.&lt;/p&gt;</content>
    <link rel="alternate" type="text/html" href="http://blooki.org/development/.atom/development/markdown-integration"/>
    <id>http://blooki.org/development/.atom/development/markdown-integration</id>
    <issued>2004-09-25T19:11:00Z</issued>
    <modified>2004-09-25T19:11:00Z</modified>
    
  </entry>

  <entry>
    <title>The Cat is Out of The Bag</title>
    <content type="text/html" mode="escaped">&lt;p&gt;I've been quitely working on this application for some time, but it looks like a good time to make it public. The package seems to be good enough to be useful to other people (one of the things that is missing is documentation). I'm &lt;a href="http://www.netlingo.com/lookup.cfm?term=eating%20your%20own%20dog%20food"&gt;dog-fooding&lt;/a&gt; blooki to run this site: it's used to run a &lt;a href="development/"&gt;development weblog&lt;/a&gt; and I also plan on using it to power support forums and a project documentation website.&lt;/p&gt;</content>
    <link rel="alternate" type="text/html" href="http://blooki.org/development/.atom/development/the-cat-is-out"/>
    <id>http://blooki.org/development/.atom/development/the-cat-is-out</id>
    <issued>2004-09-25T14:23:00Z</issued>
    <modified>2004-09-25T14:23:00Z</modified>
    
  </entry>


</feed>
