Transquotation with Javascript

Xanadu Logo

Ted Nelson’s Xanadu project has a vision for hypertext where you can quote a document without copying it. The goal is to have something like a pointer to the the selected portion of the original.

I was reading some of Ted’s archives and noticed his use of an  open source eprints publishing software. By counting the number of characters a selection is offset from the start of the document, Eprints allows people to construct links to specific selections. Linked selections can then be shown in context or excerpted in raw text.

Seeing how easily sections could be quoted got me excited about performing similar quotations on my website, but I soon realized that it would be more difficult than using simple html links.

The Quoting Architecture: Start with Quoting Proxies

All I want to do is a “remote include“, but html and javascript don’t allow me to do this directly, so I constructed an intermediary script that acts as a proxy.

The author performing the quotation instructs the reader’s browser to ask the proxy to serve it a remote web page:

<script LANGUAGE="JavaScript1.2" TYPE='text/javascript'

The proxy script connects to the remote web site on behalf of the reader:

  //open a connection with a timeout of 30 seconds
    $fp = fsockopen($host, $port, $errno, $errstr, 30);        
    fwrite($fp, $out);
    $body = false;
    while (!feof($fp)) {
        $s = fgets($fp, 1024);
        if ( $body )
            $in .= $s;
        if ( $s == "\r\n")
            $body = true;
    (Full Source)

It retrieves the contents of the page and outputs it back to the reader in Javascript output format.

   document.write("The usual story about Xerox PARC,
    that they were trying to make the computer
    understandable to the average man, was a crock.
    They imitated paper and familiar office machines
    because that was what the Xerox executives
    could understand. Xerox was a paper-walloping company,
    and all other concepts had to be ironed onto paper,
    like toner, to be even visible in their paper paradigm.");


This javascript output method is the same technique
Google uses to deliver its advertisements.

Architecture: Putting the Quotation Logic in the Proxy

It is only because Ted’s eprint server allows offsetted quoting that I
am so easily able to fetch an excerpt.

For other sites, it may make sense to implement the eprints functionality
at the proxy level. This would allow selections to be specified and a greater context shown — all without requiring the quotee to implement any addition server-side features.

For performance and realiabilty reasons, it may make sense for the proxy to cache a copy of the quotation. For compatiblity, it would be nice if all quotations used a standard syntax to specify a quotation. That way the functionality could be added to the browser and quotation meta could be aggregated by search engines.

A Final Note on Security: Open Proxies

If this were to become common, operators of proxies would probably need to only allow registered quotations, otherwise they would be overwhelmed by requests.