[Laszlo-checkins] r12822 - in openlaszlo/trunk: WEB-INF/lps/server/src/org/openlaszlo/compiler WEB-INF/lps/server/src/org/openlaszlo/servlets/responders WEB-INF/lps/server/src/org/openlaszlo/utils lps/admin lps/includes/source

hqm@openlaszlo.org hqm at openlaszlo.org
Wed Feb 11 06:28:29 PST 2009


Author: hqm
Date: 2009-02-11 06:28:22 -0800 (Wed, 11 Feb 2009)
New Revision: 12822

Modified:
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationEnvironment.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationError.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DHTMLWriter.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/Main.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/servlets/responders/ResponderCompile.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/utils/DeployMain.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/utils/DeploySOLODHTML.java
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/utils/FileUtils.java
   openlaszlo/trunk/lps/admin/solo-dhtml-deploy.jsp
   openlaszlo/trunk/lps/includes/source/embednew.js
Log:
Change 20090211-hqm-f by hqm at badtzmaru.home on 2009-02-11 09:27:20 EST
    in /Users/hqm/openlaszlo/trunk4
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: remodularize SOLO DHTML deploy process

New Features:

Bugs Fixed:

Technical Reviewer: max
QA Reviewer: mdemmon
Doc Reviewer: (pending)

Documentation:

Release Notes:

