The Mashificator for website owners, authors and developers

Aside from the bookmarklet, which is obviously about people being able to "carry around" the mashificator to whatever site they visit (and which you can customise), there are things that website authors/owners/developers can do, too. This means you can employ it in your website in a couple of different ways, which will give you different options in terms of how it looks and so on.

The options

There's a core PHP script, which is a crude web service you can call over HTTP, but you could also use it directly. The various functions take in some text to analyse and parameters like method (enrich, get collection data, or both), which services to use, and what format to return. Then they spit out what you've asked for, which might be a PHP array, some HTML, or some JSON. You can then call them from other PHP scripts or over HTTP.

Use the PHP directly

You can have the PHP source if you know how to get in touch with me, and then you can call it directly from other PHP scripts. You'll need to add your own API keys, and right now you may not be able to get one for Europeana. It all needs rewriting anyway because my PHP is completely noob, but it's a start!

Here is an example of a page that passes some text straight into an included PHP function.

Embed an iFrame

Calling data and scripts from other websites can cause problems, because web browsers have security in place to avoid "cross-site scripting". A good way to avoid this is just to embed a page from another website straight into your page, using an iFrame. There are currently a couple of (very similar) pages that you can show like this, including the one that the bookmarklet shows and a trimmed-down one for smaller "badge"-style widgets. You pass the page some text to analyse, together with a bunch of other parameters. You can either hard-code the text for analysis right into the page URL, or you can use some javascript to grab a bit of content off the page on-the-fly.

This is an example of an embedded iFrame where the content on the page is picked up by some JavaScript, much as you might do if you put this into your blog template.

Use JavaScript/JSON

You can call the web service to get back some JSON (an array of objects), which you can then use as you like. JSON doesn't have the cross-site scripting problem mentioned above, so you can do some dynamic stuff in your own page using JavaScript, or use some other server-side or client-side language of your choice.

You can also get back a chunk of HTML, but this suffers from the security constraints I mentioned before so you'd have to run the PHP that served it up on your own server. The HTML snippet you'd get is a list (a set of <li> elements).

Display

For display, the carousel display is the main focus of the scripts at present (which is why I output an HTML list). There's a fair amount you can to to configure the carousel if you so wish, whether you're using the bookmarklet or the iFrame. If you want to use this carousel for your own experiments, the script comes from http://gmarwaha.com/jquery/jcarousellite/. It depends upon jQuery (you'll need those JS files too).

Powered by Digital New Zealand Powered by Zemanta Powered by Europeana

The Cultural Enrichment Mashificator: an experiment that got out of hand. Gorge yourself on the caveats.

Gimme feedback