Monday, April 30, 2007

Ajaxified Expand Post NOW

Testing this plugin by Weng.    It's nice but I see a problem when this is used with UTW.    I have the UTW tags repeated because WP sees end of post and added tags to it and when post is expanded tags are added again?

Friday, April 27, 2007

SmartyBarebone

What you are seeing is a super-simple theme I did a while ago. It was a learning process and simple is beautiful. It's available for use with WP from here. Just look for download (2) Barebones Left Sidebar 0.2.

The original theme I did for WP has only 4 files, namely index, header, sidebar and footer. These are the skeleton you need to get something displayed. As I already have a Classical theme ported to Habari so making this SmartyBarebone theme workable here is easy.

I did spend little time brushing up the original Barebone theme a bit and corrected a few html tag mistakes. I feel good with this theme because it's simple, fast, clean and long lasting. The entire theme folder has only 20.8 kb with no image.

Next step would be converting this to work with the SmartyEngine and that was why I named this 'SmartyBarebone'.

Snap Shots

I have been using snap's Preview Anywhere for quite a while, last talked about it here.    I found the 'bubbles' at certain places very annoying so I have turned them off, say at the title of each post and all links under 'about this post'.

This is quite handy in fact the FAQ here tells you how.    If you already have a 'div class' there just add 'snap_noshots' to it like class='existing_class_name snap_noshots'.

Thursday, April 26, 2007

Ajax and jQuery

I was playing with a dead-easy for beginners ajax script from here. I was thinking what if I could easily integrate this into the sidebar or with plugins in Habari. I like short and expendable sidebar, never liked long one that I have to scroll down to find/read things.

The GET and POST method was dead-easy to play with and integrating it in Habari was also straight forward but once I tried manipulating objects and functions of Habari I found it difficult. That proves how little I know about the core.

The Wiki of course is a good teacher and the Workflow tells me how it runs. That's not the full story and I'm still a bit confused how pages are rendered by the browser. From the user group geeks there told me the magic about __autoload function which instantiates classes on demand.

That's all fine but integrating it with habari core methods is still too hard to me. Owen gave me a 'not for dummies' quick tutorial on a way to integrate Ajax in Habari via a plugin. Further reading reveals that the best is to understand jQuery which is already in the Habari package.

There is a lot to learn which could be fun. My javascript has been rusted for years or I never knew any of it. I do have a dummies book at home which is almost new perhaps it's about time to uncover it.

Tuesday, April 24, 2007

WordPress.com

I do have a account with them here.    I have not logged into it for a long time since I have to manage hosted sites, a couple of them for myself and others many months ago.    I just have a look inside there are lots of new things especially those features that have to be paid for if you want them.    I'm not surprised that open source developers leave WordPress as objectives are different once you have $$ involved.

The top menu strip, that is javascript driven, once you are logged in at the top is quite nice.    There are users of the [tag]ezLOGIN[/tag] plugin that are still looking for more handy links perhaps I could learn how to bring login/logout and handy links to the top?

2,000 downloads

The 1,000 milestone was dated 28 Feb 2007.    Today it hits 2,000.    A brief account:

[tag]Barebone[/tag] series of bare minimum template = 728

[tag]ezLogin[/tag] plugin various versions = 779

[tag]Sunset[/tag]/[tag]Sunrise[/tag] template = 295

[tag]ezCount[/tag] plugin = 182

I did a plugin, as a learning process, named Recent Comments for My Habari Test Drive which accounts for balance of 2,000

Monday, April 23, 2007

LaserJet printer driver for Vista

Found a solution from the forum to solve the driver issue for my LaserJet 1020 printer.

The trick is to install the driver CD that came with the printer even if it is not designed for Vista.   After installation a printer test page was printed successfully but other applications still can't print.   A reboot was necessary.

The trick was some changes at the printer configuration.   In the advanced tab of the printer properties click open 'print processor' and select 'IMFPrint' for processor and 'RAW' for 'default data type'.   That was it.

HomePlug

I have been using wireless router at home.   Now my dear wants to surf the net in the bedroom which is a problem as the Wifi signal isn't wrong enough to go through few walls.

To overcome this I bought 2 units of Aztech HomePlug.    It's model HL105E which is good upto 85Mpbs I guess that's OK for my use.

My first concern would be connection speed at bedroom, below are the test results.

