Posts tagged with “hacking”

Display Foursquare Badges in Chyrp without using Javascript

If you notice, I currently display my Foursquare badges over in the right hand side. I'm not sure about how long I'll display them specifically, so here's a screenshot:

I recently received an email inquiring about how I accomplished this. Well, since I use Chyrp, here's how I did it:

  1. In includes/controller/Main.php, add the following, somewhere around line 715 (immediately after $this->context["sql_queries"] =& SQL::current()->queries;):
    // BEGIN Foursquare Badges
    $cURL = curl_init();
    curl_setopt($cURL, CURLOPT_URL, "http://api.foursquare.com/v1/user.json?badges=1");

    curl_setopt($cURL, CURLOPT_HEADER, 0);
    curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($cURL, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($cURL, CURLOPT_USERPWD, "your@email.com:your_password_here");

    $strPage = curl_exec($cURL);
    curl_close($cURL);

    $foursquare = json_decode($strPage);

    $badges = $foursquare->user->badges;

    foreach ($badges as $badge) {
    $this->context['foursquare_badges'] .= '<img src="'.$badge->icon.'" title="'.$badge->description.'" />';
    }
    // END Foursquare Badges

  2. In themes/your_theme_name/content/sidebar.twig, wherever you want to display your foursquare tags, simply add:
    <div>
    <h1>Foursquare Badges</h1>
    $foursquare_badges
    </div></code>

    You can display this wherever you like, in any part of your Chyrp template.

Be aware that this requires PHP's CURL module. I encourage you to enable Chyrp's caching module as well, so every page load does not incur a single API request (I have a feeling that they probably won't appreciate it). The benefit of this is that your Foursquare badges will now be output by your server, so they are both indexable by search engines and degrade very gracefully when the client doesn't have Javascript enabled (NoScript users, particularly).

Enjoy!

Coding Contest: Shortest Full-featured CMS, BB, or Blog

There's a large number of Content Management System, Bulletin Board, and Blog solutions available, all with amazing functionality that simply can't be missed on today's rapidly advancing internet(s).

Examples
CMS: Joomla, with around 280,000 lines of code.
BB: phpBB, with around 150,000 lines of code.
Blogs: WordPress, with around 170,000 lines of code.

My challenge is this:
What is the smallest full-featured CMS, BB, or Blog that you can create?

Contest submissions must include the following features:

  • User Accounts
  • Article Posts (or "Topics" in BB-land)
  • Comment System

Submissions will be accepted in any language, so long as the content can be served up over HTTP. To submit, comment on this post with a link to your project!

Good luck and happy coding!