<?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>A Tasty Pixel » Blog &#187; Web</title>
	<atom:link href="http://atastypixel.com/blog/tag/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://atastypixel.com/blog</link>
	<description></description>
	<lastBuildDate>Wed, 16 May 2012 11:07:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Supporting WordPress shortcodes and captions in MarsEdit preview</title>
		<link>http://atastypixel.com/blog/supporting-wordpress-shortcodes-and-captions-in-marsedit-preview/</link>
		<comments>http://atastypixel.com/blog/supporting-wordpress-shortcodes-and-captions-in-marsedit-preview/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 17:50:49 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[MarsEdit]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/?p=2211</guid>
		<description><![CDATA[I noticed that WordPress these days uses a shortcode to define image captions, of the form: &#91;caption id="" align="aligncenter" width="630" caption="Image title goes here"&#93;&#60;img src=&#34;http://domain.com/imgpath/../image.jpg&#34; width=&#34;630&#34; height=&#34;420&#34; /&#62;&#91;/caption&#93; I&#8217;ve recently redone our blog template at Technomadics, and while setting up the new preview template in MarsEdit, thought I&#8217;d take a stab at implementing support for [...]]]></description>
			<content:encoded><![CDATA[<p>I noticed that WordPress these days uses a shortcode to define image captions, of the form:</p>

<p><tt>&#91;caption id="" align="aligncenter" width="630" caption="Image title goes here"&#93;&lt;img src=&quot;http://domain.com/imgpath/../image.jpg&quot; width=&quot;630&quot; height=&quot;420&quot; /&gt;&#91;/caption&#93;</tt></p>

<p>I&#8217;ve recently redone our blog template at <a href="http://technomadics.net">Technomadics</a>, and while setting up the new preview template in MarsEdit, thought I&#8217;d take a stab at implementing support for captions, too, via some javascript in the template.</p>

<p>I was successful!  Here&#8217;s how I did it:</p>

<p>Added the following to the &#8220;head&#8221; section:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">var</span> prior_content<span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> watch_for_changes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> check <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> elt <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'content'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> elt.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">!=</span> prior_content <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       elt.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> apply_filters<span style="color: #009900;">&#40;</span>elt.<span style="color: #660066;">innerHTML</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   prior_content <span style="color: #339933;">=</span> elt.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    setTimeout<span style="color: #009900;">&#40;</span>check<span style="color: #339933;">,</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
  setTimeout<span style="color: #009900;">&#40;</span>check<span style="color: #339933;">,</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> apply_shortcode<span style="color: #009900;">&#40;</span>source<span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #339933;">,</span> callback<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">return</span> source.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\\</span>['</span> <span style="color: #339933;">+</span> <span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\\</span>s*([^<span style="color: #000099; font-weight: bold;">\\</span>]]*)<span style="color: #000099; font-weight: bold;">\\</span>]((.|[<span style="color: #000099; font-weight: bold;">\s</span><span style="color: #000099; font-weight: bold;">\n</span>])*?)<span style="color: #000099; font-weight: bold;">\\</span>[/'</span> <span style="color: #339933;">+</span> <span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\\</span>]'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'g'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                         <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>match<span style="color: #339933;">,</span> paramString<span style="color: #339933;">,</span> content<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                           params <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Object<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                           reg <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">/([a-z]+)=&quot;((:?=&quot;[^&quot;]+&quot;|[^&quot;])*)&quot;/gi</span><span style="color: #339933;">;</span>
                           <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>match <span style="color: #339933;">=</span> reg.<span style="color: #660066;">exec</span><span style="color: #009900;">&#40;</span>paramString<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                             params<span style="color: #009900;">&#91;</span>match<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> match<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                           <span style="color: #009900;">&#125;</span>
                           <span style="color: #000066; font-weight: bold;">return</span> callback<span style="color: #009900;">&#40;</span>params<span style="color: #339933;">,</span> content<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                         <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> apply_filters<span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  html <span style="color: #339933;">=</span> apply_shortcode<span style="color: #009900;">&#40;</span>html<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;caption&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>args<span style="color: #339933;">,</span> content<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'&lt;div '</span><span style="color: #339933;">+</span>
               <span style="color: #3366CC;">'class=&quot;wp-caption '</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>args.<span style="color: #660066;">align</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'undefined'</span> <span style="color: #339933;">?</span> args.<span style="color: #660066;">align</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; '</span><span style="color: #339933;">+</span>
               <span style="color: #3366CC;">'style=&quot;width: '</span> <span style="color: #339933;">+</span> args.<span style="color: #660066;">width</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'px;&quot;&gt;'</span> <span style="color: #339933;">+</span> content <span style="color: #339933;">+</span>
             <span style="color: #3366CC;">'&lt;p class=&quot;wp-caption-text&quot;&gt;'</span> <span style="color: #339933;">+</span> args.<span style="color: #660066;">caption</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/p&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">return</span> html<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>


<p>…changed to &#8216;body&#8217; tag to…</p>


<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;body onload=&quot;watch_for_changes();&quot;&gt;</pre></div></div>


<p>…And wrapped a div around the main &#8220;#body#, #extended#&#8221; content with an <code>id</code> of <code>content</code>:</p>


<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;content&quot;&gt;
#body#
#extended#
&lt;/div&gt;</pre></div></div>


<p>Basically, it polls the content area for changes, and when triggered, runs it though a filter.  The above is extensible, and by adding additional &#8220;<code>apply_shortcode</code>&#8221; calls from &#8220;<code>apply_filters</code>&#8220;, more shortcodes can be simulated.</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2211" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/supporting-wordpress-shortcodes-and-captions-in-marsedit-preview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Post Grabber sniffs out POST data, generates curl scripts</title>
		<link>http://atastypixel.com/blog/post-grabber-sniffs-out-post-data-generates-curl-scripts/</link>
		<comments>http://atastypixel.com/blog/post-grabber-sniffs-out-post-data-generates-curl-scripts/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 08:59:04 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/post-grabber-sniffs-out-post-data-generates-curl-scripts/</guid>
		<description><![CDATA[Every now and then I find myself needing to automate some web requests, either to download using something a little more robust than a web browser, scrape some web content, or to maintain a session. That automation can be a bit of a pain if there&#8217;s a form submission involved, because it means opening up [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://atastypixel.com/blog/wp-content/uploads/2011/04/michaeltyson_PostGrabber_raw_master_screenshot.png" width="300" height="294" alt="Post Grabber screenshot" class="alignright" />Every now and then I find myself needing to automate some web requests, either to download using something a little more robust than a web browser, scrape some web content, or to maintain a session.  That automation can be a bit of a pain if there&#8217;s a form submission involved, because it means opening up the page source, finding the form and any connected javascript code, and figuring out what fields are submitted.</p>

<p>A little utility I just put together does that for you: <a href="https://github.com/michaeltyson/PostGrabber">Post Grabber</a> detects POST data and generates an equivalent &#8220;curl&#8221; command that can be used in shell or Automator scripts.</p>

<p>Post Grabber works with its own internal browser, so it can intercept POST submissions directly. That means it works with HTTPS, unlike the traditional web sniffer approach.</p>

<p><a href="https://github.com/downloads/michaeltyson/PostGrabber/Post%20Grabber%201.2.zip">Download the app</a>, or see the <a href="https://github.com/michaeltyson/PostGrabber">source on GitHub</a>.</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2189" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/post-grabber-sniffs-out-post-data-generates-curl-scripts/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Introducing The Cartographer Clipper: Clip any website to Google My Maps</title>
		<link>http://atastypixel.com/blog/introducing-the-cartographer-clipper-clip-any-website-to-google-my-maps/</link>
		<comments>http://atastypixel.com/blog/introducing-the-cartographer-clipper-clip-any-website-to-google-my-maps/#comments</comments>
		<pubDate>Wed, 12 Jan 2011 15:21:23 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Products]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Location]]></category>
		<category><![CDATA[Maps]]></category>
		<category><![CDATA[The Cartographer]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Webapps]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/introducing-the-cartographer-clipper-clip-any-website-to-google-my-maps/</guid>
		<description><![CDATA[I&#8217;m pleased to present The Cartographer Clipper, the perfect accompaniment to The Cartographer! The Clipper is a bookmarklet that works in any modern web browser, and lets you clip information from any website &#8212; hotel directories, restaurant websites, even forum postings &#8212; to Google My Maps. Addresses are auto-discovered via some super-sleuthing magic, images pulled [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://cartographer-app.com/#clipper"><img src="http://atastypixel.com/blog/wp-content/uploads/2011/01/clipper.jpg" width="265" height="220" alt="The Cartographer Clipper" class="alignright" /></a>
I&#8217;m pleased to present <a href="http://cartographer-app.com/#clipper">The Cartographer Clipper</a>, the perfect accompaniment to The Cartographer!</p>

<p>The Clipper is a bookmarklet that works in any modern web browser, and lets you clip information from any website &#8212; hotel directories, restaurant websites, even forum postings &#8212; to Google My Maps.  Addresses are auto-discovered via some super-sleuthing magic, images pulled out and any selected text is placed into the description.</p>

<p>You can save to an existing map, or create a new one on the spot.</p>

<p>It&#8217;s great for doing travel or errand research &#8212; find a good hostel (or just the closest Apple store!), just click the &#8220;Clipper&#8221; button, then &#8220;Save&#8221;, and it&#8217;ll appear on your maps in The Cartographer, all automatically.</p>

<p>It&#8217;s free for use, and all it needs is any modern web browser, and a Google account.</p>

<p><a href="http://cartographer-app.com/#clipper">Install The Cartographer Clipper here</a>.</p>

<p>It&#8217;s still in beta, so do <a href="http://atastypixel.com/contact">let me know</a> if you have any trouble!</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2111" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/introducing-the-cartographer-clipper-clip-any-website-to-google-my-maps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Links for May 30th through August 8th</title>
		<link>http://atastypixel.com/blog/links-may-30th-august-8th/</link>
		<comments>http://atastypixel.com/blog/links-may-30th-august-8th/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 22:00:37 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Fonts]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/?p=1921</guid>
		<description><![CDATA[Links for May 30th through August 8th: cuf&#243;n &#8211; fonts for the people A very impressive framework that embeds any font into a website, via javascript and the canvas element. Great cross-browser support. mikeash.com: Method Replacement for Fun and Profit Method replacement and method swizzling in Objective-C. Core Data Tutorial: How To Use NSFetchedResultsController &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>Links for May 30th through August 8th:</p>

<ul class="delicious-bookmarks">
<li><a href="http://cufon.shoqolate.com/generate/">cuf&oacute;n &#8211; fonts for the people</a> A very impressive framework that embeds any font into a website, via javascript and the canvas element. Great cross-browser support.</li>
<li><a href="http://www.mikeash.com/pyblog/friday-qa-2010-01-29-method-replacement-for-fun-and-profit.html">mikeash.com: Method Replacement for Fun and Profit</a> Method replacement and method swizzling in Objective-C.</li>
<li><a href="http://www.raywenderlich.com/999/core-data-tutorial-how-to-use-nsfetchedresultscontroller">Core Data Tutorial: How To Use NSFetchedResultsController | Ray Wenderlich</a> </li>
<li><a href="http://github.com/akosma/TwitThis">TwitThis &ndash; Use Multiple Twitter Clients on your iPhone Application</a> The class TwitterClientManager loads a list list of supported Twitter clients is loaded from a plist file, which can be extended to support more clients in the future;<br />
Each Twitter client is represented by an instance of the TwitterClient class;<br />
The user can choose his preferred Twitter client at any time, and launch the application by a simple touch; the TwitterClientManager class stores the selected value in the user settings.</li>

</ul>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1921" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/links-may-30th-august-8th/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keeping blog visitors by showing meaningful search results in WordPress</title>
		<link>http://atastypixel.com/blog/keeping-blog-visitors-by-showing-meaningful-search-results-in-wordpress/</link>
		<comments>http://atastypixel.com/blog/keeping-blog-visitors-by-showing-meaningful-search-results-in-wordpress/#comments</comments>
		<pubDate>Sat, 05 Jun 2010 14:43:45 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/?p=1927</guid>
		<description><![CDATA[By default, Wordpress will show you full, confusing posts when searching.  Keep your visitors happy by providing contextual search results like a proper search engine.  This post explains how to do it, in just a few minutes.]]></description>
			<content:encoded><![CDATA[<p>I recently became disgruntled with the way my blogs displayed search results.  By default, WordPress blogs will show searched posts exactly as they might appear on an index or archives page: Typically as an extract, or perhaps even as the full entry.</p>

<p>This doesn&#8217;t help at all if you&#8217;re looking for something in particular &#8211; It&#8217;s a much better idea to show the post within the context of the search query, as real search engines do.</p>

<p>See it in practice <a href="http://atastypixel.com/blog/?s=talkie">here</a>.</p>

<p>This is a fairly easy thing to actually get working in WordPress.  It&#8217;ll take just a couple of minutes, and will make a big difference to blog visitors.  Here&#8217;s how I did it.</p>

<p><span id="more-1927"></span></p>

<h2>Creating a search result page</h2>

<p>If your theme doesn&#8217;t already have one, you&#8217;ll need to construct a template within your theme that WordPress will use for search results.  By default, WordPress will use your <code>index.php</code> template, so that&#8217;s usually a good place to start with, for normal themes.</p>

<p>Duplicate <code>index.php</code>, and call it <code>search.php</code>.</p>

<p>If you already have a <code>search.php</code>, you&#8217;re all set.</p>

<h3>A note about theme engines</h3>

<p>A special case here is for theme engines like Thematic (which I use for this blog).  For Thematic, it&#8217;s a matter of un-hooking the provided search &#8216;loop&#8217; from within your child theme, and replacing it with your own.</p>

<p>In my case, with a Thematic child theme, this takes place within <code>functions.php</code>.  First, one needs an &#8216;init&#8217; action, to remove the existing hooks.</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> mytheme_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   remove_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thematic_searchloop'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thematic_search_loop'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">...</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mytheme_init'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<p>Then, it needs a replacement function to perform the search result loop:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">function mytheme_search_loop() {
  while ( have_posts() ) : the_post(); ?&gt;
&nbsp;
    &lt;div id=&quot;post-<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; class=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> thematic_post_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
      <span style="color: #000000; font-weight: bold;">&lt;?php</span> thematic_postheader<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
      &lt;div class=&quot;entry-content&quot;&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> thematic_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/* We will replace this next */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
      &lt;/div&gt;
      <span style="color: #000000; font-weight: bold;">&lt;?php</span> thematic_postfooter<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  &lt;/div&gt;&lt;!-- .post --&gt;
&nbsp;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">...</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thematic_searchloop'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mytheme_search_loop'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<h2>Some smarts to show context</h2>

<p>What I did was replace the content of each post displayed with some code that constructs and displays some context around the search terms found in the post.</p>

<p>In your <code>search.php</code> (or your search loop function, if you&#8217;re using a theme engine), look for the line that inserts the post content.  Chances are, it&#8217;ll look something like <code>&lt;?php the_content('Keep reading'); ?&gt;</code>.  In the case of the Thematic child theme above, it&#8217;s <code>&lt;php thematic_content(); ?&gt;</code>.</p>

<p>Delete that line, and replace it with the following (here&#8217;s a <a href="http://atastypixel.com/blog/wp-content/uploads/2010/06/search_snippet.txt" title="search_snippet.txt">plain-text version</a>, if that&#8217;s easier):</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Configuration</span>
<span style="color: #000088;">$max_length</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">400</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Max length in characters</span>
<span style="color: #000088;">$min_padding</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Min length in characters of the context to place around found search terms</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Load content as plain text</span>
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>post_password_required<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/<span style="color: #000099; font-weight: bold;">\r</span>?<span style="color: #000099; font-weight: bold;">\n</span>/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'@&lt;\s*(p|br\s*/?)\s*&gt;@'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> apply_filters<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_content</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Search content for terms</span>
<span style="color: #000088;">$terms</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'search_terms'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\/'</span><span style="color: #339933;">,</span> <span style="color: #990000;">join</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'|'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$terms</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #339933;">,</span> PREG_OFFSET_CAPTURE<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$padding</span> <span style="color: #339933;">=</span> <span style="color: #990000;">max</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$min_padding</span><span style="color: #339933;">,</span> <span style="color: #000088;">$max_length</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">*</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Construct extract containing context for each term</span>
  <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$last_offset</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$match</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$match</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$start</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$offset</span><span style="color: #339933;">-</span><span style="color: #000088;">$padding</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$end</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$offset</span><span style="color: #339933;">+</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #000088;">$padding</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// Preserve whole words</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$start</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/[A-Za-z0-9\'&quot;-]/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#123;</span><span style="color: #000088;">$start</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$start</span><span style="color: #339933;">--;</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$end</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/[A-Za-z0-9\'&quot;-]/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#123;</span><span style="color: #000088;">$end</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$end</span><span style="color: #339933;">++;</span>
    <span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #990000;">max</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$start</span><span style="color: #339933;">,</span> <span style="color: #000088;">$last_offset</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$context</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$start</span><span style="color: #339933;">,</span> <span style="color: #000088;">$end</span><span style="color: #339933;">-</span><span style="color: #000088;">$start</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$start</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$last_offset</span> <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$context</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'...'</span><span style="color: #339933;">.</span><span style="color: #000088;">$context</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$context</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$last_offset</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$end</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$last_offset</span> <span style="color: #339933;">!=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'...'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$max_length</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$end</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$max_length</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$end</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/[A-Za-z0-9\'&quot;-]/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$output</span><span style="color: #009900;">&#123;</span><span style="color: #000088;">$end</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$end</span><span style="color: #339933;">--;</span>
  <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$end</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'...'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Highlight matches</span>
<span style="color: #000088;">$context</span> <span style="color: #339933;">=</span> <span style="color: #990000;">nl2br</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\/'</span><span style="color: #339933;">,</span> <span style="color: #990000;">join</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'|'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$terms</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/i'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;strong&gt;$0&lt;/strong&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;p class=&quot;search_result_context&quot;&gt;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$context</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/p&gt;
&lt;p&gt;
  &lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; rel=&quot;bookmark&quot;&gt;Read this entry&lt;/a&gt;
&lt;/p&gt;</pre></div></div>


<p>Save, and search for something on your blog &#8212; you should see contextual search results, now.</p>

<h2>One final tweak: Results per page</h2>

<p>WordPress has a setting for the number of posts to show per page.  You may want to use a different number of <em>search results</em> per page, given that each result is now shorter than a full post.</p>

<p>To override this &#8216;posts per page&#8217; setting, you&#8217;ll want to find the line just before the search loop.  It&#8217;ll probably look like <code>&lt;?php if (have_posts()) : ?&gt;</code>, or, if your theme doesn&#8217;t bother with that part, <code>&lt;?php while ( have_posts() ) : the_post(); ?&gt;</code>.</p>

<p>Before that line, insert the following:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">;</span> <span style="color: #000088;">$v</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query_vars</span><span style="color: #339933;">;</span> <span style="color: #000088;">$v</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'posts_per_page'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> query_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>


<p>This will take the current query (including the search phrase, page number, etc.), add a &#8216;posts per page&#8217; parameter, then pass it back to WordPress&#8217;s query engine.</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1927" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/keeping-blog-visitors-by-showing-meaningful-search-results-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>DIY Twitter image hosting</title>
		<link>http://atastypixel.com/blog/diy-twitter-image-hosting/</link>
		<comments>http://atastypixel.com/blog/diy-twitter-image-hosting/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 14:16:07 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/?p=1757</guid>
		<description><![CDATA[Twitter doesn&#8217;t yet come with its own inline image support, so we tend to be limited to using image hosting services, and linking to them with short URLs. So, services like Tweetpic host the image, and we direct traffic to them in return. Thinking it&#8217;s better to keep things in the family, and take better [...]]]></description>
			<content:encoded><![CDATA[<p>Twitter doesn&#8217;t yet come with its own inline image support, so we tend to be limited to using image hosting services, and linking to them with short URLs.  So, services like Tweetpic host the image, and we direct traffic to them in return.</p>

<p>Thinking it&#8217;s better to keep things in the family, and take better advantage of that traffic, I put together an image hosting setup of my own.  Now viewers come to my own site, instead of someone else&#8217;s!</p>

<p>It looks like <a href="http://twitter.com/ATastyPixel/status/7478572775">this</a></p>

<p>The setup consists of an Automator service, and some PHP smarts on the site.</p>

<p><img src="http://atastypixel.com/blog/wp-content/uploads/2010/01/201001071440.jpg" width="200" height="70" alt="Send Image to Image Hosting" class="alignright polaroid rotation" />Under Snow Leopard, I can right-click on an image in Finder, click &#8216;Send Image to Image Hosting&#8217;, type in a title,  then paste the URL that&#8217;s automatically been put onto my clipboard into a tweet.</p>

<p>Here&#8217;s how it works &#8211; this assumes a moderate level of understanding of PHP and assorted web administration.<span id="more-1757"></span>
<em>Update</em>: I couldn&#8217;t help myself; I made a <a href="http://atastypixel.com/blog/wordpress/plugins/twitter-image-host">WordPress plugin</a> for this, with some extra nice features.</p>

<h2>Presentation</h2>

<p>First, we need to put together a script that will display the image.  What&#8217;s more, it would be nice to give the image a title, and link it back to the Twitter account.</p>

<p>So, we&#8217;ll want a place to put images, and a way to store the corresponding title and account name.</p>

<p>I opted to store the latter in a file alongside the image called <code>(imagename).meta</code>.  I store the title, then a newline, then the Twitter account name.</p>

<p>Lets create <code>image.php</code> &#8212; it should take an <code>image name</code> parameter, excluding the file extension, and display the corresponding image, with any corresponding meta data.</p>

<p>Here&#8217;s a sample:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$MEDIA_DIR</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;twitter-images&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Get the image name, but avoid any path shenanigans by just grabbing the 'basename' of the file</span>
<span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Make sure it exists, or report a 404 error</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$image</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #990000;">is_file</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$MEDIA_DIR</span>/<span style="color: #006699; font-weight: bold;">$image</span>.jpg&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;404.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Grab the meta data</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$MEDIA_DIR</span>/<span style="color: #006699; font-weight: bold;">$image</span>.meta&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span><span style="color: #339933;">,</span> <span style="color: #000088;">$source</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$MEDIA_DIR</span>/<span style="color: #006699; font-weight: bold;">$image</span>.meta&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Set a default title if we don't have any meta data</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$title</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ucwords</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Include the page header, if you like</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;header.inc.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;div class=&quot;content&quot;&gt;
&nbsp;
    &lt;img src=&quot;/<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> MEDIA_DIR <span style="color: #000000; font-weight: bold;">?&gt;</span>/<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$image</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>.jpg&quot; alt=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; class=&quot;image&quot; /&gt;
&nbsp;
    &lt;h1&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$title</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/h1&gt;
&nbsp;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$source</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
        &lt;p&gt;
            From &lt;a href=&quot;http://twitter.com/<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$source</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
                &lt;img src=&quot;/media/images/twitter.png&quot; width=&quot;14&quot; height=&quot;14&quot; alt=&quot;Follow us on Twitter!&quot;&gt;
                <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$source</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
            &lt;/a&gt;
        &lt;/p&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;/div&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;footer.inc.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>


<p>Make sure it works by making a sample image called, say, <code>IMG.jpg</code>, and an accompanying metadata file, called <code>IMG.meta</code> with a title on the first line and a twitter account name on the second, and opening up <code>http://yoursite.com/image.php?name=IMG</code></p>

<p>Now, we want to keep URLs short, so they don&#8217;t take up too much valuable space in a tweet, so we need to use some tricks here.</p>

<p>We&#8217;ll set up a <code>.htaccess</code> file that uses <code>mod_rewrite</code> to keep the URL short.</p>

<p>Something like this should do the trick:</p>

<blockquote>
<pre>
&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/([^/]+)$
RewriteCond %{DOCUMENT_ROOT}/twitter-images/%1.jpg -f
RewriteRule (.*) /image.php?name=$1 [L]
&lt;/IfModule&gt;
</pre>
</blockquote>

<p>Note on the fifth line we are checking inside our Twitter images folder &#8212; make sure that matches your storage path.</p>

<p>This will take any requests that:</p>

<ul>
<li>Are located in the web-root (<em>start with a slash, followed by anything but a slash until the end</em>)</li>
<li>Have a corresponding file within the directory we&#8217;ll store images in</li>
</ul>

<p>Then, it&#8217;ll rewrite the request silently to use <code>image.php</code>.</p>

<p>Save the <code>.htaccess</code> file, and open <code>http://yoursite.com/IMG</code>.  It should bring up the image, just as before.</p>

<p>Set up some CSS to make it look good, and you&#8217;re set.  Here&#8217;s mine:</p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">&nbsp;
<span style="color: #808080; font-style: italic;">/* @group Twitter images */</span>
&nbsp;
<span style="color: #6666ff;">.twitter-image</span> .<span style="color: #000000; font-weight: bold;">content</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.twitter-image</span> .<span style="color: #000000; font-weight: bold;">content</span> img<span style="color: #6666ff;">.image</span> <span style="color: #00AA00;">&#123;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
	-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#f1f1f1</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#aaa</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span>  <span style="color: #933;">40px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">60px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.twitter-image</span> .<span style="color: #000000; font-weight: bold;">content</span> h1 <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">60px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.twitter-image</span> .<span style="color: #000000; font-weight: bold;">content</span> p <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.twitter-image</span> .<span style="color: #000000; font-weight: bold;">content</span> a <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.twitter-image</span> .<span style="color: #000000; font-weight: bold;">content</span> a img <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span>text-<span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* @end */</span></pre></div></div>


<h2>Automator</h2>

<p>Now, with the web side set up, we need to set up an easy way to send content there.</p>

<p>I opted for an Automator service, which uses <code>scp</code> to upload the content.  If your web host doesn&#8217;t provide for <code>scp</code>, you may want to use something else like <a href="http://www.ncftp.com/download/">ncftpput</a>, or even an Applescript-able application.  You&#8217;ll need to modify the Automator action&#8217;s shell script accordingly.</p>

<p>Here&#8217;s the Automator service I set up: <a href="http://atastypixel.com/blog/wp-content/uploads/2010/01/Send-Image-to-Image-Hosting.zip" title="Send Image to Image Hosting.zip">Send Image to Image Hosting.zip</a>.</p>

<p>For those interested, it contains the following shell script:</p>


<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">APPSUPPORT=~/&quot;Library/Application Support/Image Hosting&quot;
TMPDIR='/tmp/image-hosting.tmp'
DEST='me@mywebsite.com:www/mywebsite/twitter-images/'
URLPREFIX='http://mywebsite.com/'
UPLOADRETRIES=3
# GROWL=&quot;/usr/local/bin/growlnotify&quot; # Uncomment this if you have Growl and growlnotify
&nbsp;
[ ! -e &quot;$APPSUPPORT&quot; ] &amp;&amp; mkdir &quot;$APPSUPPORT&quot;
&nbsp;
for f in &quot;$@&quot;
do
  if [ ! -e &quot;$f&quot; ]; then
    osascript -e 'tell application &quot;Finder&quot;' -e 'activate' -e 'display dialog &quot;Input file '&quot;$f&quot;' does not exist&quot; with title &quot;Image Hosting&quot; buttons {&quot;OK&quot;} with icon Stop' -e 'end tell'
    exit
  fi
&nbsp;
  # Generate random name
  while true; do
      name=`perl -e 'use MIME::Base64; $s=encode_base64(rand()); $s =~ s/=|\n//g; $s = substr($s, -5); print $s'`
      if ! grep &quot;$name&quot; &quot;$APPSUPPORT/Taken Names&quot; &amp;&gt;/dev/null; then break; fi;
  done;
&nbsp;
  # Gather info
  default=`php -r '$s = basename(&quot;'&quot;$f&quot;'&quot;); echo ucwords(strtolower(substr($s, 0, strpos($s, &quot;.&quot;))));'`
  title=`osascript -e 'tell application &quot;Finder&quot;' -e 'activate' -e 'text returned of (display dialog &quot;Enter image title&quot; with title &quot;Image Hosting&quot; default answer &quot;'&quot;$default&quot;'&quot; buttons {&quot;Cancel&quot;, &quot;Continue&quot;} default button 2)' -e 'end tell'`
  [ ! &quot;$title&quot; ] &amp;&amp; exit
  defaulttwitter=`cat &quot;$APPSUPPORT/Default Twitter Account&quot; 2&gt;/dev/null`
  twitter=`osascript -e 'tell application &quot;Finder&quot;' -e 'activate' -e 'text returned of (display dialog &quot;Enter Twitter account&quot; with title &quot;Image Hosting&quot; default answer &quot;'&quot;$defaulttwitter&quot;'&quot; buttons {&quot;Cancel&quot;, &quot;Continue&quot;} default button 2)' -e 'end tell'`
  [ ! &quot;$twitter&quot; ] &amp;&amp; exit
  echo $twitter &gt; &quot;$APPSUPPORT/Default Twitter Account&quot;
&nbsp;
  # Create temp files
  [ -e &quot;$TMPDIR&quot; ] &amp;&amp; rm -rf &quot;$TMPDIR&quot;
  mkdir &quot;$TMPDIR&quot;
  cp &quot;$f&quot; &quot;$TMPDIR/$name.jpg&quot;
  echo &quot;$title
$twitter&quot; &gt; &quot;$TMPDIR/$name.meta&quot;
&nbsp;
  [ -f &quot;$GROWL&quot; ] &amp;&amp; $GROWL -n 'Image Hosting' &quot;Image Hosting: `basename &quot;$f&quot;`&quot; -m &quot;Image Hosting is uploading '$name'&quot;
&nbsp;
  # Upload
  retries=0
  while [ $retries -lt $UPLOADRETRIES ]; do
    result=`scp &quot;$TMPDIR&quot;/* &quot;$DEST&quot; 2&gt;&amp;1` &amp;&amp; break;
    [ -f &quot;$GROWL&quot; ] &amp;&amp; $GROWL -n &quot;Image Hosting: `basename &quot;$f&quot;`&quot; 'Image Hosting' -m 'Upload failed: Retrying'
    retries=$((retries+1))
  done
&nbsp;
  if [ $retries -ge $UPLOADRETRIES ]; then
    osascript -e 'tell application &quot;Finder&quot;' -e 'activate' -e 'display dialog &quot;Could not upload image.  Scp said: '&quot;$result&quot;'&quot; with title &quot;Image Hosting&quot; with icon Stop' -e 'end tell'
    exit
  fi
&nbsp;
  echo $name &gt;&gt; &quot;$APPSUPPORT/Taken Names&quot;
&nbsp;
  osascript -e 'tell application &quot;Finder&quot; to set the clipboard to &quot;'&quot;$URLPREFIX$name&quot;'&quot;'
&nbsp;
  [ -f &quot;$GROWL&quot; ] &amp;&amp; $GROWL -n 'Image Hosting' &quot;Image Hosting: `basename &quot;$f&quot;`&quot; -m &quot;Upload complete.  Available at $URLPREFIX/$name (copied to clipboard)&quot;
done</pre></div></div>


<p>To use it:</p>

<ol>
<li>Unzip it, </li>
<li>Put it into <code>Library/Services</code>, </li>
<li>Double-click on it to open it in Automator,</li>
<li>Change the settings at the top of the &#8216;Shell Script&#8217; segment &#8212; 

<ul>
<li>Set <code>DEST</code> to the <code>scp</code> destination</li>
<li>Set up <a href="http://www.google.com/search?q=ssh%20authorized_keys">key-based SSH authentication</a>, so you don&#8217;t have to enter the password to upload, or, if you&#8217;d prefer to use something other than <code>scp</code> to upload the file, you can change the upload command further down in the script, underneath the &#8216;Upload&#8217; comment (look for <code>scp</code>)</li>
<li>Set <code>URLPREFIX</code> to <code>http://yoursite.com</code></li>
<li>If you have Growl and <code>growlnotify</code> installed, then set <code>GROWL</code> to the location of <code>growlnotify</code> (highly recommended)</li>
</ul></li>
<li>Save</li>
</ol>

<h2>Usage</h2>

<p>If you&#8217;re using Leopard, you may need to log out, then log back in to see the service &#8212; I&#8217;m not entirely certain.  If you&#8217;re on Snow Leopard, you should hopefully be set.  Right-click on an image file in Finder, and click &#8216;<em>Send Image to Image Hosting</em>&#8216;.</p>

<p>You should be asked for a title, then asked for a Twitter account name (this will be remembered for next time), then the upload will happen, and when it completes, the URL to the uploaded image will be put onto the clipboard so you can paste straight into Twitter.</p>

<p>Voila.</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1757" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/diy-twitter-image-hosting/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Links for June 3rd through June 18th</title>
		<link>http://atastypixel.com/blog/links-june-3rd-june-18th/</link>
		<comments>http://atastypixel.com/blog/links-june-3rd-june-18th/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 00:00:26 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/?p=1631</guid>
		<description><![CDATA[Links for June 3rd through June 18th: Ten logo design tips from the field &#124; Logo Design Love 10 astonishing CSS hacks and techniques Adaptive CSS-Layouts: New Era In Fluid Layouts? effective techniques to create 100%-functional adaptive CSS-layouts WordPress Theme Development Frameworks If you build and develop WordPress themes often, you will probably be fed [...]]]></description>
			<content:encoded><![CDATA[<p>Links for June 3rd through June 18th:</p>

<ul class="delicious-bookmarks">
<li><a href="http://www.logodesignlove.com/logo-design-tips">Ten logo design tips from the field | Logo Design Love</a> </li>
<li><a href="http://www.catswhocode.com/blog/10-astonishing-css-hacks-and-techniques">10 astonishing CSS hacks and techniques</a> </li>
<li><a href="http://www.smashingmagazine.com/2009/06/09/smart-fixes-for-fluid-layouts/">Adaptive CSS-Layouts: New Era In Fluid Layouts?</a> effective techniques to create 100%-functional adaptive CSS-layouts</li>
<li><a href="http://www.smashingmagazine.com/2009/05/27/wordpress-theme-development-frameworks/">WordPress Theme Development Frameworks</a> If you build and develop WordPress themes often, you will probably be fed up of all the repetitive code writing, the constantly checking of your mark-up and all you really want to do is focus on the design and the project-specific features. The answer is a WordPress development framework</li>
<li><a href="http://steveweller.com/articles/toolbar-icons/">How to Draw Pixel-Perfect iPhone Toolbar Icons</a> Using OmniGraffle</li>

</ul>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1631" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/links-june-3rd-june-18th/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Links for May 21st through June 2nd</title>
		<link>http://atastypixel.com/blog/links-may-21st-june-2nd/</link>
		<comments>http://atastypixel.com/blog/links-may-21st-june-2nd/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 07:01:25 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Lifestyle]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/?p=1613</guid>
		<description><![CDATA[Links for May 21st through June 2nd: 49 Decent Virtual Assistant &#38; Personal Outsourcing Resources PHP: Display Adobe PSD files on a web page &#34;Any webdesigner know the PSD filetype, which is the Adobe Photoshop format. PSDs have a lot of great features, as such as layers, but they can&#8217;t being read by a browser. [...]]]></description>
			<content:encoded><![CDATA[<p>Links for May 21st through June 2nd:</p>

<ul class="delicious-bookmarks">
<li><a href="http://thegrowinglife.com/2008/04/49-decent-virtual-assistant-personal-outsourcing-resources/">49 Decent Virtual Assistant &amp; Personal Outsourcing Resources</a> </li>
<li><a href="http://www.catswhocode.com/blog/php-display-adobe-psd-files-on-a-web-page">PHP: Display Adobe PSD files on a web page</a> &quot;Any webdesigner know the PSD filetype, which is the Adobe Photoshop format. PSDs have a lot of great features, as such as layers, but they can&rsquo;t being read by a browser. Unless you use this great PHP class!&quot;</li>
<li><a href="http://www.iconfinder.net/">Iconfinder &#8211; Icon Search Made Easy</a> </li>
<li><a href="http://www.typetester.org/">Typetester &ndash; Compare fonts for the screen</a> </li>
<li><a href="http://www.kennettnet.co.uk/code/knappguide/">KNAppGuide</a> KNAppGuide is a Cocoa framework for embedding &ldquo;guides&rdquo; into your application, visually inspired by Apple Guide from the System 7 and 8 era</li>

</ul>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1613" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/links-may-21st-june-2nd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Links for March 17th through April 24th</title>
		<link>http://atastypixel.com/blog/links-march-17th-april-24th/</link>
		<comments>http://atastypixel.com/blog/links-march-17th-april-24th/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 00:00:41 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/?p=1514</guid>
		<description><![CDATA[Links for March 17th through April 24th: XSD Schema XML Validator A XSD Schema validator in Java, provides lots of useful information; use it with a schema and an xml instance Three20 Three20 is a collection of iPhone UI classes, like a photo viewer, and general utilities, like an HTTP disk cache. Three20 is derived [...]]]></description>
			<content:encoded><![CDATA[<p>Links for March 17th through April 24th:</p>

<ul class="delicious-bookmarks">
<li><a href="http://www.herongyang.com/XML-Schema/JAXP-XSD-Schema-XML-Validator-Final-Version.html">XSD Schema XML Validator</a> A XSD Schema validator in Java, provides lots of useful information; use it with a schema and an xml instance</li>
<li><a href="http://github.com/joehewitt/three20/tree/master">Three20</a> Three20 is a collection of iPhone UI classes, like a photo viewer, and general utilities, like an HTTP disk cache. Three20 is derived from the Facebook iPhone app, which is one of the most downloaded iPhone apps ever.</li>
<li><a href="http://www.webdesignerwall.com/tutorials/css-decorative-gallery/">CSS Decorative Gallery</a> &#8230;How to decorate your images and photo galleries without editing the source images. The trick is very simple. All you need is an extra &lt;span&gt; tag and apply a background image to create the overlaying effect.</li>
<li><a href="http://en.wikipedia.org/wiki/Comet_(programming)">Comet (programming) &#8211; Wikipedia, the free encyclopedia</a> Comet is a neologism to describe a web application model in which a long-held HTTP request allows a web server to push data to a browser, without the browser explicitly requesting it</li>
<li><a href="http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/">Cocoa Is My Girlfriend &raquo; Cocoa Tutorial: awakeFromNib vs applicationDidFinishLaunching</a> A very good overview of the &#39;startup&#39; procedure for objects stored in IB nib/xibs.</li>

</ul>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1514" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/links-march-17th-april-24th/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Private Tags WordPress Plugin</title>
		<link>http://atastypixel.com/blog/wordpress/plugins/private-tags/</link>
		<comments>http://atastypixel.com/blog/wordpress/plugins/private-tags/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 09:23:17 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/2009/04/10/private-tags-wordpress-plugin/</guid>
		<description><![CDATA[The &#8220;Private Tags&#8221; WordPress plugin allows users to specify a list of tags or categories to keep hidden from the public &#8211; all posts within the specified tags/categories, and the tags/categories themselves, will not be visible to anyone but the original author. Alternatively, in &#8216;inclusive&#8217; mode specify a list of tags/categories to make public &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>The &#8220;Private Tags&#8221; WordPress plugin allows users to specify a list of tags or categories to keep hidden from the public &#8211; all posts within the specified tags/categories, and the tags/categories themselves, will not be visible to anyone but the original author.</p>

<p>Alternatively, in &#8216;inclusive&#8217; mode specify a list of tags/categories to make public &#8211; all other tags/categories will remain hidden.</p>

<p><span id="more-1586"></span></p>

<h2>Download</h2>

<p>Download the Private Tags plugin at the <a href="http://wordpress.org/extend/plugins/private-tags/">WordPress plugin page</a></p>

<p>If you like Private Tags, please consider buying one of my <a href="http://atastypixel.com/products">products</a>.</p>

<h3>Installation</h3>

<ol>
<li>Unzip the package, and upload <code>private-tags</code> to the <code>/wp-content/plugins/</code> directory</li>
<li>Activate the plugin through the &#8216;Plugins&#8217; menu in WordPress</li>
<li>Visit &#8216;Private Tags&#8217; settings underneath WordPress settings to configure</li>
</ol>

<h3>Changes</h3>

<p><em>0.1</em> &#8211; Initial release</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1586" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/wordpress/plugins/private-tags/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Sneak preview of my new web framework Michaelangelo</title>
		<link>http://atastypixel.com/blog/sneak-preview-of-my-new-web-framework-michaelangelo/</link>
		<comments>http://atastypixel.com/blog/sneak-preview-of-my-new-web-framework-michaelangelo/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 14:39:22 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/2009/03/28/sneak-preview-of-my-new-web-framework-michaelangelo/</guid>
		<description><![CDATA[I&#8217;ve been working on a new web framework which provides image theming &#8211; a little like what Elegant Grunge does with its image frames, but much more sophisticated. For example: This is a PHP framework that uses the common GD library to manipulate images. It&#8217;s main interface is a content filter &#8211; give it HTML, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a new web framework which provides image theming &#8211; a little like what <a href="http://atastypixel.com/blog/wordpress/themes/elegant-grunge">Elegant Grunge</a> does with its image frames, but much more sophisticated.</p>

<p>For example:
<img src="http://atastypixel.com/blog/wp-content/uploads/2009/03/boathouse.jpg" width="400" height="206" alt="boathouse.jpg" title="boathouse.jpg" class="aligncenter sticky-tape tape-corners noframe" /></p>

<p><img src="http://atastypixel.com/blog/wp-content/uploads/2009/03/city.jpg" width="400" alt="A dynamic caption" title="A dynamic caption" class="aligncenter polaroid rotation frame-title noframe" /></p>

<p><img src="http://atastypixel.com/blog/wp-content/uploads/2009/03/thailand.jpg" width="171" height="300" alt="thailand.jpg" title="thailand.jpg" class="alignright wood-frame noframe" /></p>

<p>This is a PHP framework that uses the common GD library to manipulate images.</p>

<p>It&#8217;s main interface is a content filter &#8211; give it HTML, containing images, and it will return the same HTML modified so that the images are now the converted versions, according to their &#8216;class&#8217; attributes, with appropriate width/height attributes, etc.  This makes it super easy to work with.</p>

<p>It stands alone, but it is also going to be a WordPress plugin (as you can see on this site, it&#8217;s already operational), a Joomla plugin, and I&#8217;m considering establishing a web service too, so those who don&#8217;t have adequate software on their server can still use it.</p>

<p><img src="http://atastypixel.com/blog/wp-content/uploads/2009/03/img-1773.jpg" width="300" height="200" alt="IMG_1773.jpg" title="IMG_1773.jpg" class="aligncenter wood-frame noframe" /></p>

<p>It has a plugin-based architecture so anyone can add new &#8216;themes&#8217; (<em>props to my partner Katherine for that beautiful wooden frame, by the way</em>).  I&#8217;m going to also implement a simple XML-based plugin schema, and possibly an interface to it, so that it&#8217;s easy to do so.  I&#8217;m planning a &#8216;community&#8217; style directory site to host contributed styles.</p>

<p>The base frame rendering code is such that it is trivially easy to add a new &#8216;theme&#8217;.  It extracts segments from a single frame image, and handles seamless tiling to make the frame the right dimensions, so you don&#8217;t even have to worry about overlapping regions.</p>

<p>I will release it soon, after adding a little more content &#8211; keep your eyes peeled.</p>

<p>For now, check out the <a href="http://atastypixel.com/blog/wp-content/plugins/michaelangelo/Michaelangelo/Sample">Michaelangelo showcase</a>, which gives an idea of the different styles, and contains an interactive sampler to play with styles (<em>IE users should stop being IE users to view this</em>).</p>

<p>Doing my bit to beautify the web.</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1566" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/sneak-preview-of-my-new-web-framework-michaelangelo/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Links for March 6th through March 16th</title>
		<link>http://atastypixel.com/blog/links-march-6th-march-16th/</link>
		<comments>http://atastypixel.com/blog/links-march-6th-march-16th/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 08:00:30 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Travel]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/?p=1488</guid>
		<description><![CDATA[Links for March 6th through March 16th: CSS Code Snippets : 15 Wicked Tricks Some useful CSS tricks; of particular interest: cross-platform min-height, a trick to clear floats (without needing a &#39;clearing&#39; div), and page breaks 45+ New jQuery Techniques For Good User Experience Here are over 45 impressive jQuery plug-ins and techniques that have [...]]]></description>
			<content:encoded><![CDATA[<p>Links for March 6th through March 16th:</p>

<ul class="delicious-bookmarks">
<li><a href="http://devsnippets.com/reviews/css-code-snippets-15-wicked-tricks.html">CSS Code Snippets : 15 Wicked Tricks</a> Some useful CSS tricks; of particular interest: cross-platform min-height, a trick to clear floats (without needing a &#39;clearing&#39; div), and page breaks</li>
<li><a href="http://www.smashingmagazine.com/2009/01/15/45-new-jquery-techniques-for-a-good-user-experience/">45+ New jQuery Techniques For Good User Experience</a> Here are over 45 impressive jQuery plug-ins and techniques that have been recently created and that could make the development of your next website an easier and more interesting experience than the last.</li>
<li><a href="http://digital-sushi.org/entry/how-to-create-a-disk-image-installer-for-apple-mac-os-x/">How to Create a Disk Image Installer for Apple Mac OS X</a> </li>
<li><a href="http://th30z.netsons.org/2009/03/cocoa-sidebar-with-badges-take-2/">Cocoa: Sidebar with Badges, Take 2</a> &#39;Source list&#39;-esque sidebar with support for badges</li>
<li><a href="http://www.soultravelers3.com/">soultravelers3</a> A family of three from Santa Cruz, California on an epic odyssey: open-ended, years long slow trip around the world as a family adventure, unschool, spiritual journey and lifestyle.</li>

</ul>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1488" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/links-march-6th-march-16th/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Links for February 28th through March 3rd</title>
		<link>http://atastypixel.com/blog/links-february-28th-march-3rd/</link>
		<comments>http://atastypixel.com/blog/links-february-28th-march-3rd/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 03:00:23 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/?p=1455</guid>
		<description><![CDATA[Links for February 28th through March 3rd: Lifehacker readers: Most Popular Reliable and Affordable Web Hosts Top seven hosts as voted by readers (DreamHost, Blue Host, NearlyFreeSpeech.NET, 1&#38;1, GoDaddy, HostGator and A Small Orange) Domainr, the domain name search engine Given a name, suggests a variety of different domain name possibilities, and reports on availability [...]]]></description>
			<content:encoded><![CDATA[<p>Links for February 28th through March 3rd:</p>

<ul class="delicious-bookmarks">
<li><a href="http://lifehacker.com/5124856/most-popular-reliable-and-affordable-web-hosts">Lifehacker readers: Most Popular Reliable and Affordable Web Hosts</a> Top seven hosts as voted by readers (DreamHost, Blue Host, NearlyFreeSpeech.NET, 1&amp;1, GoDaddy, HostGator and A Small Orange)</li>
<li><a href="http://domai.nr/">Domainr, the domain name search engine</a> Given a name, suggests a variety of different domain name possibilities, and reports on availability</li>
<li><a href="http://www.schillmania.com/content/projects/even-more-rounded-corners/">Even More Rounded Corners With CSS &#8211; Schillmania.com</a> Single-image, PNG-based, fluid rounded corner dialogs with support for borders, alpha transparency throughout, gradients, patterns and whatever else you (or your designer) could want</li>
<li><a href="http://www.smashingmagazine.com/2009/02/04/50-beautiful-and-user-friendly-navigation-menus/">50 Beautiful And User-Friendly Navigation Menus</a> Navigation inspiration</li>
<li><a href="http://ocrterminal.com/">OCR Terminal</a> OCR Terminal is a free online Optical Character Recognition service that allows you to convert scanned images and PDF&#39;s into editable and text searchable documents. It accurately preserves formatting and layout of documents.</li>

</ul>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1455" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/links-february-28th-march-3rd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Website maintenance with Textmate and FTP/SSH Bundle</title>
		<link>http://atastypixel.com/blog/website-maintenance-with-textmate-and-ftpssh-bundle/</link>
		<comments>http://atastypixel.com/blog/website-maintenance-with-textmate-and-ftpssh-bundle/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 00:54:21 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/2009/01/28/website-maintenance-with-textmate-and-ftpssh-bundle/</guid>
		<description><![CDATA[I tend to work on local copies of my websites, which have either corresponding vhost entries in my local Apache configuration, or are simply symlinked to my ~/Sites folder. That way, I can test to make sure everything&#8217;s 100% before I make changes live. This has typically been a bit of a messy workflow &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>I tend to work on local copies of my websites, which have either corresponding <em>vhost</em> entries in my local Apache configuration, or are simply symlinked to my <em>~/Sites</em> folder.  That way, I can test to make sure everything&#8217;s 100% before I make changes live.</p>

<p>This has typically been a bit of a messy workflow &#8211; I make changes, and then when happy, either open up a terminal and <em>rsync</em> the whole lot over, or open up Flow/Transmit and manually copy the changed files over.  The whole thing makes me disinclined to make changes at all!</p>

<p>That is, until on a whim, I did a google search for a Textmate FTP bundle, and found Bernhard Fürst&#8217;s <a href="http://fuerstnet.de/en/ftpssh-bundle-textmate">FTP/SSH Bundle for Textmate</a>. This little gem lets you configure FTP settings for a project, then hit Option-S to save to the remote server, or Option-R to reload from the remote server.  This way, when I&#8217;m happy with the changes, I just whack Option-S to send them to the server straight from Textmate.</p>

<p>That makes me happy.</p>

<p>One little caveat &#8211; the bundle does an odd thing with the project directory, opting to use the parent folder of the Textmate project file, something which won&#8217;t work for ad hoc projects, when one just drags a folder into Textmate (one of my favourite features).  A quick fix:</p>

<ol>
<li>Find <em>Library/Application Support/TextMate/Bundles/FTP-SSH</em> and open its contents</li>
<li>Open up <em>Support/lib/helper_functions.php</em></li>
<li>Change the <code>$PROJECT_DIR</code> definition on line 15 to:

<p><code>$PROJECT_DIR = $_ENV['TM_PROJECT_DIRECTORY'];</code></p></li>
</ol>

<p>Voila!</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1323" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/website-maintenance-with-textmate-and-ftpssh-bundle/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Elegant Grunge 1.0 released</title>
		<link>http://atastypixel.com/blog/elegant-grunge-10-released/</link>
		<comments>http://atastypixel.com/blog/elegant-grunge-10-released/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 11:12:06 +0000</pubDate>
		<dc:creator>Michael Tyson</dc:creator>
				<category><![CDATA[Geekspeak]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Themes]]></category>

		<guid isPermaLink="false">http://atastypixel.com/blog/2008/12/29/elegant-grunge-10-released/</guid>
		<description><![CDATA[A significant update to my WordPress theme, Elegant Grunge, has been released. New features and fixes include: Configurable sidebars! Choose from no sidebar, a sidebar on the right (the standard layout), or a double sidebar on the right! Support for WP 2.7 paginated and threaded comments Support for a custom header image &#8211; just enter [...]]]></description>
			<content:encoded><![CDATA[<p>A significant update to my WordPress theme, <a href="http://atastypixel.com/blog/wordpress/themes/elegant-grunge/">Elegant Grunge</a>, has been released. New features and fixes include:</p>

<ul>
<li>Configurable sidebars! Choose from no sidebar, a sidebar on the right (the standard layout), or a double sidebar on the right!</li>
<li>Support for WP 2.7 paginated and threaded comments</li>
<li>Support for a custom header image &#8211; just enter a URL to an image, typically a transparent PNG, and it will appear in the header instead of the text (SEO friendly)</li>
<li>Some bug, compatibility and i18n fixes</li>
</ul>

<p>&lt;</p>

<p>p>Note: If you have problems with this theme, please post your question at the <a href="http://wordpress.org/tags/elegant-grunge">WordPress forums</a>.  Please don&#8217;t contact me directly, as I don&#8217;t have the resources to help you.</p>
 <img src="http://atastypixel.com/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1249" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://atastypixel.com/blog/elegant-grunge-10-released/feed/</wfw:commentRss>
		<slash:comments>66</slash:comments>
		</item>
	</channel>
</rss>