Overseas connecting US using Speakeasy

Near router 970kbps download 191kbps upload

Bedroom 972kbps download 88kbps upload

Local using NWT Netspeed

Near router 5.12Mbps download 538kbps upload

Bedroom 5.14Mbps download 267kbps upload

Too bad the utility program doesn't work in Vista.    The troubleshooting guide for Vista available from Aztech's website also didn't cure the problem.

Saturday, April 21, 2007

This theme ‘Classical’

Just did a major cleanup last night. More than 100 lines in CSS were removed. Other legacy issues originated from K2 codes were also reviewed and resolved. For example login failed redirection and error page etc.

I guess if I spend few more hours further trimming could be possible. I'm getting this theme ready for porting to suit SmartyEngine.

I look forward to seeing an example such that I could learn from it.

links for 2007-04-20

Thursday, April 19, 2007

SmartyEngine

SmartyEngine for template/theme building appears to be a "must learn" for Habari. This is a good link I found and a list of software currently using/supporting SmartyEngine. The official resources are here.

Tuesday, April 17, 2007

Loginform

I'm lazy so I do things to save clicks. Just modified the loginform.php a little to add links to comments moderation page which also shows number of comments awaiting moderation. So when logged in I'll see below

loginform

This is now similar to the ezLOGIN plugin I did for WP.

Recent Comments plugin - against MVC?

The Habari project is supposed to follow the MVC model of design. I have yet to fully understand it in plain English.

Owen was of the opinion that I shouldn't have to do a plugin for 'Recent Comments' as a theme designer could easily display 'recent comments' using the MVC design feature built into Habari. The Wiki tells you how.

Owen is right of course, if I understood him correctly, but using a plugin makes thing clean, tidy and flexible, e.g. I need only one line to get what I want

RecentComments::comments('5','-4','10')


First parameter 5 is to show 5 comments, second '-4' is time zone difference in hours and last parameter '10' is to truncate comment string to 10 words.

Now I have removed my first plugin and moved the class to theme.php. I prefer using just one line to display Recent Comments instead of following the example in the Wiki.

db_profiling.php

In the footer.php file in the K2 theme that came with the download you'll find [include 'db_profiling.php'] got commented out. I guess that is for bug hunting use. I have a look at the db_profiling.php file and if I'm not wrong that could be used to generate number of queries used and total time taken to execute queries as you normally see from footer of a typical WordPress site. Below is what I have done.


class metaHabari extends Theme
{
var $total_time_querying=0; # total time used to query
var $num_query=0; # number of query used
var $what_num; # para to pass to method
function get_no($what_num)
{
$no='';
$profiles= DB::get_profiles();
foreach ($profiles as $profile) {
$num_query+=1;
$total_time_querying+=$profile->total_time; }
$total_time_querying = number_format($total_time_querying,4,'.',',');
switch(strtolower($what_num)) {
case 'query': $no=$num_query;
break;
case 'totaltime': $no=$total_time_querying;
break;
case 'ver': $no=version::get_habariversion();
break; }
echo $no;
}
}


Insert the above into your theme.php file then call the method of this class metaHabari at your footer.


[?php metaHabari::get_no('totaltime'); ?]
seconds used in executing [?php metaHabari::get_no('query'); ?]
queries by version [?php metaHabari::get_no('ver'); ?]


The only issue I can see is that upon first loading of the posts.php you'll get a funny large number of seconds used to execute queries, a second refresh gives a reasonable number. I also wondered why I'm getting version 0.1 displayed but in fact I'm using 0.1.1.

Monday, April 16, 2007

Recent Comment plugin is working!

Thanks Owen again for the direction and tutorial and his new documentation here about writing a plugin.

It was all my fault of not looking into the core class files hard enough. There are 2 classes one url.php and site.php both can give you url of some format to suit your need.

The culprit I found is URL::out('display_posts_by_slug',array('slug'=>$post->slug)). This line echos the url out of control whereas URL::get(.....) returns the url to add up to a string to be returned by the plugin function. Alternatively I could also use Site::get_url('host') or Site::get_url('habari') depending on whether installation is under domain or a subfolder.

ezLOGIN

