This is my personal blog. The views expressed on these pages are mine alone and not those of my employer.

Friday, December 28, 2007

New Purple Include Release

I've put up a new release of Purple Include, iteration 3. Purple Include is a client-side JavaScript library that allows you to do client-side transclusions.

What the heck does that mean?

It means that you can include and display fragments of one HTML page in another without copying and pasting any content.

To use Purple Include, just add the following SCRIPT tag to the following of your HTML page:

<script src="http://codinginparadise.org/projects/purple-include/purple-include.js"></script>

The big new feature of this release is a new addressing scheme that is much easier to use, named 'quote'. Here's an example:

<div href="http://docs.google.com/View?docid=dhkhksk4_8gdp9gr&pli=1#quote(In the background Dojo Offline is checking...when they are on- or off-line so you don't have to)"></div>

Notice the 'href' attribute; this will cause Purple Include to fetch the given page and inline it into that DIV (you can add the href attribute to DIVs, SPANs, BLOCKQUOTEs, Ps, and more). Also notice the #quote() at the end. This is the new addressing scheme in this release; you can now quote and grab a range of any remote page by just having a few words from the page, followed by three dots, followed by the end of the text to grab. In the example above we have:

#quote(In the background Dojo Offline is checking...when they are on- or off-line so you don't have to)

This goes to the Dojo Offline tutorial, starts grabbing HTML and text from the beginning of 'In the background Dojo Offline is checking' and continues doing so until it encounters 'when they are on- or off-line so you don't have to'. Purple Include has proper HTML range support, which means that nested tags are correctly setup when they are returned and inlined into your page.

Here is the example actually running; after a few seconds you should see the content in-line (if you are reading this in an RSS feed click here to see the example):



The older XPath addressing scheme is still there for advanced usage; the quote syntax is just much simpler and has true range support. Details on the XPath scheme here.

The other big change in this release is that I have refactored the server-side addressing system to be truly generic, so that it is much easier to drop in new addressing schemes. For example, we could create a line() scheme to grab ranges of lines from source code files.

Please note that this software is still in development. In particular, the quote() scheme needs to be tested more, and I haven't done performance work on large documents yet. I wanted to 'release early release often' on this before getting it perfect.

You don't need to host anything to use this. If you want to run your own server, however, here is the ZIP file for you to download. In your HTML you will need to point Purple Include at your custom server using a META tag. See tests/example.html for details on how to do this at the top. The client-side is BSD licensed, the server-side is GPL.

Labels: , , , , , ,


Comments:
Could the source page markup be better expressed using standard (x)HTML?

HTML has long supported citations through the q and blockquote elements. The cite attribute easily translates to the remote URI source you would like to include, and the title attribute is a good spot to define your quoted text delimiters.

My modification or best practice: define the remote citation using standard (x)HTML markup and enhance that citation with JavaScript for clients capable of render. This means filling in the text of blockquote and q for archival snapshot inclusion (Google, Internet Archive, and feed readers see it), and enhancing with live citations for capable clients.
 
@niall: Interesting idea. To be honest, I'm not really a big fan of the whole XHTML thing (I don't believe XHTML compliance should be optimized over experimentation and innovation), but if it is possible to reuse then that is a good thing. Can you post an example of what it might look like? I'm still a bit unclear from your text.
 
I created a few test cases for blockquote and q in current use, blockquote with an existing quotation replaced by remote include, and the existing method of just the blockquote element.

Purple Include does not currently replace the existing quotation with the live quotation. It hangs on a blockquote with child elements.
 
Mr N, thanks for the pointer. I'm currently up to my eyebrows in c++ application programming (and loving it!). But I seem to have a genetically-driven compulsion to hoard, packrat and catalog "stuff." Thus my interest in information management!
 
I've downloaded the zip file, but can't find the proxy php anywhere?
 
Post a Comment

Subscribe to Post Comments [Atom]



Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]