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/23 00:51:59 UTC

[3/3] git commit: Fix for when background-color and/or content-src aren't specified in config.xml

Fix for when background-color and/or content-src aren't specified in config.xml


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

Branch: refs/heads/master
Commit: 079ea13e6d6c3f24652571fa788c6f2b6c1a5f16
Parents: 0c3c16f
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Apr 22 15:40:11 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Apr 22 15:40:11 2014 -0700

----------------------------------------------------------------------
 .../cordova/lib/ApplyPlatformConfig.ps1         | 56 +++++++++++---------
 1 file changed, 31 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/079ea13e/windows8/template/cordova/lib/ApplyPlatformConfig.ps1
----------------------------------------------------------------------
diff --git a/windows8/template/cordova/lib/ApplyPlatformConfig.ps1 b/windows8/template/cordova/lib/ApplyPlatformConfig.ps1
index 56aa4a2..a0229b4 100644
--- a/windows8/template/cordova/lib/ApplyPlatformConfig.ps1
+++ b/windows8/template/cordova/lib/ApplyPlatformConfig.ps1
@@ -29,8 +29,10 @@ $manifestFile = "$platformRoot\package.appxmanifest"
 [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"
+if($config.widget.content -and $config.widget.content.src) {
+	$startPage = $config.widget.content.src
+	$manifest.Package.Applications.Application.StartPage = "www/$startpage"
+}
 
 # Add domain whitelist rules
 
@@ -40,7 +42,9 @@ $NS = $manifest.DocumentElement.NamespaceURI
 
 # Remove existing rules from manifest
 
-if ($rules) { $manifest.Package.Applications.Application.RemoveChild($rules)}
+if ($rules) { 
+	$manifest.Package.Applications.Application.RemoveChild($rules)
+}
 
 if ($acls -and ($acls -notcontains "*")) {
     $rules = $manifest.CreateElement("ApplicationContentUriRules", $NS)
@@ -54,31 +58,33 @@ if ($acls -and ($acls -notcontains "*")) {
 }
 
 # Format background color to windows8 format
-
 $configBgColor = [string]$config.widget.preference.value
-$bgColor = ($configBgColor -replace "0x", "") -replace "#", ""
-
-# Double all bytes if color specified as "fff"
-if ($bgColor.Length -eq 3) {
-    $bgColor = $bgColor[0] + $bgColor[0] + $bgColor[1] + $bgColor[1] + $bgColor[2] + $bgColor[2] 
+if($configBgColor.Length > 0) 
+{
+	$bgColor = ($configBgColor -replace "0x", "") -replace "#", ""
+
+	# Double all bytes if color specified as "fff"
+	if ($bgColor.Length -eq 3) {
+		$bgColor = $bgColor[0] + $bgColor[0] + $bgColor[1] + $bgColor[1] + $bgColor[2] + $bgColor[2] 
+	}
+
+	# Parse hex representation to array of color bytes [b, g, r, a]
+	$colorBytes = [System.BitConverter]::GetBytes(
+		[int]::Parse($bgColor,
+		[System.Globalization.NumberStyles]::HexNumber))
+
+	Add-Type -AssemblyName PresentationCore
+
+	# Create new Color object ignoring alpha, because windows 8 doesn't support it
+	# see http://msdn.microsoft.com/en-us/library/windows/apps/br211471.aspx
+	$color = ([System.Windows.Media.Color]::FromRgb(
+		$colorBytes[2], $colorBytes[1], $colorBytes[0]
+		# FromRGB method add 100% alpha, so we remove it from resulting string
+		).ToString()) -replace "#FF", "#"
+
+	$manifest.Package.Applications.Application.VisualElements.BackgroundColor = [string]$color
 }
 
-# Parse hex representation to array of color bytes [b, g, r, a]
-$colorBytes = [System.BitConverter]::GetBytes(
-    [int]::Parse($bgColor,
-    [System.Globalization.NumberStyles]::HexNumber))
-
-Add-Type -AssemblyName PresentationCore
-
-# Create new Color object ignoring alpha, because windows 8 doesn't support it
-# see http://msdn.microsoft.com/en-us/library/windows/apps/br211471.aspx
-$color = ([System.Windows.Media.Color]::FromRgb(
-    $colorBytes[2], $colorBytes[1], $colorBytes[0]
-    # FromRGB method add 100% alpha, so we remove it from resulting string
-    ).ToString()) -replace "#FF", "#"
-
-$manifest.Package.Applications.Application.VisualElements.BackgroundColor = [string]$color
-
 # Write modified manifest file
 $xmlWriter = New-Object System.Xml.XmlTextWriter($manifestFile, $null)
 $xmlWriter.Formatting = "Indented"