Added a new compiler option , "--copy-resources" which is used when
building a DHTML app for deployment. It causes any 'external' resources (ones which
reside above of the application's home directory in the filesystem) to be copied to
a "lps/resources" subdirectory in the application's home directory.

This task was formerly done by the SOLO deployer wizards. It was moved
to the compiler in order to make a fix for LPP-7660, to allow a DHTML
application to be compiled whose home directory is outside of the
LPS_HOME directory tree.


Details:

A new command line compiler option was added, COPY_RESOURCES_LOCAL,
which causes the DHTMLWriter to copy any 'external' resources to a
local directory named "lps/resources", in the application's home
directory.

This is to support packaging of a self-contained DHTML
application. This resource file copying used to be done by SOLO
deployer wizard, but while fixing LPP-7660, it was cleaner to refactor
this into the compiler.

The flag is enabled via the command line compiler (lzc) using
"--copy-resources". When compiling via the LPS server, add
"lzcopyresources=true" to the URL. This is how the DHTML SOLO wizard
activates the feature.

The flag is disabled by default.

Tests:

from command line run

[1] lzc --runtime=dhtml --copy-resources demos/calendar/calendar.lzx
 + see that subdirectory is created in calendar named "lps", which contains all
 application-external resources



[2] test via LPS server:

 + delete lps subdir from demos/calendar
 + fetch http://localhost:8080/trunk/demos/calendar/calendar.lzx?lzr=dhtml&lzcopyresources=true

+ Look at the applicaton source directory, demos/calendar/ and see
that a directory "lps/resources" was created and populated with lz
component library resources.

[3] Run SOLO deploy wizard via the [SOLO] button on the dev
console. Download the zip file, install on some other non-LPS server ,
and verify that app with custom wrapper (calendar.lzx.html) runs in
SOLO mode

[4] Run command line solo deployer (lzdeploy)
 lzdeploy --runtime=dhtml demos/calendar/calendar.lzx

+ verify that zip file calendar.lzx.zip is created

+ unpack this zip file on a non-LPS server, and verify that
calendar.lzx.html runs SOLO properly

[5] Run test case from LPP-7660, where app is symlinked to outside the
LPS_HOME, verify DHTML works properly. Make SOLO deployment from this.

[6] Place LPS demo app (such as weather.lzx or calendar) in a source
tree external to the LPS_HOME, and run command line compiler, lzc
--runtime=dhtml , and inspect compiled app file (calendar.js) to see
that it has no absolute paths for resources (that was the bug in LPP-7660)

[7] Run command line SOLO deployer on app which is outside of LPS_HOME
(e.g., put your app in ~/src/testdhtml/weather/weather.lzx, and
compile with "lzdeploy --runtime=dhtml"



Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationEnvironment.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationEnvironment.java	2009-02-11 14:21:47 UTC (rev 12821)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationEnvironment.java	2009-02-11 14:28:22 UTC (rev 12822)
@@ -38,6 +38,11 @@
     public static final String DEBUG_EVAL_PROPERTY         = "debugEval";
     public static final String SOURCE_ANNOTATIONS_PROPERTY = "lzsourceannotations";
 
+    // For DHTML runtime, make application-local copies of all compile
+    // time resource files.
+    public static final String COPY_RESOURCES_LOCAL        = "lzcopyresources";
+    public static final String APPLICATION_ROOT            = "applicationroot";
+
     // matches the values of sc.Compiler.DEBUG_BACKTRACE, NAME_FUNCTIONS, etc.
     public static final String BACKTRACE_PROPERTY         = "debugBacktrace";
     public static final String NAME_FUNCTIONS             = "nameFunctions";

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationError.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationError.java	2009-02-11 14:21:47 UTC (rev 12821)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CompilationError.java	2009-02-11 14:28:22 UTC (rev 12822)
@@ -3,7 +3,7 @@
  * ****************************************************************************/
 
 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
-* Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.              *
+* Copyright 2001-2009 Laszlo Systems, Inc.  All Rights Reserved.              *
 * Use is subject to license terms.                                            *
 * J_LZ_COPYRIGHT_END *********************************************************/
 
@@ -41,7 +41,7 @@
      * cause, instead of wrapping them in instances of
      * CompilationError.  This is useful for debugging the
      * compiler. */
-    public static boolean ThrowCompilationErrors = false;
+    public static boolean ThrowCompilationErrors = true;
 
     /** Constructs an instance.
      * @param message a string

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DHTMLWriter.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DHTMLWriter.java	2009-02-11 14:21:47 UTC (rev 12821)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/DHTMLWriter.java	2009-02-11 14:28:22 UTC (rev 12822)
@@ -40,10 +40,16 @@
  */
 class DHTMLWriter extends ObjectWriter {
 
+
+    static final String localResourceDir = "lps/resources";
+
     // Accumulate script here, to pass to script compiler
     protected PrintWriter scriptWriter = null;
     protected StringWriter scriptBuffer = null;
 
+    // List of declarations of resources
+    protected StringBuffer mResourceDefs = new StringBuffer();
+
     /** Logger */
     protected static Logger mLogger = org.apache.log4j.Logger.getLogger(DHTMLWriter.class);
 
@@ -167,30 +173,25 @@
         org.openlaszlo.iv.flash.api.FlashDef def = null;
 
         File dirfile = mEnv.getApplicationFile().getParentFile();
-        File appdir = dirfile != null ? dirfile : new File(".");
-        mLogger.debug("appdir is: " + appdir + ", LPS.HOME() is: "+ LPS.HOME());
-        //File appHomeParent = new File(LPS.getHomeParent());
-        String sHome=LPS.HOME();
-        // relativePath will perform canonicalization if needed, placing 
-        // the current dir in front of a path fragment.
-        String arPath = FileUtils.relativePath(inputFile, appdir);
-        String srPath = FileUtils.relativePath(inputFile, sHome);
-        String relPath;
-        String pType;
-        if (arPath.length() <= srPath.length()) {
-            pType="ar";
-            relPath = arPath;
-        } else {
-            pType ="sr";
-            relPath = srPath;
-        }
+        String[] fileInfo = getRelPath(inputFile);
+        String pType = fileInfo[0];
+        String relPath = fileInfo[1];
+
         // make it relative and watch out, it comes back canonicalized with forward slashes.
         // Comparing to file.separator is wrong on the pc.
          if (relPath.charAt(0) == '/') {
                  relPath = relPath.substring(1);
         }
-        mLogger.debug("relPath is: "+relPath);
 
+         // If this is a "external" resource and copy-resources flag
+         // is set, make a copy of the resource file to bundle with the app.
+         // (Note: the SOLO DHTML deploy script used to be responsible or this).
+         if (pType.equals("sr") && mEnv.getBooleanProperty(mEnv.COPY_RESOURCES_LOCAL)) {
+             // If this is a "sr" (server-root-relative) path, make a local copy in the
+             // localResourceDir
+             copyResourceFile(inputFile, dirfile, relPath);
+         }
+
         StringBuffer sbuf = new StringBuffer("LzResourceLibrary." + 
                                              name + "={ptype: \"" + pType + "\", frames:[");
         sbuf.append("'"+relPath+"'");
@@ -225,9 +226,12 @@
             sbuf.append("]");
         }
         sbuf.append("};");
-        addScript(sbuf.toString());
+        mResourceDefs.append(sbuf.toString());
     }
 
+    public void addResourceDefs () {
+        addScript(mResourceDefs.toString());
+    }
     public void importResource(List sources, String sResourceName, File parent)
     {
         writeResourceLibraryDescriptor(sources, sResourceName, parent);
@@ -249,6 +253,8 @@
         }
         String pType;
         String relPath;
+        File dirfile = mEnv.getApplicationFile().getParentFile();
+
         for (Iterator e = sources.iterator() ; e.hasNext() ;) {
             File fFile = new File((String)e.next());
             String[] fileInfo = getRelPath(fFile);
@@ -262,6 +268,15 @@
 
             mLogger.debug("relFile is: "+relPath);
 
+            // If this is a "external" resource and copy-resources flag
+            // is set, make a copy of the resource file to bundle with the app.
+            // (Note: the SOLO DHTML deploy script used to be responsible or this).
+            if (pType.equals("sr") && mEnv.getBooleanProperty(mEnv.COPY_RESOURCES_LOCAL)) {
+                // If this is a "sr" (server-root-relative) path, make a local copy in the
+                // localResourceDir
+                copyResourceFile(fFile, dirfile, relPath);
+            }
+
             sbuf.append(sep+"'"+relPath+"'");
             sep = ",";
             // Definition to add to the library (without stop)
@@ -288,13 +303,20 @@
                 ImageMontageMaker.assemble(sources, montageFile);
                 String[] fileInfo = getRelPath(new File(montageFile));
                 relPath = fileInfo[1];
+                pType = fileInfo[0];
+
+                if (pType.equals("sr") && mEnv.getBooleanProperty(mEnv.COPY_RESOURCES_LOCAL)) {
+                    // If this is a "sr" (server-root-relative) path, make a local copy in the
+                    // localResourceDir
+                    copyResourceFile(new File(montageFile), dirfile, relPath);
+                }
                 sbuf.append(",sprite:'" + relPath + "'");
             } catch (Exception e) {
                 mLogger.error("Assembling css sprite: " + sources + ", " + e);
             }
         }
         sbuf.append("};");
