Changeset 38874
- Timestamp:
- 2024-03-25T23:18:19+13:00 (5 weeks ago)
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/webswing/trunk/web/etc/webswing.config.in
r38872 r38874 122 122 "webHomeDir" : "@gsdl3webwritablehomeunix@", 123 123 "goodbyeUrl" : "/" 124 }, 125 "/collage" : { 126 "path" : "/collage", 127 "security" : { 128 "module" : "NONE", 129 "config" : { }, 130 "classPath" : [ ] 131 }, 132 133 "webFolder" : "", 134 "swingConfig" : { 135 "jreExecutable" : "${java.home}/bin/java", 136 "javaVersion" : "${java.version}", 137 "vmArgs" : "", 138 "classPathEntries" : [ "applet/*.jar", "ext/webswing/api/webswing-api.jar" ], 139 "theme" : "Murrine", 140 "fontConfig" : { 141 "dialog" : "${webswing.configDir}/fonts/Roboto-Regular.ttf", 142 "dialoginput" : "${webswing.configDir}/fonts/RobotoMono-Regular.ttf", 143 "monospaced" : "${webswing.configDir}/fonts/RobotoMono-Regular.ttf", 144 "serif" : "${webswing.configDir}/fonts/Roboto-Regular.ttf", 145 "sansserif" : "${webswing.configDir}/fonts/Roboto-Regular.ttf" 146 }, 147 "swingSessionTimeout" : 300, 148 "antiAliasText" : true, 149 "isolatedFs" : true, 150 "debug" : false, 151 "directdraw" : true, 152 "allowDelete" : false, 153 "allowDownload" : false, 154 "allowAutoDownload" : true, 155 "allowUpload" : false, 156 "allowJsLink" : true, 157 "allowLocalClipboard" : true, 158 "launcherType" : "Applet", 159 "launcherConfig" : { 160 "appletClass" : "org.greenstone.applet.GsdlCollageApplet.GsdlCollageApplet", 161 "parameters" : { 162 "library" : "library", 163 "collection" : "smallbea", 164 "gsdlversion" : "3", 165 "sitename" : "localsite", 166 "baseurl" : "'http://localhost:8383/greenstone3/", 167 "documentroot" : "greenstone3", 168 "verbosity" : "3", 169 "imageType" : ".jpg%.png", 170 "imageMustNotHave" : "interfaces/", 171 "gwcgi" : "http://localhost:8383/greenstone3/library/collection/smallbea/", 172 "classifier" : "CL2.3", 173 "maxDepth" : "500", 174 "maxDisplay" : "25", 175 "refreshDelay" : "1500", 176 "isJava2" : "auto", 177 "bgcolor" : "#96c29a" 178 } 179 }, 180 "homeDir" : "@gsdl3webwritablehomeunix@" 181 }, 182 "maxClients" : 4, 183 "maxConnections" : 4, 184 "allowStealSession" : false, 185 "name" : "Greenstone Collage Browser", 186 "sessionMode" : "ALWAYS_NEW_SESSION", 187 "uploadMaxSize" : 1200, 188 "webHomeDir" : "@gsdl3webwritablehomeunix@", 189 "goodbyeUrl" : "/" 124 190 } 125 191 } -
main/trunk/greenstone3/src/java/org/greenstone/applet/GsdlCollageApplet/DownloadImages.java
r38853 r38874 14 14 * Stores images that are downloaded but have not yet been displayed 15 15 * in the applet. Provides methods to add to and remove from this list 16 * and check it 's size. It uses an inner class to store the data for these17 * images, comprising of three parts: the image itself, it 's source url16 * and check its size. It uses an inner class to store the data for these 17 * images, comprising of three parts: the image itself, its source url 18 18 * and the name of the image */ 19 19 public class DownloadImages { -
main/trunk/greenstone3/src/java/org/greenstone/applet/GsdlCollageApplet/GsdlCollageApplet.java
r38871 r38874 5 5 import java.awt.*; 6 6 import java.net.*; 7 8 import javax.swing.JFrame; 9 import javax.swing.JLabel; 10 import java.util.Map; 11 import java.util.HashMap; 7 12 8 13 /** … … 20 25 21 26 public class GsdlCollageApplet extends JApplet { 27 // To run this GsdlCollageApplet as Application instead of as Applet 28 boolean isWebswingApplication = false; // if run as webswing *and* application (not applet) 29 boolean isRunAsApplet = true; 30 // set only if JPhind object is run as an application 31 URL docBaseURL = null; 32 JLabel statusBar = null; 33 Map<String,String> appParams; 34 22 35 // package access, used mainly for GS3 23 36 int gsdlversion = 2; … … 102 115 Thread paint ; 103 116 117 public GsdlCollageApplet() { super(); } 118 119 public GsdlCollageApplet(String[] args) { 120 // I copied the contents of this contructor for my code for the JPhind.java constructor 121 // This constructor will be used when this JApplet is run as an application 122 // instead of as applet 123 this.isRunAsApplet = false; 124 try { 125 this.docBaseURL = new URL(args[0]); 126 } catch(MalformedURLException mue) { 127 mue.printStackTrace(); 128 System.err.println("*** Unable to instantiate URL from parameter: " + args[0]); 129 System.exit(-1); 130 } 131 132 appParams = new HashMap<String,String>((args.length+1)/2); 133 134 String key = null; 135 String value = null; 136 for(int i = 1; i < args.length; i++) { // after arg0, have key-value pairs (params) 137 if(i%2==1) { 138 key = args[i].substring(2); // remove -- prefix of paramname 139 //System.err.println("got key: " + key); 140 } else { 141 value = args[i]; 142 appParams.put(key, value); 143 //System.err.println("got value: " + value); 144 145 146 // HttpUtils.parseQueryString() deprecated, so hacking decode xtra key-value pairs 147 // https://stackoverflow.com/questions/13592236/parse-a-uri-string-into-name-value-collection?page=1&tab=scoredesc#tab-top 148 // String.split() is preferred over Tokenizer but 2nd parameter behaves differently 149 // than I expected. 150 // https://docs.oracle.com/javase/6/docs/api/java/lang/String.html#split%28java.lang.String,%20int%29 151 if(key.equals("xtraParams")) { 152 value = value.replace("&", "&"); // just in case we have html entities 153 String[] param_list = value.split("&", 0); // 0 for all occurrences 154 for(String key_val : param_list) { 155 String[] paramPair = key_val.split("=", 2); // get first 2 strings, key and val 156 //System.err.println("key_val: " + key_val); 157 if(paramPair.length == 2) { 158 String xtraParamsKey = paramPair[0]; 159 String xtraParamsVal = paramPair[1]; 160 //System.err.println("key - val: " + xtraParamsKey + " - " + xtraParamsVal); 161 appParams.put(xtraParamsKey, xtraParamsVal); 162 } 163 } 164 } 165 166 key = value = null; 167 } 168 } 169 170 isWebswingApplication = appParams.getOrDefault("webswing", "0").equals("1") ? true : false; 171 172 // manually calling (J)Applet method init() 173 init(); 174 } 175 176 /** 177 * Overriding (J)Applet method getParameter to first check appParams map 178 * if Phind was run run as an application. 179 * https://stackoverflow.com/questions/15905127/overridden-methods-in-javadoc 180 */ 181 @Override 182 public String getParameter(String name) { 183 if(!isRunAsApplet) { 184 return appParams.get(name); 185 } 186 else { 187 return super.getParameter(name); 188 } 189 } 190 191 @Override 192 public URL getDocumentBase() { 193 if(!isRunAsApplet) { // launched as application 194 //System.err.println("*** docBaseURL: " + docBaseURL); 195 return this.docBaseURL; 196 } else { 197 return super.getDocumentBase(); 198 } 199 } 200 201 @Override 202 public void showStatus(String msg) { 203 // Either firefox doesn't provide a status bar window for applets any more or webswing 204 // doesn't provide a status window, so we don't see Applet.showStatus() output appear 205 // in webswing-phind and in fact don't even see any Applet statusBar in webswing. 206 // However, since we print useful and interesting information to the status bar, 207 // we'll now always show and print to our manually added statusBar now 208 // not only if(!isRunAsApplet) when we needed to manually create a statusBar. 209 this.statusBar.setText(msg); 210 if(isRunAsApplet) { 211 super.showStatus(msg); 212 } 213 } 214 104 215 public void init() 105 216 { … … 277 388 } 278 389 } 279 // starting URL (image_url) m aynot be base_url390 // starting URL (image_url) might not be base_url 280 391 this.baseURL = getParameter("baseurl"); 281 392 // TODO: is it not the other way: gwcgi should be param set to base_url … … 283 394 } 284 395 } 396 397 // status bar that applet has, but we want one also if we run JPhind as application 398 // And in fact, when webswing runs our applet, we never get a status bar. So we 399 // create a custom status bar now even if we're running as an applet. 400 // When this applet is run through the appletviewer we might end up with 2 status bars. 401 setLayout(new BorderLayout()); 402 //if(!isRunAsApplet) { 403 statusBar = new JLabel(); 404 this.add(statusBar, BorderLayout.SOUTH); 405 Dimension d = statusBar.getSize(); 406 d.height = 30; 407 statusBar.setPreferredSize(d); 408 //} 285 409 286 410 MediaTracker trk = new MediaTracker(this); … … 466 590 467 591 592 // To also be able to run this applet as an application, need a main method 593 /** 594 * Try running as: 595 java -cp ./web/applet/GsdlCollageApplet.jar:./web/WEB-INF/lib/log4j-1.2.8.jar:./web/WEB-INF/classes org.greenstone.applet.GsdlCollageApplet.GsdlCollageApplet "http://localhost:8383/greenstone3/" --gwcgi "http://localhost:8383/greenstone3/library/collection/smallbea/" --library library --collection smallbea --gsdlversion 3 --baseurl "http://localhost:8383/greenstone3/" --sitename localsite --documentroot greenstone3 --verbosity 3 --imageType ".jpg%.png" --imageMustNotHave "interfaces/" --classifier "CL2.3" --maxDepth 500 --maxDisplay 25 --refreshDelay 1500 --isJava2 auto --bgcolor "#96c29a" 596 */ 597 public static void main(String[] args) { 598 if(args.length < 9) { 599 System.err.println("Need minimum --params: <baseURL> --library <library> --collection <collection> --classifier <classifier> --phindcgi <URL> --library <libURL> [--webswing <1/0>] [--backdrop <ImgURL>] [--xtraParams <key1=value1&key2=value2&...]"); 600 } 601 else { // collection fao.org, classifier 1, phindcgi url, library url, backdrop imgurl 602 GsdlCollageApplet collageApp = new GsdlCollageApplet(args); 603 JFrame frame = new JFrame("Collage Applet as Application"); 604 frame.getContentPane().add(collageApp, BorderLayout.CENTER); 605 frame.setSize(500,400); 606 // https://stackoverflow.com/questions/19433358/difference-between-dispose-and-exit-on-close-in-java 607 // default: https://docs.oracle.com/javase/8/docs/api/javax/swing/JFrame.html#EXIT_ON_CLOSE 608 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // don't do EXIT_ON_CLOSE in Applets! 609 frame.setVisible(true); 610 611 } 612 } 468 613 } -
main/trunk/greenstone3/web/interfaces/default/interfaceConfig.xml
r38814 r38874 7 7 <subaction name="gli" xslt="pages/webswing-gli.xsl"/> 8 8 <subaction name="phind" xslt="pages/webswing-phind.xsl"/> 9 <subaction name="collage" xslt="pages/webswing-collage.xsl"/> 9 10 <subaction name="debug" xslt="pages/debuginfo.xsl"/> 10 11 <subaction name="pref" xslt="pages/pref.xsl"/> -
main/trunk/greenstone3/web/interfaces/default/transform/layouts/header.xsl
r38854 r38874 451 451 </xsl:attribute> 452 452 </xsl:if> 453 < xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=a&rt=d&s=<xsl:value-of select="@name"/>&c=<xsl:value-of select="/page/pageResponse/collection/@name"/></xsl:attribute>454 < !--<xsl:attribute name="href"><xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="/page/pageResponse/collection/@name"/>/page/collage</xsl:attribute>-->453 <!--<xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=a&rt=d&s=<xsl:value-of select="@name"/>&c=<xsl:value-of select="/page/pageResponse/collection/@name"/></xsl:attribute>--> 454 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="/page/pageResponse/collection/@name"/>/page/collage</xsl:attribute> 455 455 <xsl:value-of select="displayItem[@name='name']"/> 456 456 </a>
Note:
See TracChangeset
for help on using the changeset viewer.