<?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>gog&#039;s info</title>
	<atom:link href="http://gogs.info/feed/" rel="self" type="application/rss+xml" />
	<link>http://gogs.info</link>
	<description>&#60;?php echo array_rand(array(&#039;web&#039;, &#039;dev&#039;, &#039;computers&#039;)); ?&#62;</description>
	<lastBuildDate>Wed, 31 Mar 2010 19:56:52 +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>Blank page after a quick reply (vBulletin)</title>
		<link>http://gogs.info/2010/03/blank-page-after-a-quick-reply-vbulletin/</link>
		<comments>http://gogs.info/2010/03/blank-page-after-a-quick-reply-vbulletin/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 19:02:00 +0000</pubDate>
		<dc:creator>Goran Jurić</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[adsense]]></category>
		<category><![CDATA[vbulletin]]></category>

		<guid isPermaLink="false">http://gogs.info/?p=128</guid>
		<description><![CDATA[While launching the Google Adsense on Gameplay and its forum (vBulletin 3.8) we ran into a strange issue while posting quick reply messages to the forum with Firefox. After hitting submit the page turned blank although the comment was apparently posted. We have integrated our Adsense code into the postbit vBulletin template after the last [...]]]></description>
			<content:encoded><![CDATA[<p>While launching the Google Adsense on <a href="http://www.gameplay.hr/">Gameplay</a> and its forum (vBulletin 3.8) we ran into a strange issue while posting quick reply messages to the forum with Firefox. After hitting submit the page turned blank although the comment was apparently posted.</p>
<p>We have integrated our Adsense code into the postbit vBulletin template after the last post on the page using this syntax:</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;if</span> <span style="color: #000066;">condition</span>=<span style="color: #ff0000;">&quot;$post['islastshown']&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    Adsense code here.
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/if<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The problem happend because Quick Reply uses asynchronous javascript to submit the reply and render the new reply at the and of the page. Since we are embedding the Adsense code if the post is &#8220;last shown&#8221; this renderd the Google Adsense code twice and FF &#8220;broke&#8221;.</p>
<p>The fix is quite simple, you just have to check if the post is being sent as a response to the asynchronous request, so the new and working code looks like this:</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;if</span> <span style="color: #000066;">condition</span>=<span style="color: #ff0000;">&quot;$post['islastshown'] AND !$GLOBALS['vbulletin']-&gt;</span></span>GPC['ajax']&quot;&gt;
    Adsense code here.
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/if<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Of course this is not the only case which causes vBulletin forum to render a blank page. For a list of other possible reasons take a look at <a href="http://www.vbulletin.com/docs/html/blank_pages">this chapter in the  official documentation</a>.</p>
<p>If you are interested you can also take a look at this exhaustive <a href="http://forum.vbulletinsetup.com/f18/vbulletin-template-conditionals-list-2185.html">list of conditionals</a> which you can use in your vBulletin templates.</p>
]]></content:encoded>
			<wfw:commentRss>http://gogs.info/2010/03/blank-page-after-a-quick-reply-vbulletin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Set filenames with Nginx secure download module</title>
		<link>http://gogs.info/2010/03/set-filenames-with-nginx-secure-download-module/</link>
		<comments>http://gogs.info/2010/03/set-filenames-with-nginx-secure-download-module/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 16:34:40 +0000</pubDate>
		<dc:creator>Goran Jurić</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://gogs.info/?p=116</guid>
		<description><![CDATA[When we switched from Lighttpd to Nginx a couple of months ago we were faced with an annoying problem. Paying subscribers to our site have an option of downloading PDF files of the magazine. With Lighttpd we were using mod_secdownload to provide this functionality without exposing the files to the public. We compiled Nginx with [...]]]></description>
			<content:encoded><![CDATA[<p>When we switched from <a href="http://www.lighttpd.net/">Lighttpd</a> to <a href="http://wiki.nginx.org/">Nginx</a> a couple of months ago we were faced with an annoying problem.</p>
<p>Paying subscribers to our site have an option of downloading PDF files of the magazine. With Lighttpd we were using <a href="http://redmine.lighttpd.net/wiki/lighttpd/docs:modsecdownload">mod_secdownload</a> to provide this functionality without exposing the files to the public. We compiled Nginx with the <a href="http://wiki.nginx.org/NginxHttpSecureDownload">secure_download_module</a> and it kinda worked.</p>
<p>Files were downloading as expected but the file names where all messed up. Download links where generated for each user and they looked something like this: <em>/pdf/645.pdf/097ac16cb19ff6c163d6f813fdd44b4d/4b283bfa</em> and the browser saved the file to the users hard drive with the file name of <em>4b283bfa</em>. Since the file name didn&#8217;t have an extension it was impossible for the OS to know that is has to use a PDF reader to open the file.</p>
<p>Finally we managed to force the file name to the browser (download client) with a configuration directive that looks something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">    <span style="color: #666666; font-style: italic;"># PDF download</span>
    location <span style="color: #000000; font-weight: bold;">/</span>pdf <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        secure_download on;
        secure_download_secret <span style="color: #007800;">$request_addr</span>;
        secure_download_path_mode <span style="color: #c20cb9; font-weight: bold;">file</span>;
        root <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>dir<span style="color: #000000; font-weight: bold;">/</span>with<span style="color: #000000; font-weight: bold;">/</span>pdfs
&nbsp;
        <span style="color: #666666; font-style: italic;"># Extract the name of the PDF</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$uri</span> ~ <span style="color: #ff0000;">&quot;^/pdf/(.+\.pdf)$&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">$filename</span> $<span style="color: #000000;">1</span>;
        <span style="color: #7a0874; font-weight: bold;">&#125;</span>
        <span style="color: #666666; font-style: italic;"># Set appropriate headers</span>
        add_header Content-Disposition <span style="color: #ff0000;">&quot;attachment; filename=<span style="color: #007800;">$filename</span>&quot;</span>;
    <span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>And that&#8217;s all there is to it.</p>
]]></content:encoded>
			<wfw:commentRss>http://gogs.info/2010/03/set-filenames-with-nginx-secure-download-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UTF-8 encoding and the TinyMCE SpellCheck plugin</title>
		<link>http://gogs.info/2010/03/utf-8-encoding-and-the-tinymce-spellcheck-plugin/</link>
		<comments>http://gogs.info/2010/03/utf-8-encoding-and-the-tinymce-spellcheck-plugin/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 14:42:02 +0000</pubDate>
		<dc:creator>Goran Jurić</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[spellcheck]]></category>
		<category><![CDATA[tinymce]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://gogs.info/?p=108</guid>
		<description><![CDATA[If you have tried using the the TinyMCE spell check plugin on UTF-8 encoded page with the PSpellShell adapter you probably noticed that the implementation is broken. The spelling suggestions do not contain properly encoded UTF-8 characters. Since the creators of TinyMCE moved to Github it was a great opportunity to try and push these [...]]]></description>
			<content:encoded><![CDATA[<p>If you have tried using the the <a href="http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker">TinyMCE spell check plugin</a> on UTF-8 encoded page with the PSpellShell adapter you probably noticed that the implementation is broken. The spelling suggestions do not contain properly encoded UTF-8 characters.</p>
<p>Since the creators of TinyMCE moved to <a href="http://github.com/">Github</a> it was a great opportunity to try and push these changes to the master branch. If you need this you can look at the <a href="http://github.com/gjuric/tinymce_spellchecker_php/commit/5d8430ccb116ae83218a48c0dc36088ecc250596">changes that need to be made to the PSpellShell adapter</a> or just clone my <a href="http://github.com/gjuric/tinymce_spellchecker_php">fork of the spellcheck plugin</a>.</p>
<p>p.s. Have I mentioned how awesome Git and Github are?</p>
]]></content:encoded>
			<wfw:commentRss>http://gogs.info/2010/03/utf-8-encoding-and-the-tinymce-spellcheck-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Give your .02$ to the ZF project</title>
		<link>http://gogs.info/2009/12/give-your-02-to-the-zf-project/</link>
		<comments>http://gogs.info/2009/12/give-your-02-to-the-zf-project/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 01:23:35 +0000</pubDate>
		<dc:creator>Goran Jurić</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[zf]]></category>

		<guid isPermaLink="false">http://gogs.info/?p=101</guid>
		<description><![CDATA[Zend Framework project is about to start working on the 2.0 version. If you are using ZF in your projects, but you are not interested in contributing ideas to the project by joining the zf-contributors mailing list, the least you could do is provide feedback about your ZF experience by answering a survey. You can [...]]]></description>
			<content:encoded><![CDATA[<p>Zend Framework project is about to start working on the 2.0 version. If you are using ZF in your projects, but you are not interested in contributing ideas to the project by joining the zf-contributors mailing list, the least you could do is provide feedback about your ZF experience by answering a <a href="http://bit.ly/65khf8">survey</a>.</p>
<p>You can find more info at the <a href="http://devzone.zend.com/article/11485-Zend-Framework-Survey-for-2009">devzone</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gogs.info/2009/12/give-your-02-to-the-zf-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google confused with 301 redirects</title>
		<link>http://gogs.info/2009/11/google-confused-with-301-redirects/</link>
		<comments>http://gogs.info/2009/11/google-confused-with-301-redirects/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 11:30:23 +0000</pubDate>
		<dc:creator>Goran Jurić</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[301]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Googlebot]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[URI]]></category>

		<guid isPermaLink="false">http://gogs.info/?p=99</guid>
		<description><![CDATA[It has been almost I year since we launched nacional.hr. During the migration from the old content management we thoroughly went through the whole system and made sure that all the old URIs are still working. Although cool URIs don&#8217;t change sometimes you have no choice and that was the case with this site. We [...]]]></description>
			<content:encoded><![CDATA[<p>It has been almost I year since we launched <a href="http://www.nacional.hr/">nacional.hr</a>. During the migration from the old content management we thoroughly went through the whole system and made sure that all the old URIs are still working. Although <a href="http://www.w3.org/Provider/Style/URI">cool URIs don&#8217;t change</a> sometimes you have no choice and that was the case with this site. We had to enhance some of the URIs for SEO purpose and some of them were just clashing with our URI scheme it we did not want to maintain a large list of legacy URIs in our rewrite rules.</p>
<p>We hooked a legacy URI &#8220;plugin&#8221; in our error controller so that checking for old URIs does not interfere with the loading times of our system unless really necessary and created 301 (permanent) redirects to our new URI scheme patted ourselves on the back an forgot all about it until recently.</p>
<p>While checking the access logs for some unusual traffic spikes we where getting we noticed that Google stills checks our old category URIs and follows the redirects that we have created. The most unusual things was that the URIs where checked very often. Links to our news category pages where crawled by Google a couple of times a minute during the course of couple of days. To add to the confusion the categories that are most often crawled our the ones that list articles from our print issue which get updated once a week, the ones that are updated many times a day get crawled at a regular pace.</p>
<p>Any ideas what could cause something like this?</p>
]]></content:encoded>
			<wfw:commentRss>http://gogs.info/2009/11/google-confused-with-301-redirects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hudson and PHP Howto</title>
		<link>http://gogs.info/2009/11/hudson-and-php-howto/</link>
		<comments>http://gogs.info/2009/11/hudson-and-php-howto/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 18:53:59 +0000</pubDate>
		<dc:creator>Goran Jurić</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ci]]></category>
		<category><![CDATA[continuous Integration]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[hudson]]></category>
		<category><![CDATA[phpundercontrol]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://gogs.info/?p=93</guid>
		<description><![CDATA[After a couple of weeks of playing with phpUnderControl and reading some nice reviews of Hudson I decided to give it a try. And boy am I glad I did. Hudson definitively won me over with its clean interface and easy to setup tasks. Even plugin installation is a breeze and you can even do [...]]]></description>
			<content:encoded><![CDATA[<p>After a couple of weeks of playing with <a href="http://www.phpundercontrol.org/about.html">phpUnderControl</a> and reading some nice reviews of <a href="http://hudson-ci.org/">Hudson</a> I decided to give it a try. And boy am I glad I did.</p>
<p>Hudson definitively won me over with its clean interface and easy to setup tasks. Even plugin installation is a breeze and you can even do it right out of the comfort of your browser.</p>
<p>I found a quite nice tutorial about setting up Hudson with PHP <a href="http://toptopic.wordpress.com/2009/02/26/php-and-hudson/">here</a> but I had some questions marks hovering over my head during the installation so I have decided to write a more detailed installation tutorial.</p>
<p>If you are running a Debian flavored distribution (yes I mean Ubuntu) take a look at the <a href="http://gogs.info/wiki/debian/hudson">tutorial</a>, you should have <a href="http://gogs.info/wiki/debian/hudson">Hudson working with your PHP projects</a> in no time.</p>
<p>Bonus points if you integrate your Hudson installation to act as your staging server.</p>
]]></content:encoded>
			<wfw:commentRss>http://gogs.info/2009/11/hudson-and-php-howto/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Install phpUnit on Mac OSX 10.6</title>
		<link>http://gogs.info/2009/11/install-phpunit-on-mac-osx-10-6/</link>
		<comments>http://gogs.info/2009/11/install-phpunit-on-mac-osx-10-6/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 15:08:26 +0000</pubDate>
		<dc:creator>Goran Jurić</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpUnit]]></category>
		<category><![CDATA[unit testing]]></category>
		<category><![CDATA[Zend Studio]]></category>

		<guid isPermaLink="false">http://gogs.info/?p=90</guid>
		<description><![CDATA[Here is another quick How-to so I don&#8217;t have to look it up next time. Open up Terminal.app and enter &#8220;sudo su&#8221; and enter your password when asked (I guess you must be using an account with administrator privileges). pear upgrade PEAR pear channel-discover pear.phpunit.de pear install &#8211;alldeps phpunit/PHPUnit That&#8217;s it. phpunit binary should be [...]]]></description>
			<content:encoded><![CDATA[<p>Here is another quick How-to so I don&#8217;t have to look it up next time.</p>
<p>Open up Terminal.app and enter &#8220;sudo su&#8221; and enter your password when asked (I guess you must be using an account with administrator privileges).</p>
<blockquote><p>pear upgrade PEAR<br />
pear channel-discover pear.phpunit.de<br />
pear install &#8211;alldeps phpunit/PHPUnit</p></blockquote>
<p>That&#8217;s it. phpunit binary should be in your path now.</p>
<p>p.s.</p>
<p>For some reason phpUnit that is being used by Zend Studios (6.1) does not have mbstring extension compiled and that makes it unusable for me. I guess there is a way to force PHP interpreter that is being used in the Zend Studio to run with the mbstring extension, but this is a faster approach. Hudson or phpUnderControl (whichever you like) will take care of the code coverage reports.</p>
]]></content:encoded>
			<wfw:commentRss>http://gogs.info/2009/11/install-phpunit-on-mac-osx-10-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Munin on Debian Lenny &#8211; Howto</title>
		<link>http://gogs.info/2009/09/munin-on-debian-lenny-howto/</link>
		<comments>http://gogs.info/2009/09/munin-on-debian-lenny-howto/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 21:40:04 +0000</pubDate>
		<dc:creator>Goran Jurić</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[munin]]></category>
		<category><![CDATA[wiki]]></category>

		<guid isPermaLink="false">http://gogs.info/?p=87</guid>
		<description><![CDATA[I have been playing with an excellent monitoring tool Munin. Since I had some glitches while trying to install it on my server a have decided to update my Wiki a little bit and add a tutorial about setting up Munin on Debian Lenny. It is quite late and I do not feel like proofreading [...]]]></description>
			<content:encoded><![CDATA[<p>I have been playing with an excellent monitoring tool <a href="http://munin.projects.linpro.no/">Munin</a>. Since I had some glitches while trying to install it on my server a have decided to update <a href="http://gogs.info/wiki/">my Wiki</a> a little bit and add a tutorial about <a href="http://gogs.info/wiki/debian/munin">setting up Munin on Debian Lenny</a>. It is quite late and I do not feel like proofreading this entry right now so you will have to forgive me if I forgot something.</p>
]]></content:encoded>
			<wfw:commentRss>http://gogs.info/2009/09/munin-on-debian-lenny-howto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix the Tab key on your Mac</title>
		<link>http://gogs.info/2009/09/fix-the-tab-key-on-your-mac/</link>
		<comments>http://gogs.info/2009/09/fix-the-tab-key-on-your-mac/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 14:14:26 +0000</pubDate>
		<dc:creator>Goran Jurić</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[tab]]></category>

		<guid isPermaLink="false">http://gogs.info/?p=77</guid>
		<description><![CDATA[One of the things that bugged me the most after switching to Mac on my job was an inability to use the Tab key to move across all of the elements in a form. Using the Tab key after a fresh install of your Mac will move you over the text input fields only. Since [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things that bugged me the most after switching to Mac on my job was an inability to use the Tab key to move across all of the elements in a form. Using the Tab key after a fresh install of your Mac will move you over the text input fields only.</p>
<p>Since a have reinstalled my computer with a fresh copy of Snow Leopard couple of weeks ago I found myself browsing through the System preferences looking for the same option again.</p>
<p>So, as a future reminder for myself you have to press the Ctrl + F7, or open up System Preferences -&gt; Keyboard -&gt; Keyboard Shortcuts and select &#8220;All controls&#8221; in the bottom of your screen.</p>
<p><span id="more-77"></span></p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-80" title="Mac OSX 10.6 Keyboard Preferences Pane" src="http://gogs.info/wp-content/uploads/2009/09/system-preferences.png" alt="Mac OSX 10.6 Keyboard Preferences Pane" width="668" height="597" /></p>
]]></content:encoded>
			<wfw:commentRss>http://gogs.info/2009/09/fix-the-tab-key-on-your-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>From DocBook to PDF using Apache FOP</title>
		<link>http://gogs.info/2009/05/from-docbook-to-pdf-using-apache-fop/</link>
		<comments>http://gogs.info/2009/05/from-docbook-to-pdf-using-apache-fop/#comments</comments>
		<pubDate>Thu, 21 May 2009 11:45:47 +0000</pubDate>
		<dc:creator>Goran Jurić</dc:creator>
				<category><![CDATA[Documentation]]></category>
		<category><![CDATA[apache fop]]></category>
		<category><![CDATA[docbook]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[fop]]></category>
		<category><![CDATA[utf-8]]></category>
		<category><![CDATA[xsl]]></category>

		<guid isPermaLink="false">http://gogs.info/?p=62</guid>
		<description><![CDATA[Creating user manuals for the software you are building is an important task. Sometimes it is a project requirement but more often than that it is just more efficient having a document to which you can refer users to and stop waisting you precious time explaining the fundamentals of content management systems to novice users [...]]]></description>
			<content:encoded><![CDATA[<p>Creating user manuals for the software you are building is an important task. Sometimes it is a project requirement but more often than that it is just more efficient having a document to which you can refer users to and stop waisting you precious time explaining the fundamentals of content management systems to novice users instead of actually doing what you are payed for.</p>
<p>Since I do not like to repeat myself I wanted a system that is capable of generating documentation in variety of formats, PDF being the most important one.</p>
<p><a href="http://www.docbook.org/">DocBook</a> is the first thing that came to mind, but as it is usually the case the things are not so simple as they should be. After playing fore the most part of the day with DocBook and various utilities I decided to write it down for future reference.<span id="more-62"></span></p>
<p>I will not contemplate on the DocBook syntax as there are various sources on the internet that will teach you how to use the DocBook syntax for writing. The place that got me started was a <a href="http://blog.astrumfutura.com/archives/369-Writing-Professional-Looking-Documentation-With-Docbook,-PHP,-Phing-and-Apache-FOP-Part-1-Getting-Started.html">blog post by Pádraic Brady</a>. I am using the directory structure he created as well as sample files, with little modifications. Take a look ad DocBook samples he provides.</p>
<p>For starters I do not use any PHP code in my documentation so I do not have the need for Phing tasks that take care of syntax highlighting program listings (yet). Other modifications I made include dropping the DocBook DTD from the manual.xml. That is the line that in his sample starts with &#8220;&lt;!DOCTYPE book PUBLIC &#8220;-//OASIS//DTD DocBook XML V5.0//EN&#8221; &#8230;&#8221;.</p>
<p>Another thing I needed to add was language information for my &lt;book&gt; so for Croatian language it now looks like this:</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;book</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;hr&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;5.0&quot;</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://docbook.org/ns/docbook&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">xmlns:xlink</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xlink&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">xmlns:xi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XInclude&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">xmlns:svg</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2000/svg&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">xmlns:mml</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1998/Math/MathML&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">xmlns:html</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">xmlns:db</span>=<span style="color: #ff0000;">&quot;http://docbook.org/ns/docbook&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p>&#8220;hr&#8221; is a two-letter country code for Croatia. I will explain later why the language attribute is important.</p>
<p>To create a PDF from your DocBook XML files you will need to download:</p>
<ul>
<li><a href="http://xmlgraphics.apache.org/fop/download.html">Apache FOP</a></li>
<li><a href="http://offo.sourceforge.net/hyphenation/">FOP XML Hyphenation Patterns</a></li>
<li><a href="http://sourceforge.net/project/showfiles.php?group_id=21935&amp;package_id=16608">DocBook XSL stylesheets</a></li>
</ul>
<p>If you also want to validate the syntax of your XML files you will need the <a href="http://www.docbook.org/xml/5.0/docbook-5.0.zip">DocBook 5.0 DTD</a>. I will not go into details on validating DocBoox syntax, but it is recommended that you validate your files because I guess it is faster than invoking Apache FOP to generate you PDF and realising that somewhere at the end of your documentation there is a syntax error.</p>
<h2>DocBook XSL</h2>
<p>After you extract the archive of DocBoox XSL stylesheets you will get a myriad of files and folders. In the &#8220;fo&#8221; folders you will find XSL documents used for transformation of your XML documents, and the file you will have to pass to Apache FOP is located in &#8220;fo/docbook.xsl&#8221;.</p>
<p>Files located in the &#8220;common&#8221; folder contain common terms used in creation of a book based on the language attribute of your book. As a specified that my book is written in Croatian Apache FOP will use &#8220;common/hr.xml&#8221; to look for terms such as &#8220;Table of Content&#8221;, &#8220;Chapter&#8221;, etc. This XML file is the one you want to edit if you want to change the output strings used for creation of the PDF document.</p>
<h2>Apache FOP</h2>
<p>Since the Apache FOP will probably complain about hyphenation, <a href="http://offo.sourceforge.net/hyphenation/fop-stable/installation.html">grab the hyphenation patterns</a> and copy the jar file fop-hyph.jar into the lib directory of the your FOP installation (the place where you have extracted Apache FOP).</p>
<h2>Encoding (UTF-8) problems with Apache FOP</h2>
<p>There are 14 most used fonts that you can use in your PDF files that do not require you to embedd the font file itself into the PDF. The problems is that these fonts do not have support for all the characters you are probably using if your are converting a document that is not written in English. Accented characters are replaced with hashes if you do not use a font that supports multi-byte characters.</p>
<p>There is an explanation about <a href="http://xmlgraphics.apache.org/fop/0.94/fonts.html">embedding fonts in the PDF using Apache FOP at their site</a> but this documentation is written for Apache FOP 0.94 and since 0.95 (the current stable release) it is not necessary to create a font metrics file and trying to create one will probably result in an error.</p>
<p>To get the font file embedded into our PDF we need to tell Apache FOP to embed the fonts. Open up the &#8220;conf/fop.xconf&#8221; file with a text editor and find the part of the configuration file that is enclosed in &lt;renderer mime=&#8221;application/pdf&#8221;&gt;&lt;fonts&gt; &#8230; &lt;/font&gt;&lt;/renderer&gt; and insert</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;font</span> <span style="color: #000066;">kerning</span>=<span style="color: #ff0000;">&quot;yes&quot;</span> <span style="color: #000066;">embed-url</span>=<span style="color: #ff0000;">&quot;/Users/gog/Desktop/fop-0.95/times-roman.ttf&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;font-triplet</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Times-Roman&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;normal&quot;</span> <span style="color: #000066;">weight</span>=<span style="color: #ff0000;">&quot;normal&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;font-triplet</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Times-Roman&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;normal&quot;</span> <span style="color: #000066;">weight</span>=<span style="color: #ff0000;">&quot;bold&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/font<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Of course you will have to replace the embed-url with the path to Times New Roman.ttf file on your system.</p>
<p>Wrap it all up</p>
<p>And finally to generate the PDF navigate to the folder where you extracted the Apache FOP archive and run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>fop <span style="color: #660033;">-c</span> conf<span style="color: #000000; font-weight: bold;">/</span>fop.xconf <span style="color: #660033;">-xml</span> manual.xml <span style="color: #660033;">-xsl</span> docbook.xsl <span style="color: #660033;">-param</span> body.font.family Times-Roman <span style="color: #660033;">-param</span> title.font.family Times-Roman <span style="color: #660033;">-pdf</span> manual.pdf</pre></div></div>

<p>In case you are using Windows you probably just need to replace &#8220;./fop&#8221; at the end of the line with &#8220;fop.bat&#8221;. Ofcourse you will have to change manual.xml with the full path to your DocBook document and docbook.xsl with the full path to that file located in the DocBook XSL stylesheets inside the &#8220;fo&#8221; folder.</p>
<p>The important part to notice is that we needed to tell the XML processor to use Times-Roman font for body and title text and that we configured Apache FOP to embed the &#8220;Times-Roman&#8221; font into the PDF document.</p>
<p>I guess there is a better way to customize the output of your PDF files without using &#8220;-param&#8221; during the invocation of the FOP. Maybe I&#8217;ll come back to it later, for now this works for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://gogs.info/2009/05/from-docbook-to-pdf-using-apache-fop/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
