Wordpress to Jekyll Migration

I just finished my migration from wordpress to jekyll.

Before you start

Make yourself familiar with the Jekyll liquid template info page and the Liquid for Designers wiki page.

It is also very helpful to take a look at the sources for one of the listed jekyll sites.

Splitting up your wordpress theme template

I save the index page into a dummy file and started to split the contents of that file up into manageable parts. At the end i got the following files:

  • head-includes.html – A include file that contains all the css and javascript includes for my blog
  • default.html – The default template file that contains the raw html skeleton for my blog. It also contained include tags for the head-includes.html.
  • post.html – The post template is a child of the default.html template. This template adds those html parts to the default.html that is needed to frame a post. It also contains various includes for widgets – such as the tag cloud widget and so on.

Exporting Wordpress Posts

$ ruby -rubygems -e 'require "jekyll/migrators/wordpress"; Jekyll::WordPress.process("database", "user", "pass", "127.0.0.1")'

I had to fix a lot of encoding issues in the generated post files. I used sed to correct those encoding issues. There might by way configuring the encoding format for the exporter.

Plugins

I added some plugins to handle youtube videos, adding code snippets etc. Please note that you mostly can’t use such plugins with github pages because github is only allowing building jekyll pages with safe plugins.

RSS Feed

  • /feed/index.html
    ---
    layout: nil
    ---
    <?xml version="1.0" encoding="utf-8"?>
    <feed xmlns="http://www.w3.org/2005/Atom">
     <title>Jotschi.de</title>
     <link href="http://www.jotschi.de/atom.xml" rel="self"/>
     <link href="http://www.jotschi.de/"/>
     <updated>{{ site.time | date_to_xmlschema }}</updated>
     <id>http://www.jotschi.de/</id>
     <author>
       <name>Jotschi</name>
       <email>[email protected]</email>
     </author>
     {% for post in site.posts %}
     <entry>
       <title>{{ post.title }}</title>
       <link href="http://www.jotschi.de{{ post.url }}"/>
       <updated>{{ post.date | date_to_xmlschema }}</updated>
       <id>http://www.jotschi.de{{ post.id }}</id>
       <content type="html">{{ post.content | xml_escape }}</content>
     </entry>
     {% endfor %}
    </feed>
    

Importing Comments to Disqus

I choose disqus to handle comments on my blog. I created a comments-widget.html file which i placed within my ___includes__ directory. That file contains the needed javascript that is used to embed disqus within my website.

It is possible to import your wordpress comments into your disqus account. I created a Intense Debate xml template and Wordpress export template.

  • IntenseDebate.xml
    ---
    layout: nil
    ---
    <?xml version="1.0"?>
    <output>
      {% for post in site.posts %}
      {% if post.comments.size > 0 %}
      <blogpost>
        <url>http://www.jotschi.de{{ post.url }}</url>
        <title>{{ post.title }}</title>
        <guid>http://www.jotschi.de{{ post.url }}</guid>
        <comments>
          {% for comment in post.comments %}
          <comment>
            <isAnon>1</isAnon>
            <score>1</score>
            <name>{{ comment.author | xml_escape }}</name>
            <email>{{ comment.author_email }}</email>
            <url>{{ comment.author_url }}</url>
            <ip>127.0.0.1</ip>
            <date>{{ comment.date }}</date>
            <gmt>{{ comment.date_gmt }}</gmt>
            <comment>{{ comment.content |xml_escape }}</comment>
          </comment>
         {% endfor %}
        </comments>
      </blogpost>
      {% endif %}
      {% endfor %}
    </output>
    
  • Wordpress.xml
    ---
    layout: nil
    ---
    <?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
      xmlns:content="http://purl.org/rss/1.0/modules/content/"
      xmlns:dsq="http://www.disqus.com/"
      xmlns:dc="http://purl.org/dc/elements/1.1/"
      xmlns:wp="http://wordpress.org/export/1.0/">
      <channel>
            {% for post in site.posts %}
      		{% if post.comments.size > 0 %}
    		<item>
    		  <title>{{ post.title }}</title>
    		  <link>http://www.jotschi.de{{ post.url }}</link>
    		  <content:encoded></content:encoded>
    		  <!-- value used within disqus_identifier; usually internal identifier of article -->
    		  <dsq:thread_identifier>237</dsq:thread_identifier>
    		  <wp:post_date_gmt>{{ comment.date_gmt }}</wp:post_date_gmt>
    		  <wp:comment_status>open</wp:comment_status>
    		  {% for comment in post.comments %}
    		  <wp:comment>
    			<!-- internal id of comment -->
    			<wp:comment_id>{{ comment.id }}</wp:comment_id>
    			<wp:comment_author>{{ comment.author | xml_escape }}</wp:comment_author>
    			<wp:comment_author_email>{{ comment.author_email }}</wp:comment_author_email>
    			<wp:comment_author_url>{{ comment.author_url }}</wp:comment_author_url>
    			<wp:comment_author_IP>127.0.0.1</wp:comment_author_IP>
    			<wp:comment_date_gmt>{{ comment.date_gmt }}</wp:comment_date_gmt>
    			<wp:comment_content>{{ comment.content | xml_escape }}</wp:comment_content>
    			<wp:comment_approved>1</wp:comment_approved>
    			<wp:comment_parent>0</wp:comment_parent>
    		</wp:comment>
    		{% endfor %}
    		</item>
    		{% endif %}
    		{% endfor %}
    </channel>
    </rss>
    

