On the fourth day of Kirby Week, Four Island gave to me: An article about implementing RSS.

It's another day of Kirby Week which means another tutorial! Today's post will be short because there's not that much to dynamically creating an RSS feed. What's that, you say? You don't know what RSS is? Le gaspez!

RSS stands for Really Simple Syndication. It provides a list of your latest blog posts (or anything, really, RSS can also be used nicely for things such as comments) in a format computers can read. This way, a computer can more easily tell if you publish a new blog post, for instance, and notify anyone who wishes to be notified.

RSS is an XML specification, so the entire thing is based upon a system of tags. Let's get to writing it!

Create an rss.php file in your kirbyweek08 folder. The root tag is the <rss> tag, with a mandatory attribute (version) that has to be set to 2.0. So, our document current looks like this:

<rss version="2.0">
</rss>

Every RSS feed has to contain a <channel> tag with information about the feed in question. Let's populate it with some default data that you can change:

<rss version="2.0">
 <channel>
  <title>Kirby Week 2008</title>
  <link>http://example.org/kirbyweek08/</link>
  <description>A description! YAY!</description>
 </channel>
</rss>

The fields introduced above should be pretty self-explanatory. The next thing to do is to dynamically introduce the latest 10 blog posts into the <channel> tag. I've done that here: http://other.fourisland.com/kirbyweek08/?source=rss.php. Ensure you replace all instances of http://example.org/kirbyweek08/ in the code with the path to your blog.

So, now you've got a feed. That's great, however, people probably won't know its there. Open up your custom header.php file. Somewhere between your <HEAD> tags, add this snippet of HTML:

<LINK REL="alternate"
      TYPE="application/rss+xml"
      HREF="rss.php" />

Now that you have an RSS feed, there are other options to consider, such as using a service like Feed Burner to "burn" your feed. Feed Burner can track subscribers, links clicked on, suspicious uses and other things, for instance, making your feed look prettier with little widgets at the bottom of each post.

Currently, the URLs we use to access each of your blog posts are kind of ugly (they all contain read.php?id=). Tomorrow we'll focus on removing the query string from the blog post URLs.

Hatkirby on December 17th, 2008 at 12:38:32pm
πŸ‘ 3 πŸ‘Ž

On the third day of Kirby Week, Four Island gave to me: An article about using IntenseDebate.

Welcome back! Yesterday, I promised I'd show you how to add a commenting system to your blog. And I will! But, being the lazy person I am, I'm not going to show you how to write one. Instead, we'll be using Automattic's IntenseDebate.

IntenseDebate is a good commenting system by the makers of Wordpress. Yes. Ok. Anyway, it has lots of prettiful features that it enumerates all over its site so you should go read it.

IntenseDebate is pretty easy to get started with. Simply go to its website, register for an account, and add a blog. When it asks you what type of blog you have, choose "Custom" or "Generic". It'll provide you with two Javascript snippets.

We're nearly done! Already! Take the first snippet and paste it in read.php, after the call to displayPost() but before the inclusion of footer.php. There! You're done! That was easy!

If you want to change your settings, moderate comments or anything, simply log in at the IntenseDebate website and you're dashboard is your friend!

Tomorrow, we'll be adding RSS support to your blog so people can receive notification and other fun stuffses.

Hatkirby on December 16th, 2008 at 12:31:02pm
πŸ‘ -1 πŸ‘Ž

On the second day of Kirby Week, Four Island gave to me: A tutorial on coding an admin panel.

Welcome back to the second day of Kirby Week! As I told you yesterday, today's post is about writing an Admin Panel! Yay! We're going to only create a very basic panel: Single user login and when you get there, all you can do is write posts.

We'll be storing the single user in the database for some deranged reason. Possibly later we'll add multi-user support, I don't know. Anyway, here's the schema for the users table:

CREATE TABLE `users` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`username` VARCHAR( 255 ) NOT NULL ,
`password` VARCHAR( 255 ) NOT NULL DEFAULT ''
);

And remember to add a user to the users table!

First, you need a login form. I'll let you handle this as, I assume, if you're writing a blog you probably know something or other about HTML. It should POST to admin.php and contain Username (NAME="username") and Password (NAME="password") fields.

Finish the form? Good. Now, we need to write the back end. Create a file called admin.php and put this in it: http://other.fourisland.com/kirbyweek08/?source=admin.php.

