This Blog has Migrated from Blogger to DBBD.SG!

Recently with the Wikicliki show opening, I took a long hard look at my various websites and decided to update my semi-dormant website, dbbd.sg. For a long time, I’ve tried not to meddle with the web design of my website (because its a rabbit hole of tinkering that I am apt to fall down into), but its been a few years since my dbbd.sg site was made and maybe, just maybe, I guess I should be applying my commercially useful UX/UI/web skillz (which I teach in my day job) to my own web presence!…

The funny thing about this blog migrating to wordpress is that, it being a very busy time, I actually contemplated hiring a Fiverr to save me the time and trouble of porting my blogger blog (openurbanism) to my own server. But bizarrely, when I looked into my own server, it appears that on 31 Dec 2020 (a good time for making and breaking new year resolutions), I discovered that I had already ported my own blog over to a wordpress installation on my server??? – and then promptly forgotten about having done it?!?!

I would like to congratulate the Debbie in the past for having the foresight to do all the hard work, thus saving Present Day Debbie all that work.

Well I guess it must have been too simple – to the point that I blanked out the entire memory of doing it. No wonder the rates on Fiverr for this task are so low. If I try to retrace my steps, it seems it was just a matter of downloading an XML containing all my 371 of my existing blog posts and then importing it in to a new wordpress installation, and then throwing in a few useful plugins to quickly download all my remotely hosted images to the wordpress media library. Finally, I just roughly smushed an old but classic WordPress template together to make it look like an acceptable blog (twentysixteen, nevermind that its now twentytwentyone, but i don’t like the newer wordpress defaults). The WordPress template isn’t the best yet because the amount of time I’ve spent on it is too limited, but let’s try to keep it about the documenting, and let’s not fall into the rabbithole of the obsessive editing of tiny css snippets again!

So here we are, my newly ported blog, and this is post #372!

What would happen to my Web Presence if I unexpectedly died?

It may sound ridiculous, but it has surprised me how some of my embarassingly old websites on services like livejournal and blogger have stood the test of time and survived without any intervention from myself, whereas the many paid domains I have bought and retired have disappeared from the internet (after I stopped renewing them). I worried that if something unexpectedly should happen to myself, then no one would know how to keep my websites alive. So for the longest time, I decided to relinquish a little design control in exchange for hosting it on a fuss-free long-lived platform like blogger – also in order to stop myself from compulsively tinkering on the web design (being the obsessive pixelpusher that I am).

But…. now that I have decided I will take back control and consolidate my web empire, what does it mean for the longevity of the site? What if Debbie unexpectedly stops paying her credit card bill for her web hosting and web domain name registration and everything? What would happen to the site? Would it vanish overnight, once my hosting bill is not paid?

Well, to look at things in perspective, all my writings would not be truly lost. I found that my dbbd.sg website has indeed been archived by the Internet Archive almost every year since 2012. I’ve also always kept the openurbanism blog on the lowdown, like a public blog which feels like a private blog or well-kept secret from me just being intentionally terrible at publicising or sharing when I have posted new stuff. To be honest, I document my process because it is a cult of being “done” to me. By posting about it online, it makes me feel like the work is “done” and that I can get closure and move on to a new task. I suppose it helps me get over the sometimes paralysing need to make things perfect.

Do say: The various iterations of your website have been successfully archived by internet archive!
Don’t say: The various iterations of all your embarassing livejournals since you were 17 have also been archived by the internet archive!... 😱😱😱😱😱

WordPress Taxonomies

The next problem is that my blogger categories had translated over into WordPress categories, but I know that WordPress has both categories and tags, and they were being used differently.

According the WordPress’s support page:

“Categories are best used for broad groupings of topics. For example, if you’re creating a site that reviews media, you might use categories such as Books or Film or TV.

Tags are much more specific topics that you want to use to associate related content. For example if you were creating a site that reviews media, you might want to use tags such as science fiction or horror or action adventure.”

Unfortunately, I had been writing my blogger categories as if they were tags, so it means I might have to manually go through all 371 posts and recategorise and tag them all. 😱

I contemplated editing it in mysql but have messed up databases before, and there were several free plugins out there which were very limited in function, but I eventually found a plugin ($) which would convert categories into tags in bulk so that I wouldn’t have to spend hours trawling through all 371 posts and copy the categories over to tags (not a very meaningful task). But now that I have replaced all categories as post_tags, I have to append each of the 371 post with unique categories again…

This blog will be a work-in-progress!