Somehow the generated IntenseDebate.xml file could not be successfully imported in disqus. I therefore created the Wordpress.xml export file. This file was successfully imported.

Search engine optimization

The sitemap.xml will help the search engine crawler to find your content as fast as possible.

  • sitemap.xml
    <?xml version="1.0"?>
    ---
    ---
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="/sitemap.xsl"?>
    <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">    
      <url>
        <loc>http://www.jotschi.de/</loc>
        <lastmod>{{ site.time | date_to_xmlschema }}</lastmod>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
      </url>
      {% for post in site.posts %}
      <url>
        <loc>http://www.jotschi.de{{ post.url }}/</loc>
        <lastmod>{{ post.date | date_to_xmlschema }}</lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.8</priority>
      </url>
      {% endfor %}
    </urlset>
    
  • robots.xml
User-agent: *
Disallow:
Sitemap: http://www.jotschi.de/sitemap.xml

Google Search for Jekyll

I create a small template for a search widget. This template adds a search form that will use the google jsapi to provide search capability for my blog.

Handling wordpress urls

I wrote two templates that create a set of rewrite rules that can be used to redirect request to the old wordpress urls to the new jekyll urls.

Apache2

---
layout: nil
---
<IfModule mod_rewrite.c>
RewriteEngine on
{% for post in site.posts %}
{% if post.wordpress_url %}
# Rule for {{ post.title }}
RewriteCond %{QUERY_STRING} ^{{ post.wordpress_url }}$
RewriteRule ^$ http://www.jotschi.de{{ post.url }}? [R=302,NC,L]
{% endif %}
{% endfor %}
</IfModule>

Nginx

This template create a list of rewrite rules for nginx to handle wordpress shorturls so that those urls can be remapped for jekyll.

---
layout: nil
---
  {% for post in site.posts %}{% if post.wordpress_url %}
  # Rule for {{ post.title }}
  if ($args ~ "^p={{ post.wordpress_id }}$") {
    rewrite ^.*$ http://www.jotschi.de{{ post.url }}? permanent;
    break;
  }{% endif %}{%
   endfor %}

Include the generated file within a location / section of your nginx site configuration file like this:

location / {
  try_files $uri $uri/ /index.html;
  include /etc/nginx/sites-extra/wordpress-rewrites.conf;
}
Posted in Technik | Tagged with  |

Raspberry PI 433MHz Remote Controlled Power Plugs

Hardware

First you’ll need to buy a set of remote controlled power plugs. I got mine from pollin.de for around 10 €.

Connect your 5V VCC from the GPIO pins of your Raspberry PI to the positiv terminal of your remote control.
Connect the GCN GPIO pin to the negativ terminal of your remote control.
Connect the PIN 17 GPIO pin to a 8k Ohm resistor and the resistor to pin P1 of the remote control.
I drilled a hole trough the existing via and scrapped away the soldermask to expose the copper for soldering a connection in place.