Since I don't want to do all of the work, I'm going to let you design another form! YAY. Between the two comments ([/code]), create a form thatPOSTs toadmin.php?submit=. Create a textbox in itNAMEdtitle, a textareaNAMEdtextand another textboxNAMEdtags`. Obviously, also put in a submit button.

You may want to label the elements so you know what to do while posting. The first is the Title of the post, the second is the content, and the third is the comma-delimited list of tags for the post.

YAYish, I guess. We're done with the Admin panel.... Sort of. The admin panel is currently annoying, you have to type in all of your formatting and such using HTML. We'll fix that with a handy JavaScript editor called TinyMCE.

Download TinyMCE from the aforementioned link, extract it and plop the jscripts/tiny_mce folder into your kirbyweek08 folder. Now, let's add TinyMCE to our admin panel. Append this code above your FORM.

Hurray! If everything went right, your admin panel should now be better looking and easier to use! Remember that this is just a basic model and you should really style it and add more functionality on your own.

Next time, we'll be adding commenting system to your blog so people have the chance to talk about the wonderful things you're blogging about.), create a form thatPOSTs toadmin.php?submit=. Create a textbox in itNAMEdtitle, a textareaNAMEdtextand another textboxNAMEdtags`. Obviously, also put in a submit button.

You may want to label the elements so you know what to do while posting. The first is the Title of the post, the second is the content, and the third is the comma-delimited list of tags for the post.

YAYish, I guess. We're done with the Admin panel.... Sort of. The admin panel is currently annoying, you have to type in all of your formatting and such using HTML. We'll fix that with a handy JavaScript editor called TinyMCE.

Download TinyMCE from the aforementioned link, extract it and plop the jscripts/tiny_mce folder into your kirbyweek08 folder. Now, let's add TinyMCE to our admin panel. Append this code above your FORM.

Hurray! If everything went right, your admin panel should now be better looking and easier to use! Remember that this is just a basic model and you should really style it and add more functionality on your own.

Next time, we'll be adding commenting system to your blog so people have the chance to talk about the wonderful things you're blogging about.

Hatkirby on December 15th, 2008 at 12:31:54pm
πŸ‘ 3 πŸ‘Ž

On the first day of Kirby Week, Four Island gave to me: A tutorial on coding a blogging engine.

Welcome to Kirby Week 2008. As I told you yesterday, I'm going to spend this week teaching you how to write your own blogging engine. As we go along, we'll be adding many enhancements and such, but for now, we'll be starting with the basics. The blog you will be building will be loosely based on the SimpleBlog engine.

To do this tutorial, you, of course, need:

  • A Web Server
  • PHP
  • MySQL

We'll start with creating the base directory structure. In your webroot, create a folder called kirbyweek08. Create a css folder inside that folder.

Next, we need to set up the database. Create a new database called "kirbyweek08" and use this schema to create the tables:

