-
Notifications
You must be signed in to change notification settings - Fork 16
Adding WinPhone 8 platform to Confetti #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sannam
wants to merge
4
commits into
alunny:master
Choose a base branch
from
sannam:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0"> | ||
<DefaultLanguage code="en-US" xmlns="" /> | ||
<Languages xmlns=""> | ||
<Language code="en-US" /> | ||
</Languages> | ||
<App xmlns="" PublisherID="{{producerguid}}" ProductID="{{guid}}" Title="{{ title }}" | ||
RuntimeType="Silverlight" Version="{{version}}" Genre="apps.normal" | ||
Author="{{ author }}" | ||
Description="{{ description }}" | ||
Publisher="{{ author }}"> | ||
|
||
<IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath> | ||
<Capabilities> | ||
{{#capabilities}} | ||
<Capability Name="{{name}}" /> | ||
{{/capabilities}} | ||
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" /> | ||
</Capabilities> | ||
|
||
<Tasks> | ||
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" /> | ||
</Tasks> | ||
<Tokens> | ||
<PrimaryToken TokenID="Cordova_1._5._0_Starter1Token" TaskName="_default"> | ||
<TemplateType5> | ||
<BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI> | ||
<Count>0</Count> | ||
<Title>Cordova_1._5._0_Starter1</Title> | ||
</TemplateType5> | ||
</PrimaryToken> | ||
</Tokens> | ||
<ScreenResolutions> | ||
<ScreenResolution Name="ID_RESOLUTION_WVGA" /> | ||
<ScreenResolution Name="ID_RESOLUTION_WXGA" /> | ||
<ScreenResolution Name="ID_RESOLUTION_HD720P" /> | ||
</ScreenResolutions> | ||
</App> | ||
</Deployment> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
module Confetti | ||
module Template | ||
class WindowsPhone8Manifest < Base | ||
include VersionHelper | ||
|
||
GAP_PERMISSIONS_MAP = { | ||
'camera' => %w{ID_CAP_ISV_CAMERA}, | ||
'contacts' => %w{ID_CAP_CONTACTS}, | ||
'device' => %w{ID_CAP_IDENTITY_DEVICE}, | ||
'geolocation' => %w{ID_CAP_LOCATION}, | ||
'network' => %w{ID_CAP_NETWORKING}, | ||
'media' => %w{ID_CAP_MICROPHONE}, | ||
} | ||
|
||
def title | ||
@config.name.name | ||
end | ||
|
||
def author | ||
@config.author.name ? @config.author.name[0..49] : "" | ||
end | ||
|
||
def guid | ||
package = @config.package | ||
package ||= 'com.example.app' | ||
guid = Digest::MD5.hexdigest package | ||
res = "{#{ guid[0..7] }-#{ guid[8..11] }-" | ||
res << "#{ guid[12..15] }-#{ guid[16..19] }-" | ||
res << "#{ guid[20,guid.length-1]}}" | ||
end | ||
|
||
def producerguid | ||
package = @config.package | ||
package ||= 'com.example.app' | ||
package = "#{package}" + "second"; | ||
guid = Digest::MD5.hexdigest package | ||
res = "{#{ guid[0..7] }-#{ guid[8..11] }-" | ||
res << "#{ guid[12..15] }-#{ guid[16..19] }-" | ||
res << "#{ guid[20,guid.length-1]}}" | ||
end | ||
|
||
def description | ||
if @config.description && @config.description.length >= 250 | ||
"#{ @config.description[0..245] }..." | ||
else | ||
@config.description | ||
end | ||
end | ||
|
||
def version | ||
v = normalize_version(@config.version_string).split('.') | ||
|
||
# after the first one, each segment can only have one character | ||
"#{ v[0] }.#{ v[1][0..0] }.#{ v[2][0..0] }.0" | ||
end | ||
|
||
def capabilities | ||
default_permissions = %w{camera contacts device geolocation | ||
network media} | ||
permissions = [] | ||
capabilities = [] | ||
phonegap_api = /http\:\/\/api.phonegap.com\/1[.]0\/(\w+)/ | ||
filtered_features = @config.feature_set.clone | ||
|
||
filtered_features.each { |f| | ||
next if f.name.nil? | ||
matches = f.name.match(phonegap_api) | ||
next if matches.nil? or matches.length < 1 | ||
next unless GAP_PERMISSIONS_MAP.has_key?(matches[1]) | ||
permissions << matches[1] | ||
} | ||
|
||
if @config.feature_set.empty? and | ||
@config.preference(:permissions) != :none | ||
permissions = default_permissions | ||
end | ||
|
||
permissions.each { |p| | ||
capabilities.concat(GAP_PERMISSIONS_MAP[p]) | ||
} | ||
|
||
capabilities.sort! | ||
capabilities.map { |f| { :name => f } } | ||
end | ||
|
||
def output_filename | ||
"WMAppManifest.xml" | ||
end | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
require 'spec_helper' | ||
|
||
describe Confetti::Template::WindowsPhone8Manifest do | ||
include HelpfulPaths | ||
|
||
before :all do | ||
@template_class = Confetti::Template::WindowsPhone8Manifest | ||
end | ||
|
||
it "should have the base class of Confetti::Template" do | ||
@template_class.superclass.should == Confetti::Template::Base | ||
end | ||
|
||
it "should have a valid WMAppManifest mustace template" do | ||
@template_class.template_file.should == "#{ templates_dir }/windows_phone8_manifest.mustache" | ||
end | ||
|
||
describe "attributes" do | ||
subject { @template = @template_class.new } | ||
|
||
it { should respond_to :title } | ||
it { should respond_to :author } | ||
it { should respond_to :guid } | ||
it { should respond_to :description } | ||
it { should respond_to :version } | ||
it { should respond_to :capabilities } | ||
end | ||
|
||
it "should provide a 128 bit guid" do | ||
@config = Confetti::Config.new | ||
@config.package = "com.example.www" | ||
@template = @template_class.new @config | ||
@template.guid.should == "{1005a3fc-23ab-99bd-bdd1-9e83f3d7b989}" | ||
end | ||
|
||
describe "with a bad config object" do | ||
|
||
describe "on rendering" do | ||
|
||
it "should generate a dummy uuid if non provided" do | ||
@config = Confetti::Config.new | ||
@config.package = "com.example.app" | ||
@template = @template_class.new @config | ||
@template.guid.should == "{a163ec9b-9996-caee-009d-cdac1b7e0722}" | ||
end | ||
|
||
it "should not fail when a bad feature is found" do | ||
@config = Confetti::Config.new | ||
bad_feature = Confetti::Config::Feature.new( | ||
"http://api.phonegap.com/1.0/badfeature", | ||
"true" | ||
) | ||
good_feature = Confetti::Config::Feature.new( | ||
"http://api.phonegap.com/1.0/network", | ||
"true" | ||
) | ||
@config.feature_set << bad_feature | ||
@config.feature_set << good_feature | ||
@template = @template_class.new @config | ||
@template.capabilities.should == [{:name => "ID_CAP_NETWORKING"}] | ||
end | ||
end | ||
end | ||
|
||
describe "with a good config object" do | ||
|
||
describe "on rendering" do | ||
|
||
it "should render a valid wp7 manifest" do | ||
@config = Confetti::Config.new "#{fixture_dir}/config.xml" | ||
@template = @template_class.new @config | ||
@template.render.should == File.read( | ||
"#{fixture_dir}/windowsphone8/WMAppManifest.xml" | ||
) | ||
end | ||
|
||
it "should add a feature when a valid on is found" do | ||
@config = Confetti::Config.new | ||
feature = Confetti::Config::Feature.new( | ||
"http://api.phonegap.com/1.0/geolocation", | ||
"true" | ||
) | ||
@config.feature_set << feature | ||
@template = @template_class.new @config | ||
@template.capabilities.should == [{:name=>"ID_CAP_LOCATION"}] | ||
end | ||
|
||
it "should add default capabilities when none are specified" do | ||
@config = Confetti::Config.new | ||
@template = @template_class.new @config | ||
@template.capabilities.should == [ | ||
{:name => "ID_CAP_CONTACTS"}, | ||
{:name => "ID_CAP_IDENTITY_DEVICE"}, | ||
{:name => "ID_CAP_ISV_CAMERA"}, | ||
{:name => "ID_CAP_LOCATION"}, | ||
{:name => "ID_CAP_MICROPHONE"}, | ||
{:name => "ID_CAP_NETWORKING"}, | ||
] | ||
end | ||
|
||
it "should no add any capabilities when preference permissions is none" do | ||
@config = Confetti::Config.new | ||
@template = @template_class.new @config | ||
@config.preference_set << | ||
Confetti::Config::Preference.new("permissions", "none") | ||
@template.capabilities.should == [] | ||
end | ||
end | ||
end | ||
|
||
describe "should write a valid manifest file" do | ||
|
||
it "should write the file" do | ||
@config = Confetti::Config.new | ||
@config.feature_set << | ||
Confetti::Config::Feature.new( | ||
"http://plugins.phonegap.com/ChildBrowser/2.0.1", | ||
'true' | ||
) | ||
@config.feature_set << | ||
Confetti::Config::Feature.new( | ||
"http://api.phonegap.com/1.0/geolocation", | ||
'true' | ||
) | ||
@template = @template_class.new @config | ||
@template.capabilities.should == [ | ||
{:name => "ID_CAP_LOCATION"}, | ||
] | ||
lambda { @template.render }.should_not raise_error | ||
end | ||
end | ||
|
||
describe "description" do | ||
before do | ||
@config = Confetti::Config.new "#{fixture_dir}/config-long-desc.xml" | ||
@template = @template_class.new(@config) | ||
end | ||
|
||
it "should truncate the description to < 250 characters" do | ||
@template.description.length.should be < 250 | ||
end | ||
end | ||
|
||
describe "version" do | ||
before do | ||
@config = Confetti::Config.new | ||
@template = @template_class.new(@config) | ||
end | ||
|
||
it "should normalize the version to four parts" do | ||
@config.version_string = "1.0.0" | ||
@template.version.should == "1.0.0.0" | ||
end | ||
|
||
it "should ensure the non-initial numbers are one digit" do | ||
# THIS IS STUPID | ||
@config.version_string = "2012.05.20" | ||
@template.version.should == "2012.0.2.0" | ||
end | ||
|
||
it "should ensure letters are converted to numbers" do | ||
@config.version_string = "1.3.a" | ||
@template.version.should == "1.3.0.0" | ||
end | ||
end | ||
|
||
describe "author" do | ||
before do | ||
@config = Confetti::Config.new "spec/fixtures/config.xml" | ||
@template = @template_class.new(@config) | ||
end | ||
|
||
it "should return the Confetti Author name in the normal case" do | ||
@template.author.should == "Andrew Lunny" | ||
end | ||
|
||
it "should truncate the field to 50 chars or less" do | ||
me = "Andrew John Lunny, son of William and Vivian, brother of Hugo" | ||
short = "Andrew John Lunny, son of William and Vivian, brot" | ||
@config.author.name = me | ||
@template.author.should == short | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change producerguid to publisherid