It's been quite some time since I wrote about purple numbers -- fragment identifiers for bits of text within HTML documents. Or, Granular Addressability in HTML documents as E.E. Kim describes in 'An Introduction to Purple'.
Back then, I wasn't a fan of these anchor links, as anchor links aren't first class web citizens -- where links are currency. I'm still not a fan, but maybe the anchor links are just there to make it easy to grab pieces of this content.
A recent reference by Les Orchard (oh, look, OPML anchor tags!) to purple-include, which enables transclusion (aka including content from elsewhere, directly inline, rather than copy/paste) got the brain cells tickling tonight. So I built a Purple module for Drupal. Which, in reality, just includes the purple-include.js and a little bit of CSS to make purple links show up. I am trying to include some of Simon Willison's plinks cleverness, but not sure if I'm going to get that working.
Transclusion feels very SemWebby. No, I'm not going to use the dreaded Web 3.0-label (but do go read the Business 2.0 article if you want a backgrounder (via Nova Spivack, of course). Ahem. Back to the point.
From Facebook apps to photos stored on Flickr, we want to have all our "stuff" just magically collected together wherever we happen to be, whatever network we happen to be interacting with. Aggregation, sucking this content in, pushing it over there -- all just temporary ways of flowing content around. One that arguably duplicates content and spews extraneous permalinks around. I just want my pictures right here, or I just want to link deep into someone else's posting and pull in a piece of text. And I want the "other end" to know about that inclusion, a gentle ping, yeah, kind of a trackback. That's the Semantic Web to me: where every plain old HTML file is dynamic and intelligent and knows about the links and people that are incoming and outgoing.
OK, now to Purple. Here's an example that includes a file I have on my server, shamelessly copied from the purple-include examples page. First the code:
<hx:include src="/sites/bmannconsulting.com/files/purple_include.html#xpath!//p"></hx:include>
And now the transcluded bit:
Update: Kevin reports that the transclusion doesn't work in Safari. Stupid client side technologies :P
Note: I don't *actually* know XPath. But if you open the file directly, you'll see it just grabbed the paragraph. I'm assured you can do more complicated things than that :P
To Do: #
- Find out where purple-proxy is hiding / what to do with it so I can transclude from elsewhere
- autogenerate plinks / pilcrows / numbers, perhaps via a Drupal filter
- make a real module available somewhere, maybe also tracking down jluster's old purple numbers code
Here's pretty much the entire "meat" of the module, which does nothing but include some JavaScript and CSS:
function purple_footer() { $path = drupal_get_path('module', 'purple'); drupal_add_css($path .'/purple.css', 'module', 'screen'); drupal_add_js($path . '/purple-include.js','module'); }
That was fun, and somewhat therapeutic. It's only going to get really interesting when I grab the proxy code. Oh, and of course, I'm typing in bare HTML here and turning off the WYSIWYG which eats funky hx-namespaced code for breakfast.
Oh yes, and to the various folks I've bumped into that tell me "Sometimes I have no idea what you're talking about"...well, sorry, this is probably one of those posts :P