CREATE TABLE `posts` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(255) NOT NULL,
  `text` text NOT NULL,
  `slug` varchar(255) NOT NULL,
  `pubDate` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `tags` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`)
);

We need to let your site connect to the database. So, create a db.php in the kirbyweek08 folder, and put this in it:

<?php

$dbwebhost = 'localhost';
$dbwebuser = 'root';
$dbwebpasswd = '';
$dbwebname = 'kirbyweek08';

mysql_connect($dbwebhost, $dbwebuser, $dbwebpasswd);
mysql_select_db($dbwebname);

?>

$dbwebhost and $dbwebname are probably correct for you, but swap in the correct values for $dbwebuser and $dbwebpasswd (a.k.a. username and password of someone with permission to access and modify the kirbyweek08 database). Now that that's done, we can start making the blog.

Create an index.php file in your kirbyweek08 folder, and put this in it:

<?php

require_once('db.php');
require_once('functions.php');
include('header.php');

$getposts = "SELECT * FROM posts LIMIT 0,4";
$getposts2 = mysql_query($getposts);
$i=0;
while ($getposts3[$i] = mysql_fetch_array($getposts2))
{
    displayPost($getposts3[$i],true);

    $i++;
}

include('footer.php');

?>

A little explanation is required here. First, this file connects to the database by loading the db.php file we created before. Second, it loads a file called functions.php that we haven't created yet, and a file called header.php that we also haven't created yet. These files will contain useful functions reused often in your code, and a header to display above every file, respectively.

Next, the file downloads the latest four posts from your database and uses a function called displayPost() to display it. Finally, it loads a non-existent file called footer.php which will contain a footer.

The most important part is the displayPost() function. It will lie in the functions.php file. Instead of posting the code, I'm just going to link to it because it's rather long and it goes off of the side of the post.

Wow! That was a lot. Don't worry, that's the longest code snippet in this application. Whew. I think it's time for testing. However, if we test it now, there'll be nothing to see. First, add a record to the posts database.

The fields are simple. Ignore id and pubDate, they're automatically generated by MySQL. title and text should be self-explanatory. tags is a comma-deliminated list of tags for the post. Now we can test it.

You should see your post, surrounded by tons of errors. Oops. We forgot to make the header and footer! Also, you'll notice that it's saying your post is by "Anonymous". Want to fix that? Notice at the top of functions.php, a variable named $author. Set that to your username and you're set.

Let's create that header. Basically, you can put whatever you like in it. Just remember that it is pasted above the contents of every file, so make sure that a <BODY> tag has been opened by the time the file ends. Use this as an opportunity to theme this new blog with the rest of your site! Follow suit with footer.php as well, it's just a footer.

Nearly done! Now, all we have to do is create the other two files linked to by the displayPost() function. Here's read.php:

<?php

require_once('db.php');
require_once('functions.php');
include('header.php');

$getpost = "SELECT * FROM posts WHERE id = " . $_GET['id'];
$getpost2 = mysql_query($getpost);
$getpost3 = mysql_fetch_array($getpost2);

displayPost($getpost3, false);

include('footer.php');

?>

And tag.php:

<?php

require_once('db.php');
require_once('functions.php');
include('header.php');

$getposts = "SELECT * FROM posts WHERE tags LIKE \"%" . $_GET['tag'] . "%\" LIMIT 0,4";
$getposts2 = mysql_query($getposts);
$i=0;
while ($getposts3[$i] = mysql_fetch_array($getposts2))
{
    displayPost($getposts3[$i],true);

    $i++;
}

include('footer.php');

?>

We'll, we're pretty much done! I know, I know, it's mediocre. Don't worry, during this week we'll really spruce it up. Thank you for surviving that long tutorial, the rest is more fun.

You'll have noticed that there's no way you can post to this blog short of manually editing the database. Tomorrow we'll be looking at creating an admin panel for you to use for your bloggy funness. Enjoy!

Hatkirby on December 14th, 2008 at 12:32:13pm
πŸ‘ 7 πŸ‘Ž

I'm glad to see many "I LOVE ITs" for TGS, because it's such a great project. For you who don't know what it is, see this: The Greatest Story.

I LOVE IT. - 9 vote(s)! It's an interesting idea. - 0 vote(s)! What the negative is it? - 2 vote(s)! **** - 0 vote(s)!

I'm sure you all know, Kirby Week 2008 starts today! For those who don't know, Kirby Week is the third week of advent, when the candle is pink. Yes, I know, that wasn't funny. :)

I started the strange idea of Kirby Week in December 2006, a year before Four Island even existed. Since then, each Kirby Week has been a week of fun, joy and excitement at the holiday to come. Starting this year, I'd also like to do something for Four Island during Kirby Week.

I've decided that during Kirby Week, I shall post a weekly special (like VisitorGrid Week) on a set topic. Sound like fun? I hope it does!

This year's topic is how to code your own blog. TimTam has been nagging me to do this anyway, so I might as well use it for Kirby Week!

And also, I've decided to do use last year's Kirby Week poll for this year as well. So, all in all, I hope you all enjoy Kirby Week 2008!

Hatkirby on December 13th, 2008 at 10:55:33am
πŸ‘ 0 πŸ‘Ž

This sort of goes hand-in-hand with yesterday's post of drastic changes. I often get the urge to switch to Wordpress for my blogging engine, instead of the homebrew one I currently use.

I mean, I have pride in my own work, my own, extremely customizable, hand-typed code, but sometimes, Wordpress just really looks attractive with all of it's power and the more dedicated work put into it by a team of people.

I just started reading Lorelle again, and the first post I saw was about the new release of Wordpress that came out yesterday, 2.7. I was a little interested, but what really caught my attention was the new admin panel. It looks soooooo good! How can I resist?

It's hard, resisting a wonderful looking package (that, by the way, Color Pencils and Dream Weaver use) for my own work, but it's worth it. While I don't get the same degree of power and looks, I get the power that I want that Wordpress can't provide as easily: complete freedom.

If there's something my blog isn't doing correctly, I can just go into the source code and fix it. If there's something in Wordpress, if I was using it, that I was unhappy with, I'd have to go hack it or try to write a good plugin.

For instance, at one point, when I was developing the 7th layout that will not exist, I was using Wordpress on the development machine. However, the first, instantly noticeable problem was, "How am I going to have a pending queue?" The thing that I find most useful with my blog is that I can just write posts to it and they're posted on a daily basis, without any required intervention from me.

Wordpress can't provide that the way I want. It does have a scheduled posting feature, but with that, you have to provide the exact date and time you want each post to be posted. That wouldn't work for me, because sometimes there's an emergency post I have to post instantly, and let the pending queue delay for one day. With Wordpress, I'd have to manually edit each post and change the post date.

This would also happen if I decided to make a simple change in the order of the posts in the pending queue. With Four Island, I click on the "Move Up" or "Move Down" button next to the necessary post. With Wordpress, I'd have to manually edit both posts in question. And what if I wanted to move a post more than one space? shivers

So, in conclusion, and without a reason to care, I don't want to use Wordpress, no matter how.... tempting it may be. And I'll try to stand by that. And if that means forcing my readers to yell at me and not read my site anymore if I switch to Wordpress, so be it. :)

Hatkirby on December 11th, 2008 at 12:30:13pm
πŸ‘ 7 πŸ‘Ž

Yes, this is a reference to TimTam's I Was Sleepy. It made me think. How may of us blog people like to make random, drastic changes to their websites without thinking of the consequences and hating it later? Or is it just me?

Speaking of randomly induced drastic changes, I almost decided to release a layout #7 for Four Island, so soon after the 6th layout was released, but in the end, I decided to use the theme for the TGS webs----oops! Wasn't supposed to say that yet. Oh well, I'm going to be posting about it soon enough anyway. :)

So, how many of you out there do this? Random drastic changes? Not even just your blog! I once changed my username on the Fourm to "Starla", quickly realized that it went against my statement of anonymity (though everyone knows my name anyway) and changed it back to "hatkirby". (I actually also then changed it to "StarlaXY". It was meant to be "StarlaXYZ", but I seemed to have missed the "Z" and was too lazy to fix it)

Omigosh, I just realized, I just made another stupid question post. Oh, don't groan! I love it when people contribute! COMMENTS! GIVE ME COMMENTS! AND PINGBACKS! :)

So, anyways, here's the link to the last question post: Say What?

Hatkirby on December 10th, 2008 at 12:30:48pm
πŸ‘ -2 πŸ‘Ž

Say What?

Ok. I'm going to admit it without caring about the abuse I will get from various people for not admitting it earlier (I'm looking at you, TimTam). I like Firefox more than Internet Explorer. There, I said it.

I don't really know why I didn't say it before, I guess it's just part of the "pride" package that comes with not using Wordpress for your blog. :)

The reason I'm bringing this up is because IE is being SO ANNOYING. Any viewers out there use IE? Yes? You're lying. If you were, you couldn't read this post. For some reason, IE is hiding the text of all of my posts, horribly disfiguring The Fourm and generally being mean to Four Island.

Does anyone know why this could be? It's not just IE 6, 7 is doing it too. I've tried using the IE 7 script (the one that makes IE into a standards-compliant browser) but it doesn't work for me. So, if anyone has any ideas, I'm open! I guess this is a question post, then.

The standard seems to be to link to the last question post in all question posts, so I'll try to do that here. I think the last one was Tag Clash, but I may be wrong. :)

And yes, this post's title is a clear indication that I've been watching too much Hannah Montana. :)

Hatkirby on December 9th, 2008 at 12:30:24pm
πŸ‘ -2 πŸ‘Ž

Bzipped Tar

This always seems strange to me. Why do most people on the internet that provide software packages, such as Linux packages that do not have standard distribution formats, or PHP sites like Wordpress, always distribute their software using gzipped tars? As in .tar.gz

I mean, really. Bzipped tars (.tar.bz2) are a much better way to compress things. Bzip2 is a much more effective compression algorithm than Gzip. I always use bzipped tars to archive my data.

Or wait. Is there some kind of deficiency with the algorithm that I don't know about? Am I going to wake up one day and find all of my backups useless? Oh dear, now I'm scared. :)

So, what is with bzip2? Is it just that people can't be bothered to switch to it, or is there some huge bug that'll eat Four Island?

Hatkirby on December 8th, 2008 at 2:27:33pm
πŸ‘ 1 πŸ‘Ž