-        addScript(sbuf.toString());
+        mResourceDefs.append(sbuf.toString());
     }
 
     /** Validate a given filename is good for importing
@@ -315,34 +337,43 @@
     }
 
     private String[] getRelPath(File fFile) { 
-        File dirfile = mEnv.getApplicationFile().getParentFile();
-        String appdir = dirfile != null ? dirfile.getPath() : ".";
-        mLogger.debug("appdir is: " + appdir + ", LPS.HOME() is: "+ LPS.HOME());
-        //File appHomeParent = new File(LPS.getHomeParent());
-        String sHome=LPS.HOME();
-        String arPath;
-        String srPath;
-        String pType;
-        String relPath;
-        arPath = FileUtils.relativePath(fFile, appdir);
-        srPath = FileUtils.relativePath(fFile, sHome);
-        if (arPath.length() <= srPath.length()) {
-            pType="ar";
-            relPath = arPath;
-        } else {
-            pType ="sr";
-            relPath = srPath;
-        }
+        try {
+            File dirfile = mEnv.getApplicationFile().getParentFile();
+            String appdir = new File(dirfile != null ? dirfile.getPath() : ".").getCanonicalPath();
+            //File appHomeParent = new File(LPS.getHomeParent());
+            String sHome = LPS.HOME();
+            String arPath;
+            String pType;
+            String relPath;
 
-        // make it relative and watch out, it comes back canonicalized with forward slashes.
-        // Comparing to file.separator is wrong on the pc.
-        if (relPath.charAt(0) == '/') {
-            relPath = relPath.substring(1);
+            String appRelativePrefix = FileUtils.findMaxCommonPrefix(fFile.toString(), appdir);
+            String LPSRelativePrefix = FileUtils.findMaxCommonPrefix(fFile.toString(), sHome);
+
+            String prefix;
+
+            //appRelativePrefix.length() > LPSRelativePrefix.length() &&
+            if (fFile.toString().startsWith(appdir)) {
+                prefix = appRelativePrefix;
+                pType = "ar";}
+            else {
+                prefix = LPSRelativePrefix;
+                pType = "sr";
+            }
+
+            relPath = FileUtils.relativePath(fFile, prefix);
+
+            // make it relative and watch out, it comes back canonicalized with forward slashes.
+            // Comparing to file.separator is wrong on the pc.
+            if (relPath.charAt(0) == '/') {
+                relPath = relPath.substring(1);
+            }
+            mLogger.debug("relPath is: "+relPath);
+
+            String[] out = {pType, relPath};
+            return out;
+        } catch (java.io.IOException e) {
+            throw new ImportResourceError(fFile.toString(), e, mEnv);
         }
-        mLogger.debug("relPath is: "+relPath);
-
-        String[] out = {pType, relPath};
-        return out;
     }
 
     public void close() throws IOException { 
@@ -353,6 +384,8 @@
             throw new IllegalStateException("DHTMLWriter.close() called twice");
         }
         
+        addResourceDefs();
+
         boolean debug = mProperties.getProperty("debug", "false").equals("true");
 
         // This indicates whether the user's source code already manually invoked
@@ -389,6 +422,8 @@
     }
 
     public void closeSnippet() throws IOException {
+        addResourceDefs();
+
         // Callback to let library know we're done loading
         addScript("LzLibrary.__LZsnippetLoaded('"+this.liburl+"')");
 
@@ -534,5 +569,28 @@
 
     }
 
+    /**
+       Copies a file, INPUTFILE, to the file RELPATH relative to the
+       system-generated application local resources directory in
+       DESTDIR/lps/resources.
+     */
+    void copyResourceFile(File inputFile, File destdir, String relPath) {
+        try {
+            File resourceDirRoot = new File(destdir, localResourceDir);
+            File resCopy = new File(resourceDirRoot, relPath);
+            // Ensure that parent directories exist down to the file
+            File dir = resCopy.getParentFile();
+            if (dir != null)
+                dir.mkdirs();
+            // Make copy of file
+            FileUtils.send(new FileInputStream(inputFile), new FileOutputStream(resCopy));
+
+        }
+        catch (IOException e) {
+            mLogger.error("Error copying resource file in DHTMLWriter "+e.getMessage());
+            throw new ImportResourceError(inputFile.toString(), e, mEnv);
+        }
+    }
+
 }
 

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/Main.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/Main.java	2009-02-11 14:21:47 UTC (rev 12821)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/Main.java	2009-02-11 14:28:22 UTC (rev 12822)
@@ -39,6 +39,8 @@
         "  Location of script cache directory (default <lps>/work/scache)",
         "--media-cache-dir directory",
         "  Location of media cache directory (default <lps>/work/cache/cmcache)",
