From MWWiki
Back to GSoC 2008
> First: can you explain what exactly the functional differences of
> the common/, gadgets/, socialdata/, and socialrest/ folders are
> within the PHP src/ folder of shindig? I understand that
> socialrest/ has to do with implementing the RESTful API; socialdata/
> has to do with retrieving and modifying social network information;
> gadgets/ involves handling those XML gadget URLs; common/, I'm
> assuming, is just a library of common functions that the other three
> libraries make use of.
The basic idea is that we have 2 main components in shindig, one is
the gadget rendering server (gadgets/), and the other is the social
api (which is in the /social-api directory now).
Anything that is used by both of those components, is located in the
common directory.
We used to have 2 wire formats for the social api, one was the 'old
0.7 wire format', which was located in the socialdata folder, and we
had a 0.8 new style, RESTful interface, which was the socialrest
folder .. it took a bit of time to make the new interface stable &
production ready on both the java and php side, so that's why for a
little while we actually had 2 wire formats in svn, and there was an
option 'useRest' in shindig/config/container.js, which allowed you to
(false) use the old wireformat or (true) use the new RESTful interface.
Now we switched completely to the new REST interface, and the old one
went away, and all the social api logic is located in the social-api
folder, a lot less confusing in the end :P
> The reason I ask leads to my second question: the three Partuza
> handlers - ActivitiesService, AppDataService, and PeopleService -
> all extend abstract superclasses with those methods spotted out;
> however, there are two different versions of these classes. One
> version in the socialdata/opensocial/ folder, and the other in the
> socialrest/opensocial/ folder. The Partuza installation
> instructions state that the Partuza handlers should be put in the
> socialdata/ folder, but upon inspection they actually extend the
> classes from the socialrest/ folder. How does this work? Does it
> matter which version of the classes I extend for use in, say, Joomla?
Yep that was the confusing thing of having 2 wire formats in shindig,
which one to pick? :P With our complete switch to the RESTful
interface only the {Activities,AppDataPeople}Service.php classes are
left, and their the ones you want to use to implement your Joomla data
interfaces.
The partuza instructions ... yea i need to update the guide still tbh :)
Oh and one nice new feature that will make integration a lot easier,
the config system has been changed a bit, and you can put a
'local.php' file in the shindig/php/config directory now with your
local settings (the keys set in there override the default ones),
which makes it easier to keep up with svn/etc, and not have conflicts.
Then there's the new configuration option ('extension_class_paths')
to add a path to scan in the __autoinclude function in which your data
service classes are located, so you no longer have to copy or link
classes into the shindig tree.. a lot cleaner really :)
For instance my local.php config has:
<?php
$shindigConfig = array(
'gadget_css' => 'body,td,div,span,p{font-family:arial,sans-
serif;} body {background-color:#ffffff; font-family: arial, sans-
serif; padding: 0px; margin: 0px; font-size: 12px; color: #000000;}a,
a:visited {color: #3366CC;text-decoration: none; }a:hover {color:
#3366CC; text-decoration: underline;} input, select { border: 1px
solid #bdc7d8;font-size: 11px;padding: 3px;}',
'people_service' => 'PartuzaPeopleService',
'activity_service' => 'PartuzaActivitiesService',
'app_data_service' => 'PartuzaAppDataService',
'extension_class_paths' => '/Users/chabotc/googleprojects/
partuza/Shindig',
'focedJsLibs' => 'opensocial-0.7:dynamic-height:setprefs'
);
So i override the gadget CSS to a more partuza style one, define which
service classes to use, add my local partuza/Shindig folder to the
class path, and force a default set of javascript libraries to be
external. The external libs btw is a nice feature to put that
javascript in one external js file, that is very cachable by the
browser, which saves a ton for the document size of the gadget.
You'd probably also would want to add the default / generated
'token_cipher_key' and 'token_hmac_key' to the local config, and
figure out a way to maybe generate these automatically or prompt the
user to choose some passwords for those? If you'd use the default key
then malicious gadgets could create their own fake security tokens,
and pretend to be someone else for instance (the token contains all
the owner / viewer / app etc information), so for a complete and
secure setup you'd need to have a unique password too :)
> And perhaps the crux of everything: off the top of your head, in
> order to have Shindig play nicely with Joomla, is implementing
> extensions of those three classes really all that's required to have
> some external entity utilize Shindig as a blackbox opensocial
> implementation?
Yep, as far as the data hookup goes, thats it! (that and the stuff
outlined above about security tokens and class paths)
However next to the data service you'd also want to use the meta-data
service for a number of things:
1) retrieve user visible gadget information to use in the gadget
gallery (author, title, screenshot)
2) retrieve which user preferences this gadget has, and create an
interface for setting these (the standard igoogle horoscope gadget has
a setting 'sign' for instance)
3) Retrieve the preferred height (& width if you support that) of the
gadget so you can add a style="height: {$height}px" in the gadget
iframe, saves the browser having to re-render the page once the gadget
is loaded.
Also you'd want to take a good look at how partuza creates the gadget
iframe's, all the stuff the gadget needs to know is communicated
through that .. languages, country, the current view, the security
token, user preferences (&up_{foo}=bar) etc. It's not so hard to make
with a good example, but quite crucial to having a working setup :)
See:
http://code.google.com/p/partuza/source/browse/trunk/Application/Views/gadget/gadget.php
> Thank you very very very much!
Hope that helped and made sense and if not please don't hesitate to
make me aware of this fact! :) Typing while nurturing the first cup of
coffee of the day sometimes makes for some crooked sentences :)
-- Chris