You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/04/08 21:55:01 UTC

git commit: CB-6256 CB-6266 Add support for domain whitelist and start page settings to Windows8

Repository: cordova-windows
Updated Branches:
  refs/heads/master ca106cfd9 -> c4dabc9fd


CB-6256 CB-6266 Add support for domain whitelist and start page settings to Windows8


Project: http://git-wip-us.apache.org/repos/asf/cordova-windows/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-windows/commit/c4dabc9f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-windows/tree/c4dabc9f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-windows/diff/c4dabc9f

Branch: refs/heads/master
Commit: c4dabc9fd8f177ce2e59eefc77c5a9a26eb0362b
Parents: ca106cf
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Mon Apr 7 12:59:43 2014 +0400
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Mon Apr 7 18:12:56 2014 +0400

----------------------------------------------------------------------
 .../cordova/lib/ApplyPlatformConfig.ps1         | 58 ++++++++++++++++++++
 windows8/template/cordova/lib/build.js          | 15 +++--
 2 files changed, 69 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/c4dabc9f/windows8/template/cordova/lib/ApplyPlatformConfig.ps1
----------------------------------------------------------------------
diff --git a/windows8/template/cordova/lib/ApplyPlatformConfig.ps1 b/windows8/template/cordova/lib/ApplyPlatformConfig.ps1
new file mode 100644
index 0000000..10f0e4b
--- /dev/null
+++ b/windows8/template/cordova/lib/ApplyPlatformConfig.ps1
@@ -0,0 +1,58 @@
+<#
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+#>
+
+param(
+    [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
+    [string] $platformRoot
+)
+
+$configFile = "$platformRoot\config.xml"
+$manifestFile = "$platformRoot\package.appxmanifest"
+
+[xml]$config = Get-Content $configFile
+[xml]$manifest = Get-Content $manifestFile
+
+# Replace app start page with config.xml setting.
+$startPage = $config.widget.content.src
+$manifest.Package.Applications.Application.StartPage = "www/$startpage"
+
+# Add domain whitelist rules
+$acls = [string[]]$config.widget.access.origin
+$rules = $manifest.Package.Applications.Application.ApplicationContentUriRules
+$NS = $manifest.DocumentElement.NamespaceURI
+
+# Remove existing rules from manifest
+if ($rules) { $manifest.Package.Applications.Application.RemoveChild($rules)}
+
+if ($acls -and ($acls -notcontains "*")) {
+    $rules = $manifest.CreateElement("ApplicationContentUriRules", $NS)
+    $manifest.Package.Applications.Application.AppendChild($rules)
+    $acls | foreach {
+        $elem = $manifest.CreateElement("Rule", $NS)
+        $elem.SetAttribute("Match", $_)
+        $elem.SetAttribute("Type", "include")
+        $rules.AppendChild($elem)
+    }
+}
+
+$xmlWriter = New-Object System.Xml.XmlTextWriter($manifestFile, $null)
+$xmlWriter.Formatting = "Indented"
+$xmlWriter.Indentation = 4
+$manifest.WriteContentTo($xmlWriter)
+$xmlWriter.Close()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/c4dabc9f/windows8/template/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/windows8/template/cordova/lib/build.js b/windows8/template/cordova/lib/build.js
index 77296e0..9f816ea 100644
--- a/windows8/template/cordova/lib/build.js
+++ b/windows8/template/cordova/lib/build.js
@@ -26,6 +26,8 @@ var args = WScript.Arguments;
 // working dir
 var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\build.js').join('');
 
+var PLATFORM_CONFIG_SCRIPT = "\\cordova\\lib\\ApplyPlatformConfig.ps1";
+
 // help/usage function
 function Usage() {
     Log("");
@@ -80,7 +82,7 @@ function is_cordova_project(path) {
         var proj_files = new Enumerator(proj_folder.Files);
         for (;!proj_files.atEnd(); proj_files.moveNext()) {
             if (fso.GetExtensionName(proj_files.item()) == 'jsproj') {
-                return true;  
+                return true;
             }
         }
     }
@@ -98,7 +100,7 @@ function getSolutionDir(path) {
     var proj_files = new Enumerator(proj_folder.Files);
     for (;!proj_files.atEnd(); proj_files.moveNext()) {
         if (fso.GetExtensionName(proj_files.item()) == 'sln') {
-            return path + '\\' + fso.GetFileName(proj_files.item());  
+            return path + '\\' + fso.GetFileName(proj_files.item());
         }
     }
 
@@ -115,7 +117,7 @@ function getMSBuildToolsPath(path) {
     var proj_folder = fso.GetFolder(path);
     var proj_files = new Enumerator(proj_folder.Files);
     for (;!proj_files.atEnd(); proj_files.moveNext()) {
-        if (fso.GetExtensionName(proj_files.item()) == 'jsproj' && 
+        if (fso.GetExtensionName(proj_files.item()) == 'jsproj' &&
             fso.OpenTextFile(proj_files.item(), 1).ReadAll().indexOf('ToolsVersion="12.0"') > 0) {
                 MSBuildVer = '12.0';
                 installInstructions = 'Please install Microsoft Visual Studio 2013 or later';
@@ -142,6 +144,11 @@ function build_appx(path,isRelease) {
 
     try {
         wscript_shell.CurrentDirectory = path;
+        
+        // Apply config.xml settings to package.appxmanifest
+        Log("Applying config.xml to package.appxmanifest");
+        exec_verbose('powershell -ExecutionPolicy RemoteSigned  \"Unblock-File .' + PLATFORM_CONFIG_SCRIPT + '; . .' + PLATFORM_CONFIG_SCRIPT + ' ' + path + '\"');
+
         var MSBuildToolsPath = getMSBuildToolsPath(path);
         Log("\tMSBuildToolsPath: " + MSBuildToolsPath);
         var solutionDir = getSolutionDir(path);
@@ -203,7 +210,7 @@ if (args.Count() > 0) {
         WScript.Quit(2);
     }
      
-    isRelease = (args(0) == "--release" || args(0) == "-r");   
+    isRelease = (args(0) == "--release" || args(0) == "-r");
 }
 
 Log(build_appx(ROOT,isRelease));