+        "--application-root",
+        "  Location of root of application directory, if different from LPS_HOME",
         "",
         "Output options:",
         "--runtime=[swf7|swf8|swf9|swf10|dhtml|j2me|svg|null]",
@@ -152,6 +154,8 @@
                     System.err.println("--keepscriptcache is deprecated.  This is now the default behavior.");
                 } else if (arg == "--flush-script-cache") {
                     flushScriptCache = true;
+                } else if (arg == "--copy-resources") {
+                    compiler.setProperty(CompilationEnvironment.COPY_RESOURCES_LOCAL, "true");
                 } else if (arg == "-o" || arg == "--output") {
                     outFileArg = safeArg("-o or --output", args, ++i);
                     if (outFileArg == null) {
@@ -431,7 +435,7 @@
 }
 
 /**
- * @copyright Copyright 2001-2008 Laszlo Systems, Inc.  All Rights
+ * @copyright Copyright 2001-2009 Laszlo Systems, Inc.  All Rights
  * Reserved.  Use is subject to license terms.
  */
 

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/servlets/responders/ResponderCompile.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/servlets/responders/ResponderCompile.java	2009-02-11 14:21:47 UTC (rev 12821)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/servlets/responders/ResponderCompile.java	2009-02-11 14:28:22 UTC (rev 12822)
@@ -3,7 +3,7 @@
  * ****************************************************************************/
 
 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
-* Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.              *
+* Copyright 2001-2009 Laszlo Systems, Inc.  All Rights Reserved.              *
 * Use is subject to license terms.                                            *
 * J_LZ_COPYRIGHT_END *********************************************************/
 
@@ -415,6 +415,7 @@
      * <li> "lzscript" true|false   -- emit javascript, not object file
      * <li> "lzconsoledebug" use remote debug protocol
      * <li> "cssfile"
+     * <li> "lzcopyresources" -- dhtml compilation should make local copy of external resources
      * <ul>
      * also grabs the request URL.
      */
@@ -482,6 +483,14 @@
                 props.setProperty(CompilationEnvironment.SOURCE_ANNOTATIONS_PROPERTY, srcann);
             }
 
