<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mixu&#039;s tech blog</title>
	<atom:link href="http://blog.mixu.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mixu.net</link>
	<description>When I read what I write I learn what I think</description>
	<lastBuildDate>Mon, 26 Jul 2010 12:03:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Kohana3: Setting up phpUnit and phpDocumentor</title>
		<link>http://blog.mixu.net/2010/07/25/kohana3-setting-up-phpunit-and-phpdocumentor/</link>
		<comments>http://blog.mixu.net/2010/07/25/kohana3-setting-up-phpunit-and-phpdocumentor/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 11:00:54 +0000</pubDate>
		<dc:creator>Mikito Takada</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.mixu.net/?p=1053</guid>
		<description><![CDATA[Here is my quick guide on how to setup phpUnit and phpDoc for Kohana 3. phpUnit 1. Setup Install phpUnit using pear: pear install phpunit (See the PEAR site for how to install PEAR.) Get the Kohana unittest module from http://github.com/kohana/unittest. If you aren&#8217;t using git for your repo, just clone the files (git clone [...]]]></description>
			<content:encoded><![CDATA[<p>Here is my quick guide on how to setup <a href="http://www.phpunit.de/manual/3.4/en/index.html">phpUnit</a> and <a href="http://manual.phpdoc.org/HTMLframesConverter/default/">phpDoc </a>for <a href="http://kohanaframework.org/">Kohana 3</a>.</p>
<h2>phpUnit</h2>
<h3>1. Setup</h3>
<p>Install phpUnit using pear:</p>
<pre>pear install phpunit</pre>
<p>(See the PEAR site for <a href="http://pear.php.net/manual/en/installation.getting.php">how to install PEAR</a>.)<br />
Get the Kohana unittest module from <a href="http://github.com/kohana/unittest">http://github.com/kohana/unittest</a>. If you aren&#8217;t using git for your repo, just clone the files (<code>git clone http://github.com/kohana/unittest.git</code>), get rid of the .git subdirectories and copy the module to your modules/ directory.</p>
<p><a href="http://github.com/kohana/unittest">Follow the setup instructions on GitHub</a>. Some tips:</p>
<p>It may be easiest to define an alternative default database configuration, since currently unittest does not automatically change any of the database configurations (ex. in models). Since I use a Fedora VM for development but prefer to run tests on Windows, I added the following logic to config/database.php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strtoupper</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">PHP_OS</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #0000ff;">'WIN'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'default'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">..</span>test config<span style="color: #339933;">..</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'default'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">..</span>normal config<span style="color: #339933;">..</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I did the same thing in bootstrap.php, selectively enabling the unittest module and changing the cache dir based on the OS. You can probably think of some way to do the same in your setup even if you aren&#8217;t using a different OS for serving HTTP requests.</p>
<h3>2. Creating tests</h3>
<p>Tests for application files go into the application/tests/ folder you create.</p>
<p>Tests for any module (inc. application, database, unittest etc.) go in the &#8216;tests&#8217; folder in the module.</p>
<p>Tests extend Kohana_Unittest_TestCase, not PHPUnit_Framework_TestCase.</p>
<p>To group individual tests into modules you need to add the tests to a group for that module. The convention for group names is modules.{module_name}. This is done using the docblock @group specification (can have multiple group specifications). See <a href="http://github.com/kohana/unittest/blob/master/guide/unittest.testing.md">Writing Tests in the repo on GitHub</a>.</p>
<h3>3. Fixtures</h3>
<p>The easiest way to create fixtures is to use setUp() to set the DB, then tearDown() to clean up. You can just use the DB class, or use ORM to add the records. Example:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> WhateverTest <span style="color: #000000; font-weight: bold;">extends</span> Kohana_Unittest_TestCase <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">function</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">// setup the DB</span>
      DB<span style="color: #339933;">::</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;TRUNCATE `kohana_test`.`whatever`;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>execute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$fixture_rows</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
          <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'key'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'billing_key'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'value'</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'0'</span><span style="color: #339933;">,</span>
          <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #666666; font-style: italic;">// add the necessary items</span>
      <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fixture_rows</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         DB<span style="color: #339933;">::</span><span style="color: #004000;">insert</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'whatever'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array_keys</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>values<span style="color: #009900;">&#40;</span><span style="color: #990000;">array_values</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>execute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000000; font-weight: bold;">function</span> tearDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #009900;">&#125;</span></pre></div></div>

<p>There is probably a better way using a proper fixture class, but I haven&#8217;t seen one for Kohana yet.</p>
<h3>4. Execution</h3>
<p>You will need to specify the path to the KO3 webroot index.php as the bootstrap for phpUnit. This is because the dependencies which your code has need to be loaded by Kohana.</p>
<p>By default, all tests in application/tests/ will be run.</p>
<pre>phpunit --bootstrap=index.php ./modules/unittest/tests.php</pre>
<p>To run a specific group of tests on the cli add &#8211;group {groupname.in.testfile} between the &#8211;bootstrap switch and the path to the tests folder.</p>
<pre>phpunit --bootstrap=index.php --group groupname.in.testfile ./modules/unittest/tests.php</pre>
<h2>phpDocumentor</h2>
<p>Install phpDocumentor using PEAR: <code>pear install phpDocumentor</code>.</p>
<p>On Windows, if you use paths with spaces in them it is easiest to make sure that phpDocumentor is in the php include path (edit php.ini if necessary), and invoke php while passing the phpdoc file directly (see below for example).</p>
<p>You will probably only want to generate API docs for application/, perhaps selectively adding a few modules. And you probably want to exclude: application/vendor/, application/logs/, application/views/, application/bootstrap.php and application/config/ from the API documentation.</p>
<p>Remember that <a href="http://blog.mixu.net/2009/09/09/phpdocumentor-1-4-3-gotchas/">phpDocumentor does not support multiple option specifications</a>: you have to join the paths with a comma. Furthermore, remember to have the directory separator character at the end of directories to trigger the correct interpretation.</p>
<p>Kohana3 uses a number of custom tags, so you will want to exclude those. Here is a sample run:</p>
<pre>php "c:\Program Files (x86)\PEAR\phpdoc" --directory application/
--ignore application/vendor/,application/logs/,application/views/,application/bootstrap.php,application/config/ --target doc/api
--customtags type,default,constructor,chainable,class,namespace,module,group</pre>
<p>There are a few options that may also prove useful:<br />
&#8211;parseprivate causes private methods to be shown<br />
&#8211;output HTML:frames:earthli changes the output to earthli, which I like.<br />
&#8211;undocumentedelements Adds warnings to errors.html for undocumented elements.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mixu.net/2010/07/25/kohana3-setting-up-phpunit-and-phpdocumentor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Better web application interface markup: lessons from theme frameworks</title>
		<link>http://blog.mixu.net/2010/07/20/better-web-application-interface-markup-lessons-from-theme-frameworks/</link>
		<comments>http://blog.mixu.net/2010/07/20/better-web-application-interface-markup-lessons-from-theme-frameworks/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 10:24:36 +0000</pubDate>
		<dc:creator>Mikito Takada</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.mixu.net/?p=944</guid>
		<description><![CDATA[Every time I start a new web application project, I spend a while (re)thinking what the layout structure should be in terms of CSS and HTML (e.g. semantic naming, organizing CSS markup). Recently, I did a project using the Thematic theme framework for WordPress, and that got me thinking about how custom web applications interfaces [...]]]></description>
			<content:encoded><![CDATA[<p>Every time I start a new web application project, I spend a while (re)thinking what the layout structure should be in terms of CSS and HTML (e.g. <a href="http://blog.mixu.net/2009/08/12/semantic-css-naming-best-practices/">semantic naming</a>, <a href="http://blog.mixu.net/2010/03/15/7-additional-tips-for-css-markup/">organizing CSS markup</a>).</p>
<p>Recently, I did a project using the <a href="http://themeshaper.com/thematic/">Thematic </a>theme framework for WordPress, and that got me thinking about how custom web applications interfaces could be improved. As an individual developer, I rarely have the luxury of focusing on the details of the layout. In contrast, the developers building theme frameworks have spent years thinking about how to create a generic, extensible structure for web application interfaces.</p>
<p>I had a look at <a href="http://themeshaper.com/thematic/">Thematic</a>, <a href="http://wpframework.com/">WP-Framework</a> and <a href="http://themehybrid.com/">Theme Hybrid</a> (see more frameworks <a href="http://www.smashingmagazine.com/2009/05/27/wordpress-theme-development-frameworks/">in this Smashing Magazine article</a>). I used Thematic, since I ended up using it in the WordPress project I did. Here is how Thematic does it&#8217;s HTML layout:</p>
<p><strong>An overview of the HTML code (based on Thematic)</strong></p>
<p>I think the most interest parts of Thematic for web application design are the HTML structure, use of ids and classes and the CSS files. The hook-and-filter system (<a href="http://bluemandala.com/thematic/thematic-structure.html">overview here</a>) is less interesting from the web application point of view, since you will most likely be writing all of the code from scratch for your own web applications.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;wordpress y2010 m06 d02 h03 home blog not-singular windows firefox ff3&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;wrapper&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
   <span style="color: #808080; font-style: italic;">&lt;!-- Header --&gt;</span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;header&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;branding&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;blog-title&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         ...
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;access&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;menu&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>          
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #808080; font-style: italic;">&lt;!-- Main --&gt;</span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;main&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;container&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;content&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;primary&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #808080; font-style: italic;">&lt;!-- Footer --&gt;</span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;footer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;siteinfo&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><strong>1. Body and wrapper</strong></p>
<p>In all of the frameworks, the body classes contain various information such as the platform (windows) and the browser (firefox, ff3). </p>
<p>Benefits:<br />
<b>Easier to specify per-browser css fixes</b> (if needed). This makes it easier to make adjustments based on the browser or OS used in CSS, eg. &#8220;.windows xxx.yyy { &#8230; }&#8221;.</p>
<p><b>Separation between body and content wrapper</b>. In the framework, the content is wrapped in a wrapper layer (id=wrapper), so that the body has only one child element. I would imagine this is to make it easier to use CSS to adjust the padding and background of the pages. </p>
<p><strong>2. Heading</strong></p>
<p>The heading consists of two sub-divs, as shown below:</p>
<p><a href="http://blog.mixu.net/files/2010/06/thematic.png"><img class="alignnone size-full wp-image-951" title="thematic" src="http://blog.mixu.net/files/2010/06/thematic.png" alt="" width="533" height="421" /></a></p>
<p>There are only three subelements to the content wrapper: heading, main and footer. Each of these divs is full-size and positioned relatively. </p>
<p>Benefits:<br />
<b>Easy to add repeating backgrounds</b>. One can easily apply a CSS background-image to create a repeating and consistent heading.</p>
<p><b>Easy positioning of the elements</b>. The heading consist of the branding and access divs. This makes it easy to add new heading elements in the branding, while keeping the menu (=access div) separate, with it&#8217;s own background.</p>
<p><b>Standard menu HTML</b>. All of the frameworks appear to be using the <a href="http://users.tpg.com.au/j_birch/plugins/superfish/#examples">Superfish menu</a> by default, which is based on jQuery.</p>
<p><strong>3. Main content </strong></p>
<p>The main content consists of a container with a content-sub-div and a primary sidebar:</p>
<p><a href="http://blog.mixu.net/files/2010/06/thematic-main.png"><img class="alignnone size-full wp-image-952" title="thematic-main" src="http://blog.mixu.net/files/2010/06/thematic-main.png" alt="" width="533" height="743" /></a></p>
<p>The main content div has a fixed size. This is then subdivided into two divs, container (for the content) and primary (for the primary menu block). </p>
<p>Benefits:<br />
<b>Semantic markup; floats to reposition</b> Having these separate divs means that switching from &#8220;menu on the right&#8221; to menu on the left is simple, since one can change the CSS float directions to reverse the positions of the subcontainers.<br />
<b>Easy to add new content areas</b> One could also add more subdiv for additional content areas, and create multiple columns relatively easily by positioning the subdivs within the main content div.<br />
<b>Easy to add sub-items</b> The primary menu is a div, with each block having its own unordered list (ul). In practice, this leads to two levels of lists &#8211; one for the item blocks themselves, the other for the sub-items (e.g. the links in a Archives block).</p>
<p><strong>4. Footer</strong></p>
<p>The footer consists of a single subdiv:</p>
<p><a href="http://blog.mixu.net/files/2010/06/thematic-footer.png"><img class="alignnone size-full wp-image-953" title="thematic-footer" src="http://blog.mixu.net/files/2010/06/thematic-footer.png" alt="" width="533" height="160" /></a></p>
<p>Again, the top-level div only specifies the margin, while the inner divs are positioned within it. This makes it easy to add a background to the footer div.</p>
<p><strong>Does this work?</strong></p>
<p>I&#8217;m currently using this approach in recent two web applications I built. The markup seems a lot cleaner, more standard and I have found that re-theming the same basic HTML is much nicer than reinventing the wheel. In short, I think this is a good approach. Let me know if you have improvements via a comment.</p>
<p><strong>Somewhat related: What about other techniques, such as CSS Grid frameworks or Haml/Sass?</strong></p>
<p>I&#8217;m not yet convinced that I need to use a CSS Grid framework (e.g. <a href="http://stackoverflow.com/questions/203069/what-is-the-best-css-framework-and-are-they-worth-the-effort/203133#203133">Stackoverflow discussion</a>). </p>
<p>As for <a href="http://en.wikipedia.org/wiki/Haml">Haml</a>, I&#8217;m pretty sure that I am fine with regular HTML without any syntactic sugar.</p>
<p><a href="http://sass-lang.com/">Sass</a> seems to be a real improvement over CSS (variables, nesting, mixins etc.), but on the other hand I haven&#8217;t had the time to set it up with my non-Ruby environment. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mixu.net/2010/07/20/better-web-application-interface-markup-lessons-from-theme-frameworks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick tip: Netbeans is excluding / ignoring directories in version control</title>
		<link>http://blog.mixu.net/2010/07/10/quick-tip-netbeans-is-excluding-ignoring-directories-in-version-control/</link>
		<comments>http://blog.mixu.net/2010/07/10/quick-tip-netbeans-is-excluding-ignoring-directories-in-version-control/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 10:08:51 +0000</pubDate>
		<dc:creator>Mikito Takada</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.mixu.net/?p=1019</guid>
		<description><![CDATA[Is Netbeans not showing the version control options correctly for some of your directories? Check whether you have accidentally left .svn directories. All source control system directories are hidden by default in Netbeans, which makes spotting this a bit tricky. Check for whether there is a another repo, e.g. a .svn directory somewhere in your [...]]]></description>
			<content:encoded><![CDATA[<p>Is Netbeans not showing the version control options correctly for some of your directories? Check whether you have accidentally left .svn directories. All source control system directories are hidden by default in Netbeans, which makes spotting this a bit tricky. </p>
<p>Check for whether there is a another repo, e.g. a .svn directory somewhere in your path. Netbeans seems to allow &#8220;stacking&#8221; source control systems, and will unsuccessfully try to load this versioning data instead of whatever you are using in your repository. This means that you won&#8217;t get those pretty markers for modified lines and won&#8217;t be able to view history for those files or perform a diff from the Netbeans GUI.</p>
<p>See ~/.netbeans/$version/var/log/messages.log for debugging information. Look for messages related to source control loading failures.</p>
<p>Get rid of the extra directories (e.g. .svn in each directory) in your repo, and delete ~/.netbeans/$version/var/cache/svncache to avoid conflicts with cached incorrect versioning data.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mixu.net/2010/07/10/quick-tip-netbeans-is-excluding-ignoring-directories-in-version-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick tip: how to fix &#8220;mysqlnd cannot connect to MySQL 4.1+ using old authentication&#8221; onPHP5.3</title>
		<link>http://blog.mixu.net/2010/06/06/quick-tip-how-to-fix-mysqlnd-cannot-connect-to-mysql-4-1-using-old-authentication-onphp5-3/</link>
		<comments>http://blog.mixu.net/2010/06/06/quick-tip-how-to-fix-mysqlnd-cannot-connect-to-mysql-4-1-using-old-authentication-onphp5-3/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 17:13:22 +0000</pubDate>
		<dc:creator>Mikito Takada</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.mixu.net/?p=989</guid>
		<description><![CDATA[I recently upgraded to PHP 5.3 on Windows, and ran into this problem: Warning: mysql_connect(): OK packet 6 bytes shorter than expected in ... Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using old authentication in ... I run my Linux servers on VMWare when I do development, so the MySQL database itself was from [...]]]></description>
			<content:encoded><![CDATA[<p>I recently upgraded to PHP 5.3 on Windows, and ran into this problem:</p>
<pre>
Warning: mysql_connect(): OK packet 6 bytes shorter than expected in ...
Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using old authentication in ... </pre>
<p>I run my Linux servers on VMWare when I do development, so the MySQL database itself was from quite a while ago. As you will see, the core issue here is that MySQL can have passwords with hashes stored in the old 16-character format, which is not supported by PHP 5.3&#8242;s new mysqlnd  library.</p>
<p>Since I couldn&#8217;t find a good solution with a quick Google, here is how I solved this <strong>without having to downgrade PHP or MySQL</strong> (as some of the solutions suggested):</p>
<p><strong>1. Change MySQL to NOT to use old_passwords </strong></p>
<p>It seems that even MySQL 5.x versions still default to the old password hashes. You need to change this in &#8220;my.cnf&#8221; (e.g. /etc/my.cnf): remove or comment out the line that says</p>
<pre>
old_passwords = 1
</pre>
<p>Restart MySQL. If you don&#8217;t, MySQL will keep using the old password format, which will mean that you cannot upgrade the passwords using the builtin PASSWORD() hashing function. You can test this by running:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"> <span style="color: #993333; font-weight: bold;">SELECT</span> Length<span style="color: #66cc66;">&#40;</span>PASSWORD<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'xyz'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;  
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------------------------+</span>
<span style="color: #66cc66;">|</span> Length<span style="color: #66cc66;">&#40;</span>PASSWORD<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'xyz'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------------------------+</span>
<span style="color: #66cc66;">|</span>                      <span style="color: #cc66cc;">16</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------------------------+</span>
<span style="color: #cc66cc;">1</span> row <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.00</span> sec<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>The old password hashes are 16 characters, the new ones are 41 characters.</p>
<p><strong>2. Change the format of all the passwords in the database to the new format</strong></p>
<p>Connect to the database, and run the following query:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> user<span style="color: #66cc66;">,</span>  Length<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`Password`</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">FROM</span>   <span style="color: #ff0000;">`mysql`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`user`</span>;</pre></div></div>

<p>This will show you which passwords are in the old format, ex:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------+--------------------+</span>
<span style="color: #66cc66;">|</span> user     <span style="color: #66cc66;">|</span> Length<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`Password`</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------+--------------------+</span>
<span style="color: #66cc66;">|</span> root     <span style="color: #66cc66;">|</span>                 <span style="color: #cc66cc;">41</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span> root     <span style="color: #66cc66;">|</span>                 <span style="color: #cc66cc;">16</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span> user2    <span style="color: #66cc66;">|</span>                 <span style="color: #cc66cc;">16</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span> user2    <span style="color: #66cc66;">|</span>                 <span style="color: #cc66cc;">16</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------+--------------------+</span></pre></div></div>

<p>Notice here that each user can have multiple rows (one for each different host specification).</p>
<p>To update the password for each user, run the following:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> mysql<span style="color: #66cc66;">.</span>user <span style="color: #993333; font-weight: bold;">SET</span> Password <span style="color: #66cc66;">=</span> PASSWORD<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'password'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WHERE</span> user <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'username'</span>;</pre></div></div>

<p>Finally, flush privileges:</p>
<pre>
FLUSH PRIVILEGES;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.mixu.net/2010/06/06/quick-tip-how-to-fix-mysqlnd-cannot-connect-to-mysql-4-1-using-old-authentication-onphp5-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kohana3: automatically collect internationalization strings</title>
		<link>http://blog.mixu.net/2010/06/02/kohana3-automatically-collect-internationalization-strings/</link>
		<comments>http://blog.mixu.net/2010/06/02/kohana3-automatically-collect-internationalization-strings/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 20:50:48 +0000</pubDate>
		<dc:creator>Mikito Takada</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.mixu.net/?p=976</guid>
		<description><![CDATA[I started implementing i18n for my upcoming KO3 application, and implemented a quick patch so that I don&#8217;t need to manually find and type translation strings. What this code does What the code below does is it checks whether the translation string exists, if not then it saves it into the translation file with the [...]]]></description>
			<content:encoded><![CDATA[<p>I started implementing i18n for my upcoming KO3 application, and implemented a quick patch so that I don&#8217;t need to manually find and type translation strings.</p>
<p><strong>What this code does</strong></p>
<p>What the code below does is it checks whether the translation string exists, if not then it saves it into the translation file with the English equivalent. This updated version of the translation string file is saved into /application/i18n/languagename.php, and the old file is saved with a new name containing the current date and time.</p>
<p>Hope this helps!</p>
<p><strong>How to set it up</strong></p>
<p>First set the language using i18n::lang(&#8216;xy-xx&#8217;) in bootstrap.php.</p>
<p>Also, add the following as the last line in bootstrap.php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Write the updated language file, if necessary</span>
i18n<span style="color: #339933;">::</span><span style="color: #004000;">write</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Finally, add the file <b>/application/classes/i18n.php</b> which overrides i18n::get():</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * A patch for the Internationalization (i18n) class.
 *
 * @package    I18n
 * @author Mikito Takada
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> I18n <span style="color: #000000; font-weight: bold;">extends</span> Kohana_I18n <span style="color: #009900;">&#123;</span>
   <span style="color: #666666; font-style: italic;">// Cache of missing strings</span>
   protected static <span style="color: #000088;">$_cache_missing</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009933; font-style: italic;">/**
    * Returns translation of a string. If no translation exists, the original
    * string will be returned.
    *
    * @param   string   text to translate
    * @return  string
    */</span>
   <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> get<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span>I18n<span style="color: #339933;">::</span><span style="color: #000088;">$_cache</span><span style="color: #009900;">&#91;</span>I18n<span style="color: #339933;">::</span><span style="color: #000088;">$lang</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
         <span style="color: #666666; font-style: italic;">// Load the translation table</span>
         I18n<span style="color: #339933;">::</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span>I18n<span style="color: #339933;">::</span><span style="color: #000088;">$lang</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #666666; font-style: italic;">// Return the translated string if it exists</span>
      <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span>I18n<span style="color: #339933;">::</span><span style="color: #000088;">$_cache</span><span style="color: #009900;">&#91;</span>I18n<span style="color: #339933;">::</span><span style="color: #000088;">$lang</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>         
         <span style="color: #b1b100;">return</span> I18n<span style="color: #339933;">::</span><span style="color: #000088;">$_cache</span><span style="color: #009900;">&#91;</span>I18n<span style="color: #339933;">::</span><span style="color: #000088;">$lang</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #666666; font-style: italic;">// Translated string does not exist</span>
         <span style="color: #666666; font-style: italic;">// Store the original string as missing - still makes sense to store the English string so that loading the untranslated file will work.</span>
         I18n<span style="color: #339933;">::</span><span style="color: #000088;">$_cache_missing</span><span style="color: #009900;">&#91;</span>I18n<span style="color: #339933;">::</span><span style="color: #000088;">$lang</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$string</span><span style="color: #339933;">;</span>
         <span style="color: #b1b100;">return</span> <span style="color: #000088;">$string</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> write<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">// something new must be added for anything to happen</span>
      <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span>I18n<span style="color: #339933;">::</span><span style="color: #000088;">$_cache_missing</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #000088;">$contents</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;?php defined(\'SYSPATH\') or die(\'No direct script access.\');
/**
 * Translation file in language: '</span><span style="color: #339933;">.</span>I18n<span style="color: #339933;">::</span><span style="color: #000088;">$lang</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'
 * Automatically generated from previous translation file.
 */
return '</span><span style="color: #339933;">.</span><span style="color: #990000;">var_export</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span>I18n<span style="color: #339933;">::</span><span style="color: #000088;">$_cache_missing</span><span style="color: #009900;">&#91;</span>I18n<span style="color: #339933;">::</span><span style="color: #000088;">$lang</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> I18n<span style="color: #339933;">::</span><span style="color: #000088;">$_cache</span><span style="color: #009900;">&#91;</span>I18n<span style="color: #339933;">::</span><span style="color: #000088;">$lang</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">';'</span><span style="color: #339933;">;</span>
&nbsp;
         <span style="color: #666666; font-style: italic;">// save string to file</span>
         <span style="color: #000088;">$savepath</span> <span style="color: #339933;">=</span> APPPATH<span style="color: #339933;">.</span><span style="color: #0000ff;">'/i18n/'</span><span style="color: #339933;">;</span>
         <span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> I18n<span style="color: #339933;">::</span><span style="color: #000088;">$lang</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.php'</span><span style="color: #339933;">;</span>
         <span style="color: #666666; font-style: italic;">// check that the path exists</span>
         <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$savepath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// if not, create directory</span>
            <span style="color: #990000;">mkdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$savepath</span><span style="color: #339933;">,</span> <span style="color: #208080;">0777</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
         <span style="color: #666666; font-style: italic;">// rename the old file - if the file size is different.</span>
         <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$savepath</span><span style="color: #339933;">.</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">filesize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$savepath</span><span style="color: #339933;">.</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$contents</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$savepath</span><span style="color: #339933;">.</span><span style="color: #000088;">$filename</span><span style="color: #339933;">,</span> <span style="color: #000088;">$savepath</span><span style="color: #339933;">.</span>I18n<span style="color: #339933;">::</span><span style="color: #000088;">$lang</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y_m_d_H_i_s'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
               <span style="color: #666666; font-style: italic;">// Rename failed! Don't write the file.</span>
               <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
         <span style="color: #009900;">&#125;</span>
         <span style="color: #666666; font-style: italic;">// save the file</span>
         <span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$savepath</span><span style="color: #339933;">.</span><span style="color: #000088;">$filename</span><span style="color: #339933;">,</span> <span style="color: #000088;">$contents</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Caveats and notes</strong></p>
<p>There are two things that have to be taken into account:  </p>
<ul>
<li>First, this is would obviously be inefficient for a production site, since actual files are being rewritten on each request that finds new translation strings.
</li>
<li>Why this is not a problem: My recommendation is that you shouldn&#8217;t run this code in production mode, since there is no point and it is very easy to remove the code after developement is completed. </li>
<li>Second, this approach is less comprehensive than using something like the gettext tools that are available &#8211; those tools scan all of the source code, while my approach depends on run-time detection of new strings. This means that a small percentage of strings will not be found automatically (ex. rare errors that never get triggered). </li>
<li>Why this is not a problem: This approach will still get the vast majority of the strings without requiring any manual hunting for strings, so I think it&#8217;ll save you quite a bit of time.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.mixu.net/2010/06/02/kohana3-automatically-collect-internationalization-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 3.0 multi-site multi-domain problems with solutions</title>
		<link>http://blog.mixu.net/2010/05/31/wordpress-3-0-multi-site-multi-domain-problems-with-solutions/</link>
		<comments>http://blog.mixu.net/2010/05/31/wordpress-3-0-multi-site-multi-domain-problems-with-solutions/#comments</comments>
		<pubDate>Mon, 31 May 2010 15:14:46 +0000</pubDate>
		<dc:creator>Mikito Takada</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.mixu.net/?p=935</guid>
		<description><![CDATA[Here are some problems I ran into when setting up WordPress 3.0 with multiple different domains, along with how I solved them. I figured it&#8217;s better to get them out on the blog now, and update this post if/when I have more solutions. Problem 1: I can&#8217;t load page URLs except when using ?p=xyz permalinks [...]]]></description>
			<content:encoded><![CDATA[<p>Here are some problems I ran into when setting up WordPress 3.0 with multiple different domains, along with how I solved them. I figured it&#8217;s better to get them out on the blog now, and update this post if/when I have more solutions.</p>
<h3>Problem 1: I can&#8217;t load page URLs except when using ?p=xyz permalinks</h3>
<p>If you are having problems with page URLs not working on multisite domains, make sure you have:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">    <span style="color: #00007f;">AllowOverride</span> FileInfo <span style="color: #00007f;">Options</span></pre></div></div>

<p>defined in your httpd.conf for the directory the Virtual host is in.</p>
<h3>Problem 2: The new themes I installed and activated on the main WP 3.0 site do not show up on separate domains</h3>
<p>The permissions for separate domains do not get automatically updated when you activate themes on the main site.</p>
<p>In MySQL, copy the value for &#8220;allowedthemes&#8221; in the wp_sitemeta table. This will enable themes on separate domains. Example:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`wordpress_database`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`wp_sitemeta`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`meta_id`</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`site_id`</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`meta_key`</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`meta_value`</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'2'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'allowedthemes'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'a:2:{s:9:&quot;it-oikeus&quot;;b:1;s:9:&quot;twentyten&quot;;b:1;}'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>where the site_id is the site ID for the separate domain, and meta_value is copied from the first site.</p>
<h3>Problem 3: I cannot access Plugins on separate domains</h3>
<p>In MySQL, copy the value for &#8220;menu_items&#8221; in the wp_sitemeta table. This will enable plugins on separate domains. Example:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`wordpress_database`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`wp_sitemeta`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`meta_id`</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`site_id`</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`meta_key`</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`meta_value`</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'2'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'menu_items'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'a:1:{s:7:&quot;plugins&quot;;s:1:&quot;1&quot;;}'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>where the site_id is the site ID for the separate domain, and menu_items is copied from the first site.</p>
<h3>Problem 4: New users are not visible on separate domains</h3>
<p>in wp_usermeta, set:</p>
<p>wp_2_capabilities = a:1:{s:13:&#8221;administrator&#8221;;s:1:&#8221;1&#8243;;}<br />
wp_2_user_level = 10</p>
<h3>(NEW June/2010) Problem 5: Upload files not working on separate domains</h3>
<p>Replace site_id (2) with your site id in the query below:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`wordpress_database`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`wp_sitemeta`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`meta_id`</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`site_id`</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`meta_key`</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`meta_value`</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'2'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'upload_filetypes'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'jpg jpeg png gif midi mid aac ac3 aif aiff m3a m4a m4b mka mp1 mp2 mp3 ogg oga ram wav wma asf avi divx dv flv m4v mkv mov mp4 mpeg mpg mpv ogm ogv qt rm vob wmv doc docx docm dotm odt pages pdf rtf wp wpd numbers ods xls xlsx xlsb xlsm key ppt pptx pptm odp swf asc csv tsv txt bz2 cab dmg gz rar sea sit sqx tar tgz zip css htm html php js
'</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.mixu.net/2010/05/31/wordpress-3-0-multi-site-multi-domain-problems-with-solutions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Upgrading / moving WordPress 2.9 installs to multisite WP 3.0</title>
		<link>http://blog.mixu.net/2010/05/23/upgrading-moving-wordpress-2-9-installs-to-multisite-wp-3-0/</link>
		<comments>http://blog.mixu.net/2010/05/23/upgrading-moving-wordpress-2-9-installs-to-multisite-wp-3-0/#comments</comments>
		<pubDate>Sun, 23 May 2010 08:33:24 +0000</pubDate>
		<dc:creator>Mikito Takada</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.mixu.net/?p=880</guid>
		<description><![CDATA[In the previous blog post I discussed how the multi-site functionality in WP 3.0 can be enabled and how it can be hacked to use multiple different domains. Now, let&#8217;s have a look at how you can migrate all of your old WP 2.9 sites under a single WP3.0 installation. The basic steps are: Move [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://blog.mixu.net/2010/05/17/setting-up-multisite-wordpress-3-0-with-multiple-different-domains/">previous blog</a> post I discussed <a href="http://blog.mixu.net/2010/05/17/setting-up-multisite-wordpress-3-0-with-multiple-different-domains/">how the multi-site functionality in WP 3.0 can be enabled</a> and how it can be hacked to use multiple different domains. Now, let&#8217;s have a look at how you can migrate all of your old WP 2.9 sites under a single WP3.0 installation.</p>
<p>The basic steps are:</p>
<ol>
<li>Move posts</li>
<li>Move attached files</li>
<li>Fix URLs in posts</li>
<li>Move/recreate users</li>
</ol>
<h3>1. Moving the posts from WP 2.9 to 3.0</h3>
<p>Moving the posts, links, comments and terms to WP 3.0 is quite easy. A table-by-table comparison shows that the main tables have identical structures (comparison between a 2.9.2 site and 3.0 beta 2). This means that we can use SQL for the migration. Alternatively, you could export and import (see the functionality under Tools -&gt; Export / Import).</p>
<p>In WP 3.0, the tables are sharded &#8211; each blog has it&#8217;s own set of tables, and the id of the blog is used as a part of the table name: for example, wp_2_commentmeta is the wp_commentmeta table for the multisite blog with id=2. Find out what the blog_id for your blog is, and use it in the SQL queries below.</p>
<p>I performed the following queries, which move all the tables EXCEPT the options table. Moving the options table seems to result in a broken blog, since the themes, settings and plugins referenced by WordPress will not exist in the new environment.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">TRUNCATE</span> newblog<span style="color: #66cc66;">.</span>wp_2_commentmeta;
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> newblog<span style="color: #66cc66;">.</span>wp_2_commentmeta <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> oldblog<span style="color: #66cc66;">.</span>wp_commentmeta;
&nbsp;
<span style="color: #993333; font-weight: bold;">TRUNCATE</span> newblog<span style="color: #66cc66;">.</span>wp_2_comments;
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> newblog<span style="color: #66cc66;">.</span>wp_2_comments <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> oldblog<span style="color: #66cc66;">.</span>wp_comments;
&nbsp;
<span style="color: #993333; font-weight: bold;">TRUNCATE</span> newblog<span style="color: #66cc66;">.</span>wp_2_links;
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> newblog<span style="color: #66cc66;">.</span>wp_2_links <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> oldblog<span style="color: #66cc66;">.</span>wp_links;
&nbsp;
<span style="color: #993333; font-weight: bold;">TRUNCATE</span> newblog<span style="color: #66cc66;">.</span>wp_2_postmeta;
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> newblog<span style="color: #66cc66;">.</span>wp_2_postmeta <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> oldblog<span style="color: #66cc66;">.</span>wp_postmeta;
&nbsp;
<span style="color: #993333; font-weight: bold;">TRUNCATE</span> newblog<span style="color: #66cc66;">.</span>wp_2_posts;
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> newblog<span style="color: #66cc66;">.</span>wp_2_posts <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> oldblog<span style="color: #66cc66;">.</span>wp_posts;
&nbsp;
<span style="color: #993333; font-weight: bold;">TRUNCATE</span> newblog<span style="color: #66cc66;">.</span>wp_2_terms;
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> newblog<span style="color: #66cc66;">.</span>wp_2_terms <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> oldblog<span style="color: #66cc66;">.</span>wp_terms;
&nbsp;
<span style="color: #993333; font-weight: bold;">TRUNCATE</span> newblog<span style="color: #66cc66;">.</span>wp_2_term_relationships;
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> newblog<span style="color: #66cc66;">.</span>wp_2_term_relationships <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> oldblog<span style="color: #66cc66;">.</span>wp_term_relationships;
&nbsp;
<span style="color: #993333; font-weight: bold;">TRUNCATE</span> newblog<span style="color: #66cc66;">.</span>wp_2_term_taxonomy;
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> newblog<span style="color: #66cc66;">.</span>wp_2_term_taxonomy <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> oldblog<span style="color: #66cc66;">.</span>wp_term_taxonomy;</pre></div></div>

<p><strong>What if these queries fail?</strong></p>
<p>Some WordPress plugins modify the default tables &#8211; which means there are extra fields that need to be ignored. If the INSERT INTO statements below don&#8217;t work for you, you need to explicitly state the names of the source and destination fields instead of using *. This means losing the added fields, so you need to think about it on a case-by-case basis. See the MySQL docs for INSERT INTO &#8230; SELECT syntax.</p>
<h3>2. Moving attached files</h3>
<p>WP 3.0 uses a slightly different directory structure for multisite. The files for each blog are under blogs.dir/[blog_id]/, and use the same substructure as before. Hence, the new directory structure is like this:</p>
<pre>/wp-content/blogs.dir/[blog_id]/files/...</pre>
<p>and if you keep using the same structure (ex. &#8220;year/month/filename&#8221;) you can just copy the files:</p>
<pre>mkdir -p ./wp-content/blogs.dir/[blog_id]/files/</pre>
<pre>cp -R ./oldblog/wp-content/uploads/* ./newblog/wp-content/blogs.dir/[blog_id]/files/</pre>
<h3>3. Fixing URLs in posts</h3>
<p>Try loading a post with images. The URLs (may) change from:</p>
<p>http://blog.domain.com/wp-content/uploads/2010/04/image.png</p>
<p>to:</p>
<p>http://blog.domain.com/files/2010/04/image.png</p>
<p>You can fix this by performing a replace on the wp_[blog_id]_posts table:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> wp_2_posts <span style="color: #993333; font-weight: bold;">SET</span> guid <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>guid<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://oldblog.domain.com/wp-content/uploads&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://blog.domain.com/files&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">UPDATE</span> wp_2_posts <span style="color: #993333; font-weight: bold;">SET</span> post_content_filtered <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>post_content_filtered<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://oldblog.domain.com/wp-content/uploads&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://blog.domain.com/files&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">UPDATE</span> wp_2_posts <span style="color: #993333; font-weight: bold;">SET</span> pinged <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>pinged<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://oldblog.domain.com/wp-content/uploads&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://blog.domain.com/files&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">UPDATE</span> wp_2_posts <span style="color: #993333; font-weight: bold;">SET</span> post_excerpt <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>post_excerpt<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://oldblog.domain.com/wp-content/uploads&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://blog.domain.com/files&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">UPDATE</span> wp_2_posts <span style="color: #993333; font-weight: bold;">SET</span> post_content <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>post_content<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://oldblog.domain.com/wp-content/uploads&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://blog.domain.com/files&quot;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>If you also changed the domain, you need to fix the links (do this after you fix the file upload paths):</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> wp_2_posts <span style="color: #993333; font-weight: bold;">SET</span> guid <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>guid<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://oldblog.domain.com&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://blog.domain.com&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">UPDATE</span> wp_2_posts <span style="color: #993333; font-weight: bold;">SET</span> post_content_filtered <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>post_content_filtered<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://oldblog.domain.com&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://blog.domain.com&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">UPDATE</span> wp_2_posts <span style="color: #993333; font-weight: bold;">SET</span> pinged <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>pinged<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://oldblog.domain.com&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://blog.domain.com&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">UPDATE</span> wp_2_posts <span style="color: #993333; font-weight: bold;">SET</span> post_excerpt <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>post_excerpt<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://oldblog.domain.com&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://blog.domain.com&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">UPDATE</span> wp_2_posts <span style="color: #993333; font-weight: bold;">SET</span> post_content <span style="color: #66cc66;">=</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span>post_content<span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://oldblog.domain.com&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;http://blog.domain.com&quot;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<h3>4. Moving the users</h3>
<p>You can either 1) manually create new user accounts for your users, or 2) try to move the user accounts. Most blogs don&#8217;t really have many users beyond the admin, since commenting doesn&#8217;t need a user account. My recommendation would be to manually add the very few users you have.</p>
<p>If you want to move the users in bulk using SQL, then you will need to take into account that:</p>
<ol>
<li>In WP 3.0, the <em>wp_users </em>table is shared among <em>all the sites</em>.</li>
<li>The wp_users table in WP 3.0 has two extra fields: spam and deleted.</li>
<li>Each blog site has its own <em>wp_capabilities</em>, <em>wp_user-settings</em> and <em>wp_user-settings_time</em> fields (e.g. wp_2_capabilities) in the <em>wp_users</em> table. The format (serialized PHP arrays) appears to be the same, so you will need to create one user with the rights you want manually, then these three keys for each of the blogs you want to user to be able to access.</li>
</ol>
<p>I didn&#8217;t try this out, since the blogs I have only use a small number of users. I just created individual admin accounts for those blogs that I am not administering personally.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mixu.net/2010/05/23/upgrading-moving-wordpress-2-9-installs-to-multisite-wp-3-0/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Setting up multisite WordPress 3.0 with multiple different domains</title>
		<link>http://blog.mixu.net/2010/05/17/setting-up-multisite-wordpress-3-0-with-multiple-different-domains/</link>
		<comments>http://blog.mixu.net/2010/05/17/setting-up-multisite-wordpress-3-0-with-multiple-different-domains/#comments</comments>
		<pubDate>Mon, 17 May 2010 15:28:08 +0000</pubDate>
		<dc:creator>Mikito Takada</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.mixu.net/?p=866</guid>
		<description><![CDATA[WordPress 3.0 is coming out very soon (apparently they missed their original deadline, see the schedule here) &#8211; and it has one killer feature for anyone who maintains multiple WordPress sites: official support for multiple subdomains and (unofficial) support for multiple different domains. This means that one only has to maintain and upgrade one WordPress [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress 3.0 is coming out very soon (apparently they missed their original deadline, see <a href="http://wpdevel.wordpress.com/version-3-0-project-schedule/">the schedule here</a>) &#8211; and it has one killer feature for anyone who maintains multiple WordPress sites: <strong>official support for multiple subdomains</strong> and (<em>unofficial</em>) support for multiple different domains. This means that one only has to maintain and upgrade one WordPress installation.</p>
<p>Here is my guide to setting up WordPress 3.0 with multiple different domains and subdomains &#8211; based on the experience I got from moving my own blogs to WP 3.0 beta 2 (still waiting for the final release before moving clients as well).</p>
<h2>Installing WordPress 3.0</h2>
<p>The basic installation process is the same as that of WP 2.9. Download, unzip, set up the database and the set up wp-config.php. If you aren&#8217;t going to use the multi-site support, then not much will change. Brief instructions below.</p>
<h2>Multi-site mode with Apache</h2>
<p>You will need to separately enable the multi-site mode, as well as take care of your Apache settings. WP 3.0 will handle all the requests it gets from a single directory, which means that all your subdomains must use that directory as their DocumentRoot/VirtualDocumentRoot.</p>
<p>Furthermore, WP 3.0 will assume that if you are using multi-site mode with subdomains, you want the subdomains under the first site&#8217;s URL &#8211; ex. if your first WP 3.0 install is under www.domain.com, then WP 3.0 will set up subdomains in the format subdomain1.www.domain.com.</p>
<p>That means that if you want to use first-level subdomains (ex. blog.domain.com, subdomain2.domain.com etc.), you have to set up WP 3.0 so that your first blog is using the bare domain (ex. domain.com) and not on the www.domain.com subdomain.</p>
<h3>0. (Optional) Bare domain setup for Apache</h3>
<p>The way in which you setup your bare domain (and forward from the www -subdomain to the bare domain) depends a lot on how you have set up your domain originally in Apache.</p>
<p>I have been using virtual hosts to host multiple sites, with each subdomain having its own directory. This means that I had to add an additional Vhost directive before my original Vhost directive in httpd.conf. Here is how I did it:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">    <span style="color: #00007f;">ServerName</span> domain.com
    <span style="color: #00007f;">ServerAlias</span> domain.com blog.domain.com subdomain1.domain.com
    <span style="color: #00007f;">DocumentRoot</span> /var/www/domain.com/www</pre></div></div>

<p>As you can see in the first Vhosts directive, I have used the ServerAlias directive to specify domain.com, blog.domain.com and subdomain1.domain.com to be served from the DocumentRoot /var/www/domain.com/www (which is where I have installed WP 3.0).</p>
<p>In addition, I still have the rest of my subdomains served from a VirtualDocumentRoot, and have a forward from the www.domain.com -subdomain to the domain.com bare domain.</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">    <span style="color: #00007f;">ServerName</span> domain.com
    <span style="color: #00007f;">ServerAlias</span> *.domain.com
    <span style="color: #00007f;">VirtualDocumentRoot</span> /var/www/domain.com/%1
    <span style="color: #adadad; font-style: italic;"># rewrite www to bare domain</span>
    <span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span>
    <span style="color: #00007f;">RewriteCond</span> %{HTTP_HOST} ^www\.domain\.com$ [NC]
    <span style="color: #00007f;">RewriteRule</span> (.*) http://domain.com$<span style="color: #ff0000;">1</span> [R=<span style="color: #ff0000;">301</span>,L]</pre></div></div>

<p>Apache will use the first matching VirtualHost directive (see &#8220;<a href="http://httpd.apache.org/docs/2.2/vhosts/details.html">An in-depth discussion of Virtual Host Matching</a>&#8221; for more details).</p>
<p>If you want to test your setup &#8211; remember to restart Apache &#8211; you can use an online redirect checker such as: <a href="http://www.internetofficer.com/seo-tool/redirect-check/">http://www.internetofficer.com/seo-tool/redirect-check/</a></p>
<h3>1. Get the files and unzip them</h3>
<h3>2. Edit wp_config_sample.php</h3>
<p>You can use <a href="https://api.wordpress.org/secret-key/1.1/salt/">https://api.wordpress.org/secret-key/1.1/salt/</a> to generate the secret keys</p>
<h3>3. Enable multisite</h3>
<p>Add:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span>’WP_ALLOW_MULTISITE’<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>to wp-config.php after the secret keys</p>
<h3>4. Log in, go to Tools/Network</h3>
<p>Select either the blogs-as-subdomains or blogs-as-directories option and install.</p>
<h3>5. Make the changes detailed on the post-install page</h3>
<p>WP 3.0 gives you a number of changes you will need to make manually to .htaccess and wp-config.php.</p>
<h2>Adding a new subdomain</h2>
<p>You have now set up the multisite functionality. Next, add a subdomain (see below for how to add a different domain).</p>
<h3>1. Login in on your main site</h3>
<h3>2. Go to Super Admin (new menu at the top)</h3>
<h3>3. Use the add site form to add a new subdomain</h3>
<h3>4. Configure your DNS and add a Vhost for the subdomain</h3>
<p>Make sure there is a DNS entry for your subdomain &#8211; if you don&#8217;t have a wildcard redirect for your domain to your server. If you did the Apache configuration, all you need to do now is to set up your DNS so that the subdomains you want are mapped to your server.</p>
<p><strong>Quick tip for Windows</strong>: edit C:\Windows\System32\drivers\etc\hosts and add a temporary hosts entry for your new subdomain, such as:</p>
<pre>123.14.15.16 subdomain.domain.com</pre>
<p>This will allow you to test the subdomain without having to wait for DNS to propagate. Under Win7, you need to start Notepad as an Administrator (right-click) to edit the file.</p>
<h3>5. All done!</h3>
<p>Try navigating to your new subdomain. It should be set up now!</p>
<h2>Adding a new (different) domain</h2>
<h3>1. Use the add site form to add a new subdomain</h3>
<p>You will use the default tools to create all the tables, then you will make a small number of changes to make WordPress accept a different domain. All credit for this method goes <a href="http://www.interconnectit.com/840/wordpress-3-0-multisite-with-multiple-domains-setup/">InterconnectIt &#8211; see their writeup here</a>.</p>
<h3>2. Configure your DNS and add a Vhost for the subdomain</h3>
<p>The easiest way is to add another ServerAlias domain to the original domain&#8217;s VirtualHost -&gt; ServerAlias directive.</p>
<p>If you try to access the site now, you will get a &#8220;Registration&#8221; page. This means the Vhost is working.</p>
<h3>3. Edit the wp_site table to include your new domain</h3>
<p>This table stores all the domains that can be used in WP 3.0.</p>
<p>Leave &#8220;id&#8221; empty (it is an autoincrement field), set &#8220;domain&#8221; to the domain name, &#8220;path&#8221; should be /.</p>
<p>Make a note of the id your newly inserted row gets after saving, since you will need it in the next step.</p>
<h3>4. Edit the wp_blogs table to use the new domain</h3>
<p>Find the row for the subdomain you added earlier. Change &#8220;site_id&#8221; to the id given to the new row in the wp_site table. Change &#8220;domain&#8221; to the domain name you want to use.</p>
<h3>5. Edit wp_[blog_id]_options to use the new domain name</h3>
<p>The WP 3.0 multisite database schema is sharded by having the blog id in the table names. By default these are in the form wp_[blog_id]_*, so you will need to find which set of tables contains your new blog.</p>
<p>Each WordPress blog stores a small number of settings which need be changed to use the new domain name. You can use the query below to find the mentions of the domain in the options table:</p>
<pre>SELECT * FROM `wp_[blog_id]_options` WHERE `option_value` LIKE "%subdomain.domain.com%";</pre>
<p>For me these are: siteurl, home, fileupload_url. Change them to use the new domain.</p>
<h3>6. Done!</h3>
<p><strong>Do you need to move an existing WP 2.9 to WP3.0 multisite?</strong> If you are moving an existing site to the WP multisite you&#8217;ve set up, <a href="http://blog.mixu.net/2010/05/23/upgrading-moving-wordpress-2-9-installs-to-multisite-wp-3-0/">check out my second tutorial on the topic</a>.</p>
<p><strong>Did you run into problems enabling themes or plugins on your separate domains?</strong> Have a look at <a href="http://blog.mixu.net/2010/05/31/wordpress-3-0-multi-site-multi-domain-problems-with-solutions/">how I solved a number of issues related to the separate domains setup</a>.</p>
<h2>References</h2>
<ol>
<li><a href="http://www.interconnectit.com/840/wordpress-3-0-multisite-with-multiple-domains-setup/">http://www.interconnectit.com/840/wordpress-3-0-multisite-with-multiple-domains-setup/</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.mixu.net/2010/05/17/setting-up-multisite-wordpress-3-0-with-multiple-different-domains/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Syntax highlighting / color schemes for Netbeans</title>
		<link>http://blog.mixu.net/2010/05/03/syntax-highlighting-color-schemes-for-netbeans/</link>
		<comments>http://blog.mixu.net/2010/05/03/syntax-highlighting-color-schemes-for-netbeans/#comments</comments>
		<pubDate>Mon, 03 May 2010 12:42:55 +0000</pubDate>
		<dc:creator>Mikito Takada</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.mixu.net/?p=808</guid>
		<description><![CDATA[There are two important things to try out in picking the IDE settings that work best for you: 1) the font you use and 2) the color scheme for syntax highlighting. Choice of font My font of choice is Consolas (included in Vista/Win7 and available for download). It looks awesome with ClearType and the zero [...]]]></description>
			<content:encoded><![CDATA[<p>There are two important things to try out in picking the IDE settings that work best for you: 1) the font you use and 2) the color scheme for syntax highlighting.</p>
<p><strong>Choice of font</strong></p>
<p>My font of choice is Consolas (included in Vista/Win7 and <a href="http://www.microsoft.com/DOWNLOADS/details.aspx?familyid=22E69AE4-7E40-4807-8A86-B3D36FAB68D3&amp;displaylang=en">available for download</a>). It looks awesome with ClearType and the zero character is different from the letter O. My second choice is Bitstream Vera Sans Mono, which is free and widely available.</p>
<p>The Code Project has a great compilation of <a href="http://www.codeproject.com/KB/work/FontSurvey.aspx">the 42 best programming fonts</a>.</p>
<p><strong>Choice of color</strong></p>
<p><strong><a href="http://blog.mixu.net/files/2010/05/darkwhite.png"><img class="alignnone size-full wp-image-816" title="darkwhite" src="http://blog.mixu.net/files/2010/05/darkwhite.png" alt="" width="759" height="313" /></a></strong></p>
<p>The basic choice is between a dark background and a light background. Full contrast schemes are considered more hard to read, which means that slightly off-white or off-black backgrounds are easier to read.</p>
<p>Personally, I prefer white or off-white with dark text. <a href="http://www.codinghorror.com/blog/2005/07/code-colorizing-and-readability.html">Jeff Atwood did some background reading </a>into this and quotes from a study that <em>&#8220;When light text is placed on a dark background the text may seem to glow and become blurred; this is referred to as halation, and it may make the text harder to read.&#8221; </em>Subjectively, I find white text on dark backgrounds to be a bit uncomfortable.</p>
<p>&#8220;If everything is important, then nothing is important&#8221;. This was mentioned in Garret Dimon&#8217;s <a href="http://www.slideshare.net/garrettdimon/application-interface-design">Application Interface Design presentation</a>, and I think it is a good point: Don&#8217;t highlight every syntactically different part of the code with sharp colors, just the stuff that matters the most. For me, these would be the keywords, variables and class names.</p>
<p>Hence I changed comments to be de-emphasized (gray) as well as any HTML tags (which are less important than the code in views). I am experimenting with a off-white background to slightly reduce contrast and eyestrain.</p>
<p><strong>My color scheme:</strong></p>
<p>See what my color scheme looks like at the bottom of the post. You can download it for NetBeans <a href="http://blog.mixu.net/files/2010/05/fonts.zip">here</a>.</p>
<p><strong>More color schemes:</strong></p>
<p>Whether or not you use Visual Studio (I use Netbeans), go check out the great <a href="http://studiostyles.info/schemes">gallery of syntax coloring schemes at studiostyles</a>. They have dozens of user-submitted color schemes and alternatives which you can use as a basis for configuring your own IDE.</p>
<p><a href="http://blog.mixu.net/files/2010/05/colors.png"><img class="alignnone size-full wp-image-811" title="colors" src="http://blog.mixu.net/files/2010/05/colors.png" alt="" width="634" height="596" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mixu.net/2010/05/03/syntax-highlighting-color-schemes-for-netbeans/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>7 additional tips for CSS markup</title>
		<link>http://blog.mixu.net/2010/03/15/7-additional-tips-for-css-markup/</link>
		<comments>http://blog.mixu.net/2010/03/15/7-additional-tips-for-css-markup/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 21:15:30 +0000</pubDate>
		<dc:creator>Mikito Takada</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.mixu.net/?p=740</guid>
		<description><![CDATA[1. Use a test page Make a test page that has: All of the common HTML elements All of your widgets and inline elements &#8230; on one page. This allows you to make and preview changes quickly. Snippllr.com has a couple of test pages containing the major HTML elements: http://snipplr.com/view/8121/html-test-page-for-css-style-guide/ http://snipplr.com/view/12564/css-test-page/ 2. Start with a [...]]]></description>
			<content:encoded><![CDATA[<h2>1. Use a test page</h2>
<p>Make a test page that has:</p>
<ol>
<li>All of the common HTML elements</li>
<li>All of your widgets and inline elements</li>
</ol>
<p>&#8230; on one page. This allows you to make and preview changes quickly.</p>
<p>Snippllr.com has a couple of test pages containing the major HTML elements:</p>
<p><a href="http://snipplr.com/view/8121/html-test-page-for-css-style-guide/ ">http://snipplr.com/view/8121/html-test-page-for-css-style-guide/<br />
</a><a href="http://snipplr.com/view/8121/html-test-page-for-css-style-guide/ "> http://snipplr.com/view/12564/css-test-page/</a></p>
<h2>2. Start with a CSS reset</h2>
<p>Using a CSS reset helps because it eliminates the inconsistencies between browsers and forces you to specify all of the styles you want. It makes CSS stylesheets more explicit, which is a good thing for maintainability.</p>
<p><a href="http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/">http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/</a></p>
<p><a href="http://developer.yahoo.com/yui/reset/  ">http://developer.yahoo.com/yui/reset/</a></p>
<h2 style="font-size: 1.5em;">3.Order your rulesets into sections &#8211; generic to specific</h2>
<p>Use stylesheet rule order to define &#8220;base&#8221; and &#8220;special case&#8221; tags. First, organize your CSS rules into sections so that the most generic rules (e.g. typography) come first before specific rules such as widgets. This is useful because it makes it easier to locate rules within the file and to make modifications.</p>
<p>For example, I have used the following sections:</p>
<div id="_mcePaste">
<ol>
<li> Base/reset styles (Yahoo&#8217;s CSS reset rules)</li>
<li> Typography styles (inline elements applied to the whole page such as fonts, links, headings, paragraphs)</li>
<li> Layout (fixed containers, blocks of content and other &#8220;website-specific&#8221; positioning)</li>
<li>Widgets (ex.  informational messages, contextual help, menu lists, collapsible navigation list, tabs, table styles&#8230;)</li>
</ol>
</div>
<h2 style="font-size: 1.5em;">4. Order your widget rules from &#8220;base&#8221; to &#8220;special case&#8221;</h2>
<p>Organize the rules into &#8220;base&#8221; widgets and &#8220;special case&#8221; if necessary. Have the &#8220;base&#8221; widget specify the most important rules, and then override for the &#8220;special case&#8221;.</p>
<h2 style="font-size: 1.5em;">5. Indent your CSS files!</h2>
<p>Use indentation to organize the code &#8211; the first level of indentation is for sections, the second for widgets and the third for special cases of widgets or sub-widgets. (If you are concerned about bandwidth, use a CSS minifier afterwards &#8211; don&#8217;t sacrifice understandability just to try to save a few characters).</p>
<p>For example:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/** Css reset **/</span>
<span style="color: #808080; font-style: italic;">/** Base styles **/</span>
   ...
<span style="color: #808080; font-style: italic;">/** Typography styles **/</span>
   ...
<span style="color: #808080; font-style: italic;">/** Layout styles **/</span>
   <span style="color: #808080; font-style: italic;">/** Containers **/</span>
   ...
<span style="color: #808080; font-style: italic;">/** Widgets **/</span>
   <span style="color: #808080; font-style: italic;">/** Information messages **/</span>
   ...
   <span style="color: #808080; font-style: italic;">/** Tabs widget **/</span>
   div<span style="color: #6666ff;">.tabs</span> <span style="color: #00AA00;">&#123;</span>
      ...
   <span style="color: #00AA00;">&#125;</span>
   div<span style="color: #6666ff;">.tabs</span> ul <span style="color: #00AA00;">&#123;</span>
      ...
   <span style="color: #00AA00;">&#125;</span>
   div<span style="color: #6666ff;">.tabs</span> ul li <span style="color: #00AA00;">&#123;</span>
      ...
   <span style="color: #00AA00;">&#125;</span>
   div<span style="color: #6666ff;">.tabs</span> ul a<span style="color: #3333ff;">:link</span><span style="color: #00AA00;">,</span> div<span style="color: #6666ff;">.tabs</span> ul a<span style="color: #3333ff;">:visited </span><span style="color: #00AA00;">&#123;</span>
      ...
   <span style="color: #00AA00;">&#125;</span>
   div<span style="color: #6666ff;">.tabs</span> ul li<span style="color: #6666ff;">.selected</span> a<span style="color: #00AA00;">,</span> div<span style="color: #6666ff;">.tabs</span> ul a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
      ...
   <span style="color: #00AA00;">&#125;</span></pre></div></div>

<h2>6. Keep the dependency chains as short as possible</h2>
<p>Avoid modifying the HTML element styles without specifying a class. Adding styles to tags without a class -attribute is problematic because it makes the dependencies much more complex.</p>
<p>By keeping dependency chains short &#8211; so that the base CSS is unmodified and all necessary styles are defined on a class-specific level &#8211;  you keep the dependencies reasonably simple.</p>
<h2>7. Never rely on coincidental nesting &amp; avoid &#8220;class-itis&#8221;</h2>
<p>&#8220;Class-itis&#8221; is the disease that causes CSS files to have too many classes. Instead, use tag nesting to create widgets.</p>
<p>Have single base element with a simple but descriptive class name, and then specify the sub-elements.</p>
<p>For example:</p>
<ul>
<li>Instead of &#8220;div.content-title&#8221; use &#8220;#content h1&#8243; (e.g. div#content with a h1 tag inside it)</li>
<li>Instead of &#8220;div.form-label&#8221; use &#8220;#form label&#8221; (e.g. form#form with a label tag inside it)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.mixu.net/2010/03/15/7-additional-tips-for-css-markup/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
