Showing posts with label shindig. Show all posts
Showing posts with label shindig. Show all posts

Monday, November 08, 2010

How to run/debug Shindig in Eclipse

Instructions here (http://shindig.apache.org/developers/java/build.html#Setting_up_an_Eclipse_project_to_build_Apache_Shindig) are for old versions of Eclipse.

I am using Eclipse Helios. You should install Maven plugin m2eclipse before following following instructions.

  1. Download or check out shindig code.
  2. File –> Import
    Maven –> Existing Maven Projects
    Specify the root directory of shindig code.
  3. Right click top level imported project (*-project):  Debug As –> Debug Configuration
    Create a new configuration for “Maven Build”.
    Base directory: root directory of shindig code
    Profiles: run
    Unselect “Skip Tests”.
    If you want to use a port number rather than 8080, add a parameter “jetty.port”.
    Clicek “Debug”.
  4. Jetty server should run successfully. Look at your console for possible error messages.

Add breakpoints, then send a request to Jetty server. Eclipse complains that it cannot find source code for the debugged app, and prompt you to add source lookup directories.

Wednesday, September 15, 2010

OAuth in OGCE gadget container

OGCE gadget container makes support of OAuth as easy as possible.

Follow two files are the most important related to OAuth configuration.

  1. config/shindig/shindig.properties
    Most important config parameter is shindig.signing.global-callback-url. It has been rewritten correctly so the end users don’t need to worry about it.
  2. config/shindig/oauth.json
    This files contains information of all consumers of which the OGCE gadget container is a proxy.

If you want to write OAuth gadget, follow instructions showed on this page: http://code.google.com/apis/gadgets/docs/oauth.html.
More complicated cases: http://sites.google.com/site/oauthgoog/oauth-proxy/social-oauthproxy

Thursday, November 05, 2009

A bug in Shindig code (for revision 832845)

Recently, I tried to deploy cyberaide filetransfer gadget (http://lily01.rit.edu/cyberaideFiletransfer.xml) and jobman gadget (http://lily01.rit.edu/cyberaideJobman.xml). They did NOT work in shindig server built from revision 832845. Those two gadgets use ‘tab’ feature which is not implemented well in shindig code.

Problem description
See source code of tab feature at http://svn.apache.org/repos/asf/incubator/shindig/trunk/features/src/main/javascript/features/tabs/tabs.js?p=832845.
In this file, function ‘html_sanitize’ is used. It is a function from caja javascript library.
Shindig website does not provide much useful information about integration of caja. http://incubator.apache.org/shindig/developers/java/build.html#Running_with_Caja
I found a useful wiki page in caja project: http://code.google.com/p/google-caja/wiki/GettingStarted.
Basically the user needs to add following text to ModulePrefs element of the gadget xml file
    <Require feature="caja"/>
After I changed the gadget xml file, it still didn’t work. It seems that after caja library sanitizes the rendered html/javascript code, some useful code is removed.

My solution
To make it simple, I disabled caja. I just removed invocations of functions belonging to caja library. Concretely, I removed invocations of function ‘html_sanitize’ in file ‘tab.js

Also, feature ‘minimessage’ also uses caja functions to sanitize html/javascript. If your gadgets use that feature, corresponding changes must be made as well.

Monday, November 02, 2009

Enable and disable Shindig caching

Shindig implements a complex caching hierarchy including referred external resources, locale messages, gadget specification files, etc.
During development phase, the developers want to disable caching to make modifications take effect immediately.

  • Build-Time Solution
    It is according to this post https://studio.atlassian.com/browse/AG-145.
    Download source code tree and build the war file using command “mvn –Pdebug package
  • Run-time solution
    HttpCache: caches http request sent out from shindig server. During gadget rendering, this is controlled by “nocache” parameter. So when you render a gadget, add parameter ‘nocache’ with value 1.
    I don’t know how to do it at server side.

Friday, August 28, 2009

Dynamic-height in Shindig

Gadget specification provides a feature called dynamic-height to dynamically adjust height of a gadget.
If gadget server and gadget container are in the same domain, this can be done using javascript.
However, if gadget server and gadget container are in different domains, this can not be achieved by directly using Javascript and DOM because of same-origin policy imposed by modern browsers.
This email http://markmail.org/message/53r5dwhr56lby733#query:dynamic%20height%20shindig+page:1+mid:53r5dwhr56lby733+state:results includes some information about how to make it work.
I am going to give more details here.

Gadget container

  1. Download
        http://svn.apache.org/repos/asf/incubator/shindig/trunk/javascript/container/cookies.js
        http://svn.apache.org/repos/asf/incubator/shindig/trunk/javascript/container/gadgets.js
        http://svn.apache.org/repos/asf/incubator/shindig/trunk/javascript/container/util.js
        http://your_shindig_deploy/gadgets/js/rpc.js?c=1&debug=1 (//this file actually includes rpc framework and all possible communication mechanism, e.g. ifpc, wpm...)
    And put them into your gadget container server.
  2. Include following code in your container web page to make them point to those javascript files you downloaded in step 1).
    <script type="text/javascript" src="rpc.js"></script>
    <script type="text/javascript" src="cookies.js"></script>
    <script type="text/javascript" src="util.js"></script>
    <script type="text/javascript" src="gadgets.js"></script>
  3. Download
        rpc_relay.html : http://svn.apache.org/repos/asf/incubator/shindig/trunk/javascript/container/rpc_relay.html
    or
        rpc_relay_uncompressed.html: http://svn.apache.org/repos/asf/incubator/shindig/trunk/javascript/container/rpc_relay.uncompressed.html

Gadget server/renderer

  1. Check out Shindig source code. See http://incubator.apache.org/shindig/source-repository.html
  2. Change source code of file ifpc.transport.js
    Original:
    // The RPC mechanism supports two formats for IFPC (legacy and current). var src = null; if (rpc.l) {
    New
    // The RPC mechanism supports two formats for IFPC (legacy and current).
    var src = null;
    if (false) {
    This disables use of legacy data format which is buggy.
  3. Change configuration in file config/container.js
        Original: "parentRelayUrl" : "/gadgets/files/container/rpc_relay.html"
        New:       "parentRelayUrl" : "rpc_relay file address on your gadget container" //it is download in this step
    Also you may want to use ifpc instead of browser-specific communication mechanisms.
        Original: "useLegacyProtocol" : false    //gadget tries browser-specific communication mechanisms first. If they fail, fall back to ifpc.
        New:      "useLegacyProtocol" : true           //use ifpc directly.
    Note: the current wire format will be used instead of legacy format because we have disabled legacy format.
    This option is not used in the way described by comment in the source code. The shindig developers want users to use this option to control whether legacy format is used. I use it to configure whether ifpc is used. If ifpc is used, only current wire format is utilized.
    This can also be set after you deploy shindig. The configuration file is located at WEB-INF/classes/containers/default/.
  4. Rebuild shindig.
  5. Copy generated .war file in directory server/target to your servlet container.

Resources

Detailed discussion: http://docs.google.com/View?id=dmxthpg_125ckh55fff
Cross-Domain Communication with IFrames: http://softwareas.com/cross-domain-communication-with-iframes

Saturday, February 07, 2009

Shindig server on Tomcat

Shindig can be run with built-in jetty server without problems. But after I deployed the war to Tomcat, there are some problems. I got a blank page when I tried to render a gadget. I searched for the problem, some other guys got this problem as well.

Other posts related to this problem:
http://mail-archives.apache.org/mod_mbox/incubator-shindig-dev/200805.mbox/%3C483C780B.6080802@oracle.com%3E

Finally I figured out how to make shindig work on Tomcat.
Why does not it work?
It ignores the context path. In other words, the implementation only considers the situation that the application is deployed as root application.

Two possible Solutions
(1) make shindig war the root application
Two alternative ways:
    (*) rename it to ROOT.war and deploy it to tomcat. (The original ROOT application cannot be used)
    (*) change conf/context.xml to set shindig application as root application
(2) Modify shindig configuration files <shindig>/java/common/conf/shindig.properties and <shindig>/config/container.js to add context path in all related urls.
It seems to work well. I am not sure whether there is any potential problem.