+            // Look for "lzcopyresources=true" flag
+            props.setProperty(CompilationEnvironment.COPY_RESOURCES_LOCAL, "false");
+            String lzcopyresources = req.getParameter(CompilationEnvironment.COPY_RESOURCES_LOCAL);
+            if (lzcopyresources != null) {
+                mLogger.info("lzcopyresources = "+lzcopyresources);
+                props.setProperty(CompilationEnvironment.COPY_RESOURCES_LOCAL, lzcopyresources);
+            }
+
         }
 
         // Set the 'lzproxied' default = false

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/utils/DeployMain.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/utils/DeployMain.java	2009-02-11 14:21:47 UTC (rev 12821)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/utils/DeployMain.java	2009-02-11 14:28:22 UTC (rev 12822)
@@ -119,7 +119,7 @@
         }
 
         if (outfile == null) {
-            outfile = sourcepath + ".zip";
+            outfile = new File(sourcepath).getName() + ".zip";
         }
 
         if (sourcepath == null) {

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/utils/DeploySOLODHTML.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/utils/DeploySOLODHTML.java	2009-02-11 14:21:47 UTC (rev 12821)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/utils/DeploySOLODHTML.java	2009-02-11 14:28:22 UTC (rev 12822)
@@ -3,7 +3,7 @@
  * ****************************************************************************/
 
 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
-* Copyright 2001-2004, 2008 Laszlo Systems, Inc.  All Rights Reserved.              *
+* Copyright 2001-2004, 2008, 2009 Laszlo Systems, Inc.  All Rights Reserved.              *
 * Use is subject to license terms.                                            *
 * J_LZ_COPYRIGHT_END *********************************************************/
 
@@ -123,6 +123,8 @@
             // Compile a SOLO app with DHTML runtime.
             compilationProperties.setProperty(CompilationEnvironment.RUNTIME_PROPERTY, "dhtml");
             compilationProperties.setProperty(CompilationEnvironment.PROXIED_PROPERTY, "false");
+            // Forces compiler to copy any external resources into an app subdirectory named lps/resources
+            compilationProperties.setProperty(CompilationEnvironment.COPY_RESOURCES_LOCAL, "true");
             org.openlaszlo.compiler.Compiler compiler = new org.openlaszlo.compiler.Compiler();
 
             //FIXME: this may create temp file anywhere
@@ -291,31 +293,6 @@
             // track how big the file is, check that we don't write more than some limit
             int contentSize = 0;
 
-            // Now make copies of all resources which live external to the app's home directory.
-            // Look for <resolve> tags in stats:
-            // <canvas>
-            //  <stats>
-            //   <resolve src="xxxx.png" pathname="c:\foo\bar\realpath.png"/>
-
-            Element stats = getChild(canvasElt, "stats");
-            NodeList elts = stats.getElementsByTagName("resolve");
-            for (int i=0; i < elts.getLength(); i++) {
-                Element res = (Element)elts.item(i);
-                String src = res.getAttribute("src");
-                String pathname = res.getAttribute("pathname");
-                String relativePathname = pathname.substring(basedir.getAbsolutePath().length() + 1);
-                String zip_pathname = "lps/resources/"+relativePathname;
-                if (zippedfiles.contains(zip_pathname)) { continue; }
-                // compare the pathname that the resource resolved to with the app directory path 
-                if (pathname.startsWith(appdir.getAbsolutePath())) {
-                    // It's under the app directory, ignore, we copied it already in the appfiles
-                    // code above.
-                } else {
-                    // Copy the resource file into lps/resources/serverroot-relative-pathname
-                    copyFileToZipFile(zout, pathname, zip_pathname, zippedfiles);
-                }
-            }
-
             // Compress the app files
             for (int i=0; i<appfiles.size(); i++) {
                 String srcname = (String) appfiles.get(i);

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/utils/FileUtils.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/utils/FileUtils.java	2009-02-11 14:21:47 UTC (rev 12821)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/utils/FileUtils.java	2009-02-11 14:28:22 UTC (rev 12822)
@@ -3,7 +3,7 @@
  * ****************************************************************************/
 
 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
-* Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.              *
+* Copyright 2001-2009 Laszlo Systems, Inc.  All Rights Reserved.              *
 * Use is subject to license terms.                                            *
 * J_LZ_COPYRIGHT_END *********************************************************/
 
@@ -736,6 +736,30 @@
         }
     }
 
