Archive for Blogging

Switchover

Well, if you can see this post, it means that the webhost switchover was successful. There may be a few bugs to iron out in terms of links to files that I’ve been hosting, but I’m grepping through database files to find them.

For now, my gallery will remain in the same place because of the large amounts of disk space it requires.

Comments

Hacking Seagull for Ajax support (with Rico)

Seagull is a PHP framework that is gaining popularity. One thing that it is lacking is AJAX support, but you can hack something together by going through the source files. Note that this should be fixed in the future because Seagull is being made more flexible, and will be able to support different output formats automatically.

I used the Rico (or OpenRico) AJAX Javascript library to handle all of the hard work, but the backend was lacking XML (or whatever arbitrary format) output. I wanted to stay within the framework for the output, because Seagull is handling things like user login, sessions, and permissions. If you don’t need this, just write a PHP script that outputs XML. :)

Normally when you make a custom class for Seagull, you extend the SGL_Manager class. We don’t want to this, because the data would then be passed to the Flexy template which is expecting HTML, and it’s a big mess.

Instead, we want to create functions that simulate how the SGL_Manager class works, in our own custom class.

So the functions we need are:

  • Constructor
  • validate($req, &$input)
  • _action((&$input, &$output)
  • process(&$input, &$output)
  • display($input, $output)

The constructor sets up the variables in the class. The _aActionsMapping variable must be set up here to dispatch the action to the correct page. If this doesn’t make sense, read up on creating custom Seagull modules.

Validate is required to process the page. It also sets up any variables that were POSTed as form values, or in the URL.

Your _action function is where things get done. Make sure you set the content type: header(’Content-type: text/xml’);. The data is output here with an ‘echo’ statement. Remember to format your XML properly. Firefox is great for debugging at this point because it will barf on bad XML.

The process function is copied from the SGL_Manager class but modified so that it doesn’t go through flexy:


function process(&$input, &$output)
{
SGL::logMessage(null, PEAR_LOG_DEBUG);

$conf = & $GLOBALS['_SGL']['CONF'];
$className = get_class($this);

// don't perform checks if authentication is disabled in debug
if ($conf['debug']['authenticationEnabled']) {

// setup classwide perm
$classPerm = @constant('SGL_PERMS_' . strtoupper($className));

// if user has no class perms check for each action
if (! SGL_HTTP_Session::hasPerms($classPerm)) {

// ...and if linked methods to be called are allowed
foreach ($this->_aActionsMapping[$input->action] as $methodName) {

// allow redirects without perms
if ($methodName == 'redirectToDefault') {
continue;
}
$methodName = '_' . $methodName;

// build relevant perms constant
$perm = @constant('SGL_PERMS_' . strtoupper($className . $methodName));

// redirect if user doesn't have method specific or classwide perms
if (! SGL_HTTP_Session::hasPerms($perm)) {
SGL::raiseMsg('you do not have perms');
SGL::logMessage('You do not have the required perms for ' .
$className . '::' .$methodName, PEAR_LOG_NOTICE);

// make sure no infinite redirections
$lastRedirected = SGL_HTTP_Session::get('redirected');
$now = time();
SGL_HTTP_Session::set('redirected', $now);
if ($now - $lastRedirected < 2) {
PEAR::raiseError('infinite loop detected, clear cookies and check perms',
SGL_ERROR_RECURSION, PEAR_ERROR_DIE);
}
// get default params for logout page
$aParams = $this->getDefaultPageParams();
SGL_HTTP::redirect($aParams);
}
}
}
}

// all tests passed, execute relevant method
foreach ($this->_aActionsMapping[$input->action] as $methodName) {
$methodName = '_'.$methodName;
$this->$methodName($input, $output);
}
}

display is an empty function since we already did the displaying though the action function.

At this point, you will be able to point your browser to your custom module’s URL and get an XML page. After that, make sure your Rico code is pointing to this URL and you should see it show up in your page!

Comments (8)

CKNW covers podcasting

Josh Bancroft is going to be in town to talk to CKNW about podcasting etc.

I didn’t see any posts from Roland Tanglao, or any of the other Bryght guys, nor anything from Darren Barefoot. I wonder why they weren’t invited?

I hope I can listen online on my Linux box tomorrow to see what these guys have to say!

Comments (2)

Keeping your finger on the blog pulse

I never had much use for the blog tracking tools like Blogpulse, Icerocket, Technorati, ad nauseum, until recently. I was using them as search engines, which they can be used for, but the more useful thing IMO is for keeping your finger on the pulse of the blogosphere.

For example, I’m interested in the ‘Hundred Mile Diet‘, but it’s impossible for me to find all of the blogs that talk about it, even with trackbacks.

But with these blog tracking services, they let me create my own queries, and they make an RSS feed out of the search results. I pop those in my RSS reader, and all of a sudden I can keep track of the conversations spread across the web!

Comments

Wikipedized version of the BBC

Yes, yes, YES! Another example about how your website can be infinitely more useful when you open the API:

Have a look at this example: BBC NEWS | Business | Glazer wins control of Man United

I don’t know exactly how it works, but basically the proxy inserts links to Wikipedia into BBC articles.

How is this different from Google’s Autolink which caused quite a stir in the blogosphere? The BBC is encouraging you to do this.

Comments

Blogs are advertising: Elections B.C.

Elections BC says that blogs are advertising.

Can Elections BC scale? There are so many BC blogs available, and I’m sure everyone is going to have some comments on the lead up to the election, or the results afterwards. A change is required, and even Elections BC admits that. Jennifer Miller says:

“If we feel certain parts of the act can be amended to make it more effective and efficient, we will definitely make that recommendation”

Now, journalists don’t seem to have the requirement of registering to be election advertisers when they write editorials in newspapers. At least, I didn’t see any in the list of election advertisers. So, can bloggers be considered journalists? Do they want to be?

Comments

Online Poker

Online poker is great fun, and I always like to help a good Googlebomb!

Comments

I’ve been blog spammed!

I’ve been comment spammed, but fortunately WordPress caught them before they made it on the site. I wonder where I should go with this. I have the poster’s IP, so I think I will do some detective work and follow up with their ISP.

Geez, I only have this website up for a month and it gets spammed. I wonder if it’s a human that goes around doing this, or if they have a script that looks for WordPress installations and adds comments automatically.

When I have time I’m going to dig through my Apache logs and see if there is a referrer or useragent from their IP address.

Comments (2)

CNET News.com now doing trackbacks

CNET News.com has introduced trackbacks and pingbacks into their site. This is great for readers because they can see who else on the net is discussing the articles.

I wonder how long it will take for them to develop permalinks for their site (see linked URL). :)

Off I go to see if my trackback actually made it.

Comments (14)

Blogging dinner with Dave

Went for dinner on Friday to Phnom Penh, a Vietnamese and Cambodian restaurant, with a bunch of people from the local blogging community.

Dave Winer was the guest of honour.

Met a bunch of interesting people, although I haven’t had time to check out their blogs yet.

The food was amazing and fortunately Roland was there to order for us, since it was very overwhelming to try and pick something out.

It was my first time having pho, where I accidentally ate some tripe (I thought it was squid or something). We also had some other great dishes, the papaya salad, squid (the real stuff this time), and a raw marinated beef dish, garnished with cilantro. Tracy was even brave enough to try the beef (but not the frogs legs).

Darren pointed out a very cool site called Sail Freyja that is a blog of some Vancouverites that have sailed down to Oceana to tour around. They’re visiting places like the Marquesas, Tongo, New Zealand. I’m very jealous… time to work on the plans for the Chinese junk. :)

Edit: Still learning about this trackback stuff…

Comments

« Previous Page« Previous entries « Previous Page · Next Page » Next entries »Next Page »