On 1/19/07, dlcohen1 <[EMAIL PROTECTED]> wrote:
> 1/18/07
>
> Is there any way to possibly get this or a future version to work
> with an EditGrid spreadsheet? (www.editgrid.com)  Thank you.

Now it is, at least if you point to the subversion Exhibit and turn
off bundles. (The latter might not be neccessary in a few days or so,
and I guess the static code tree might get updated soon too.)

On 1/24/07, Johan Sundström <[EMAIL PROTECTED]> wrote:
> On 1/24/07, Philip Cooper <[EMAIL PROTECTED]> wrote:
> > Has anyone looked at
> >
> > http://www.EditGrid.com
>
> Nobody has yet presented a way of getting it to expose JSONP data
> access, which Exhibit needs, being a 100% client side application.
>
> > Even better, you can upload an xsl file and define the extension
> > associated with the xslt transformed file (rdf/xml or perhaps JSON
> > anyone?).
>
> This sounds potentially workable, if a bit roundabout. Can we upload
> an xslt template of our own to reformat a spreadsheet however we want?
> That would make Exhibit integration *possible*, in a slightly
> perverted sort of way. :-)

I took a peek at this myself today, and whipped up a least-effort XSL
template for transforming editgrid spreadsheets to an Exhibit JSONP
input so you can hotplug the two without having to download and host
any files yourself.

Usage:
* Under the editgrid My Data Formats tab (menu Data -> My Data Formats...),
  click the "Create New Data Format »" link on top.
* Fill in extension jsonp and Content Type text/javascript,
description perhaps "Exhibit JSONP".
* Pick All my spreadsheets if you do not want to repeat this procedure
for other spreadsheets.
* Load this xsl template in a separate browser window:
     http://ecmanaut.googlepages.com/exhibit-editgrid-to-jsonp-xslt.txt
* Paste its contents into the XML Stylesheet text area.
* Click Save.

This template excavates the first row of cells as property names. Be
sure to have at least one cell named "label". Just as with the Google
Spreadsheets integration, following rows list one item per line. For
now, it uses the same header formats as Google Spreadsheets if you run
with the code below, but with a useful twist:

* The name of the work sheet is used as the type of each item in the sheet.
* All work sheets of a document get loaded at the same time (and in a
single http request).

Set up your exhibit like this if you want to try it, and point your
Exhibit to the subversion code, bundles off.

window.exhibit = Exhibit.create();
exhibit.loadJSONP( 'the permalink of the jsonp page, as seen in the My
Data Formats... view',
   editgidConverter );

editgridConverter = function(json) {
    var items = [];
    var properties = {};
    var types = {};
    var valueTypes = { "text":true, "number":true, "item":true,
"url":true, "boolean":true };

    var entries = json.items, entry;
    for (var i = 0; entry = entries[i]; i++) {
        var item = { type:entry.type };
        delete entry.type;
        for (var prop in entry) {
            var openBrace = prop.indexOf("{");
            var closeBrace = prop.indexOf("}", openBrace+1);
            if (closeBrace < 0) {
                break;
            }

            var fieldSpec = prop.substring(openBrace+1,
closeBrace).trim().split(":");
            var fieldValues = entry[prop].trim();

            var fieldName = fieldSpec[0].trim();
            var property = properties[fieldName];
            if (!(property)) {
                var fieldDetails = fieldSpec.length > 1 ?
                    fieldSpec[1].split(",") : [];
                property = {};

                for (var d = 0; d < fieldDetails.length; d++) {
                    var detail = fieldDetails[d].trim();
                    var property = { single: false };
                    if (detail in valueTypes) {
                        property.valueType = detail;
                    } else if (detail == "single") {
                        property.single = true;
                    }
                }

                properties[fieldName] = property;
            }

            if (!property.single) {
                fieldValues = fieldValues.split(";");
                for (var v = 0; v < fieldValues.length; v++) {
                    fieldValues[v] = fieldValues[v].trim();
                }
            }
            item[fieldName] = fieldValues;
        }
        items.push(item);
    }
    return { types:types, properties:properties, items:items };
};


I'm reluctant to commit the above to subversion right away, as I'd
prefer to try to convince the editgrid people to add full JSONP
support first, so we don't randomly clobber things or end up in messy
race condition / mixup situations. But it's something to play with.

I tossed up an example (some grades from long ago) that seems to bug
out on some issue I haven't yet figured out, but which works apart
from the facets, which uses three different types and sheets to render
itself:

  http://ecmanaut.googlepages.com/highschool-courses.html

Happy hacking!

-- 
 / Johan Sundström, http://ecmanaut.blogspot.com/

_______________________________________________
General mailing list
[email protected]
http://simile.mit.edu/mailman/listinfo/general

Reply via email to