Changeset 38817 for main


Ignore:
Timestamp:
2024-03-03T20:31:57+13:00 (2 months ago)
Author:
anupama
Message:

I can't find a better way (the webswing way) to customise the applet parameters collection and library, no matter what I try. So I have made use of the fact that the docBaseURL of the applet that is available to the applet code contains both these pieces of information. Whether this will always be true when not using the default Greenstone DL URL structure, I'm not too sure. But for now, it is better than my previous commits where I hardcoded the library and, still worse, the collection name into the webswing config file to get the applet to show up with webswing. Better to leave the code in this improved state and maybe Kathy or Dr Bainbridge will know how it should actually be solved when configuring webswing options at JavaScript level (which had worked for GLI which didn't use appletParams but args/customArgs).

Location:
main/trunk/greenstone3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/applet/phind/JPhind.java

    r38813 r38817  
    732732    // What is this collection called?
    733733    collection = parameterValue("collection");
     734
     735    String docBase = getDocumentBase().toString();
     736    int index = -1;
     737    // Fallback for webswing, as customising applet param "collection" didn't work
     738    // and the ideally-customisable collection and library applet params remain null
     739    // This assumes webswing running the applet has a docBase URL of the form:
     740    //docBase = "http://localhost:8383/greenstone3/library/collection/tudor/page/phind";
     741    if(collection == null) {
     742        //System.err.println("*** docBase: " + docBase);
     743        index = docBase.indexOf("collection/");     
     744        if(index != -1) {
     745        index += "collection/".length();
     746        int endIndex = docBase.indexOf("/", index);
     747        collection = docBase.substring(index, endIndex);
     748        //System.err.println("*** collection: " + docBase.substring(index, endIndex) );
     749        }
     750    }
     751       
    734752    System.out.println("Phind collection: " + collection);
    735753
     
    740758    // Where is the Greenstone library
    741759    library_address = parameterValue("library");
     760   
     761    // Fallback for webswing, as customising applet param "library" didn't work
     762    if(library_address == null) {   
     763        index = docBase.indexOf("/collection");
     764        if(index != -1) {
     765        String docBasePrefix = docBase.substring(0, index);
     766        index = docBasePrefix.lastIndexOf("/");     
     767        if(index != -1) {
     768           
     769            library_address = docBasePrefix.substring(index+1);
     770            //System.err.println("*** library: " + docBasePrefix.substring(index+1) );
     771        }
     772        }
     773    }   
    742774    library_address = tidy_URL(library_address, true);
    743775    System.out.println("Phind library: " + library_address);
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/webswing-phind.xsl

    r38813 r38817  
    9999
    100100      <gsf:script>
    101 
     101        // https://www.webswing.org/docs/23.2/configure/applet.html
     102        // https://www.webswing.org/docs/23.2/configure/swing.html
     103        // https://www.webswing.org/docs/23.2/integrate/javascript-api?_h=customArgs%2Cargs#usage-with-customization-and-options       
     104        // https://www.webswing.org/docs/23.2/integrate/embed.html
     105        // https://www.webswing.org/docs/20.1/integrate/urlparams.html
     106        // https://www.webswing.org/docs/23.2/integrate/urlparams.html
     107        // https://www.webswing.org/docs/20.1/integrate/customize.html
     108        // https://www.webswing.org/docs/2.7/integrate/embed.html
     109       
    102110    var webswingInstance0 = {
    103111        options: {
    104             autoStart: true,
    105      
     112        autoStart: true,
     113    //appletParams: getParam('appletParams'),
     114    //appletParams: {"collection":"tudor", "library":"library"},
    106115            connectionUrl:'/webswing-server/phind',
    107116
    108117        customization: function(injector) {
    109118        injector.services.base.handleActionEvent = function(actionName, data, binaryData) {
    110                 console.log("WebSwing actionEvent callback handler: called with actionName = " + actionName);
    111         /*
    112         if (actionName == "previewURL") {
    113               var url = data;
    114               window.open(url, '_blank');
    115         }
    116             else if (actionName == "downloadURL") {
    117           // currently the same as 'previewURL' but separate name gives this some future proofing
    118               var url = data;
    119               window.open(url, '_blank');
    120         }
    121             else if (actionName == "setCursor") {
    122             var cursor_type = data;
    123             $('#webswing-phind').css("cursor",cursor_type);         
    124         }
    125         else if (actionName == "javaToWebswingJSConsoleLog") {
    126             console.log("Got message from java:\n" + data);
    127         }
    128         */
    129        
     119                console.log("WebSwing actionEvent callback handler: called with actionName = " + actionName);       
    130120          }
    131121            }
     
    134124       }
    135125       };
     126       /*
    136127       // Not yet working. Stick ${customArgs} at end of final param Value (BEFORE the value's closing double quote) in webswing.config.in
    137128       // The applet jar files can just remain in web/applet where they are compiled up
    138        /*if(!webswingInstance0.options.args) {
     129       if(!webswingInstance0.options.args) {
    139130       webswingInstance0.options.args="";
    140131       }
     
    144135       webswingInstance0.options.args += ", -Dwebswing.appletParam_library=";
    145136       webswingInstance0.options.args+=(gs.xsltParams.library_name)?gs.xsltParams.library_name:"library";
     137       
     138       console.log("args: " +  webswingInstance0.options.args);
    146139       */
     140
     141       /*       
     142       if(!webswingInstance0.options.appletParams) {
     143       webswingInstance0.options.appletParams={};
     144       }       
     145       if (gs.cgiParams.c) {       
     146       webswingInstance0.options.appletParams["collection"] = gs.cgiParams.c;
     147       }       
     148       webswingInstance0.options.appletParams["library"] = (gs.xsltParams.library_name) ? gs.xsltParams.library_name : "library";
     149       */
     150       /*
     151       if(!webswingInstance0.options.appletParams) {
     152       webswingInstance0.options.appletParams="";
     153       }
     154       webswingInstance0.options.appletParams += "&amp;collection=tudor&amp;library=library";     
     155       console.log("Custom Args: " + JSON.stringify(webswingInstance0.options.appletParams));
     156       */
     157       
    147158    function getParam(name) {
    148159        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
Note: See TracChangeset for help on using the changeset viewer.