Changeset 38933 for main


Ignore:
Timestamp:
2024-04-17T14:41:57+12:00 (2 weeks ago)
Author:
anupama
Message:
  1. The webswing code uses more dynamically values for parameters. 2. For which some extra javascript variables are set up in javascript-global-setup.xsl (for example, the collage app needs to know the servlet_context). 3. The applet element still exists in classifier.xsl, though it is not used by the webswing collage application on the page, nor would it be used if the webswing collage was an applet. But as browsers don't display applet elements anymore, rendering them inactive, leaving the applet element in allows us to still run the appletviewer on the collage URL. 4. The applet element includings its parameters now work out the dynamic parameters instead of leaving them hardcoded in there.
Location:
main/trunk/greenstone3/web/interfaces/default/transform
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/transform/javascript-global-setup.xsl

    r38895 r38933  
    5050            <xsl:text disable-output-escaping="yes">gs.xsltParams.interface_name = "</xsl:text><xsl:value-of select="$interface_name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
    5151            <xsl:text disable-output-escaping="yes">gs.xsltParams.site_name = "</xsl:text><xsl:value-of select="$site_name"/><xsl:text disable-output-escaping="yes">";</xsl:text>
     52            <!-- servlet_context isn't part of the xsltparams element list when
     53                 viewing o=xml, but I need it set and gs.xsltParams setup is using it
     54                 for setting gs.xsltParams.cookie_path already anyway -->
     55            <xsl:text disable-output-escaping="yes">gs.xsltParams.servlet_context = "</xsl:text><xsl:value-of select="$servlet_context"/><xsl:text disable-output-escaping="yes">";</xsl:text>
    5256            <xsl:text disable-output-escaping="yes">gs.xsltParams.use_client_side_xslt = "</xsl:text><xsl:value-of select="$use_client_side_xslt"/><xsl:text disable-output-escaping="yes">";</xsl:text>
    5357            <xsl:text disable-output-escaping="yes">gs.xsltParams.filepath = "</xsl:text><xsl:value-of select="$filepath"/><xsl:text disable-output-escaping="yes">";</xsl:text>
     
    146150            <xsl:text disable-output-escaping="yes">
    147151                gs.requestInformation.fullURL = "</xsl:text><xsl:value-of select="/page/pageRequest/@fullURL"/><xsl:text disable-output-escaping="yes">";
     152                gs.requestInformation.baseURL = "</xsl:text><xsl:value-of select="/page/pageRequest/@baseURL"/><xsl:text disable-output-escaping="yes">";
    148153            </xsl:text>
    149154        </script>
  • main/trunk/greenstone3/web/interfaces/default/transform/layouts/webswing-collage.xsl

    r38932 r38933  
    7878       
    7979       //https://stackoverflow.com/questions/25203124/how-to-get-base-url-with-jquery-or-javascript
    80        var baseURL = window.location.origin+window.location.pathname;       
    81        // webswingInstance0.options.args += "\"" + baseURL+ "?a=a&amp;rt=d&amp;s=GsdlCollageApplet&amp;c=smallbea\"";
    82        var servlet_index = baseURL.indexOf("/"+gs.xsltParams.library_name);
    83        if(servlet_index > 0) {
    84        baseURL = baseURL.substring(0, servlet_index+1);
    85        }
    86        var baseClassifier = "CL3";
     80       var baseURL;
     81       if(gs.requestInformation.baseURL) {
     82          baseURL = window.location.protocol + gs.requestInformation.baseURL; // contains servlet
     83       } else { // will this else block ever need to be used?
     84          baseURL = window.location.origin+window.location.pathname;       
     85          // webswingInstance0.options.args += "\"" + baseURL+ "?a=a&amp;rt=d&amp;s=GsdlCollageApplet&amp;c=smallbea\"";
     86          var servlet_index = baseURL.indexOf("/"+gs.xsltParams.library_name);
     87          if(servlet_index > 0) {
     88             baseURL = baseURL.substring(0, servlet_index+1);
     89      }
     90       }
     91       
    8792       //var gs3CollImgPath = gs.xsltParams.library_name + "/sites/" + gs.xsltParams.site_name + "/collect/" + gs.cgiParams.c;
    88        var gs3CollBrowsePath = gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/browse/" + baseClassifier;
     93       var gs3CollBrowsePath = gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/browse/" + gs.cgiParams.cl; // cl is classifier, e.g "CL3"
     94
    8995       
    9096       webswingInstance0.options.args += "--baseurl \"" + baseURL + "\"";
     
    9298       webswingInstance0.options.args += " --collection " + gs.cgiParams.c;
    9399       webswingInstance0.options.args += " --library " + gs.xsltParams.library_name;
    94        webswingInstance0.options.args += " --documentroot greenstone3";
     100       webswingInstance0.options.args += " --documentroot " + gs.xsltParams.servlet_context;
    95101       webswingInstance0.options.args += " --hrefMustHave " + gs3CollBrowsePath;
    96102       webswingInstance0.options.args += " --imageMustNotHave \"interfaces/\"";
    97103       webswingInstance0.options.args += " --verbosity " + 3;
    98104       webswingInstance0.options.args += " --imageType " + "\".jpg%.png\"";
    99        webswingInstance0.options.args += " --classifier \"" + baseClassifier + ".1\""; // "CL3.1"
     105       webswingInstance0.options.args += " --classifier \"" + gs.cgiParams.cl + ".1\""; // "CL3.1"
    100106       webswingInstance0.options.args += " --maxDepth 500 --maxDisplay 25 --refreshDelay 1500 --bgcolor \"#96c29a\"";       
    101107
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/classifier.xsl

    r38932 r38933  
    148148  </xsl:template>
    149149
     150
    150151  <xsl:template name="Collage">
    151 
    152152    <xsl:text>TODO: Here is the collage applet</xsl:text>
    153     <!-- Copied from GS2.88's about.dm (document.dm has a more applet params).
     153    <!-- Copied from GS2.88's about.dm (document.dm has more applet params).
    154154
    155155     Modified params: codebase, GsdlCollageApplet class' package, gwcgi, collection, classifier value="CL2.3", hrefMustHave value="cl=CL3.1". Param isJava2's value changed from auto to true.
    156156     And made all param XML elements self-closing.
    157157    -->
    158     <!-- When run in the browser or as an application, it's enough to specify applet as
    159      the relative folder for where to find the jars (we seem to be in the web dir then,
    160      so can directly look in web's applet subdirectory for the jar). But for running with
    161      this applet with the appletviewer we need the "full URL path" to the applet folder,
    162      which is off /greenstone3. Though once the collage applet is run in the appletviewer,
    163      a securityexception is thrown as appears it's in a sandbox and has no permission to
    164      download URLs or follow external links or something.
     158    <!-- When run in the browser or as an application, it's enough to specify "applet" for codebase
     159     as the relative folder where to find the jars (we seem to be in the "web" dir then,
     160     so can directly look in web's "applet" subdirectory for the jar). But for running
     161     this applet with the appletviewer, we need the "full URL path" to the applet folder,
     162     which is off /greenstone3 (the servlet_context). Though once the collage applet is run
     163     in the appletviewer, a securityexception is thrown as it appears to run in a sandbox
     164     that has no permission to download URLs or follow external links or something. That's
     165     as far as the Java appletviewer executable can run Greenstone's collage applet program.
     166     But being able to run it through the appletviewer this far gives us some confidence that
     167     the collage applet actually successfully starts running as an applet.
    165168    -->
    166     <applet codebase="/greenstone3/applet"
     169    <applet
    167170        code="org.greenstone.applet.GsdlCollageApplet.GsdlCollageApplet.class"
    168171        archive="GsdlCollageApplet.jar, webswing-api.jar"
    169172        width="600"
    170173        height="300">
     174      <xsl:attribute name="codebase">/<xsl:value-of select="$servlet_context"/>/applet</xsl:attribute>
     175
     176      <!-- declaring some local variables -->
     177      <xsl:variable name="coll_name"><xsl:value-of select="/page/pageRequest/paramList/param[@name='c']/@value"/></xsl:variable>
     178      <xsl:variable name="classifier"><xsl:value-of select="/page/pageRequest/paramList/param[@name='cl']/@value"/></xsl:variable>
     179      <xsl:variable name="fullURL"><xsl:value-of select="/page/pageRequest/@fullURL"/></xsl:variable>
     180      <xsl:variable name="url_protocol_prefix"><xsl:value-of select="substring-before (/page/pageRequest/@fullURL,'/')"/></xsl:variable>
     181
     182      <!-- setting the applet parameters: first the dynamic ones -->
    171183     
     184      <!-- pageRequest attribute "baseURL" lacks protocol prefix and looks like
     185       e.g "//localhost:8383/greenstone3/", but we want to set xsl:variable "baseurl"
     186       to all of e.g "http://localhost:8383/greenstone3/" -->
     187      <param name="baseurl"><xsl:attribute name="value"><xsl:value-of select="$url_protocol_prefix"/><xsl:value-of select="/page/pageRequest/@baseURL"/></xsl:attribute></param>
     188     
     189      <param name='library'><xsl:attribute name="value"><xsl:value-of select="$library_name"/></xsl:attribute></param>
     190      <param name='collection'><xsl:attribute name="value"><xsl:value-of select="$coll_name"/></xsl:attribute></param>
     191      <param name='classifier'><xsl:attribute name="value"><xsl:value-of select="$classifier"/>.1</xsl:attribute></param><!--
     192      e.g. "CL3.1". The first level subclassifier (.1) contains the hidden classifier structure
     193      that the collage app starts exploring from for images -->
     194
     195      <param name='documentroot'><xsl:attribute name="value"><xsl:value-of select="$servlet_context"/></xsl:attribute></param> <!-- e.g. "greenstone3" -->
     196
     197      <param name="hrefMustHave"><xsl:attribute name="value"><xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="$coll_name"/>/browse/<xsl:value-of select="$classifier"/></xsl:attribute></param><!-- e.g. "library/collection/smallbea/browse/CL3" -->
     198
     199      <!-- applet parameters that are fixed for GS3 or we probably don't want to modify -->
    172200      <param name='gsdlversion' value='3' />
    173       <param name='baseurl' value='http://localhost:8383/greenstone3/' />
    174       <!--<param name='sitename' value='localsite' />-->
    175       <param name='library' value='library'/>
    176       <param name="collection" value="smallbea"/>
    177       <param name="classifier" value="CL3.1"/>
    178 
    179       <param name='documentroot' value='greenstone3'/>
    180       <!--<param name="documentroot" value="/greenstone/web/images"/> for GS2-->
     201      <param name='imageMustNotHave' value='interfaces/' />
    181202     
     203      <!-- applet parameters that can be manually adjusted -->
    182204      <param name='imageType' value='.jpg%.png' />     
    183205      <param name='verbosity' value='3' />
    184       <!--<param name="hrefMustHave" value="CL3"/>-->
    185       <param name="hrefMustHave" value="library/collection/smallbea/browse/CL3"/>
    186       <param name='imageMustNotHave' value='interfaces/' />
    187206      <param name="maxDepth" value="500"/>
    188207      <param name='maxDisplay' value='25' />
     
    194213   </applet>
    195214  </xsl:template>
    196  
     215
    197216  <xsl:template name="Collage_javascript_deprecated">
    198217    <script type="text/javascript" src="interfaces/{$interface_name}/js/collage_scripts.js"><xsl:text> </xsl:text></script>
Note: See TracChangeset for help on using the changeset viewer.