Design choices: To avoid the occupational hazard of spending too long tinkering with the wordpress template and web design (instead of doing the actual DEBBIEWORK I want to do!!!) I simply took the default WordPress template from a few years back and adapted it briefly for my needs. I looked at all the default wordpress templates over the years and decided that I liked the simplicity of twentysixteen, the year before I moved back to Singapore. I like this shade of #0000ff blue (attempted to print my MA thesis in this colour) and I needed a strong contrast colour so the blog is basic internet blue and red now. I didn’t make the font black because it looked boring and these are not finalised or “resolved” documentations of my works. Its a process blog!

Obsdocu, Artsciencepocketbooth, and Ujikajirecords

One reason why I’ve wanted to go away on residency was because it was hard to break the cycle of overworking. Now I’ve taught my last class for the year, but the crazy working still continues. So here’s an update of the “fun” work done this month (I’m not even going to talk about the commercial work I’ve also been working on…):

obsdocu.sg

Screen shot 2012-04-29 at PM 11
A simple website for a crowdfunded documentary about one of my favorite Singaporean bands of all time, The Observatory. I’ve followed them and their various other bands for well over a decade, in the form of other bands as well, and they’ve dedicated so much time to their craft and music. I’m proud we have guys making music like this here in Singapore. The folks who are trying to produce the film are also friends of mine, and we’re seeking funding to make this documentary. Please donate generously if you would like to support this project!

Visit obsdocu.sg


 

artsciencepocketbooth.org

Screen shot 2012-04-29 at PM 11
A simple website for a flash interactive onsite at the ArtScience Museum, part of the children’s section of the Andy Warhol exhibition. Visitors can take pictures of their belongings and it uploads straight to this site online. Visitors can also tag the pictures with their own keywords, although so far most people seem content to be tagging it with

Visit artsciencepocketbooth.org


 

COMING SOON: BRAND NEW UJIKAJI RECORDS ONLINE SHOP!

ujikaji_for_facebook
handdrawn chinese words for ujikaji!
I’m also rebuilding an online shop for Ujikaji Records, run by my good friend Mark “Ujikaji” Wong. Ujikaji Records is a label/distro specialising in experimental music from Singapore/South East Asia, and they’ll be releasing a number of new digital releases soon and also a compilation of experimental music from Singapore soon (AS SOON AS WE GET ALL THIS UP!). This week, after building the above two sites in record time, I suddenly discovered the magical WordPress plugin known as Jigoshop and after one evening of tinkering I already had incredible results, and I’ve realised its certainly well within my ability to BUILD AN ENTIRE ECCOMMERCE SITE IN TWO WEEKS! OH YEAH, SO THATS WHAT I’M GONNA DO.

Don’t visit ujikaji.net until next week!

Creating a Flash app with a PHP script to upload webcam images to WordPress

This month’s challenge is to build a flash application that is able to take a photo, upload it, and insert it into a wordpress post so that posts can be easily edited later. (AND ALL WITHIN ONE OR TWO WEEKS!) I am building this for a museum exhibition that has just opened and it is going to be a kiosk with a large touchscreen that will be moved around from venue to venue, collecting photos of people’s pockets and stuff, and then digitally archiving them, while allowing one to also tag it collaboratively after that.

I am not a PHP developer although I understand PHP sufficiently well in order to make it do what I need to do, so if anyone more technically inclined can tell me if this is an efficient way to proceed with this, I would be glad to hear if there are other ways to do this!

1. Uploading Image to server

I used php’s mktime to generate a unique number for each photo’s filename. Each photo was encoded using JPGEncoder in flash, and then using urlLoader I sent it to my php file, which saved it onto my server with a filename derived from the mktime number.

After that, the posts were pushed to wordpress with the help of Incutio XML-RPC Library for PHP. You can post to wordpress with a php script with the help of xml-rpc. The following examples are my own mashup of bits and pieces found online, the most instructive guide being this entry: WordPress XMLRPC – Posting Content From Outside WordPress Admin Panel

<?php
if(isset($GLOBALS["HTTP_RAW_POST_DATA"])){

$jpg = $GLOBALS[“HTTP_RAW_POST_DATA”];
$img = $_GET[“img”];
$filename = “images/booth_” . mktime(). “.jpg”;
file_put_contents($filename, $jpg);

require_once(“IXR_Library.php.inc”);

$client->debug = true; //Set it to false in Production Environment
$title=’Pocket No. ‘.mktime(); // $title variable will insert your blog title
$body='<img src=”http://yourdomain.org/’.$filename.'”>’; // $body will insert your blog content (article content)
$category=”pocket”; // Comma seperated pre existing categories. Ensure that these categories exists in your blog.
$keywords=”keyword1, keyword2, keyword3″; // Comma Seperated keywords
$customfields=array(‘key’=>’Author-bio’, ‘value’=>’Author Bio Here’); // Insert your custom values like this in Key, Value format

$title = htmlentities($title,ENT_NOQUOTES,$encoding);
$keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);