Software

1. Install wiringpi
https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/

2. Install rcswitch-pi
https://github.com/r10r/rcswitch-pi

3. Execute test command


// Send off command to plug 4 with system id 11111
./send 11111 4 0
// Send on command to plug 4 with system id 11111
./send 11111 4 1

NFS Debian Squeeze CheatSheet

1. Install nfs

apt-get install nfs-kernel-server 

2. Add the export

 echo "/media/nfs-share 192.168.0.15(rw,no_subtree_check)" >> /etc/exports

3. Update your exports

exportfs -a

4. Change the following line in /etc/default/nfs-kernel-server

RPCMOUNTDOPTS="--manage-gids"

to

RPCMOUNTDOPTS="-p 32767 --manage-gids"

This will bind the nfs to the given port. Otherwise i guess you would have to use portmap.

Finally mount your data:

sudo mount -t nfs YOURNFSSERVERIP:/media/nfs-share nfs-share

A fstab entry could look like this:

YOURNFSSERVERIP:/media/nfs-share /media/nfs-share nfs rw,rsize=4096,wsize=4096,hard,intr,async,nodev,nosuid 0 0

DIY Dual Screen HMD

This page will contain images and descriptions of my current DIY HMD project that was inspired by the Oculus Rift. Please note that this rift clone will most likely not be compatible with any “Rift Ready” Game.

Used Parts:

Hardware TODOs:

  • IR LED mounting outside the goggles
  • Mouting fixture for the LCD Panels inside the goggles
  • IMU mounting inside the goggles
  • External Pixart sensor mounting

Software TODOs:

  • OpenGL ES Demo Code
  • WiiMote I2C WiringPi (Example + Code)
  • Raspberry PI UART → Razor IMU (Example + Code)

My rift inpired HMD will use two HV056WX1-100 LCD panels. Each display has an active area of 120.960 mm by 75.600 mm. My setup will utilizes around 75.00 mm by 75.00 mm of each lcd screen per eye.

Driver Box

I finally put all the pices together for my driver box. It houses two driver board. The 7+1 Board which i bought from eBay (vitrolight) and the smaller NT68674.5X.


LVDS <→ HDMI Breakout Boards

Both boards use a LVDSHDMI breakout adapter. The 7+1 board uses a adapter which i build from an spare HDMI cable with an female connector. The smaller NT68674.5X uses a breakout board which i build from an HDMI terminal block.


Note: The “blon” label is not positioned correctly. It should be moved down to the other pin.

The new adapter works better when compared with the adapter that utilizes a hdmi cable. Soldering fine cables to a PCB is never a good idea. I ran into trouble with loose or broken connections. Nevertheless.. the adapter which i use for the 7+1 board works well for the moment.

Failed attempts:

Display driver board + breakout board:

Notes About Boards And Cables

I tried various HDMI cables to connect my LVDS breakout boards. It turns out that Amazon basic cables work very well. I also tried super thin HDMI cables. Those also work but it really depends on the LVDS cable that was shipped with the display. I got two different LVDS cables because i bought two different boards.

The LVDS board which was included with my NT68674.5X has a better quality than the one i got with the 7+1 board.

The cable that was included with my 7+1 board got some unpopulated pins for VCC and Ground where the other cable was completely populated. Maybe it uses ground from the BLON pin for the backlight connection?

I also got the impression that the 7+1 board provides a better signal to the display in comparison to the NT68674.5X. Overall the 7+1 Board could handle longer cables.

HMD Unit – Paper Prototype

At the first step i build a paper model for the HMD so that i could get an idea how the screens would fit inside the case and what the dimensions would be.

The unpainted paper model:

HMD Lense Mount


The goggles. Somehow they remind me of the goggles that Abe Sapien wears.

HMD Renderings

A simple rendering that shows how the screens will be positioned inside the case:


HMD Unit – Plastic Model

I measured the paper model and cut some plastic sheets that were hot glued + cable tied + scotch taped together.

The backside of the HMD can be opened for easy access to displays and other internal wiring. The displays are placed in between two guide rails and affixed using a plastic plate that is connected to a screw that can be fastened.

Posted in Technik | Tagged with  |