<%
    my ($os) = @_;
    my %o = %{$cdcfg::prj->{opts}};
    $o{__tmp_plat} = $os;

sub mytoJSON
{
        my (@args) = @_;
        eval("use JSON;");
        return JSON->new->utf8->pretty(1)->encode(@args);
}

sub g #returns value of the setting
{
    my($osname,$n) = @_;
    my $k = $osname . '_nodewebkit_' . $n;
    my $v = $o{$k};
#    print STDERR "nw - kn=$n key=$k value $v\n";
    return $v;
}

sub gb #returns value of the BOOLEAN setting
{ 
    my($osname,$n) = @_;
    my $v = g($osname,$n);
    return $v ? 'true' : 'false';
}

    #see description for all keys here https://github.com/nwjs/nw.js/wiki/Manifest-format
    my $data = {
	    'name',g($os,'app_identifier'),
	    "version", "1.0",
	    "description", "",
	    "main", "../nodewebkit-start.html",
	    "single-instance", 'false', #
	    "node-remote", "<local>", #enable node in all pages served from localhost

	    'window', {
		'title',g($os,'dflt_title'),
		'width',g($os,'dflt_width'),
		'height',g($os,'dflt_height'),
		'min_width',g($os,'min_width'),
		'min_height',g($os,'min_height'),
		'max_width',g($os,'max_width'),
		'max_height',g($os,'max_height'),
		'toolbar',gb($os,'show_toolbar'),
		'resizable',gb($os,'resizable'),
		'always-on-top',gb($os,'always_on_top'),
		'fullscreen',gb($os,'fullscreen'),
		'show',gb($os,'show'),
		'kiosk',gb($os,'kiosk'),
		},
	    'webkit', {
		'plugin',gb($os,'enable_plugins'),
		'java',gb($os,'java'),
		'page-cache',gb($os,'page_cache'),
	    },
	    "platform",$os,
	    '_enable_devtools',gb($os,'enable_devtools'), #enabling devtools slows down each http transaction
    };
    if ($os eq 'w')
    {
	$data->{window}->{icon} = 'icon-windows.png';
    };
    {
	my $str = mytoJSON($data);
	$str =~ s,(width|height)" : "(\d+)",$1" : $2,mg; #convert "123" into 123 - otherwise they are not parsed as ints!
	$str =~ s,: "(true|false)",: $1,mg; #otherwise they are not parsed as bools!

	print $str;
    }
%>
