flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshtynj...@apache.org
Subject [1/4] git commit: [flex-falcon] [refs/heads/develop] - compiler-jx: plucked some template HTML generation out into separate functions to allow easier overrides in subclasses
Date Wed, 05 Oct 2016 00:08:39 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop e02ae9e06 -> 936f2562b


compiler-jx: plucked some template HTML generation out into separate functions to allow easier
overrides in subclasses


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/df7e6d6d
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/df7e6d6d
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/df7e6d6d

Branch: refs/heads/develop
Commit: df7e6d6df4c7c653ad25b8abdca1e72f6d6ab5a2
Parents: e02ae9e
Author: Josh Tynjala <joshtynjala@gmail.com>
Authored: Tue Oct 4 16:22:30 2016 -0700
Committer: Josh Tynjala <joshtynjala@gmail.com>
Committed: Tue Oct 4 16:22:30 2016 -0700

----------------------------------------------------------------------
 .../mxml/flexjs/MXMLFlexJSPublisher.java        | 108 +++++++++----------
 1 file changed, 54 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/df7e6d6d/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
index e8287b3..7f8bc4c 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
@@ -599,81 +599,81 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
IJSPublisher
         if (width != null)
         	result = result.replaceAll("\\$\\{width\\}", width.toString());
         //result = result.replaceAll("\\$\\{useBrowserHistory\\}", useBrowserHistory);
-        
+
         StringBuilder addHTML = new StringBuilder();
-		for (String s : additionalHTML)
-		    addHTML.append(s).append("\n");
-		
-		if ("intermediate".equals(type))
-		{
-			addHTML.append("\t<script type=\"text/javascript\" src=\"./library/closure/goog/base.js\"></script>\n");
-			addHTML.append("\t<script type=\"text/javascript\">\n");
-			addHTML.append(deps);
-			addHTML.append("\t\tgoog.require(\"");
-			addHTML.append(projectName);
-			addHTML.append("\");\n");
-			addHTML.append("\t</script>\n");
-		}
-		else
-		{
-			addHTML.append("\t<script type=\"text/javascript\" src=\"./");
-			addHTML.append(projectName);
-			addHTML.append(".js\"></script>\n");
-		}
+        addHTML.append(getTemplateAdditionalHTML(additionalHTML));
+		addHTML.append(getTemplateDependencies(type, projectName, deps));
         result = result.replaceAll("\\$\\{head\\}", addHTML.toString());
-		
-        StringBuilder htmlFile = new StringBuilder();
-		htmlFile.append("\t<script type=\"text/javascript\">\n");
-		htmlFile.append("\t\tnew ");
-		htmlFile.append(projectName);
-		htmlFile.append("()");
-		htmlFile.append(".start();\n");
-		htmlFile.append("\t</script>\n");
 
-        result = result.replaceAll("\\$\\{body\\}", htmlFile.toString());
+        String templateBody = getTemplateBody(projectName);
+        result = result.replaceAll("\\$\\{body\\}", templateBody);
 
 		writeFile(dirPath + File.separator + ((JSGoogConfiguration) configuration).getHtmlOutputFileName(),
result, false);
 	}
 
-    protected void writeHTML(String type, String projectName, String dirPath, String deps,
List<String> additionalHTML)
-            throws IOException
+    protected String getTemplateAdditionalHTML(List<String> additionalHTML)
     {
         StringBuilder htmlFile = new StringBuilder();
-        htmlFile.append("<!DOCTYPE html>\n");
-        htmlFile.append("<html>\n");
-        htmlFile.append("<head>\n");
-        htmlFile.append("\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n");
-        htmlFile.append("\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n");
-        htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\" href=\"").append(projectName).append(".css\">\n");
-
         for (String s : additionalHTML)
+        {
             htmlFile.append(s).append("\n");
+        }
+        return htmlFile.toString();
+    }
 
+    protected String getTemplateDependencies(String type, String projectName, String deps)
+    {
+        StringBuilder depsHTML = new StringBuilder();
         if ("intermediate".equals(type))
         {
-            htmlFile.append("\t<script type=\"text/javascript\" src=\"./library/closure/goog/base.js\"></script>\n");
-            htmlFile.append("\t<script type=\"text/javascript\">\n");
-            htmlFile.append(deps);
-            htmlFile.append("\t\tgoog.require(\"");
-            htmlFile.append(projectName);
-            htmlFile.append("\");\n");
-            htmlFile.append("\t</script>\n");
+            depsHTML.append("\t<script type=\"text/javascript\" src=\"./library/closure/goog/base.js\"></script>\n");
+            depsHTML.append("\t<script type=\"text/javascript\">\n");
+            depsHTML.append(deps);
+            depsHTML.append("\t\tgoog.require(\"");
+            depsHTML.append(projectName);
+            depsHTML.append("\");\n");
+            depsHTML.append("\t</script>\n");
         }
         else
         {
-            htmlFile.append("\t<script type=\"text/javascript\" src=\"./");
-            htmlFile.append(projectName);
-            htmlFile.append(".js\"></script>\n");
+            depsHTML.append("\t<script type=\"text/javascript\" src=\"./");
+            depsHTML.append(projectName);
+            depsHTML.append(".js\"></script>\n");
         }
+        return depsHTML.toString();
+    }
+
+	protected String getTemplateBody(String projectName)
+    {
+        StringBuilder bodyHTML = new StringBuilder();
+        bodyHTML.append("\t<script type=\"text/javascript\">\n");
+        bodyHTML.append("\t\tnew ");
+        bodyHTML.append(projectName);
+        bodyHTML.append("()");
+        bodyHTML.append(".start();\n");
+        bodyHTML.append("\t</script>\n");
+        return bodyHTML.toString();
+    }
+
+    protected void writeHTML(String type, String projectName, String dirPath, String deps,
List<String> additionalHTML)
+            throws IOException
+    {
+        StringBuilder htmlFile = new StringBuilder();
+        htmlFile.append("<!DOCTYPE html>\n");
+        htmlFile.append("<html>\n");
+        htmlFile.append("<head>\n");
+        htmlFile.append("\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n");
+        htmlFile.append("\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n");
+        htmlFile.append("\t<link rel=\"stylesheet\" type=\"text/css\" href=\"").append(projectName).append(".css\">\n");
+
+        htmlFile.append(getTemplateAdditionalHTML(additionalHTML));
+        htmlFile.append(getTemplateDependencies(type, projectName, deps));
 
         htmlFile.append("</head>\n");
         htmlFile.append("<body>\n");
-        htmlFile.append("\t<script type=\"text/javascript\">\n");
-        htmlFile.append("\t\tnew ");
-        htmlFile.append(projectName);
-        htmlFile.append("()");
-        htmlFile.append(".start();\n");
-        htmlFile.append("\t</script>\n");
+
+        htmlFile.append(getTemplateBody(projectName));
+
         htmlFile.append("</body>\n");
         htmlFile.append("</html>");
 


Mime
View raw message