Journal embedding through JSON

May 09, 2008 16:36


Title
Journal embedding through JSON

Short, concise description of the idea
Allow access to the content of your LiveJournal through JSON, so people can embed it in their web sites through JavaScript.

Full description of the idea
JSON is a lightweight means for passing data through JavaScript. Making LiveJournal posts available through JSON would ( Read more... )

entry viewing, friends, markup, external services, security, javascript, § no status

Leave a comment

Comments 5

slothman June 19 2008, 18:45:39 UTC
A while after I submitted this, it occurred to me that this could be done through the S2 system. This works in XHTML:

LiveJournal posts

You must enable JavaScript to see inlined content.

(Using an extra close tag to make sure that HTML parsers can cope with it.)

This manipulates a page in DOM:

Reply

Awesome! Now the nitpicks... petter_haggholm August 28 2008, 04:47:46 UTC

I've been looking for a solution like this for quite some time; none of the embedding options suit me very well. My few comments:

  1. Your tutorial should probably read document.createElement for createElement, and something like foo.innerHTML += bar for appendText(foo, bar).

  2. When I embed your example, my site complains about an undefined entity for the post.subject. This could be an artefact of the non-ASCII entity in one of your posts, perhaps (There’s just no substitute for fiscal discipline), but: For whatever obscure reason, my browser (FF3) pukes.

  3. How can I get this for myself‽ It's a wonderful idea, but I don't really want to embed your LJ in my website (no offence intended). Your S2 layer link takes me only to a helpful error page informing me that I'm not authorised to view this layer.


Minor wrinkles sorted out, this really ought to be posted in the embedding FAQ.

Reply

Re: Awesome! Now the nitpicks... slothman August 28 2008, 05:23:26 UTC
Whoops! Forgot the code for createElement. Since IE doesn’t like XHTML, I have to hotwire the web server to serve it up as HTML, and compensate like this:

var createElement = function(x) {
if (navigator.userAgent.search("MSIE") >= 0) {
return document.createElement(x);
} else {
return document.createElementNS('http://www.w3.org/1999/xhtml', x);
}
};

You can see the whole thing in operation at my soon-to-be-home-page once I finish a few items.

Is there some subtlety to making a layer like that public for others’ use? Meanwhile, here’s the source code to it:

layerinfo "type" = "layout ( ... )

Reply

petter_haggholm August 28 2008, 05:53:25 UTC
I've no idea how to do anything much with S2 layers-I find the whole thing to be irritatingly confusing. (…Which embarrasses me, but also puzzles me a bit: If I can write bash scripts and hack the Python interpreter whilst tearing out only small amounts of hair, how can this get to me?) As such, I'm afraid I've no clue how to make such layers public.

However, this is frankly even better. With that source I managed to hack up a JSON source that I can use and embed in my homepage, and customise for my own nefarious purposes. Thank you!

Reply


Leave a comment

Up