<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Build Internet &#187; Tutorials</title>
	<atom:link href="http://buildinternet.com/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://buildinternet.com</link>
	<description>Web Design, Development, and Business</description>
	<lastBuildDate>Fri, 02 Mar 2012 20:10:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Updating Social Widgets with the History API</title>
		<link>http://buildinternet.com/2012/03/updating-social-widgets-with-the-history-api/</link>
		<comments>http://buildinternet.com/2012/03/updating-social-widgets-with-the-history-api/#comments</comments>
		<pubDate>Fri, 02 Mar 2012 20:08:28 +0000</pubDate>
		<dc:creator>Zach Dunn</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[History API]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Social Media]]></category>

		<guid isPermaLink="false">http://buildinternet.com/?p=10219</guid>
		<description><![CDATA[Keep social widgets in sync with pages loaded via history API]]></description>
			<content:encoded><![CDATA[<h3>Keep Your Social Current</h3>
<p>After working with the HTML5 history API for the launch of <a title="A Big Game of Would You Rather" href="http://yourather.com" target="_blank">You Rather</a>, I hit a snag with keeping social widgets current. The content and URL would update, but the Like button would stick to the original document location. As it turns out, <span class="important">Twitter and Facebook widgets that can&#8217;t simply be updated via typical jQuery selectors</span> since they are parsed into iframes once the page loads. Fortunately for us, there is an easy fix.</p>
<p>In the function below, you can see that on push state we replace the HTML of the widget&#8217;s parent with the new unparsed snippet. Then we search for a window level object of FB for <code>Facebook</code> and <code>twttr</code> for Twitter and reload each if they exist. For those looking to update Google Analytics you&#8217;ll also notice there is a section where the URL is pushed as a new pageview. You earned those pageviews, so don&#8217;t forget to claim them.</p>
<pre name="code" class="javascript">
var update_social = function(title, url) {

	// Add a new pageview to Analytics
	if (typeof _gaq !== 'undefined')
	{
		window._gaq.push(['_trackPageview', url]);
	}

	//Need the full URL for outside sites
	var full_url = window.location.href;

	//Populate new Facebook widget
	$('#fb-like').html('&lt;fb:like href="' + full_url + '" show_faces="false" width="350" action="like" send="true" font="segoe ui" colorscheme="light" /&gt;');

	//Reload Facebook
	if (typeof FB !== 'undefined') {
		FB.XFBML.parse(document.getElementById('fb-like'));
	}

	//Populate new Twitter widget
	var twitter_text = title + " via " + "@buildinternet";
	$('#twitter-share').html('&lt;a href="https://twitter.com/share" vclass="twitter-share-button" data-url="' + full_url + '" data-text="'+ twitter_text +'" data-related="buildinternet"&gt;Tweet&lt;/a&gt;');

	//Reload Twitter
	if (typeof twttr !== 'undefined') {
		twttr.widgets.load();
	}
}
</pre>
<p>For a look at this in action, take a look at the <a title="Updating Social Widget with History API" href="http://buildinternet.com/live/history-social/" target="_blank">the demo page</a>. The source code shows more of the context in a working History API driven page.</p>
<p>If you&#8217;re looking for more reading on how to get started with the history API, I recommend <a title="Getting started with history API" href="http://js-html5.com/post/3014620142/history-api" target="_blank">taking a look at this tutorial before looping back</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildinternet.com/2012/03/updating-social-widgets-with-the-history-api/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tweet Sheet &#8211; Creating a Popup Tweet in iOS 5</title>
		<link>http://buildinternet.com/2011/10/tweet-sheet-creating-a-popup-tweet-in-ios-5/</link>
		<comments>http://buildinternet.com/2011/10/tweet-sheet-creating-a-popup-tweet-in-ios-5/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 15:08:37 +0000</pubDate>
		<dc:creator>Eli Perkins</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[iOS5]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://buildinternet.com/?p=10080</guid>
		<description><![CDATA[Implement the new Twitter capabilities in iOS5 to create a quick tweet in your own app.]]></description>
			<content:encoded><![CDATA[<h3>Twitter Integration Made Easy</h3>
<p>With the release of iOS 5 on Wednesday, a flurry of new features became available to developers. From hot <a href="http://developer.apple.com/technologies/ios5/" target="_blank">new features</a> like iCloud and iMessage to Android-like notifications, one standout new feature for developers is the addition of an entire Twitter framework, allowing developers to access the Twitter-verse in a much easier way. In prior iterations of iOS, developers needed to add in third-party libraries to authenticate Twitter accounts, post tweets, search for hashtags, and so on. With the new Twitter.framework, iOS takes the wheel from the developers&#8217; apps for the heavy lifting.</p>
<p>This tutorial will let you learn the basics to implementing the new Twitter framework into your iOS app to create and post tweets. By the end, you&#8217;ll have a simple app that will let you tweet any given message, link, or image!</p>
<h3>Overview</h3>
<p>The Twitter.framework has a pre-built modal view controller for presenting the user with a quick tweet, named TWTweetComposeViewController. This &#8220;tweet sheet&#8221; is a quick way for developers to post text, images or links from within their app, without bouncing out to Safari or the Twitter app.</p>
<p>iOS 5 has a new Accounts framework as well, which allows for a neat and tidy way to store usernames, passwords, etc. Apple has taken the initiative to package the Accounts framework into the new Twitter framework. This means that if an iOS 5 user logs into Twitter in any Twitter-using applications, his credentials can be stored into the iOS Settings and are able to be used by other apps as well.</p>
<p>What if our user is not logged in to Twitter when they get our extravagant tweeting app? Well, that is up to us as the developer to handle. For this example, I&#8217;ll show you two different ways to handle this situation. The first is to just let iOS notify the user that they need to be logged in to tweet. The second is to just not let them tweet at all. The decision is up to you! So let&#8217;s get started.</p>
<hr />
<h3>Getting Started</h3>
<p>Since this tutorial involves new iOS features in iOS 5, it is assumed you&#8217;re already running Xcode 4+</p>
<p>To begin, let&#8217;s work with a simple, single-view based app. Create a new single-view project in Xcode. Let&#8217;s call it TweetThis. For the sake of being cutting edge, let&#8217;s make sure the project uses <a href="http://clang.llvm.org/docs/AutomaticReferenceCounting.html">Automatic Reference Counting (ARC)</a>.</p>
<h4>Add Twitter.framework</h4>
<p>To take advantage of the new Twitter framework, we need to link our binary with the Twitter library. This is accomplished by clicking on your project in the Navigator sidebar, selecting your project&#8217;s target, and going to Build Phases. This should pull up a table with a few items. Click the arrow next to Link Binary With Libraries to expand the options and click the + button to add a new library. Find the library named Twitter.framework in the popup menu and select add button. Your end product should look a bit like this:<br />
<a href="http://buildinternet.s3.amazonaws.com/images/create-tweet-sheet/tweetthis-linkbinary.png"><img class="size-medium wp-image-10102 aligncenter" title="Binaries linked!" src="http://buildinternet.s3.amazonaws.com/images/create-tweet-sheet/tweetthis-linkbinary.png" alt="" width="360" height="194" /></a></p>
<h4>Setup your interface</h4>
<p>For this example app, we only need a couple UI elements. In your ViewController.xib, add in a button and a label.</p>
<p style="text-align: center;"><img class="size-medium wp-image-10103 aligncenter" title="You can make yours look a little more snazzy" src="http://buildinternet.s3.amazonaws.com/images/create-tweet-sheet/tweetthis-interface.png" alt="" width="299" height="373" /></p>
<p>The button will say something like &#8220;Tweet this!&#8221; and will be linked to the action that brings up our tweet sheet.</p>
<p>The label we add is for displaying an error message should the user not be logged in to Twitter. Let&#8217;s give this some text like &#8220;Not logged in to Twitter&#8221; for now. We&#8217;ll simply just hide and unhide this depending of if the user can tweet or not.Last but not least, create an IBOutlet for the button (I named mine tweetButton) and label (mine was errorLabel) and an IBAction for the tweeting named tweetButtonPressed for the event touch up inside. Now let&#8217;s hit the code.</p>
<h3>ViewController.h</h3>
<h4>Check for availability</h4>
<p>At this point, your ViewController.h should look something like this:</p>
<pre class="objc">#import &lt;UIKit/UIKit.h&gt;
@interface ViewController : UIViewController {
     IBOutlet UIButton *tweetButton;
     IBOutlet UILabel *errorLabel;
}
- (IBAction)tweetButtonPressed:(id)sender;
@end</pre>
<p>We should add in one more variable here before moving on. Add in the interface a BOOL named _canTweet. This boolean will keep track of whether or not the ability to tweet is available. What do you mean by &#8220;the ability to tweet is available&#8221;? It&#8217;s two-fold. The TWTweetComposeViewController has a method named canSendTweet. The method returns true should the user be logged in <em>and if the device is able to reach the Twitter service</em>. While this doesn&#8217;t mean it&#8217;ll return false if Twitter is down (which is rare anyway), it will be very helpful should the user be in Airplane Mode, or not have service, or some similar situation.</p>
<p>With that boolean, our ViewController header should be complete for now. Let&#8217;s head over to ViewController.m and get some work done.</p>
<h3>ViewController.m</h3>
<p>First things first, let&#8217;s import the Twitter framework by importing the header for it. Add the following import line at the top of your file:</p>
<pre class="objc">#import &lt;Twitter/Twitter.h&gt;</pre>
<p>Remember earlier when I mentioned that we have a couple of options to handle if our user isn&#8217;t logged in to Twitter yet? Let&#8217;s use a define to set this. Add the following line right under your import:</p>
<pre class="objc">#define letOSHandleLogin FALSE</pre>
<p>Since we&#8217;re going to modify interface items based on tweeting ability, let&#8217;s check our ability to tweet by overriding the loadView method as such:</p>
<pre class="objc">- (void)loadView
{
     [super loadView];
     //Check to see if the user is able to tweet
     /**
     * This part is somewhat optional. iOS will prompt the user to log in to Twitter if they aren't already
     * However, it's best practice to do something similar to this, like show custom alerts, etc.
     **/
     if ([TWTweetComposeViewController canSendTweet]){
          _canTweet = YES;
     }
     if (letOSHandleLogin) {
          errorLabel.hidden = YES;
     } else{
          tweetButton.hidden = !(_canTweet);      //If able to tweet, show button
          errorLabel.hidden = _canTweet;          //If able to tweet, hide error
     }
}</pre>
<p style="text-align: center;">Great! Now at this point you should be able to run your application and depending on whether or not your simulator has a Twitter account setup already, you should see the button or the error message! But that&#8217;s just step one. Step two is the fun part: composing the actual tweet!<br />
<a href="http://buildinternet.s3.amazonaws.com/images/create-tweet-sheet/tweetthis-nolabel.png"><img class="size-medium wp-image-10104 aligncenter" title="No label? Connected." src="http://buildinternet.s3.amazonaws.com/images/create-tweet-sheet/tweetthis-nolabel.png" alt="" width="159" height="300" /></a></p>
<h4>Composing and Displaying the Tweet Sheet</h4>
<p>The last step to creating this awesome tweet is actual composition of the tweet sheet itself. This step is actually quite simple and takes only a few lines of code. Define your IBAction for tweetButtonClicked as such:</p>
<pre class="objc">- (IBAction)tweetButtonPressed:(id)sender {
     //Create the tweet sheet
     TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];

     //Customize the tweet sheet here
     //Add a tweet message
     [tweetSheet setInitialText:@"Just learned how to use the #iOS5 Twitter Framework on @buildinternet"];

     //Add an image
     [tweetSheet addImage:[UIImage imageNamed:@"tweetThumb.png"]];

     //Add a link
     //Don't worry, Twitter will handle turning this into a t.co link
     [tweetSheet addURL:[NSURL URLWithString:@"http://buildinternet.com/2011/10/ios-creating-your-own-tweet-sheet"]];

     //Set a blocking handler for the tweet sheet
     tweetSheet.completionHandler = ^(TWTweetComposeViewControllerResult result){
          [self dismissModalViewControllerAnimated:YES];
     };

     //Show the tweet sheet!
     [self presentModalViewController:tweetSheet animated:YES];
}</pre>
<p style="text-align: center;">Let&#8217;s go through this line by line real quick to see what&#8217;s going on. First, we alloc-init a new tweet sheet; Objective-C basics. After that, we can customize what the actual tweet is. We can set text with the setInitialText method, add an image with addImage, and add a link with addLink (which will be converted to a t.co link for you by Twitter). Next, we have to set a blocking handler for the result. This is to ensure that we don&#8217;t mess up the rest of the app while tweeting until we dismiss the modal view (that is our tweet sheet). The last line displays our tweet sheet! Build and run your app to see the tweet in all its glory.<br />
<img class="size-full wp-image-10105 aligncenter" title="tweetthis-tweetsheet" src="http://buildinternet.s3.amazonaws.com/images/create-tweet-sheet/tweetthis-tweetsheet.png" alt="" width="396" height="744" /></p>
<hr />
<h3>Wrap Up</h3>
<p>I&#8217;ve included a sample project for you to learn from <a href="https://github.com/eliperkins/TweetThis">here</a> on GitHub. This project is only one example of how to use the Twitter framework. Implement it to your pleasing! Add your own images, craft your own tweets, and bring your app to the next level of the Twitter-verse.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildinternet.com/2011/10/tweet-sheet-creating-a-popup-tweet-in-ios-5/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Cycle Through Images on Hover with jQuery</title>
		<link>http://buildinternet.com/2011/09/cycle-through-images-on-hover-with-jquery/</link>
		<comments>http://buildinternet.com/2011/09/cycle-through-images-on-hover-with-jquery/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 17:04:18 +0000</pubDate>
		<dc:creator>Sam Dunn</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[slideshow]]></category>

		<guid isPermaLink="false">http://buildinternet.com/?p=10042</guid>
		<description><![CDATA[A quick way to add a hover responsive, fast cycling, jQuery powered slideshow to your site.]]></description>
			<content:encoded><![CDATA[<h3>The Basics</h3>
<p>I first saw this style slideshow as a Flash solution on <a href="http://cargocollective.com/" target="_blank">Cargo Collective</a>, which has since been updated to Javascript. As it turns out, it&#8217;s actually quite easy, making it a quick addition to any site you wish to implement it on.</p>
<p>Here&#8217;s what we&#8217;ll be doing:</p>
<ul>
<li>Super fast slideshow that only runs when hovered over.</li>
<li>Overlay logo that toggles between two different states depending on hover state</li>
<li>Inspiration piece for this tutorial: <a href="http://cargocollective.com/" target="_blank">Cargo Collective</a></li>
<li>See our end goal by visiting our <a href="http://buildinternet.com/live/cycle-images/" target="_blank">demo page</a>.</li>
</ul>
<h3>The HTML</h3>
<p>This is the structure for each slideshow, with the images are pulled from the unordered list and turned into a slideshow by <a href="http://jquery.malsup.com/cycle/" target="_blank">jQuery Cycle Plugin</a>.</p>
<p>The .link element is where a URL can be provided for when the slideshow is clicked. It is also how we will swap the logo on hovers.</p>
<pre>&lt;!-- Slideshow
=========================--&gt;
&lt;div class="slideshow-block"&gt;
	&lt;a href="http://website.com" class="link"&gt;&lt;/a&gt;
	&lt;ul class="slides"&gt;
		&lt;li&gt;&lt;img src="image.jpg"/&gt;&lt;/li&gt;
		&lt;!-- Any other slides --&gt;
	&lt;/ul&gt;
&lt;/div&gt;</pre>
<h3>The CSS</h3>
<p>The dimensions for my slideshow are 200px by 150px. Depending on the sizes of your logo and slides, the below background position coordinates and overall dimensions may need to get adjusted.</p>
<ul>
<li>The logo is toggled between the two color variations using the <a href="http://www.noobcube.com/tutorials/html-css/create-an-advanced-css-menu-using-the-hover-and-position-properties-/">background position hover technique</a>.</li>
<li>The unordered  slides list is given a class of &#8220;active&#8221; when hovered over, making it visible on the page.</li>
</ul>
<pre>*{
	margin: 0;
	padding: 0;
	outline: none;
	border: none;
}
.slideshow-block{
	position: relative;
	width: 200px;
	height: 150px;
	overflow: hidden;
	background: #111 url('img/bg.jpg');
}
a.link{
	position:absolute;
	height: 150px;
	width: 200px;
	display: block;
	z-index: 10;
	background: url('img/logo.png') no-repeat center top;
}
a.link:hover{
	background-position: center -150px;
}
.slides{
	z-index:0;
	visibility:hidden;
}
.slides.active{
	visibility:visible;
}</pre>
<h3>The jQuery</h3>
<p>On the jQuery side, we want to accomplish two tasks:</p>
<ol>
<li>Tie the jQuery Cycle Plugin to our list of images, turning them into a slideshow.</li>
<li>Swap between pause and play states when the slideshow is hovered over. This means the slideshow is hidden and paused when the mouse is not over it.</li>
</ol>
<pre>&lt;script type="text/javascript"&gt;
jQuery(function($){

	// Cycle plugin
	$('.slides').cycle({
	    fx:     'none',
	    speed:   1,
	    timeout: 70
	}).cycle("pause");

	// Pause &amp; play on hover
	$('.slideshow-block').hover(function(){
		$(this).find('.slides').addClass('active').cycle('resume');
	}, function(){
		$(this).find('.slides').removeClass('active').cycle('pause');
	});

});
&lt;/script&gt;</pre>
<h3>Closing</h3>
<p>I&#8217;ve included two versions of the script, one with the TV and one without (for easier copy and paste implementation). As always, when in doubt, try using the downloadable demos as a foundation to build from.</p>
<p>I look forward to seeing what folks are able to make happen &#8211; enjoy!</p>
<p><em>Note: You are able to place multiple slideshows on the same page, meaning it&#8217;s feasible for you to make a gallery out of a series of thumbnail slideshows.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://buildinternet.com/2011/09/cycle-through-images-on-hover-with-jquery/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Make a Fluid Thumbnail Bar with jQuery</title>
		<link>http://buildinternet.com/2011/06/make-a-fluid-thumbnail-bar-with-jquery/</link>
		<comments>http://buildinternet.com/2011/06/make-a-fluid-thumbnail-bar-with-jquery/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 22:06:01 +0000</pubDate>
		<dc:creator>Sam Dunn</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Fluid]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Thumbnails]]></category>

		<guid isPermaLink="false">http://buildinternet.com/?p=9898</guid>
		<description><![CDATA[Learn how to make a fluid thumbnail bar that pages through the images it contains.]]></description>
			<content:encoded><![CDATA[<h3>Overview</h3>
<p>The idea of a fluid thumbnail bar is simple: Create a list of thumbnails within a space where the overflow can be flipped through page by page. Speaking of pages, make sure we&#8217;re on the same one by checking out the <a href="http://buildinternet.com/live/fluid-bar/demo.html">demo page</a>.</p>
<p>To be clear, this tutorial is intended to show you how to add this functionality to an existing list of images, in hopes you can use it to compliment whatever your current setup might be. <em>This tutorial assumes you have some level of experience with jQuery</em>.</p>
<p><strong>Features</strong></p>
<ul>
<li>Cycle through thumbnails in different intervals depending on container width</li>
<li>Page arrows only displayed when needed (thumbnails overflow container)</li>
</ul>
<hr/>
<h3>Getting Started</h3>
<p>First off, let&#8217;s make sure we have a base structure to work with, outlined below.</p>
<h4>Scripts</h4>
<p>jQuery (surprise!), Easing, and the separate file which will contain our script.</p>
<pre name="code" class="javascript">&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/jquery.easing.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/fluid.thumbs.js"&gt;&lt;/script&gt;</pre>
<p>&nbsp;</p>
<h4>CSS</h4>
<p>Just one stylesheet needed, nothing crazy. For the sake of brevity, I will let you review the stylesheet on your own, which is available in <a href="http://buildinternet.s3.amazonaws.com/live-tutorials/fluid-thumbnails/buildinternet-fluidbar.zip">the download</a>.</p>
<pre name="code" class="css">&lt;link rel="stylesheet" href="css/fluid.thumbs.css" type="text/css" media="screen" /&gt;</pre>
<h4>HTML</h4>
<p>Below is the structure of the list which will contain the thumbnails, wrapped in a container.</p>
<pre name="code" class="html">&lt;div id="thumb-tray"&gt;
     &lt;ul id="thumb-list"&gt;
          &lt;li&gt;&lt;img src="thumb-1.jpg"/&gt;&lt;/li&gt;
          &lt;li&gt;&lt;img src="thumb-2.jpg"/&gt;&lt;/li&gt;
          &lt;li&gt;&lt;img src="thumb-x.jpg"/&gt;&lt;/li&gt;
     &lt;/ul&gt;
     &lt;div id="thumb-prev"&gt;&lt;/div&gt;
     &lt;div id="thumb-next"&gt;&lt;/div&gt;
&lt;/div&gt;</pre>
<hr/>
<h3>The jQuery</h3>
<p>This is where the bulk of the functionality will be made possible, to get a good sense of what we&#8217;re aiming to do, here are the goals:</p>
<ul>
<li>Automatically resize the width of thumbnail list to fit number of images it contains (when the window is loaded or resized).</li>
<li>Calculate how many thumbs are visible within the visible area.</li>
<li>Cycle through the pages of thumbs when the forward or back arrows are clicked.</li>
</ul>
<h4>The Variables</h4>
<p>To make editing easier, we are going to plug the elements into variables. Additionally, we are defining the thumbInterval and thumbPage variables, which store the pixel width of each page and the pixel distance from zero, respectively.</p>
<pre name="code" class="javascript">var thumbTray = '#thumb-tray',
thumbList = '#thumb-list',
thumbNext = '#thumb-next',
thumbPrev = '#thumb-prev',
thumbInterval,
thumbPage = 0;</pre>
<h4>Setup</h4>
<p>When the document is first ready, the width of the thumbnail list must be calculated, and then depending whether or not it exceeds to visible area, the thumb arrows are displayed and the pixel width of each thumb page is calculated.</p>
<pre name="code" class="javascript">// Adjust to true width of thumb markers
$(thumbList).width($('&gt; li', thumbList).length * $('&gt; li', thumbList).outerWidth(true));</pre>
<p>The width is calculated by multiplying the width of one <em>li</em> by the total number of items within the list. The <a href="http://api.jquery.com/outerWidth/" target="_blank">outerWidth</a> function allows us to include padding and margins in our calculation.</p>
<pre name="code" class="javascript">// Hide thumb arrows if not needed
if ($(thumbList).width() &lt;= $(thumbTray).width()) $(thumbPrev+","+thumbNext).fadeOut(0);</pre>
<p>If the width of the thumbnail list is larger than the thumb tray, then the arrows are needed and faded in.</p>
<pre name="code" class="javascript">// Thumb Intervals
thumbInterval = Math.floor($(thumbTray).width() / $('&gt; li', thumbList).outerWidth(true)) * $('&gt; li', thumbList).outerWidth(true);</pre>
<p>Similar to how the true width of the thumb list was calculated, we are now figuring out the width of each page of thumbnails, establishing how far to shift the list (left or right) when it is cycled through.</p>
<h4>Thumb Navigation</h4>
<p>Pages are navigated by adjusting the left property in a positive(backward) or negative(forward) direction. The thumbInterval variable stores what distance is considered a page, while the thumbPage variable stores the total distance from the left. </p>
<p>If the beginning or end of the list is reached, it will automatically spill over to the opposite end of the list. Each page is calculated based on how many <em>complete</em> list items can be visible in the current visible space. We make use of easing for these animations to add extra smooth transitions.</p>
<pre name="code" class="javascript">
// Thumb Next Button
$(thumbNext).click(function(){
	if (thumbPage - thumbInterval <= -$(thumbList).width()){
		thumbPage = 0;
		$(thumbList).stop().animate({'left': thumbPage}, {duration:500, easing:'easeOutExpo'});
	}else{
		thumbPage = thumbPage - thumbInterval;
		$(thumbList).stop().animate({'left': thumbPage}, {duration:500, easing:'easeOutExpo'});
	}
});

// Thumb Previous Button
$(thumbPrev).click(function(){
	if (thumbPage + thumbInterval > 0){
		thumbPage = Math.floor($(thumbList).width() / thumbInterval) * -thumbInterval;
		if ($(thumbList).width() <= -thumbPage) thumbPage = thumbPage + thumbInterval;
		$(thumbList).stop().animate({'left': thumbPage}, {duration:500, easing:'easeOutExpo'});
	}else{
		thumbPage = thumbPage + thumbInterval;
		$(thumbList).stop().animate({'left': thumbPage}, {duration:500, easing:'easeOutExpo'});
	}
});
</pre>
<h4>Handling Resizes</h4>
<p>Since the thumbInterval and thumbPage are calculated when the page first loads, we need to adjust for the fact that when the browser window size changes, those numbers are no longer relevant. In order to keep this simple, when the window is resized, the variables are recalculated and the page is set back to zero.</p>
<pre name="code" class="javascript">
$(window).resize(function(){

	// Update Thumb Interval &#038; Page
	thumbPage = 0;
	thumbInterval = Math.floor($(thumbTray).width() / $('> li', thumbList).outerWidth(true)) * $('> li', thumbList).outerWidth(true);

	// Adjust thumbnail markers
	if ($(thumbList).width() > $(thumbTray).width()){
		$(thumbPrev+","+thumbNext).fadeIn('fast');
		$(thumbList).stop().animate({'left':0}, 200);
	}else{
		$(thumbPrev+","+thumbNext).fadeOut('fast');
	}

});
</pre>
<h3>Wrap-up &amp; Expanded Script</h3>
<p><span class="important">I've taken the basics of this tutorial and expanded upon them in <a href="https://github.com/buildinternet/thumbreel">Thumb Reel</a></span>, a free script I released that has added functionality such as clicking and keyboard navigation. You can also see this script used in the <a href="http://buildinternet.com/project/supersized/slideshow/3.2/demo.html">newest Supersized release</a>, which is what it was originally made for, although it has since been modified.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildinternet.com/2011/06/make-a-fluid-thumbnail-bar-with-jquery/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>Add a Mobile Landing Page to Your Site</title>
		<link>http://buildinternet.com/2011/01/add-a-mobile-landing-page-to-your-site/</link>
		<comments>http://buildinternet.com/2011/01/add-a-mobile-landing-page-to-your-site/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 01:05:28 +0000</pubDate>
		<dc:creator>Sam Dunn</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Five Minute Upgrade]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://buildinternet.com/?p=9448</guid>
		<description><![CDATA[Give mobile visitors a way to quickly access your company phone number, email, or just directions to the office.]]></description>
			<content:encoded><![CDATA[<h3>Why Have a Landing Page?</h3>
<p><span class="important">Having a mobile specific layout allows on-the-go visitors to quickly access to telephone numbers, email addresses, and directions</span> &#8211; exactly the sort of thing a visitor from a mobile device might be there for.</p>
<p>This tutorial isn&#8217;t about creating an entire mobile version of your site, although some of the stuff you&#8217;ll see here today can be used for exactly that. Instead, this is a means of offering a quick introduction to visitors from the mobile world before passing them through through to your main site.</p>
<h3>The Goal</h3>
<p><a href="http://m.onemightyroar.com/" target="_blank"><img class="alignnone" title="Mobile Landing Page" src="http://buildinternet.s3.amazonaws.com/images/mobile-landing/mobile-landing-goal.jpg" alt="" width="600" height="400" /></a></p>
<hr />
<h3>Getting Started</h3>
<p><span class="important">To make this easy, I have provided a <a href="http://buildinternet.s3.amazonaws.com/images/mobile-landing/mobile-landing-page.zip">mobile template</a> for you to download, which means that all we will have to do is set up redirects for mobile browsers.</span> You can customize the template landing page however you see fit &#8211; it&#8217;s just standard HTML/CSS.</p>
<p>Here&#8217;s what you need to do to get started:</p>
<ol>
<li>Download the <a href="http://buildinternet.s3.amazonaws.com/images/mobile-landing/mobile-landing-page.zip">template file</a>.</li>
<li>Create a directory (or page) to send mobile users to &#8211; some common subdomains are &#8220;m&#8221; or &#8220;mobile&#8221; (eg. <a href="http://m.digg.com" target="_blank">m.digg.com</a> and <a href="http://m.facebook.com" target="_blank">m.facebook.com</a>).</li>
<li>We will be using JS Mobile Redirection to redirect mobile browsers, the script can be <a href="https://github.com/sebarmeli/JS-Redirection-Mobile-Site" target="_blank">downloaded on GitHub</a>. Place the .js file wherever you choose, I have placed mine in a folder called &#8220;js&#8221;.</li>
</ol>
<h3>Set the Redirect</h3>
<p>On the index page of your site, in the &lt;head&gt; section paste in the following lines:</p>
<pre name="code" class="javascript">&lt;script type="text/javascript" src="js/redirection_mobile.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
SA.redirection_mobile ({param:"isDefault", mobile_prefix : "m", cookie_hours : "1" });
&lt;/script&gt;</pre>
<p>This will send any visitor that arrives on the index page to the subdomain &#8220;m.website.com&#8221;, but only once every hour. If they press the link on the template page that says &#8220;continue to full site&#8221;, they will not be redirected within the defined timeframe.</p>
<p>That&#8217;s pretty much it. Congratulations, you have a mobile landing page &#8211; now go forth and customize.</p>
<p><em>Note: If you are redirecting to a specific page rather than a subdomain you can do this by including mobile_url : &#8220;website.com/mobile&#8221; and mobile_prefix : &#8220;http&#8221;. Refer to </em><em><a href="https://github.com/sebarmeli/JS-Redirection-Mobile-Site" target="_blank">the documentation</a></em><em> for further explanation.</em></p>
<hr />
<h3>Additional Notes</h3>
<h4>Fitting to Screen</h4>
<p>You may have noticed the following meta tag in the downloadable files for this tutorial:</p>
<pre name="code" class="html">&lt;meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=false;" /&gt;</pre>
<p>This is the tag that determines how the page fits to the screen and if a visitor can zoom in and out. Mozilla does a fine job of explaining this in great detail, <a href="https://developer.mozilla.org/en/Mobile/Viewport_meta_tag" target="_blank">check out their page</a> on the viewport meta tag for a more rigorous exploration.</p>
<h4>Further iOS Reading</h4>
<p>For more information regarding possibilities on iOS, check out the <a href="http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/l">Safari Web Content Guide</a>. Some nice ones to start with include their <a href="http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html">viewport</a> and <a href="http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/AdjustingtheTextSize/AdjustingtheTextSize.html" target="_blank&quot;">text size adjustment</a> pages.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildinternet.com/2011/01/add-a-mobile-landing-page-to-your-site/feed/</wfw:commentRss>
		<slash:comments>79</slash:comments>
		</item>
		<item>
		<title>Debugging JavaScript Behind the Scenes</title>
		<link>http://buildinternet.com/2010/12/debugging-javascript-behind-the-scenes/</link>
		<comments>http://buildinternet.com/2010/12/debugging-javascript-behind-the-scenes/#comments</comments>
		<pubDate>Fri, 31 Dec 2010 20:17:38 +0000</pubDate>
		<dc:creator>Zach Dunn</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Best Practice]]></category>
		<category><![CDATA[Browser]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Firebug]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://buildinternet.com/?p=9395</guid>
		<description><![CDATA[Learn how to keep your page layouts clean from debugging mess using the browser's console API.]]></description>
			<content:encoded><![CDATA[
<h3>Meet the Console</h3>
<p>Our final post for 2010 comes after a few discussions with industry friends. I was surprised to find that a number of them had never used the in-browser debugging consoles for JavaScript. Regrettably this also included a certain member of our own office, but he can remain nameless for now.</p>
<p>So for those of you who haven&#8217;t yet been formally introduced to the browser console API, here&#8217;s a great way to start fresh in 2011.</p>
<h3>Visual Debugging</h3>
<p>When you work on websites, debugging is mostly a visual experience. It&#8217;s easy to see misaligned columns or overlapping text, change something, and then refresh. With PHP, error reporting stops the script and displays the issue right on the page. In short, a good chunk of web design errors can be handled identified by page load.</p>
<p>The console API is a browser object that can be used to output debugging information as a page loads. For example, the console might output an error if an image element had a source of &#8220;definitelynotareallink&#8221; instead of a valid URL. The console really shines when it comes to JavaScript, especially when sorting through the DOM.</p>
<p><img class="aligncenter" title="Chrome Developer Tools Panel" src="http://buildinternet.s3.amazonaws.com/images/console-api/developer-tool-panel.png" alt="Chrome Developer Tools Panel" width="600" height="567" /></p>
<p><a title="Console API Wiki" href="http://getfirebug.com/wiki/index.php/Console_API">Firebug has the best documented (and robust) console API</a>, but Firefox isn&#8217;t the only browser that can use it. Most modern browsers have development tools that include a console tab. For Chrome and Safari, you can reach this view by right-clicking and selecting &#8220;Inspect Element&#8221; from the context menu.</p>
<h3>Simple Examples</h3>
<p>The console support a number of options, but you&#8217;ll probably only use the same 3-4 regularly. From my own experience, the log() function is by far the most useful. It outputs a new message line to the console that can contain plaintext, DOM Elements, or variables. The examples below cover a couple of the more common functions.</p>
<p>In this script, the console outputs a different result depending on whether or not the full_name variable is empty:</p>
<pre name="code" class="javascript">if (full_name != ""){
	console.log('The name \"' + full_name + '\" was entered');
}else{
	console.error('No name was entered');
}</pre>
<p>For this jQuery click event, the console will return information about the target element&#8217;s attributes:</p>
<pre name="code" class="javascript">$('.trace').click(function(){
	//Run a trace on this click event
	console.trace();
	return false;
});</pre>
<p>I&#8217;ve put together <a title="Console API Demos" href="http://buildinternet.s3.amazonaws.com/live-tutorials/console-api/index.html">a demo page</a> to help showcase more of the basics. Try running it with your console open, and view the source for specific explanations.</p>
<p><a href="http://buildinternet.s3.amazonaws.com/live-tutorials/console-api/index.html"><img class="aligncenter" title="Console API Demos" src="http://buildinternet.s3.amazonaws.com/images/console-api/console-api-demos.png" alt="Console API Demos" width="600" height="300" /></a></p>
<h4>Direct Input is Allowed</h4>
<p>The console goes much deeper than simple outputs, and can also accept direct input similar to a command line. For example, type &#8220;document&#8221; and press enter to get the page returned. Console DOM traversal is a bit heavier (and not as immediately useful) for an introduction, so we&#8217;ll leave that for another post.</p>
<h3>Keep the Page Clean</h3>
<p>Debugging behind the scenes keeps your page clear of any &#8220;testing only&#8221; outputs that must be deleted before launching. It&#8217;s entirely possible to leave console debugging in a live installation without the user ever noticing.</p>
<p>Next time you&#8217;re working on a JavaScript project, give the console a go. It&#8217;s a hell of a lot easier than creating random alert() boxes for specific triggers. When it comes to troubleshooting, <span class="important">unobtrusive is wonderful</span>.</p>
<p>If there&#8217;s a further interest in this topic, there are a number of things we can do more on, particularly with tracking jQuery events. If you have any suggestions, questions, or expertise of your own to throw in, leave a comment below and we&#8217;ll compile something for a future post.</p>
<h4>Links &amp; Reading</h4>
<ol>
<li><a title="Firebug and Logging" href="http://getfirebug.com/logging">Firebug and Logging</a></li>
<li><a title="Debugging in Safari and Webkit" href="http://developer.apple.com/library/safari/#documentation/appleapplications/Conceptual/Safari_Developer_Guide/DebuggingYourWebsite/DebuggingYourWebsite.html">Apple&#8217;s Documentation on Console Debugging</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://buildinternet.com/2010/12/debugging-javascript-behind-the-scenes/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Using the Dribbble API with PHP</title>
		<link>http://buildinternet.com/2010/11/using-the-dribbble-api-with-php/</link>
		<comments>http://buildinternet.com/2010/11/using-the-dribbble-api-with-php/#comments</comments>
		<pubDate>Wed, 10 Nov 2010 05:00:46 +0000</pubDate>
		<dc:creator>Zach Dunn</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Dribbble]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://buildinternet.com/?p=9111</guid>
		<description><![CDATA[Get your Dribbble shots out into the wild using the API plus open source PHP project.]]></description>
			<content:encoded><![CDATA[
<h3>The GitHub Project</h3>
<p>It might have taken a while, but two weeks ago I finally got into GitHub. For those not familiar, GitHub is a site focused on the version control system Git, and allows. It&#8217;s not the only place that you can get hosted Git repositories from (e.g. <a title="Beanstalk SVN and Git" href="http://beanstalkapp.com/">Beanstalk</a>), but it does have a much more open-source friendly environment. It&#8217;s no coincidence that their tagline is &#8220;Social Coding&#8221;.</p>
<p>As part of my orientation to GitHub, I wanted to contribute something to an existing project. As it turned out, <a href="https://github.com/martinbean/dribbble-php" title="Martin's Project">Martin Bean&#8217;s Dribbble PHP wrapper</a> was a brilliant candidate. Martin had already done a <em>substantial</em> amount of work in getting the raw JSON data into a workable format. I decided to help out and add in support for comments, rebounds, and some updated examples. This tutorial is the finishing touch.</p>
<p><img class="aligncenter" title="Github Octocat" src="http://buildinternet.s3.amazonaws.com/images/dribbble-php/github-octacat.jpg" alt="Github Octocat" /></p>
<h3>Dribble API in PHP</h3>
<p><a title="The Dribbble API" href="http://dribbble.com/api" target="_blank">Dribbble has a nicely documented API</a>. Unfortunately for some, it only documents the API&#8217;s output, which means that you&#8217;d have to do some work on your own to get it to working on a project. On the bright side, finding a library for your language is not hard. In this tutorial, we&#8217;ll walk through a couple examples using the Dribbble PHP project hosted on GitHub.</p>
<p>As part of my GitHub update, I included formatted example pages that cover most of the regular API activity. This includes displaying rebounds, comments, and a number of the preset feeds given by Dribbble. If you <a href="http://github.com/martinbean/dribbble-php/archives/master" title="Source files on GitHub">download the source files</a> and look at the examples, getting started should be straightforward. For the average person, displaying their account&#8217;s last five shots is perfectly fine.</p>
<p><img class="aligncenter" title="Preset Dribbble Feeds via API" src="http://buildinternet.s3.amazonaws.com/images/dribbble-php/preset-feed-examples.jpg" alt="Preset Dribbble Feeds" width="600" height="400" /></p>
<h3>General Installation</h3>
<p><em><strong>Note:</strong> All of these instructions are based on the version available as of November 1, 2010. If you&#8217;re reading this in the future, things may look different. That&#8217;s technology for you.</em></p>
<p><em> </em>To start off, make sure that you&#8217;ve <a title="Download direct from GitHub" href="https://github.com/martinbean/dribbble-php">downloaded the most recent version</a> from the project page. Once you&#8217;ve unzipped the project folder you&#8217;ll see a couple folders. The first is &#8220;examples/&#8221; and has a few sample pages that you can play with and see how things work. The second is &#8220;src&#8221; and contains all the files you need to integrate it into your own project.</p>
<p>Assuming you leave these files in the &#8220;src/&#8221; folder, you&#8217;ll load the class using the following code at the top of your page. <span class="important">This code must be present in order for any of the examples below to work.</span></p>
<pre class="php"  name="code">&lt;?php

require_once('src/dribbble.php');

$dribbble = new Dribbble();

?&gt;</pre>
<p>This will create a new dribbble object stored in $dribbble. Everything below branches from this.</p>
<h4>Example 1: List by User</h4>
<p>This is probably what 90% of you are interested in. A Dribbble feed makes an excellent addition to any portfolio/personal site. The following code will pull in the latest 3 shots made by the specified account.</p>
<pre class="php"  name="code">&lt;ul class="dribbble-shots"&gt;
	&lt;?php
		$player = $dribbble-&gt;player-&gt;find('zachdunn');
		$shots = $player-&gt;shots(array('per_page' =&gt; 3));
		foreach ($shots-&gt;shots as $shot) {
			echo sprintf('&lt;li&gt;&lt;a href="%s"&gt;&lt;img src="%s" alt="%s" /&gt;&lt;/a&gt;&lt;/li&gt;', $shot-&gt;url, $shot-&gt;image_url, $shot-&gt;title);
	} ?&gt;
&lt;/ul&gt;</pre>
<p>Shots can be called in two sizes: teaser and full. The example above uses the full 400&#215;300 default, but if you wanted to display teasers instead, you can replace the $shot-&gt;image_url with $shot-&gt;image_teaser_url.</p>
<p><em><strong>For those unfamiliar with PHP&#8217;s sprintf() function, here&#8217;s a quick primer:</strong> The &#8220;%s&#8221; acts as a placeholder for the arguments provided after the first comma. In the example above, the $shot-&gt;url result will be placed into the href attribute, etc. You don&#8217;t have to use this method, but I find it to be much neater than a series of PHP blocks for one-liners.</em></p>
<h4>Example 2: Popular Shots</h4>
<p>Here&#8217;s how you could use the API to get the three latest shots from Dribbble&#8217;s popular section:</p>
<pre class="php" name="code">&lt;ul class="shots"&gt;

	&lt;?php
		//If we're using the same dribbble object, this will overwrite previous calls
		$popular_shots = $dribbble-&gt;shot-&gt;popular(array('page' =&gt; 1, 'per_page' =&gt; 3));
	foreach ($popular_shots-&gt;shots as $shot) { ?&gt;
		&lt;li&gt;
			&lt;h2&gt;&lt;a href="&lt;?php echo $shot-&gt;url;?&gt;"&gt;&lt;?php echo $shot-&gt;title; ?&gt;&lt;/a&gt;&lt;/h2&gt;
			&lt;a href="&lt;?php echo $shot-&gt;url;?&gt;"&gt;&lt;img src="&lt;?php echo $shot-&gt;image_url; ?&gt;" alt="&lt;?php echo $shot-&gt;title; ?&gt;"/&gt;&lt;/a&gt;
			&lt;p&gt;from &lt;a href="&lt;?php echo $shot-&gt;player-&gt;url; ?&gt;"&gt;&lt;?php echo $shot-&gt;player-&gt;name; ?&gt;&lt;/a&gt;
		&lt;/li&gt;
	&lt;?php } ?&gt;

&lt;/ul&gt;</pre>
<p>Notice that you&#8217;re also able to display information about each shot&#8217;s author as well as link to their respective profiles.</p>
<h4>Example 3: Comments on a Shot</h4>
<p><img class="aligncenter" title="Comments on a Shot" src="http://buildinternet.s3.amazonaws.com/images/dribbble-php/comments-on-shot.jpg" alt="Comments on a Shot" width="600" height="400" /></p>
<p>This last one would be useful if you wanted to make a Dribbble-powered testimonial system. The loop below will display comments for the shot specified by ID.</p>
<pre class="php"  name="code"># find a shot
$shot = $dribbble-&gt;shot-&gt;find(62170);

# Get first 5 comments on first page
$comments = $shot-&gt;comments(array('page' =&gt; 1, 'per_page' =&gt; 5));

	&lt;ul class="shots"&gt;
		&lt;li&gt;
			&lt;h2&gt;&lt;a href="&lt;?php echo $shot-&gt;url;?&gt;"&gt;&lt;?php echo $shot-&gt;title; ?&gt;&lt;/a&gt;&lt;/h2&gt;
			&lt;a href="&lt;?php echo $shot-&gt;url;?&gt;"&gt;&lt;img src="&lt;?php echo $shot-&gt;image_url; ?&gt;" alt="&lt;?php echo $shot-&gt;title; ?&gt;"/&gt;&lt;/a&gt;
			&lt;p&gt;from &lt;a href="&lt;?php echo $shot-&gt;player-&gt;url; ?&gt;"&gt;&lt;?php echo $shot-&gt;player-&gt;name; ?&gt;&lt;/a&gt;
		&lt;/li&gt;
	&lt;/ul&gt;

	&lt;?php if ($comments) : ?&gt;

		&lt;ul class="comments"&gt;

		&lt;?php foreach ($comments as $comment) { ?&gt;

			&lt;li&gt;
				&lt;p&gt;&lt;span class="author"&gt;&lt;a href="&lt;?php echo $comment-&gt;player-&gt;url; ?&gt;"&gt;&lt;?php echo $comment-&gt;player-&gt;name; ?&gt;&lt;/a&gt; says:&lt;/span&gt; &lt;?php echo $comment-&gt;body; ?&gt;&lt;/p&gt;
			&lt;/li&gt;

		&lt;?php } ?&gt;

		&lt;/ul&gt;

	&lt;?php else : ?&gt;

		&lt;p&gt;No comments on this shot yet&lt;/p&gt;

	&lt;?php endif; ?&gt;</pre>
<p>If you have any confusion with these (or other) examples, <span class="important">I recommend you take a look at the demo pages packaged with the source code.</span> I tried to make sure that they were as clear-cut as possible, and should make it easy to figure out most issues.</p>
<h3>Fork It Yourself</h3>
<p>Since the project is open source, if anyone is motivated enough to contribute, that would be wonderful. Even though the current version covers all of the basics, there are plenty of features that could be improved upon and integrated from scratch. Even a couple hours can add miles (or kilometers) of polish. If you make a branch that&#8217;s got some exciting stuff in it, post up a link in the comments! We&#8217;d love to see it.</p>
<p><span class="important">&#8230;and before you ask, <a title="People are going to ask anyway." href="http://canigetadribbbleinvite.com/">I don&#8217;t have any dribbble invites</a>.</span> Sorry to disappoint!</p>
<h4>Links &amp; References</h4>
<ol>
<li><a title="Project homepage on GitHub" href="http://github.com/martinbean/dribbble-php" target="_blank">The Dribbble PHP project on GitHub</a></li>
<li><a title="Dribbble API Documentation" href="http://dribbble.com/api">Dribbble&#8217;s official API documentation</a></li>
<li><a title="Zach Dunn on Dribbble" href="http://dribbble.com/zachdunn">Follow me on Dribbble</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://buildinternet.com/2010/11/using-the-dribbble-api-with-php/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>When to use $_SESSION vs $_COOKIE</title>
		<link>http://buildinternet.com/2010/07/when-to-use-_session-vs-_cookie/</link>
		<comments>http://buildinternet.com/2010/07/when-to-use-_session-vs-_cookie/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 19:55:48 +0000</pubDate>
		<dc:creator>Brian Muse</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Basics]]></category>
		<category><![CDATA[Cookies]]></category>
		<category><![CDATA[Managing Data]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Sessions]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://buildinternet.com/?p=8907</guid>
		<description><![CDATA[A critical feature in web programming is the ability to seamlessly pass data from one page load to the next. It’s used most commonly when dealing with user logins, but also for passing error messages, shopping carts, etc. Storing data across pages using PHP is done with two variables in the global scope, called $_SESSION [...]]]></description>
			<content:encoded><![CDATA[<p><span id="more-8907"></span><!--noteaser--></p>
<p>A critical feature in web programming is the ability to seamlessly pass data from one page load to the next. It’s used most commonly when dealing with user logins, but also for passing error messages, shopping carts, etc.</p>
<p>Storing data across pages using PHP is done with two variables in the global scope, called $_SESSION and $_COOKIE, and although accomplishing the same end goal, the both go about it in very different ways. The purpose of this article is to give a brief look into the differences between cookies and sessions, when it’s better to use one versus the other, and the pros and cons of the two.</p>
<p><strong>The difference is in how each store data.</strong> Cookies store data locally in the user&#8217;s browser, while sessions store data on the webserver.</p>
<h3>Session Basics</h3>
<p>Sessions are simply server-side cookies each with a corresponding client side cookie that contains only a reference to its server-side counterpart. When a user visits a page, the client sends the reference code to the server, and PHP will then match that reference code to a server-side cookie and load the data in the server’s cookie into the $_SESSION superglobal.</p>
<h4>Pros</h4>
<ol>
<li>Can store very large amounts of data easily.</li>
<li>Save bandwidth by passing only a reference to the session each pageload. A client-side cookie has to pass all of its data.</li>
<li>Data is stored on the web server. This makes sessions secure, because the data cannot be viewed or edited by the client.</li>
</ol>
<h4>Cons</h4>
<ol>
<li>Ends when the browser is closed unless you&#8217;ve configured php.ini to extend sessions&#8217; cookie lifetime. Cannot last forever.</li>
</ol>
<h3>Cookie Basics</h3>
<p>Cookie data is sent to the web server every page load. PHP reads and stores the value into the $_COOKIE superglobal. When a cookie is created, you can give it a lifespan. After that lifespan runs out, it will expire.</p>
<h4>Pros</h4>
<ol>
<li>Can last as long as the website needs. They will still be there even if the browser is closed and reopened.</li>
<li>Useful for “remember me” logins</li>
<li>Useful for storing temporary user settings. For example, if a user is browsing a paginated list of items, sorted a certain way, the sorting setting can be stored in a cookie.</li>
</ol>
<h4>Cons</h4>
<ol>
<li>Stored in the users filesystem. This means that the user can tamper with it and view it.</li>
<li>Can only store a limited amount of data.</li>
<li>Must pass all data to the webserver each pageload. This takes up more bandwidth.</li>
</ol>
<h3>Cookies in Action</h3>
<h4>Creating a cookie</h4>
<p>The function definition:</p>
<p><em>bool setcookie ( string name [, string value [, int expire [, string path [, string domain [, int secure]]]]])</em></p>
<pre class="php" name="code">&lt;?php
    if (!isset($_COOKIE['Ordering'])) {
        setcookie("Ordering", $_POST['ChangeOrdering'], time() + 31536000);
    }
?&gt;</pre>
<h4>Using a cookie</h4>
<pre class="php" name="code">&lt;?php
	echo (isset($_COOKIE[‘ordering’])) ? $_COOKIE[‘ordering’] : ‘cookie value not set’;
?&gt;</pre>
<h4>Deleting a cookie</h4>
<pre class="php" name="code">&lt;?php setcookie(‘favorite_color’); ?&gt;</pre>
<p>Setting a cookie with no value is the same as deleting it. This will not remove the file from the client computer. To do this, you can set the cookie expiration date to a time in the past, and the browser will take care of it.</p>
<h3>Sessions in Action</h3>
<h4>Creating a session</h4>
<pre class="php" name="code">&lt;?php session_start(); ?&gt;</pre>
<p>This must be called near the top of your code before any output. When you call this function, PHP will check to see if the user sent a session cookie. If so, it will load the session data into $_SESSION. If not, it will create a new session file on the server and send the ID back to the client.</p>
<h4>Setting a value</h4>
<pre class="php" name="code">&lt;?php $_SESSION[‘first_name’] = ‘Brian’; ?&gt;</pre>
<h4>Reading a session value</h4>
<pre class="php" name="code">&lt;?php echo $_SESSION[‘first_name’]; ?&gt;</pre>
<h4>Removing session data</h4>
<pre class="php" name="code">&lt;?php unset($_SESSION[‘first_name’]); ?&gt;</pre>
<h4>Ending a session</h4>
<pre class="php" name="code">&lt;?php session_destroy(); ?&gt;</pre>
<h3>The Bottom Line</h3>
<p>Sessions are cookies where the data is stored on the server. Cookies are stored in the users filesystem (typically in their “Temporary Internet Files” folder). Both have their advantages, but on any given day, you’ll probably find yourself using sessions much more commonly.</p>
<h4>PHP Documentation</h4>
<ol>
<li><a title="PHP Session Manual" href="http://www.php.net/manual/en/book.session.php">PHP Manual: Sessions</a></li>
<li><a title="PHP Cookie Manual" href="http://php.net/manual/en/features.cookies.php">PHP Manual: Cookies</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://buildinternet.com/2010/07/when-to-use-_session-vs-_cookie/feed/</wfw:commentRss>
		<slash:comments>56</slash:comments>
		</item>
		<item>
		<title>Warping Drop Shadows to Give Depth</title>
		<link>http://buildinternet.com/2010/06/warping-drop-shadows-to-give-depth/</link>
		<comments>http://buildinternet.com/2010/06/warping-drop-shadows-to-give-depth/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 19:01:05 +0000</pubDate>
		<dc:creator>Zach Dunn</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Interface Design]]></category>
		<category><![CDATA[Photoshop]]></category>
		<category><![CDATA[Trend]]></category>

		<guid isPermaLink="false">http://buildinternet.com/?p=8819</guid>
		<description><![CDATA[Even though CSS3 has brought a lot to the table in regards to drop shadow effects, there are still plenty of reasons to use image alternatives. The drop shadows generated by CSS3 are relatively uniform, and don&#8217;t deviate much past size and transparency. In some cases, you might want to give a page some extra [...]]]></description>
			<content:encoded><![CDATA[<p><span id="more-8819"></span><!--noteaser--></p>
<p>Even though CSS3 has brought a lot to the table in regards to drop shadow effects, there are still plenty of reasons to use image alternatives. The drop shadows generated by CSS3 are relatively uniform, and don&#8217;t deviate much past size and transparency. In some cases, you might want to give a page some extra depth.</p>
<p>I ran into a similar situation in a recent client project, and decided to use a recent trend of warping drop shadows to help add some extra excitement to the page. You might have seen similar effects in other tutorials involving deleting a circular section, but this method will keep the edges from being too sharp. It also allows you to work with non-rectangular shapes because all points are editable in the warp tool&#8217;s grid.</p>
<h3>Setting Up</h3>
<p>Start a new Photoshop document. The size doesn&#8217;t matter because all of the elements will scale accordingly. I recommend changing the background color to something that will make a white box stand out, but not drown out a black shadow. We&#8217;ll use a light blue for the example. Draw up a white box and we&#8217;re ready to start on the shadow.</p>
<p><img class="aligncenter" title="Before any shadows" src="http://buildinternet.s3.amazonaws.com/images/warping-drop-shadows/2d-content-box.png" alt="Before any shadows" width="600" height="300" /></p>
<h3>Add the Shadow</h3>
<p>You might be tempted to use blending options right now. Resist the urge, because we&#8217;re aiming for something much more distinct.</p>
<p>Start by making a new layer that is positioned between the background and content box from the previous step. On the new layer, draw a rectangle selection that is just slightly smaller than the width of the content box. Fill this area with black.</p>
<p><img class="aligncenter" title="Fill selection with black" src="http://buildinternet.s3.amazonaws.com/images/warping-drop-shadows/drop-shadow-solid-rectangle.png" alt="Fill selection with black" width="600" height="300" /></p>
<p>With the black rectangle layer selection go to Filter&gt;Gaussian Blur and set the radius to 6 pixels.</p>
<p><img class="aligncenter" title="Blurring the Shadow" src="http://buildinternet.s3.amazonaws.com/images/warping-drop-shadows/gaussian-blur-drop-shadow.png" alt="Blurring the Shadow" width="600" height="420" /></p>
<h4>Love the Warp Tool</h4>
<p><a title="Introduction to the warp tool" href="http://psd.tutsplus.com/tutorials/photo-effects-tutorials/making-sense-of-the-warp-tool-its-all-about-the-lines/">Photoshop&#8217;s warp tool</a> is wildly underrated. It&#8217;s good for much more than messing around with celebrity faces or other random attempts to doctor photos. It&#8217;s particular <strong>good at taking specific shapes and molding them into another shape without ruining the appearance</strong>. This point is exactly why we&#8217;ll use it to shape our new drop shadow.</p>
<p>With the shadow layer selected, head to Edit&gt;Transform&gt;Warp to bring up the warping grid. Use the handles on this control to give a curvature to the blurred rectangle. Feel free to shift the layer around to get the best positioning.</p>
<p><img class="aligncenter" title="Warp grid in action" src="http://buildinternet.s3.amazonaws.com/images/warping-drop-shadows/drop-shadow-warp-grid.png" alt="Warp grid in action" width="600" height="300" /></p>
<p>Once the shape is set, simply lower the layer&#8217;s opacity down to about 15% and you&#8217;ve got a finished shadow that simulates a subtle page curl. Nice work!</p>
<p><img class="aligncenter" title="A warped drop shadow" src="http://buildinternet.s3.amazonaws.com/images/warping-drop-shadows/warped-shadow-final.png" alt="A warped drop shadow" width="600" height="300" /></p>
<h3>Wrapping Up</h3>
<p>There you have it, a drop shadow that gives content areas a feeling of &#8220;coming off the page&#8221; depth. As you might have guessed by now, this is a perfect footer background for content areas throughout the page. Not bad!</p>
]]></content:encoded>
			<wfw:commentRss>http://buildinternet.com/2010/06/warping-drop-shadows-to-give-depth/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>How to Automatically Linkify Text with PHP Regular Expressions</title>
		<link>http://buildinternet.com/2010/05/how-to-automatically-linkify-text-with-php-regular-expressions/</link>
		<comments>http://buildinternet.com/2010/05/how-to-automatically-linkify-text-with-php-regular-expressions/#comments</comments>
		<pubDate>Sun, 30 May 2010 00:55:21 +0000</pubDate>
		<dc:creator>Brian Muse</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Advanced]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Regular Expressions]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://buildinternet.com/?p=8784</guid>
		<description><![CDATA[Good software enables us to take a lot of niceties for granted. Intelligent interfaces handle all the simple tasks so that we don&#8217;t need to worry about them. For example, when I type &#8220;www.desktopped.com&#8221; into an email or an instant message, I expect that it will be clickable on the other end without having to [...]]]></description>
			<content:encoded><![CDATA[<p><span id="more-8784"></span><!--noteaser--></p>
<p>Good software enables us to take a lot of niceties for granted. Intelligent interfaces handle all the simple tasks so that we don&#8217;t need to worry about them. For example, when I type &#8220;<a href="http://www.desktopped.com">www.desktopped.com</a>&#8221; into an email or an instant message, I expect that it will be clickable on the other end without having to manually add in HTML tags. Another example is parsing text from a twitter feed. For example, &#8220;<a href="http://www.twitter.com/desktopped">@desktopped</a> is a blog about the <a href="http://search.twitter.com/search?q=computers">#computers</a>&#8220;, we expect both <a href="http://www.twitter.com/desktopped">@desktopped</a> and <a href="http://search.twitter.com/search?q=computers">#computers</a> to be links.</p>
<p>The ability to &#8220;linkify&#8221; text is a great tool to have when developing a blog or website. Possible uses include:</p>
<ul>
<li>Turning URLs clickable in content, comments, and anywhere else</li>
<li>Turning valid email addresses clickable</li>
<li>Turning twitter text clickable so that <a href="http://www.twitter.com/desktopped">@desktopped</a>, <a href="http://search.twitter.com/search?q=computers">#computers</a>, <a href="http://www.desktopped.com">www.desktopped.com</a> all become links.</li>
</ul>
<p>To search a string for patterns, such as strings that begin with &#8220;http://&#8221; or &#8220;@&#8221; is an ability that can be applied in almost endless ways to improve the way we process and display data.</p>
<p>How can we do this? The best way with PHP is to use a universal pattern matching syntax called regular expressions and some useful PHP functions.</p>
<h3>Regular Expressions Basics</h3>
<p>A regular expression is a pattern string that represents a set of strings by using a variety of special characters.</p>
<h4>The Basic Special Characters</h4>
<ul>
<li>| connects two possible values and will turn up a match if the string matches either. For example hi|hello matches the strings &#8220;hi&#8221; and &#8220;hello&#8221;</li>
<li>() are used to group values and set order of operations. For example, br(i|y)an will match both &#8220;brian&#8221; and &#8220;bryan&#8221;.</li>
<li>[] are used to match a single character that appears inside the brackets. [abc] will match &#8220;a&#8221;, &#8220;b&#8221;, or &#8220;c&#8221;, but not &#8220;d&#8221;.</li>
<li>* will turn up a match if there is zero or more of the preceding element. The string go*gle will match &#8220;ggle&#8221;, &#8220;gogle&#8221;, &#8220;google&#8221;, &#8220;gooogle&#8221;, etc.</li>
<li>+ will turn up a match if there is one or more of the preceding element. The string go+gle will match &#8220;gogle&#8221;, &#8220;google&#8221;, gooogle&#8221;, etc.</li>
<li>? will turn up a match if there is zero or one of the preceding character. The string desktopp?ed will match both &#8220;desktopped&#8221; and &#8220;desktoped&#8221;.</li>
</ul>
<h4>Other Common Special Characters</h4>
<ul>
<li>\w will match a &#8220;word&#8221; character, which translates to any character alphanumeric or &#8216;_&#8217;</li>
<li>\n \r and \t will match a new line, carriage return and tab respectively.</li>
</ul>
<p>A full reference for special characters can be found here:</p>
<p>http://www.php.net/manual/en/function.preg-replace.php#89364</p>
<h3>PHP Function: preg_replace</h3>
<p>The preg_replace function in PHP will take a regular expressions pattern, a replacement string, and the text to be examined as arguments. It will check the input text against the pattern and then if there&#8217;s a match it will place certain pieces of the input text into the replacement string.</p>
<p>The pieces that are placed into the replacement string are determined by what is in parenthesis in the pattern string. They are then referenced in the replacement string by using $0, $1, $2, etc., where the $n matches the nth parenthesized pattern.</p>
<h4>A Simple Example</h4>
<pre class="php" name="code">$text= 'My name is Brian';
$pattern = 'My name is (Brian|Sam|Zach)';
$replacement = '$1 is a pretty cool guy.';
echo preg_replace($pattern, $replacement, $text);</pre>
<p>The code will output &#8220;Brian is a pretty cool guy.&#8221; If $text was &#8220;My name is Zach&#8221;, the output would be &#8220;Zach is a pretty cool guy.&#8221; If $text was &#8220;My name is Nick&#8221;, there&#8217;d be no match and the original text would be returned; &#8220;My name is Nick&#8221;.</p>
<h4>Useful Regex Functions</h4>
<p>This function will turn all URLs in a body of text into clickable links</p>
<pre class="php" name="code">function link_it($text)
{
    $text= preg_replace("/(^|[\n ])([\w]*?)((ht|f)tp(s)?:\/\/[\w]+[^ \,\"\n\r\t&lt;]*)/is", "$1$2&lt;a href=\"$3\" &gt;$3&lt;/a&gt;", $text);
    $text= preg_replace("/(^|[\n ])([\w]*?)((www|ftp)\.[^ \,\"\t\n\r&lt;]*)/is", "$1$2&lt;a href=\"http://$3\" &gt;$3&lt;/a&gt;", $text);
    $text= preg_replace("/(^|[\n ])([a-z0-9&#038;\-_\.]+?)@([\w\-]+\.([\w\-\.]+)+)/i", "$1&lt;a href=\"mailto:$2@$3\"&gt;$2@$3&lt;/a&gt;", $text);
    return($text);
}</pre>
<p>This function will turn all pound signs (#) and at-sign (@) into hash tag and @reply links in a twitter feed.</p>
<pre class="php" name="code">function twitter_it($text)
{
    $text= preg_replace("/@(\w+)/", '&lt;a href="http://www.twitter.com/$1" target="_blank"&gt;@$1&lt;/a&gt;', $text);
    $text= preg_replace("/\#(\w+)/", '&lt;a href="http://search.twitter.com/search?q=$1" target="_blank"&gt;#$1&lt;/a&gt;',$text);
    return $text;
}</pre>
<p>This function finds strings in your post body that you&#8217;ve identified with the pattern :tagname: and turns them into tag searches on your blog. For example: &#8220;This post is about :PHP:.&#8221; will result in &#8220;The post is about <a href="http://buildinternet.com/tag/php/">PHP</a>&#8220;.</p>
<pre class="php" name="code">function tag_it($text)
{
    $text= preg_replace("/:(\w+):/", '&lt;a href="http://www.buildinternet.com/tag/$1/" target="_blank"&gt;$1&lt;/a&gt;',$text);
    return $text;
}</pre>
<p>This function will highlight search terms in search result titles on your WordPress blog. Pass an array of keywords and it will do the rest. (Must be used inside the loop)</p>
<pre class="php" name="code">function highlight_terms($keys_array)
{
    $title = get_the_title();
    return preg_replace('/('.implode('|', $keys_array) .')/iu', '&lt;span class="highlight"&gt;$0&lt;/span&gt;', $title);
}</pre>
<p>The function will take any string (usually a page title) and generate a URL slug.</p>
<pre class="php" name="code">function create_slug($string)
{
    $string= strtolower(trim($string));
    $string= preg_replace('/[^a-z0-9-]/', '-', $string);
    $string= preg_replace('/-+/', "-", $string);
    return $string;
}</pre>
<h4>Further Reading</h4>
<p>Regular Expressions Resource:<br />
<a href="http://www.regular-expressions.info">http://www.regular-expressions.info</a></p>
<p>PHP pre_replace Manual:<br />
<a href="http://php.net/manual/en/function.preg-replace.php">http://php.net/manual/en/function.preg-replace.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://buildinternet.com/2010/05/how-to-automatically-linkify-text-with-php-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using memcached
Database Caching using memcached
Object Caching 754/839 objects using disk: basic

Served from: buildinternet.com @ 2012-05-23 18:32:10 -->