$content = array(
‘title’=>$title,
‘description’=>$body,
‘mt_allow_comments’=>0, // 1 to allow comments
‘mt_allow_pings’=>0, // 1 to allow trackbacks
‘post_type’=>’post’,
‘mt_keywords’=>$keywords,
‘categories’=>array($category),
‘custom_fields’ => array($customfields)
);

// Create the client object
$client = new IXR_Client(‘http://yourdomain.org/xmlrpc.php’);
$username = “admin”;
$password = “password”;
$params = array(0,$username,$password,$content,true); // Last parameter ‘true’ means post immediately, to save as draft set it as ‘false’

// Run a query for PHP
if (!$client->query(‘metaWeblog.newPost’, $params)) {
die(‘Something went wrong – ‘.$client->getErrorCode().’ : ‘.$client->getErrorMessage());
}
else
echo “Article Posted Successfully”;

} else{
echo “Encoded JPEG information not received.”;
}
?>

 

2. Retrieving images to put into gallery

This php script will retrieve the last 10 entries in your wordpress and help format them into an xml sheet that you can use in flash to display wordpress entries and images in a flash gallery.

<?php
set_time_limit(0);
require_once("IXR_Library.php.inc"); 
// Echo the header (XML)
header("Content-Type: application/xml;charset=ISO-8859-1");
echo '<?xml version="1.0" encoding="ISO-8859-1"?>' . "rn";
echo "<GALLERY>rn";

// Prepare the XML file
$client->debug = true; // Set it to false in Production Environment

// Create the client object
$client = new IXR_Client(‘http://artsciencepocketbooth.org/xmlrpc.php’);
$username = “admin”;
$password = “password”;
$params = array(0,$username,$password,10); // Last Parameter tells how many posts to fetch

// Run a query To Read Posts From WordPress
if (!$client->query(‘metaWeblog.getRecentPosts’, $params)) {
die(‘Something went wrong – ‘.$client->getErrorCode().’ : ‘.$client->getErrorMessage());
}
$myresponse = $client->getResponse();
$i=0; ?>

<?php
//foreach ($myresponse as $key => $value)
foreach ($myresponse as $res)
{

if($res[‘post_status’]!=”draft”){
//$times = new IXR_Date(); ?>
<image id ='<?php echo $i+1; ?>’ postid='<?php echo $res[‘postid’]; ?>’ title='<?php echo $res[‘title’]; ?>’ keywords='<?php echo $res[‘mt_keywords’]; ?>’/>
<?php $i++; } } ?>
<?php echo “</GALLERY>”; ?>


The resulting XML file will look like this:
Screen shot 2012-03-21 at PM 08

3. Tagging images in gallery

 


 

PHP: Creating automatic XML Sheet from ALL images within a folder

If you need to create an XML sheet from all the photos within one folder, this is a script you can use to create one! It will include any image with a image-related file extension. This is my script which I have customised for my own needs based on notes and tutorials found online.

<?php
// Set which extensions should be approved in the XML file
$extensions = array
(
  'jpg', 'JPG',
  'png', 'PNG',
  'gif', 'GIF',
  'bmp', 'BMP'
);

// Echo the header (XML)
header(“Content-Type: application/xml;charset=ISO-8859-1″);

// Prepare the XML file
echo ‘<?xml version=”1.0″ encoding=”ISO-8859-1”?>’ . “rn”;
echo “<GALLERY>rn”;

// Get the files from the current directory
if (file_exists (“./”))
{
if (is_dir (“./”))
{
$dh = opendir (“./”) or die (” Directory Open failed !”);

// Prepare the images array
$imgs = array();
while ($file = readdir ($dh))
{
// Only get the files ending with the correct extension
if ( in_array( substr($file, -3), $extensions ) )
{
array_push($imgs, $file);
}
}
Closedir ($dh);
}

// Sort the array
sort($imgs);

foreach ($imgs as $img)
{
// Return all images in XML format
echo (‘ <image FULL=”/images/’ . $img . ‘” THUMB=”/images/’ . $img . ‘” />’);
echo “rn”;
}
}
echo “</GALLERY>”;
?>

 


 

OOP & PHP?

there is an interesting article here that argues for OOP in PHP. i admit even in flash sometimes when doing something quick dirty for example i would use global code instead instead of encapsulation. but i guess i find the analogies arguing in favour of OOP rather interesting.