+    
+
+    /**
+       Find maximum common prefix of path1 and path2
+     */
+    public static String findMaxCommonPrefix(String path1, String path2) {
+        int i = 0;
+        int len1 = path1.length();
+        int len2 = path2.length();
+        while ((i < len1) && (i < len2)) {
+            if (path1.charAt(i) != path2.charAt(i)) {
+                break;
+            }
+            i++;
+        }
+        if (path1.charAt(i-1) == '/') {
+            return path1.substring(0, i-1);
+        } else {
+            return path1.substring(0, i);
+        }
+        
+    }
+
+
     /** Return a path that resolves to the same file relative to
      * dest as path does relative to source. Paths use '/' as
      * separators. source and dest are assumed to be directories. */

Modified: openlaszlo/trunk/lps/admin/solo-dhtml-deploy.jsp
===================================================================
--- openlaszlo/trunk/lps/admin/solo-dhtml-deploy.jsp	2009-02-11 14:21:47 UTC (rev 12821)
+++ openlaszlo/trunk/lps/admin/solo-dhtml-deploy.jsp	2009-02-11 14:28:22 UTC (rev 12822)
@@ -146,10 +146,10 @@
         }
 
         wrapperUrl = new URL(new URL(baseUrl),
-                             appUrl + "?lzr=dhtml&lzt=html&lzproxied=false");
+                             appUrl + "?lzr=dhtml&lzt=html&lzproxied=false&lzcopyresources=true");
 
         canvasUrl = new URL(new URL(baseUrl),
-                             appUrl + "?lzr=dhtml&lzt=canvas&lzproxied=false");
+                             appUrl + "?lzr=dhtml&lzt=canvas&lzproxied=false&lzcopyresources=true");
 
 
         // load the app's canvas descriptor from the compiler
@@ -430,31 +430,6 @@
          // track how big the file is, check that we don't write more than some limit
          int contentSize = 0;
 
-         // Now make copies of all resources which live external to the app's home directory.
-         // Look for <resolve> tags in stats:
-         // <canvas>
-         //  <stats>
-         //   <resolve src="xxxx.png" pathname="c:\foo\bar\realpath.png"/>
-
-         Element stats = getChild(canvasElt, "stats");
-         NodeList elts = stats.getElementsByTagName("resolve");
-         for (int i=0; i < elts.getLength(); i++) {
-             Element res = (Element)elts.item(i);
-             String src = res.getAttribute("src");
-             String pathname = res.getAttribute("pathname");
-             String relativePathname = pathname.substring(basedir.getAbsolutePath().length() + 1);
-             String zip_pathname = "lps/resources/"+relativePathname;
-             if (zippedfiles.contains(zip_pathname)) { continue; }
-             // compare the pathname that the resource resolved to with the app directory path 
-             if (pathname.startsWith(appdir.getAbsolutePath())) {
-                 // It's under the app directory, ignore, we copied it already in the appfiles
-                 // code above.
-             } else {
-                 // Copy the resource file into lps/resources/serverroot-relative-pathname
-                 copyFileToZipFile(zout, pathname, zip_pathname, zippedfiles);
-             }
-         }
-
          // Compress the app files
      for (int i=0; i<appfiles.size(); i++) {
          String srcname = (String) appfiles.get(i);

Modified: openlaszlo/trunk/lps/includes/source/embednew.js
===================================================================
--- openlaszlo/trunk/lps/includes/source/embednew.js	2009-02-11 14:21:47 UTC (rev 12821)
+++ openlaszlo/trunk/lps/includes/source/embednew.js	2009-02-11 14:28:22 UTC (rev 12822)
@@ -306,7 +306,7 @@
             // add lps vars to query string
             if (i == 'lzr' || i == 'lzt'
                 || i == 'debug' || i == 'profile' || i == 'lzbacktrace' || i =='lzconsoledebug'
-                || i == 'lzdebug' || i == 'lzkrank' || i == 'lzprofile'
+                || i == 'lzdebug' || i == 'lzkrank' || i == 'lzprofile' || i == 'lzcopyresources'
                 || i == 'fb' || i == 'sourcelocators' || i == '_canvas_debug'
                 || i == 'lzsourceannotations') {
                 query += i + '=' + v + '&';



More information about the Laszlo-checkins mailing list