Thanks silverelf for his comments on this post.    Current version for [tag]ezLogin[/tag] 0.32 has links for writing a post/page and manage posts/pages already also you could go straight to comments page of admin to edit/remove/manage your comments in moderation.    I don't know what other links silverelf wants to add.    However it should be noted that I can't do much to the default user control except providing handy links to save you from getting into/out of admin dashboard.    It'll be a completely different plugin if you want to customize the default user authority control in WP.

What I have been doing

I have spent time recently on Habari an opportunity to learn something new.   I have been with WordPress since September 2005 that was version 1.5.2 when I first tried it.    The pick up wasn't too difficult as a user of the platform but quite heavy for me as PHP was new to me and I really want to know the insider of the software that runs behind.

Habari is a great opportunity as it's a new born and core developers or early Habarians as I want to call them are celebrities of the WordPress community.    I can't pick up faster than I could but at least I could see it grow day by day.

My test drive is here.

Sunday, April 15, 2007

My first plugin - one didn’t quite work

I was trying to figure out how plugin is done. First obvious step would be looking at plugins that came with the download. There are 3 of them, namely 'commentfilter', 'spamchecker' and 'wpimport'. I firstly looked at their structure. They all look pretty much the same as below:


class MyPlugin extends Plugin
{
function info[]
{
return array [
'name' => 'MyPlugin',
'url' => 'http://habari.sfong.net',
'author' => 'sfong15',
'authorurl' => 'http://habari.sfong.net',
'version' => '0.1',
'description' => 'Show recent comments',
'license' => 'no such thing',
];
}
public function action_plugins_loaded[]
{
//Utils::debug('ok');
}
function DoSomething[] {
...code here...
}
}


The purpose of the function 'info' is obvious it provides information required by the activation interface. I don't know what 'action_plugins_loaded' actually does as the line for 'Utils' has been commented out. The purpose of function(s) at the end is also obvious as they actually do something. That could return something as output or act as filters. Writing simple function like that is what beginner like me can do.

You look at the sidebar you'll see I hard coded 'recent comments'. That wasn't difficult as I could 'borrow' codes from the 'admin' interface. Transforming those to that function 'DoSomething' was also a piece of cake.

The final hurdle was calling this function in the posts.php. I looked around but couldn't find an example as other plugins were used as filters. I then realize there was some basic thing that I didn't have. That is the OOP part of PHP5. That is something that I didn't have to learn in WordPress.

The first line of the plugin file class MyPlugin extends Plugin tells me that MyPlugin is a extended class of a base or generic class 'Plugin'. An explanation of keyword extends is here and simple examples are here. Now I can call the function like this

$obj=new MyPlugin;
$obj->DoSomething();

I believe the base 'Plugin' class is there to make this happen.

Once this is understood then I can use a Scope Resolution Operator '::' to call the function in a much simplified way such as MyPlugin::DoSomething();

All is well but why my first plugin didn't quite work I really don't know. As you can see recent comments are shown in a unordered list but the comment url, name etc are also displayed, in fact duplicated outside the 'ul' tags, in a string. I have checked and checked a few times and found that string was actually produced outside the function.

I'm clueless at the moment so bug hunt goes on.

Friday, April 13, 2007

Recent Comments plugin - against MVC?

Just hard coded 'recent comments' on to the sidebar.

I was lazy omitting 'http://' when entering fake comments so links to comment authors aren't workable. Also found that 'edit' button for recent comments isn't yet working in dashboard.

Thursday, April 12, 2007

This Theme ‘Classical’

A bit further work on this theme. Lots of unnecessary classes have been removed from post.php and posts.php and the footer is now within the big box instead of outside. There are still a lot cleaning up works to do.

Hacking it

When I'm logged in I now have the link to 'Admin' grouped under 'user'. This is done at the loginform.php by placing below line after if ($user) {....

Here is [a href="[?php Site::out_url('admin'); ?]" title="Admin area"]Dashboard[/a]

Only just found out that I can place core classes with my hacks in \user\classes\ folder. By doing this classes under this folder will override those under \system\classes\. So far I have made changes to utils.php and userhandler.php.

When I'm logged in I'll be redirected to the blog, i.e. posts.php instead of 'admin', likewise after I logged out I'll be here again instead of seeing "IT WORKS", how nice thanks Owen.

In line 240 of utils.php ...'['.$current.']'.... is to indicate the current page number but at the same time in line 242 ...?'class="current-page"':.... is there to let me style 'current-page'.

