Archive for 'projects' Category

Brightkite Badge Widget

Sep 3rd, 2008 by Andrew Acomb | Comments

Brightkite Widget by Andrew Acomb

I’ve been getting a lot requests for the code to my Brightkite badge. It’s the “Where I’m At” status you see on my page near the top on the right. Instead of sending the same email over and over again, I decided to post the code here.

First, since this uses the SImpleXML extension, you need to make sure that you have PHP 5 or greater installed on your server. SimpleXML makes it so incredibly easy to convert XML into an object that then can be manipulated normally.

Below is the HTML and PHP code I used to create my Brightkite badge. I tried to put a lot of comments in the code to explain my thought process and what the code was doing. It’s not much code once you take out all the comments. It’s really not very complicated at all.

If anyone has any questions or ways to make this better, please don’t hesitate to send me an email or leave a comment.

<div id=”brightkite_where_im_at”>
<h2>Where I’m At</h2>
<?php

/* puts your checkins feed into the $xml varibiable using simplexml, this require php 5.X */
$xml = simplexml_load_file(”http://brightkite.com/people/andrewacomb/objects.xml?filters=checkins”);

/* compares the name variable with the display_location variable, if they are the same returns 0, if different returns another number other than 0 */
$same = strcmp($xml->checkin[0]->place->name, $xml->checkin[0]->place->display_location);

/* scope is a variable in the Brightkite feed that describes the checkin, it could be an address, city, state, or something like that, if the scope if an address AND if the address and name variable are not the same, then the address has a name associated with it so this will ouput for example ‘currently at Hudson Photography on 321 Pacific Ave, Bremerton, WA, USA, update 5 minutes ago’ */
if ($xml->checkin[0]->place->scope==”address” && $same!=0) {
echo ‘currently at <a href=”http://brightkite.com/places/’, $xml->checkin[0]->place->id, ‘”>’, $xml->checkin[0]->place->name, ‘</a> on ‘, $xml->checkin[0]->place->display_location, ‘<span id=”brightkite_updated”> updated ‘, $xml->checkin[0]->created_at_as_words, ‘ ago</span>’;
}

/* if the scope is an address AND if the address and name are the same, then the address does not have a name associated with it so this will output for example ‘currently at 321 Pacific Ave, Bremerton, WA, USA, updated 5 minutes ago’ rather than having it say ‘currently at 321 Pacific Ave, Bremerton, WA, USA on 321 Pacific Ave, Bremerton, WA, USA, updated 5 minutes ago’, that make no sense */
elseif ($xml->checkin[0]->place->scope==”address” && $same==0){
echo ‘currently at <a href=”http://brightkite.com/places/’, $xml->checkin[0]->place->id, ‘”>’, $xml->checkin[0]->place->display_location, ‘</a>’, ‘<span id=”brightkite_updated”> updated ‘, $xml->checkin[0]->created_at_as_words, ‘ ago</span>’;
}

/* if the the above two conditions are not met, this will be the default, it will print for example ‘currently in Bremerton, WA, USA, updated 5 minutes ago’ */
else {
echo ‘currently in <a href=”http://brightkite.com/places/’, $xml->checkin[0]->place->id, ‘”>’, $xml->checkin[0]->place->display_location, ‘</a>’,'<span id=”brightkite_updated”> updated ‘, $xml->checkin[0]->created_at_as_words, ‘ ago</span>’;
}

/* this prints ‘follow me on Brightkite’ which links back to your Brightkite profile */
echo’<p><span id=”brightkite_follow_me”><a href=”http://brightkite.com/people/’, $xml->checkin[0]->creator->login, ‘”>follow me on BrightKite</a></span></p>’;

?>
</div>

Below is the CSS I used to style my Brightkite Badge. You will definitely have to modify this for your site. I enclosed the entire Brightkite Badge with the “brightkite_where_im_at” div tag. I styled the “h2″ tag because I wanted “Where I’m At” on the left with a line underneath it. I used a “brightkite_update” id to make the “updated 2 days ago” text slightly smaller than the rest of the text. I used “brightkite_follow_me” id to align the “follow me on Brightkite” text to the right.

#brightkite_where_im_at{
width:265px;
height:50px;
}
#brightkite_andrewacomb h2{
font-size:1.2em;
margin-bottom: 5px;
color: #dbf1fc;
border-bottom: 1px #c8eb94 solid;

}
#brightkite_updated {
font-size: 0.8em;
}

#brightkite_follow_me {
text-align:right;
}

Again if anyone has any questions or ways to make this better, please don’t hesitate to send me an email or leave a comment. I will always get back to you.

If you use all or part of the code to create your own Brightkite badge, put a link to your site in the comments.

Tumblr Theme Notepad Chaos

Aug 29th, 2008 by Andrew Acomb | Comments

Tumblr Theme Notebook Chaos for Jennifer's New Tumblr Site by Andrew Acomb

I finished a Tumblr Theme for Jennifer’s new Tumblr site. I really liked the Wordpress theme called Notepad Chaos. The theme was design by Evan Eckard specifically for Smashing Magazine. It really is a great theme. I kept searching for other themes, but I just couldn’t find a Tumblr theme that was as good as Notebook Chaos.

While I was searching, I came across a Tumblr site called Random Alisha. She converted the Notepad Chaos Wordpress theme over to Tumblr, but she wasn’t sharing the code by a request from the original author. So, I decided to do it myself.

I’m really glad I decided to convert the theme over to Tumblr, because I was able to change a few things I did not like in Alisha’s version. First, I didn’t like how she had the “Recent Posts” widget in the right column when the recent posts are next to it in the left column. It just didn’t make sense to me. So I changed it to “Recent Comments“.

Recent Posts on Random Alisha's Tumblr Site by Andrew Acomb Recent Comments on Jennifer Acomb's Tumblr Site by Andrew Acomb

Tumblr doesn’t have a comment system by default, so you must intall one. There are many great choices out there. I decided to go with Disqus. They make it so easy to install their comment system on Tumblr. After you add your site to Disqus, you choose “Install” and they walk you through it step by step.

I created a Disqus account for Jennifer and added the code to the theme. I modified the Disqus widget that is available on their site to display the “Recent Comments” in the sidebar.

There are a few little things that I still have to finish like formatting some Tumblr block code and cleaning up a couple of background images to fit together better.

Check Jennifer’s Tumblr site out and let me know what you think of the Notebook Chaos Wordpress theme on Tumblr.