I've built a quite showoffy JavaScript library that uses the Piwigo API to fetch photo streams, allowing you to build completely custom gallery views using only client-side code (HTML/JS templates). This allows for complete separation between front-end designer and back-end coder, or designer and Piwigo.com operator, etc. Specifically, this was built to allow a client to use Piwigo.com (the hosted service) for its great Control Panel and support + and an outside developer to write the actual pages, while we don't even have to have PHP on our servers => no worries.
The catch: because of cross-domain restrictions, the only reason this works is that we happen to run a reverse proxy server (from doing a lot of similar work in the past) so we can redirect example.com/piwigo to example.piwigo.com. Works fine. But adds an additional level of indirection -- and network traffic and possible support concerns -- that makes the solution "almost there."
I'm ready to open-source the library (based on MooTools) and I think many would find it attractive, but I don't want to say "simply requires a reverse proxy or mod_proxy." :P
Instead, if the Piwigo API supported JSONP (obviously for the get* API calls only) we'd be good to go without the proxy. Note I am not expect Piwigo to support CORS for this -- that would require you to adapt to XDR plaintext requests anyway, so it's probably as much if not more work. But rather supporting JSON w/the callback wrapper would be... freakin' awesome! I'd partially sponsor this work (a high two-figure donation, let's say) as it would make the rollout of even this one project better, let alone all the subsequent projects we and others could build.
Offline
Hi swhiteman,
Can you give an "real life" example of what you're expecting?
Offline
Sure. I get a response like this from method=json&pwg.categories.getImages:
{ "stat": "ok", "result": { "images": { "page": 0, "per_page": 100, "count": 1, "_content": [ { "id": 330, "width": 1600, "height": 1200, "hit": 0, "file": "featuredpuppies.jpg", "name": "featuredpuppies", "comment": null, "date_creation": null, "date_available": "2013-03-14 17:12:21", "page_url": "http:\/\/carolkbrown.piwigo.com\/picture?\/330", "element_url": "http:\/\/carolkbrown.piwigo.com\/uploads\/5\/d\/t\/5dtz9u6g22\/\/2013\/03\/14\/20130314171221-3523231b.jpg", "derivatives": { "square": { "url": "http:\/\/carolkbrown.piwigo.com\/i?\/uploads\/5\/d\/t\/5dtz9u6g22\/\/2013\/03\/14\/20130314171221-3523231b-sq.jpg", "width": 10, "height": 10 }... }
I want to call method=jsonp&callback=myCallbackFunction&pwg.categories.getImages and get:
myCallbackFunction ({ "stat": "ok", "result": { "images": { "page": 0, "per_page": 100, "count": 1, "_content": [ { "id": 330, "width": 1600, "height": 1200, "hit": 0, "file": "featuredpuppies.jpg", "name": "featuredpuppies", "comment": null, "date_creation": null, "date_available": "2013-03-14 17:12:21", "page_url": "http:\/\/carolkbrown.piwigo.com\/picture?\/330", "element_url": "http:\/\/carolkbrown.piwigo.com\/uploads\/5\/d\/t\/5dtz9u6g22\/\/2013\/03\/14\/20130314171221-3523231b.jpg", "derivatives": { "square": { "url": "http:\/\/carolkbrown.piwigo.com\/i?\/uploads\/5\/d\/t\/5dtz9u6g22\/\/2013\/03\/14\/20130314171221-3523231b-sq.jpg", "width": 10, "height": 10 }... });
Make sense?
Offline
In case it cannot be done in piwigo core, I think it can be done through a plugin to encapsulate json response in a json response with a callback.
Offline
Possibly so. But hooking into the Web API seems like a significant learning curve (I don't know if all this is allowed on Piwigo.com, even) compared to building into core with another "method" option -- and JSONP is basically an industry standard so it's not a really niche need. I'm confident it will be used widely if built.
Offline