I removed the square brackets [ ] and inserted below in CSS

a.current-page {
color:#mycolor;
background-color:#mycolor;
}

User information

The default K2 theme doesn't give you user information for each post, you can add this at the bottom of each post

echo $post->author->username

I have further adjusted styling to the 'current-page' class for the page-selector at the bottom of each page.


a.current-page {
border:none !important;
color:#000;
cursor:default;
background-color: #fff !important;
}
a.current-page:hover {
text-decoration:none !important;
}

Tuesday, April 10, 2007

Vista

I resisted Vista for nearly 4 months today I bought a copy.   I have Ultimate upgrade version because I want to use the windows movie maker which is only available to ultimate or home premium.

I decided on upgrade instead of clean install which took just under 2 hours on my super slow PC.    That was trouble-free.

I ran the Windows Vista Upgrade Advisor first and printed out a copy of the task list which is a good guide of things to do after the installation.

Next would be a online upgrade which wasn't really complete because certain upgrades have failed.   However latest device driver such as that for my VIA/S3G was upgraded.

Few "must have" applications, such as Firefox XAMPP PSPad and Microsoft Office, have been checked running OK.

Jobs' iTunes is a problem as neither I could start it nor reinstall it.    Found that this is still an issue although you may try installing latest 7.1.1 but you could be prompted having vbscript issue which I couldn't yet fix.   My current option is wait.

Another issue is printer driver from my HP LaserJet 1020, I'll have to use my notebook if I want to print at home.   HP's website says driver may be available July 2007.

Saturday, April 7, 2007

Theme for Habari

This is a theme named "Classical" currently used at my WordPress site Because I Learn.

There are still lots of rubbish left in the style sheet as I still have to simplify the original K2 theme that came with the Habari download.

Friday, April 6, 2007

Now running 0.1.1

The errors on search are now gone but I think there are still problems with page navigation of search results.

Wednesday, April 4, 2007

Installation at Site5

The habari-dev group and user group are must read before you start trying installation of a test site at hosting. The project site is here where you also find wiki (not much) and downloads.

I would recommend anyone to try installation at localhost first. I did that under XAMPP version 1.5.4a with PHP 5.1.6. I recommend that you check rewrite_module is enabled in httpd.conf file of your Apache before starting. Without this you won't even see the installation screen of Habari. Next would be creating a MySql database, it's harmless to use 'habari' as its name but this default entry in the installation screen is confusing as the AJAX check isn't quite ready so it's still OK to proceed even if you see "failed" and a message that your database can't be detected...etc. For more details see this thread.

With the experience at localhost I proceeded to installing a test site at my hosting Site5. See this thread if you want to know what silly things I have done.

Tuesday, April 3, 2007

Habari - Developer Release 0.1

I first talked about Habari here.    The developer release 0.1 is out now, see this post at Bloggingpro.    The Habari Project site is here check it out.

I have just downloaded the release 0.1 from Google code.    Too bad my first experience isn't too good as it failed to install in my XAMPP localhost.    I have now joined the Google group for Habari users and I'm user 201.

I'm also glad to hear that Habari has been tested with my host Site5.

Monday, April 2, 2007

Gmail Paper

Every time Google introduces something new, revolutionary, innovative people ask why.    It's perfectly normal to ask why or what's next.    Seeing what's next is probably the biggest concern of Google's competitors.

With a click of a button now Google prints your emails and will mail it to your home FREE, it's called [tag]gmail paper[/tag].    But why?

Have a lot of people asked for this?   I don't think so.    Printers are so cheap these days and even your grandma knows how to setup a new unit at home.     You may say printer cartridges aren't cheap but I don't expect you printing a thousand copy of your email for distribution.    Google says it here that "...You can make us print one, one thousand, or one hundred thousand of your emails. It’s whatever seems reasonable to you....".    You could also get your attachment such as a thick scanned book or photos printed, it's all part of the deal they say.

What are the motives?   It's surely not for office users.   My guesses are

  • they want to know exactly where you live.
  • they are penetrating into the physical world, planning a startup to compete with UPS or DHL.
  • I really don't know

Apparently this service isn't available to everyone yet as I don't see the button when logged in.

This goes against [tag]paperless[/tag] and Gmail's original idea of not deleting another email so I don't like it.