This space intentionally left blank

Photoblog Theme Updated

A while back I wrote a really basic photoblog theme for me to use for my photos. I no longer use it (I have a version of this blog's theme running on my neglected photoblog), but I have meaning to review it and make it available on the Habari-Extras repository. I've finally gotten around to it, so here is a little more information about it.

Fun with Photoblogs

Screenshot of the theme

Licence

The theme is licensed under Apache Software License (http://www.apache.org/licenses/).

Posting photos

The theme splits all posts into two parts, the photo and the accompanying information. The photo is displayed first and the extra info, along with the comments, can be seen by clicking the link beneath the photo.

There are two options for posting the photo and additional information:

Option 1 - No plugin

When you create your post you need to include the image HTML at the top. After that line add . Everything after <!--details--> will appear on the second screen.

Option 2 - With the plugin

In the theme folder there is another folder called "Fun with photos plugin". To use this copy it into the Habari plugins directory and activate it as normal.

Once activated you will find that your post page has a new text box for the image URL. The Habari Silo will also have an extra option: Use Photo, that will insert the image URL into that box for you.

Habari Silo with the plugin

If you use this method then everything in the normal post box will be extra text that is separated out onto the second page.

Changing the title graphic

Included with the theme is a folder called PSD. In it you will find a photoshop document with the blog title in it so you can change it.

Download it

You can download it from Habari Extras.

I've moved the wizard

A few posts ago I wrote about the first implementation of the plugin generator wizard that I set up. This was a Habari version of the WordPress plugin generator that runs on my other site. I've decided that this site isn't the best place for the wizard so I have moved it.

When I wrote the Habari implementation of it I started from scratch instead of trying to port over the WordPress plugin. I planned on using FormUI which worked differently from the form classes I set up for the WP wizard and I also wanted to make it a much more flexible system so I wouldn't need to code every question, option and condition from scratch.

All of this meant that I had two entirely different sets of code for pretty much the same function and that was always going to be a headache.

To solve the problem I have set up a new site just for Wizards called Fun with Wizards. It is running Habari, and using the Habari plugin to control the wizards. Unfortunately it also means I have had to go back to the standard (non-Pratchett) method of spelling wizard, or else the domain would never get found, or remembered.

This new site gives me a lot of potential for expanding the wizard idea to other platforms that I don't necessarily know much about and lets me get much more targeted feedback without boring everyone that subscribes to my other sites.

I am also planning to create a version for Habari theme.php files at some point.

Converting WordPress themes to Habari: Reference

One of the great things about WordPress is the community of themers and the ease with which themes can be produced. Habari makes it pretty easy to produce themes as well, but, as a new product, there aren't that many themes around. To try and get a handle on the differences between the systems I decided to port over one of the great themes that are available for WordPress.

Rather than create a tutorial I decided to create a short reference guide to the functions and code I have changed. I think this is likely to be more useful to people looking to move over from WordPress. This isn't intended to be a guide to switching, or a comprehensive list of differences but a general introduction to what I have done with this theme.

Habari supports a number of different theme engines so depending on your background you might prefer different methods of theming. For WordPress however the RAWPHP engine is a pretty good match so that is what I will use.

The theme I have decided to use is the Dilectio by Design Disease. You can download the Habari version here.

This is the first theme I have moved across so if you find anything that doesn't work the way it should, please let me know. Similarly, if there is anything in this post that is confusing, or missed out, again, let me know.

The following tables include details of the changes that I have made. Note that in a lot of cases WordPress creates the HTML to go around the information whereas Habari gives you the data. Where this is the case for things such as links I have only included the Habari functions that output the important part, i.e. the URL.

Also note that most of the Habari content needs to be echod and not just inserted. I have not included the echo command in the examples.

This post is being written prior to the release of Habari 0.6

File names

File Names
Displays WordPress Habari
Home Page index.php home.php
Single Post single.php entry.single.php
Single Page page.php page.single.php
Archives archives.php Removed
Posts by date archive.php multiple.php
Categories category.php multiple.php (for tags)
Attached Files attachment.php Removed
Comments Popup category.php Removed
Theme Functions functions.php theme.php
Theme Information Included in styles.css Added theme.xml

General Functions

Header / Blog Functions
Function WordPress Habari
Page Title wp_title( args ) See Page Title below
Template URL bloginfo('template_url'); Site::out_url( 'theme' );
Blog Name bloginfo('name'); Options::out( 'title' );
Blog Description / Tagline bloginfo('description'); Options::out( 'tagline' );
Home Page get_option('home'); or
bloginfo('url');
Site::out_url( 'habari' );
Stylesheet URL bloginfo('stylesheet_url'); <?php Site::out_url( 'theme' ); ?>/style.css
Feed URL bloginfo('rss2_url');
bloginfo('rss_url');
bloginfo('atom_url');
$theme->feed_alternate();

Include Tags

Include Tags
Function WordPress Habari
Get Header get_header(); $theme->display( 'header');
Get Sidebar get_sidebar(); $theme->display( 'sidebar');
Get Footer get_footer(); $theme->display( 'footer');
Show Comments comments_template(); $theme->display ('comments');

Checking conditions

Checking Conditions
Function WordPress Habari
Whether there are any posts selected have_posts() count($posts) > 0
Comment Status $comment->comment_approved == '0'
( 0 = unapproved, 1 = approved )
$comment->status == Comment::STATUS_UNAPPROVED
( or Comment::STATUS_APPROVED )
Comments Permitted 'open' == $post->comment_status (open or closed) $post->info->comments_disabled (true or false)
Plugins are loaded function_exists( plugin_function ) See Theme Functions below

Page Menu

See Page Menu below

Page / Post Information

Post Information
Function WordPress Habari
The Loop See The Loop below
Post ID the_id(); $post->id;
Post Permalink the_permalink() $post->permalink;
Post Title the_title(); $post->title;
Formatting Post Dates the_time( 'j M Y' ) Format::nice_date( $post->pubdate , 'j M Y');
$post->pubdate->out('j M Y'); ( 0.6 onwards)
Post Category See Category Alternatives below
Post Author the_author() $post->author->displayname;
Post Content the_content() $post->content_out;
List the Tags the_tags( Arguments ) $post->tags_out; (See also Tag Formatting below)
Single post comment feed comments_rss_link('RSS 2.0'); URL::out( 'atom_feed_entry_comments' , array( "slug" => $post->slug) );

Comments

Comments
Function WordPress Habari
Number of Comments comments_number('None', 'One', '%' ) $post->comments->moderated->count
Comment Loop foreach ( $comments as $comment ) foreach ( $post->comments->moderated as $comment )
Comment ID comment_ID() $comment->id;
Comment Author comment_author_link() Name: $comment->name;
URL: $comment->url;
Comment Date comment_date('F jS, Y') Format::nice_date( $comment->date , 'j M Y');
$comment->date->out('j M Y'); ( 0.6 onwards)
Comment Time comment_time(); See Comment Date above
Comment Content comment_content(); $comment->content_out;
Form Field Values
Commenter Name $comment_author $commenter_name
Commenter email $comment_author_email $commenter_email
Commenter Website $comment_author_url; $commenter_url
Comment Content None $commenter_content

Page Title

WordPress uses a built in function for displaying the page title: wp_title(). This is usually used with other text and conditions to change the order of the title for archives etc.

The title that is shown on the top of the page, for search or archives is usually put together within the theme using conditional statements; i.e. is_single, is_day, is_month, etc.

Habari encourages the use of functions within the theme.php file to keep the logic out of the template files so I have created a function in theme.php called the_title to calculate the correct title.

The function checks which rewrite rule has been matched by getting the value of $this->matched_rule->name This is equivalent to checking is_search, is_category, etc

The appropriate title is then calculated and returned.

It has one argument $head, which adds on the blog title to the end if it is intended to be used in the HEAD section of the HTML. Here is a small section of that function:

  1.  
  2. function the_title( $head ) {
  3.  
  4. switch( $this->matched_rule->name ){
  5. case 'display_entry':
  6. $title .= $this->post->title;
  7. break;
  8. case 'display_page':
  9. $title .= $this->post->title;
  10. break;
  11. }
  12.  
  13. if ( $head ){
  14. return ( empty($title)) ? Options::get( 'title' )
  15. : $title . ' - ' . Options::get( 'title' );
  16. }
  17.  
  18. return $title;
  19.  
  20. }
  21.  

Page Menu

The original WordPress theme used wp_list_pages to get a list of the pages, and then regular expressions to clean up the html that was generated. Habari doesn't have an equivalent function.

Instead I have created a function in theme.php that uses Posts::get to retrieve a list of posts and then looped through them to create an html list.

  1.  
  2. $options_array = array(
  3. "content_type" => 'page',
  4. "status" => Post::status('published'),
  5. "nolimit" => 1);
  6. $pages = Posts::get( $options_array );
  7.  
  8. foreach( $pages as $page ){
  9.  
  10. ....
  11.  
  12. }

The Loop

Habari doesn't uses a foreach instead of the WordPress While loop:

WordPress

  1.  
  2. if (have_posts()) : while (have_posts()) : the_post()
  3.  
  4. ...
  5.  
  6. endwhile; endif;
  7.  

Habari

  1.  
  2. foreach( $posts as $post ){
  3.  
  4. ...
  5.  
  6. }
  7.  

Category Alternatives

I believe future releases of Habari will feature the ability to use hierarchical categories. Or at least for plugins to be able to make use of that option. For the moment though it only uses tags.

Where this theme previously listed categories for each post I have simply replaced the list with a list of tags. In the sidebar though I wanted to limit the number of tags shown to more closely replicate the idea of using categories; i.e. that they represent significant subject divisions.

To do this I have created a function in theme.php that limits the tags that are displayed to those that are used in a given percentage of posts.

The call in sidebar.php to $theme->list_tags( 10 ) will list tags that are used in at least 10% of the posts.

Post Excerpts

WordPress has a tag the_excerpt();

Habari has a formatting function called Format::summarize that can produce an excerpt. I have used this to shorten the recent comments in the sidebar.

Habari also has a formatting function that can be attached to the post_content_out hook, so that it is not necessary to use it within the template itself. This is the more function, and it replaces the post output with an excerpt of a given length whenever the content is output on a page that lists more than one post, i.e. home, search, archives, etc.

This is applied by calling the following within the function action_init_theme in theme.php

  1.  
  2. Format::apply_with_hook_params( 'more',
  3. 'post_content_out',
  4. _t('Read More') . ' ยป' ,
  5. 100,
  6. 1 )
  7.  

Tag Formatting

The tags shown for each post are formatted by applying a formatting function to the tags_out hook. It takes the tags and creates an HTML list with an 'and' before the last tag.

This is applied by calling the following within the function action_init_theme in theme.php

  1.  
  2. Format::apply( 'tag_and_list', 'post_tags_out' );
  3.  

Password Protected Posts

Habari doesn't have them.

Theme Functions

The WordPress version of the theme checks to make sure that the appropriate function exists before calling it.

In Habari, plugins add methods to the theme object. Calling a theme method that doesn't exist does not trigger an error, therefore no further checks are needed.

Plugin Templates

There are some additional files in the theme folder: filckrfeed.php and blogroll.php. These contain a template to override the default included with those plugins.

Links to plugins

The plugins can be got from http://www.habariproject.org/dist/plugins/

The plugins required for this theme are: Blogroll, Monthly Archives and FlickrFeed

Perfcast: Habari Love Podcast

So last night (this morning) was the Perfcast Podcast, dedicated to Habari this time and I have never seen so many people in a Talkshoe podcast before. The place was jammed.

Unfortunately, I couldn't get my gear to work so I was restricted to the chat room but it was really great to hear some Habari questions getting answered that real users, like the generally non-technical host Jeff Chandler, might want to know.

So much was discussed from the philosophy and nature of the community to licensing issues, code benefits, how great the admin interface is, and, unsurprisingly there were a lot of contrasts made with WordPress.

The best thing is that there was a buzz about it that shows how interesting the project is; even once it ended there were still questions being thrown about.

This bodes well for Habari in my book.

What am I doing?

As this is a new site I haven't really figured out where I want, or need to go with it. I am hopeful that it will help with the adoption of Habari, and help converts from other platforms figure things out, but I also want to make sure that I do something that is useful to more experienced Habari users. If I don't I imagine the site will quickly get boring.

For the select few that currently subscribe (this is currently a very exclusive club) here is an update on what I intend to do over the next however long these things take.

Wizzards

An area of my WordPress site that has proven very popular is the plugin generator, and so I have been working to set up a Habari version here. I uploaded the first working version today.

You can test out the first version of the Fun with Habari Plugin Generator. I am interested to get any thoughts on what it should provide, or if there are any errors in the basic content that is there already.

Sites

One thing that I think would really help the adoption of Habari is for people to see what can be done with it. With that in mind I am searching for really good examples of sites built on Habari.

More for fun than anything else, I have built a limited webspider that searches for Habari based websites. It checked for the line "powered by Habari" but also checks for the presence of the Charcoal Theme's XML file. So far I have around 50 sites identified, most if not all of which are listed on the Wiki, but you never know it might come up with something eventually.

Themes

Theming is really big in WordPress and there seems no reason for that not to be true with Habari as well so I plan to run a series of posts demonstrating the process of converting a WordPress theme to Habari. I am looking for a good quality theme to convert and once I have found that I will start writing.

Samples

Finally, I am considering using one or more of my spare domains to produce some sample sites. If I can come up with some interesting attention grabbing ideas then that could be quite interesting. I own the domain - funwithonions.co.uk so I imagine there should be some possibilities surrounding that.

 1 2 3 4 Next →