You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Axel Nennker <ig...@gmail.com> on 2014/02/28 21:34:02 UTC

get config.xml data from js

Hi,

I fear this is a stupid question but I could not find the answer in the
cordova docs or on the net or reading the source (Luke).

As an app developer and cordova user how do I get data from config.xml?

We want to add an "about" page to an cordova app and could not find a
simple javascript way to get to things like author, id, version, name or
description from config.xml.
Writing a plugin seems to be overkill. Using the file or file-transfer
plugins is heavy lifting too.

Shouldn't there be a way to write cordova.config.name to get the contents
of the name element in config.xml?

Someone added "metadata" to cordova_plugins.js.
Maybe we could add something similar to cordova.js too?

Does this make sense?

Thanks
Axel

Re: get config.xml data from js

Posted by Axel Nennker <ig...@gmail.com>.
This only effects "preference" elements. Not author, name, widget.id,
description.



2014-02-28 21:57 GMT+01:00 Michal Mocny <mm...@chromium.org>:

> David already wrote a plugin for this a few months ago for us to use in the
> test harness:
>
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
>
> I think he planned on proposing it for core but there was never really a
> reason for it.  I guess now's a good time to get that going.
>
> On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <ag...@chromium.org>
> wrote:
>
> > Certainly a reasonable thing to want to do, but there's no way currently
> > short of writing a custom plugin, or a post-prepare hook.
> >
> >
> >
> > On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <ig...@gmail.com>
> > wrote:
> >
> > > Hi,
> > >
> > > I fear this is a stupid question but I could not find the answer in the
> > > cordova docs or on the net or reading the source (Luke).
> > >
> > > As an app developer and cordova user how do I get data from config.xml?
> > >
> > > We want to add an "about" page to an cordova app and could not find a
> > > simple javascript way to get to things like author, id, version, name
> or
> > > description from config.xml.
> > > Writing a plugin seems to be overkill. Using the file or file-transfer
> > > plugins is heavy lifting too.
> > >
> > > Shouldn't there be a way to write cordova.config.name to get the
> > contents
> > > of the name element in config.xml?
> > >
> > > Someone added "metadata" to cordova_plugins.js.
> > > Maybe we could add something similar to cordova.js too?
> > >
> > > Does this make sense?
> > >
> > > Thanks
> > > Axel
> > >
> >
>

Re: get config.xml data from js

Posted by Axel Nennker <ig...@gmail.com>.
Michal: Does your plugin work for non-string preferences?
https://github.com/apache/cordova-labs/blob/cdvtest/cordova-plugin-appsettings/src/android/AppSettings.java#L22has
a getString.

BTW: When looking a the code of Config.java I was wondering why there are
all those "equalsIgnoreCase" e.g.
https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/Config.java#L118
There is a toLowerCase anyway before


2014-02-28 22:06 GMT+01:00 Michal Mocny <mm...@chromium.org>:

> Now that I look a bit deeper, that plugin I only returns <preferences>
> specifically, not the entire contents of config.xml (name is not a
> <preference>).
>
> It also does not currently implement a way to inspect all preferences, just
> has a way to get the value for a specific one.
>
> I do think it would be a good idea to just have one core plugin (perhaps
> extend that one I linked) to include all config file values.
>
> Filed: https://issues.apache.org/jira/browse/CB-6139
>
> -Michal
>
>
> On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <mm...@chromium.org> wrote:
>
> > David already wrote a plugin for this a few months ago for us to use in
> > the test harness:
> >
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
> >
> > I think he planned on proposing it for core but there was never really a
> > reason for it.  I guess now's a good time to get that going.
> >
> > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <agrieve@chromium.org
> >wrote:
> >
> >> Certainly a reasonable thing to want to do, but there's no way currently
> >> short of writing a custom plugin, or a post-prepare hook.
> >>
> >>
> >>
> >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <ig...@gmail.com>
> >> wrote:
> >>
> >> > Hi,
> >> >
> >> > I fear this is a stupid question but I could not find the answer in
> the
> >> > cordova docs or on the net or reading the source (Luke).
> >> >
> >> > As an app developer and cordova user how do I get data from
> config.xml?
> >> >
> >> > We want to add an "about" page to an cordova app and could not find a
> >> > simple javascript way to get to things like author, id, version, name
> or
> >> > description from config.xml.
> >> > Writing a plugin seems to be overkill. Using the file or file-transfer
> >> > plugins is heavy lifting too.
> >> >
> >> > Shouldn't there be a way to write cordova.config.name to get the
> >> contents
> >> > of the name element in config.xml?
> >> >
> >> > Someone added "metadata" to cordova_plugins.js.
> >> > Maybe we could add something similar to cordova.js too?
> >> >
> >> > Does this make sense?
> >> >
> >> > Thanks
> >> > Axel
> >> >
> >>
> >
> >
>

Re: get config.xml data from js

Posted by Michal Mocny <mm...@chromium.org>.
Absolutely, we should implement in JS if possible, but it would still be
nice if all core (and 3rdparty) plugins could shar the same snippet of
code, shared caching etc, and I think a core plugin is the way to go at the
moment.

-Michal


On Fri, Feb 28, 2014 at 5:16 PM, Jesse <pu...@gmail.com> wrote:

> So I guess things are not as standardized as we thought.
>
> iOS, WP7, WP8, Windows8, Ubuntu?[1] :
> ../config.xml
> Android :
> ../../android_res/xml/config.xml
> bb10 :
> config.xml
>
>
> [1]
>
> https://github.com/apache/cordova-ubuntu/blob/cd6b3d11b58f38932797f1f4130ce40f772bdcd5/main.cpp#L66
>
> Still completely manageable from JavaScript; IMHO
> just switch on cordova.platformId ...
>
> @purplecabbage
> risingj.com
>
>
> On Fri, Feb 28, 2014 at 2:06 PM, Axel Nennker <ig...@gmail.com>
> wrote:
>
> > Looks better than it works.
> > This does not trigger the alert. Neither with two / or three / after
> > "file:"
> > while "config.xml" alone works after I have put config.xml in www
> >
> >                                 document.addEventListener( "deviceready",
> > function() {
> > function readConfig() {
> >     var xhr = new XMLHttpRequest();
> >     xhr.addEventListener("load", function () {
> >         var parser = new DOMParser();
> >         var doc = parser.parseFromString(xhr.responseText,
> > "application/xml");
> >         alert("Description : " +
> > doc.getElementsByTagName("description").item(0).textContent);
> >     });
> >     xhr.open("get", "file:///android_res/xml/config.xml", true);
> >     xhr.send();
> > }
> > readConfig();
> >
> > Anyway this is not very cross platform.
> >
> >
> >
> > 2014-02-28 22:57 GMT+01:00 Joe Bowser <bo...@gmail.com>:
> >
> > > BTW: android_res and android_assets are special Android URIs that
> > > access the APK directly.  They are read-only directories, and they
> > > basically are used to access static files.  They also tend to be buggy
> > > as all hell, so YMMV.
> > >
> > > On Fri, Feb 28, 2014 at 1:54 PM, Joe Bowser <bo...@gmail.com> wrote:
> > > > Can't you just use an XHR to this URI:
> > > > file://android_res/xml/config.xml?
> > > >
> > > >
> > > >
> > > > On Fri, Feb 28, 2014 at 1:48 PM, Jesse <pu...@gmail.com>
> > wrote:
> > > >> They seem to be in the root iOS, android, and windows phone.
> > > >>
> > > >> NSString* path = [[NSBundle mainBundle] pathForResource:@"config"
> > > ofType:
> > > >> @"xml"];
> > > >>
> > > >> int id = action.getResources().getIdentifier("config", "xml",
> action.
> > > >> getClass().getPackage().getName());
> > > >>
> > > >> *StreamResourceInfo streamInfo = Application.GetResourceStream(new
> > > >> Uri("config.xml", UriKind.Relative));*
> > > >>
> > > >>
> > > >>
> > > >> @purplecabbage
> > > >> risingj.com
> > > >>
> > > >>
> > > >> On Fri, Feb 28, 2014 at 1:21 PM, Andrew Grieve <
> agrieve@chromium.org>
> > > wrote:
> > > >>
> > > >>> config.xml isn't in the www/ on all platforms.
> > > >>>
> > > >>>
> > > >>> On Fri, Feb 28, 2014 at 4:15 PM, Jesse <pu...@gmail.com>
> > > wrote:
> > > >>>
> > > >>> > function readConfig() {
> > > >>> >     var xhr = new XMLHttpRequest();
> > > >>> >     xhr.addEventListener("load", function () {
> > > >>> >         var parser = new DOMParser();
> > > >>> >         var doc = parser.parseFromString(xhr.responseText,
> > > >>> > "application/xml");
> > > >>> >         alert("Description : " +
> > > >>> > doc.getElementsByTagName("description").item(0).textContent);
> > > >>> >     });
> > > >>> >     xhr.open("get", "../config.xml", true);
> > > >>> >     xhr.send();
> > > >>> > }
> > > >>> >
> > > >>> > @purplecabbage
> > > >>> > risingj.com
> > > >>> >
> > > >>> >
> > > >>> > On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <
> mmocny@chromium.org
> > >
> > > >>> wrote:
> > > >>> >
> > > >>> > > Now that I look a bit deeper, that plugin I only returns
> > > <preferences>
> > > >>> > > specifically, not the entire contents of config.xml (name is
> not
> > a
> > > >>> > > <preference>).
> > > >>> > >
> > > >>> > > It also does not currently implement a way to inspect all
> > > preferences,
> > > >>> > just
> > > >>> > > has a way to get the value for a specific one.
> > > >>> > >
> > > >>> > > I do think it would be a good idea to just have one core plugin
> > > >>> (perhaps
> > > >>> > > extend that one I linked) to include all config file values.
> > > >>> > >
> > > >>> > > Filed: https://issues.apache.org/jira/browse/CB-6139
> > > >>> > >
> > > >>> > > -Michal
> > > >>> > >
> > > >>> > >
> > > >>> > > On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <
> > mmocny@chromium.org
> > > >
> > > >>> > wrote:
> > > >>> > >
> > > >>> > > > David already wrote a plugin for this a few months ago for us
> > to
> > > use
> > > >>> in
> > > >>> > > > the test harness:
> > > >>> > > >
> > > >>> > >
> > > >>> >
> > > >>>
> > >
> >
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
> > > >>> > > >
> > > >>> > > > I think he planned on proposing it for core but there was
> never
> > > >>> really
> > > >>> > a
> > > >>> > > > reason for it.  I guess now's a good time to get that going.
> > > >>> > > >
> > > >>> > > > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <
> > > agrieve@chromium.org
> > > >>> > > >wrote:
> > > >>> > > >
> > > >>> > > >> Certainly a reasonable thing to want to do, but there's no
> way
> > > >>> > currently
> > > >>> > > >> short of writing a custom plugin, or a post-prepare hook.
> > > >>> > > >>
> > > >>> > > >>
> > > >>> > > >>
> > > >>> > > >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <
> > > >>> ignisvulpis@gmail.com>
> > > >>> > > >> wrote:
> > > >>> > > >>
> > > >>> > > >> > Hi,
> > > >>> > > >> >
> > > >>> > > >> > I fear this is a stupid question but I could not find the
> > > answer
> > > >>> in
> > > >>> > > the
> > > >>> > > >> > cordova docs or on the net or reading the source (Luke).
> > > >>> > > >> >
> > > >>> > > >> > As an app developer and cordova user how do I get data
> from
> > > >>> > > config.xml?
> > > >>> > > >> >
> > > >>> > > >> > We want to add an "about" page to an cordova app and could
> > not
> > > >>> find
> > > >>> > a
> > > >>> > > >> > simple javascript way to get to things like author, id,
> > > version,
> > > >>> > name
> > > >>> > > or
> > > >>> > > >> > description from config.xml.
> > > >>> > > >> > Writing a plugin seems to be overkill. Using the file or
> > > >>> > file-transfer
> > > >>> > > >> > plugins is heavy lifting too.
> > > >>> > > >> >
> > > >>> > > >> > Shouldn't there be a way to write cordova.config.name to
> > get
> > > the
> > > >>> > > >> contents
> > > >>> > > >> > of the name element in config.xml?
> > > >>> > > >> >
> > > >>> > > >> > Someone added "metadata" to cordova_plugins.js.
> > > >>> > > >> > Maybe we could add something similar to cordova.js too?
> > > >>> > > >> >
> > > >>> > > >> > Does this make sense?
> > > >>> > > >> >
> > > >>> > > >> > Thanks
> > > >>> > > >> > Axel
> > > >>> > > >> >
> > > >>> > > >>
> > > >>> > > >
> > > >>> > > >
> > > >>> > >
> > > >>> >
> > > >>>
> > >
> >
>

Re: get config.xml data from js

Posted by Axel Nennker <ig...@gmail.com>.
I think is is either
file:///android_res/config.xml or "../../res/config.xml.

I am not sure why there is a config.xml in a FirefoxOS app anyway.
Cordova creates a manifest.webapp from the project's config.xml
Probably a relict to copy that to the app's root directory.

I think readConfig on FirefoxOS should use manifest.webapp.
Although I do not know how <preference> elements from config.xml are
treated on FirefoxOS...

-Axel



Am 01.03.2014 02:58, schrieb Andrew Grieve:
> Didn't know about android_res/ neat!
> 
> 
> On Fri, Feb 28, 2014 at 6:27 PM, Jesse <pu...@gmail.com> wrote:
> 
>> Yes, but then we have to agree on the format of config.json, which could
>> take weeks.
>>
>> Something like this [1] should handle it.  Untested ...
>>
>>
>> [1] https://gist.github.com/purplecabbage/9282132
>>
>>
>>
>> @purplecabbage
>> risingj.com
>>
>>
>> On Fri, Feb 28, 2014 at 3:14 PM, Brian LeRoux <b...@brian.io> wrote:
>>
>>> So, before we go too much farther with this...what is the usecase? Could
>> a
>>> build step hook address the idea? (Eg write a file called config.json)
>>>
>>>
>>> On Fri, Feb 28, 2014 at 2:57 PM, Axel Nennker <ig...@gmail.com>
>>> wrote:
>>>
>>>> cordova.js is platform specific anyway.
>>>>  Am 28.02.2014 23:16 schrieb "Jesse" <pu...@gmail.com>:
>>>>
>>>>> So I guess things are not as standardized as we thought.
>>>>>
>>>>> iOS, WP7, WP8, Windows8, Ubuntu?[1] :
>>>>> ../config.xml
>>>>> Android :
>>>>> ../../android_res/xml/config.xml
>>>>> bb10 :
>>>>> config.xml
>>>>>
>>>>>
>>>>> [1]
>>>>>
>>>>>
>>>>
>>>
>> https://github.com/apache/cordova-ubuntu/blob/cd6b3d11b58f38932797f1f4130ce40f772bdcd5/main.cpp#L66
>>>>>
>>>>> Still completely manageable from JavaScript; IMHO
>>>>> just switch on cordova.platformId ...
>>>>>
>>>>> @purplecabbage
>>>>> risingj.com
>>>>>
>>>>>
>>>>> On Fri, Feb 28, 2014 at 2:06 PM, Axel Nennker <ignisvulpis@gmail.com
>>>
>>>>> wrote:
>>>>>
>>>>>> Looks better than it works.
>>>>>> This does not trigger the alert. Neither with two / or three /
>> after
>>>>>> "file:"
>>>>>> while "config.xml" alone works after I have put config.xml in www
>>>>>>
>>>>>>                                 document.addEventListener(
>>>> "deviceready",
>>>>>> function() {
>>>>>> function readConfig() {
>>>>>>     var xhr = new XMLHttpRequest();
>>>>>>     xhr.addEventListener("load", function () {
>>>>>>         var parser = new DOMParser();
>>>>>>         var doc = parser.parseFromString(xhr.responseText,
>>>>>> "application/xml");
>>>>>>         alert("Description : " +
>>>>>> doc.getElementsByTagName("description").item(0).textContent);
>>>>>>     });
>>>>>>     xhr.open("get", "file:///android_res/xml/config.xml", true);
>>>>>>     xhr.send();
>>>>>> }
>>>>>> readConfig();
>>>>>>
>>>>>> Anyway this is not very cross platform.
>>>>>>
>>>>>>
>>>>>>
>>>>>> 2014-02-28 22:57 GMT+01:00 Joe Bowser <bo...@gmail.com>:
>>>>>>
>>>>>>> BTW: android_res and android_assets are special Android URIs that
>>>>>>> access the APK directly.  They are read-only directories, and
>> they
>>>>>>> basically are used to access static files.  They also tend to be
>>>> buggy
>>>>>>> as all hell, so YMMV.
>>>>>>>
>>>>>>> On Fri, Feb 28, 2014 at 1:54 PM, Joe Bowser <bo...@gmail.com>
>>>> wrote:
>>>>>>>> Can't you just use an XHR to this URI:
>>>>>>>> file://android_res/xml/config.xml?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Fri, Feb 28, 2014 at 1:48 PM, Jesse <
>> purplecabbage@gmail.com>
>>>>>> wrote:
>>>>>>>>> They seem to be in the root iOS, android, and windows phone.
>>>>>>>>>
>>>>>>>>> NSString* path = [[NSBundle mainBundle] pathForResource:@
>>> "config"
>>>>>>> ofType:
>>>>>>>>> @"xml"];
>>>>>>>>>
>>>>>>>>> int id = action.getResources().getIdentifier("config", "xml",
>>>>> action.
>>>>>>>>> getClass().getPackage().getName());
>>>>>>>>>
>>>>>>>>> *StreamResourceInfo streamInfo =
>>> Application.GetResourceStream(new
>>>>>>>>> Uri("config.xml", UriKind.Relative));*
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> @purplecabbage
>>>>>>>>> risingj.com
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Fri, Feb 28, 2014 at 1:21 PM, Andrew Grieve <
>>>>> agrieve@chromium.org>
>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> config.xml isn't in the www/ on all platforms.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Fri, Feb 28, 2014 at 4:15 PM, Jesse <
>>> purplecabbage@gmail.com>
>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>> function readConfig() {
>>>>>>>>>>>     var xhr = new XMLHttpRequest();
>>>>>>>>>>>     xhr.addEventListener("load", function () {
>>>>>>>>>>>         var parser = new DOMParser();
>>>>>>>>>>>         var doc = parser.parseFromString(xhr.responseText,
>>>>>>>>>>> "application/xml");
>>>>>>>>>>>         alert("Description : " +
>>>>>>>>>>>
>> doc.getElementsByTagName("description").item(0).textContent);
>>>>>>>>>>>     });
>>>>>>>>>>>     xhr.open("get", "../config.xml", true);
>>>>>>>>>>>     xhr.send();
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> @purplecabbage
>>>>>>>>>>> risingj.com
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <
>>>>> mmocny@chromium.org
>>>>>>>
>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Now that I look a bit deeper, that plugin I only returns
>>>>>>> <preferences>
>>>>>>>>>>>> specifically, not the entire contents of config.xml (name
>>> is
>>>>> not
>>>>>> a
>>>>>>>>>>>> <preference>).
>>>>>>>>>>>>
>>>>>>>>>>>> It also does not currently implement a way to inspect all
>>>>>>> preferences,
>>>>>>>>>>> just
>>>>>>>>>>>> has a way to get the value for a specific one.
>>>>>>>>>>>>
>>>>>>>>>>>> I do think it would be a good idea to just have one core
>>>> plugin
>>>>>>>>>> (perhaps
>>>>>>>>>>>> extend that one I linked) to include all config file
>>> values.
>>>>>>>>>>>>
>>>>>>>>>>>> Filed: https://issues.apache.org/jira/browse/CB-6139
>>>>>>>>>>>>
>>>>>>>>>>>> -Michal
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <
>>>>>> mmocny@chromium.org
>>>>>>>>
>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> David already wrote a plugin for this a few months ago
>>> for
>>>> us
>>>>>> to
>>>>>>> use
>>>>>>>>>> in
>>>>>>>>>>>>> the test harness:
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
>>>>>>>>>>>>>
>>>>>>>>>>>>> I think he planned on proposing it for core but there
>> was
>>>>> never
>>>>>>>>>> really
>>>>>>>>>>> a
>>>>>>>>>>>>> reason for it.  I guess now's a good time to get that
>>>> going.
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <
>>>>>>> agrieve@chromium.org
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Certainly a reasonable thing to want to do, but
>> there's
>>> no
>>>>> way
>>>>>>>>>>> currently
>>>>>>>>>>>>>> short of writing a custom plugin, or a post-prepare
>>> hook.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <
>>>>>>>>>> ignisvulpis@gmail.com>
>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I fear this is a stupid question but I could not
>> find
>>>> the
>>>>>>> answer
>>>>>>>>>> in
>>>>>>>>>>>> the
>>>>>>>>>>>>>>> cordova docs or on the net or reading the source
>>> (Luke).
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> As an app developer and cordova user how do I get
>> data
>>>>> from
>>>>>>>>>>>> config.xml?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> We want to add an "about" page to an cordova app and
>>>> could
>>>>>> not
>>>>>>>>>> find
>>>>>>>>>>> a
>>>>>>>>>>>>>>> simple javascript way to get to things like author,
>>> id,
>>>>>>> version,
>>>>>>>>>>> name
>>>>>>>>>>>> or
>>>>>>>>>>>>>>> description from config.xml.
>>>>>>>>>>>>>>> Writing a plugin seems to be overkill. Using the
>> file
>>> or
>>>>>>>>>>> file-transfer
>>>>>>>>>>>>>>> plugins is heavy lifting too.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Shouldn't there be a way to write
>>> cordova.config.nameto
>>>>>> get
>>>>>>> the
>>>>>>>>>>>>>> contents
>>>>>>>>>>>>>>> of the name element in config.xml?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Someone added "metadata" to cordova_plugins.js.
>>>>>>>>>>>>>>> Maybe we could add something similar to cordova.js
>>> too?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Does this make sense?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thanks
>>>>>>>>>>>>>>> Axel
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
> 

Re: get config.xml data from js

Posted by Andrew Grieve <ag...@chromium.org>.
Didn't know about android_res/ neat!


On Fri, Feb 28, 2014 at 6:27 PM, Jesse <pu...@gmail.com> wrote:

> Yes, but then we have to agree on the format of config.json, which could
> take weeks.
>
> Something like this [1] should handle it.  Untested ...
>
>
> [1] https://gist.github.com/purplecabbage/9282132
>
>
>
> @purplecabbage
> risingj.com
>
>
> On Fri, Feb 28, 2014 at 3:14 PM, Brian LeRoux <b...@brian.io> wrote:
>
> > So, before we go too much farther with this...what is the usecase? Could
> a
> > build step hook address the idea? (Eg write a file called config.json)
> >
> >
> > On Fri, Feb 28, 2014 at 2:57 PM, Axel Nennker <ig...@gmail.com>
> > wrote:
> >
> > > cordova.js is platform specific anyway.
> > >  Am 28.02.2014 23:16 schrieb "Jesse" <pu...@gmail.com>:
> > >
> > > > So I guess things are not as standardized as we thought.
> > > >
> > > > iOS, WP7, WP8, Windows8, Ubuntu?[1] :
> > > > ../config.xml
> > > > Android :
> > > > ../../android_res/xml/config.xml
> > > > bb10 :
> > > > config.xml
> > > >
> > > >
> > > > [1]
> > > >
> > > >
> > >
> >
> https://github.com/apache/cordova-ubuntu/blob/cd6b3d11b58f38932797f1f4130ce40f772bdcd5/main.cpp#L66
> > > >
> > > > Still completely manageable from JavaScript; IMHO
> > > > just switch on cordova.platformId ...
> > > >
> > > > @purplecabbage
> > > > risingj.com
> > > >
> > > >
> > > > On Fri, Feb 28, 2014 at 2:06 PM, Axel Nennker <ignisvulpis@gmail.com
> >
> > > > wrote:
> > > >
> > > > > Looks better than it works.
> > > > > This does not trigger the alert. Neither with two / or three /
> after
> > > > > "file:"
> > > > > while "config.xml" alone works after I have put config.xml in www
> > > > >
> > > > >                                 document.addEventListener(
> > > "deviceready",
> > > > > function() {
> > > > > function readConfig() {
> > > > >     var xhr = new XMLHttpRequest();
> > > > >     xhr.addEventListener("load", function () {
> > > > >         var parser = new DOMParser();
> > > > >         var doc = parser.parseFromString(xhr.responseText,
> > > > > "application/xml");
> > > > >         alert("Description : " +
> > > > > doc.getElementsByTagName("description").item(0).textContent);
> > > > >     });
> > > > >     xhr.open("get", "file:///android_res/xml/config.xml", true);
> > > > >     xhr.send();
> > > > > }
> > > > > readConfig();
> > > > >
> > > > > Anyway this is not very cross platform.
> > > > >
> > > > >
> > > > >
> > > > > 2014-02-28 22:57 GMT+01:00 Joe Bowser <bo...@gmail.com>:
> > > > >
> > > > > > BTW: android_res and android_assets are special Android URIs that
> > > > > > access the APK directly.  They are read-only directories, and
> they
> > > > > > basically are used to access static files.  They also tend to be
> > > buggy
> > > > > > as all hell, so YMMV.
> > > > > >
> > > > > > On Fri, Feb 28, 2014 at 1:54 PM, Joe Bowser <bo...@gmail.com>
> > > wrote:
> > > > > > > Can't you just use an XHR to this URI:
> > > > > > > file://android_res/xml/config.xml?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On Fri, Feb 28, 2014 at 1:48 PM, Jesse <
> purplecabbage@gmail.com>
> > > > > wrote:
> > > > > > >> They seem to be in the root iOS, android, and windows phone.
> > > > > > >>
> > > > > > >> NSString* path = [[NSBundle mainBundle] pathForResource:@
> > "config"
> > > > > > ofType:
> > > > > > >> @"xml"];
> > > > > > >>
> > > > > > >> int id = action.getResources().getIdentifier("config", "xml",
> > > > action.
> > > > > > >> getClass().getPackage().getName());
> > > > > > >>
> > > > > > >> *StreamResourceInfo streamInfo =
> > Application.GetResourceStream(new
> > > > > > >> Uri("config.xml", UriKind.Relative));*
> > > > > > >>
> > > > > > >>
> > > > > > >>
> > > > > > >> @purplecabbage
> > > > > > >> risingj.com
> > > > > > >>
> > > > > > >>
> > > > > > >> On Fri, Feb 28, 2014 at 1:21 PM, Andrew Grieve <
> > > > agrieve@chromium.org>
> > > > > > wrote:
> > > > > > >>
> > > > > > >>> config.xml isn't in the www/ on all platforms.
> > > > > > >>>
> > > > > > >>>
> > > > > > >>> On Fri, Feb 28, 2014 at 4:15 PM, Jesse <
> > purplecabbage@gmail.com>
> > > > > > wrote:
> > > > > > >>>
> > > > > > >>> > function readConfig() {
> > > > > > >>> >     var xhr = new XMLHttpRequest();
> > > > > > >>> >     xhr.addEventListener("load", function () {
> > > > > > >>> >         var parser = new DOMParser();
> > > > > > >>> >         var doc = parser.parseFromString(xhr.responseText,
> > > > > > >>> > "application/xml");
> > > > > > >>> >         alert("Description : " +
> > > > > > >>> >
> doc.getElementsByTagName("description").item(0).textContent);
> > > > > > >>> >     });
> > > > > > >>> >     xhr.open("get", "../config.xml", true);
> > > > > > >>> >     xhr.send();
> > > > > > >>> > }
> > > > > > >>> >
> > > > > > >>> > @purplecabbage
> > > > > > >>> > risingj.com
> > > > > > >>> >
> > > > > > >>> >
> > > > > > >>> > On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <
> > > > mmocny@chromium.org
> > > > > >
> > > > > > >>> wrote:
> > > > > > >>> >
> > > > > > >>> > > Now that I look a bit deeper, that plugin I only returns
> > > > > > <preferences>
> > > > > > >>> > > specifically, not the entire contents of config.xml (name
> > is
> > > > not
> > > > > a
> > > > > > >>> > > <preference>).
> > > > > > >>> > >
> > > > > > >>> > > It also does not currently implement a way to inspect all
> > > > > > preferences,
> > > > > > >>> > just
> > > > > > >>> > > has a way to get the value for a specific one.
> > > > > > >>> > >
> > > > > > >>> > > I do think it would be a good idea to just have one core
> > > plugin
> > > > > > >>> (perhaps
> > > > > > >>> > > extend that one I linked) to include all config file
> > values.
> > > > > > >>> > >
> > > > > > >>> > > Filed: https://issues.apache.org/jira/browse/CB-6139
> > > > > > >>> > >
> > > > > > >>> > > -Michal
> > > > > > >>> > >
> > > > > > >>> > >
> > > > > > >>> > > On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <
> > > > > mmocny@chromium.org
> > > > > > >
> > > > > > >>> > wrote:
> > > > > > >>> > >
> > > > > > >>> > > > David already wrote a plugin for this a few months ago
> > for
> > > us
> > > > > to
> > > > > > use
> > > > > > >>> in
> > > > > > >>> > > > the test harness:
> > > > > > >>> > > >
> > > > > > >>> > >
> > > > > > >>> >
> > > > > > >>>
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
> > > > > > >>> > > >
> > > > > > >>> > > > I think he planned on proposing it for core but there
> was
> > > > never
> > > > > > >>> really
> > > > > > >>> > a
> > > > > > >>> > > > reason for it.  I guess now's a good time to get that
> > > going.
> > > > > > >>> > > >
> > > > > > >>> > > > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <
> > > > > > agrieve@chromium.org
> > > > > > >>> > > >wrote:
> > > > > > >>> > > >
> > > > > > >>> > > >> Certainly a reasonable thing to want to do, but
> there's
> > no
> > > > way
> > > > > > >>> > currently
> > > > > > >>> > > >> short of writing a custom plugin, or a post-prepare
> > hook.
> > > > > > >>> > > >>
> > > > > > >>> > > >>
> > > > > > >>> > > >>
> > > > > > >>> > > >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <
> > > > > > >>> ignisvulpis@gmail.com>
> > > > > > >>> > > >> wrote:
> > > > > > >>> > > >>
> > > > > > >>> > > >> > Hi,
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > I fear this is a stupid question but I could not
> find
> > > the
> > > > > > answer
> > > > > > >>> in
> > > > > > >>> > > the
> > > > > > >>> > > >> > cordova docs or on the net or reading the source
> > (Luke).
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > As an app developer and cordova user how do I get
> data
> > > > from
> > > > > > >>> > > config.xml?
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > We want to add an "about" page to an cordova app and
> > > could
> > > > > not
> > > > > > >>> find
> > > > > > >>> > a
> > > > > > >>> > > >> > simple javascript way to get to things like author,
> > id,
> > > > > > version,
> > > > > > >>> > name
> > > > > > >>> > > or
> > > > > > >>> > > >> > description from config.xml.
> > > > > > >>> > > >> > Writing a plugin seems to be overkill. Using the
> file
> > or
> > > > > > >>> > file-transfer
> > > > > > >>> > > >> > plugins is heavy lifting too.
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > Shouldn't there be a way to write
> > cordova.config.nameto
> > > > > get
> > > > > > the
> > > > > > >>> > > >> contents
> > > > > > >>> > > >> > of the name element in config.xml?
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > Someone added "metadata" to cordova_plugins.js.
> > > > > > >>> > > >> > Maybe we could add something similar to cordova.js
> > too?
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > Does this make sense?
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > Thanks
> > > > > > >>> > > >> > Axel
> > > > > > >>> > > >> >
> > > > > > >>> > > >>
> > > > > > >>> > > >
> > > > > > >>> > > >
> > > > > > >>> > >
> > > > > > >>> >
> > > > > > >>>
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: get config.xml data from js

Posted by Michal Mocny <mm...@chromium.org>.
On Tue, Mar 4, 2014 at 2:32 AM, Axel Nennker <ig...@gmail.com> wrote:

> Just found this: chrome.runtime (Stable since Chrome 22.)
> http://developer.chrome.com/extensions/runtime#method-getManifest
>
> getManifest
>  object chrome.runtime.getManifest()
>

Obligatory:
https://github.com/MobileChromeApps/mobile-chrome-apps/blob/master/chrome-cordova/plugins/chrome-runtime/api/runtime.js#L46

For cca apps, we aren't at the moment moving any of the cordova
<preference>s into the chrome manifest (we are considering it), but the
canonical source for name/version/description etc is the chrome manifest,
so those values are available at runtime for cca apps.

Having access to certain manifest settings from JS is quite useful to apps
and for our plugins, such as getting client_id and oauth scopes for the
identity plugin which has one implementation entirely in js (etc).


> Returns details about the app or extension from the manifest. The object
> returned is a serialization of the full manifest
> file<http://developer.chrome.com/extensions/manifest.html>.
>
> Returns
> The manifest details.
>
> There seems to be some need for meta/runtime information about an app but
> not standard way to access it...
>
> What is the W3C way to get such information?
>
> -Axel
>
>
>
> 2014-03-03 21:24 GMT+01:00 Jonathan Bond-Caron <jb...@gdesolutions.com>:
>
> > On Mon Mar 3 12:45 PM, Brian LeRoux wrote:
> > > sure, but that is most certainly a user space instrumentation and done
> > > very easily
> > > with a hook
> > >
> > > do ALL apps need that instrumentation? probably not
> > >
> >
> > Fair enough, don't have a strong opinion about it.
> >
> > Is the list of installed plugins & versions in cordova_plugins.js more
> > 'core' ?
> >
> >
> >
> >
> >
>

Re: get config.xml data from js

Posted by Axel Nennker <ig...@gmail.com>.
Just found this: chrome.runtime (Stable since Chrome 22.)
http://developer.chrome.com/extensions/runtime#method-getManifest

getManifest
 object chrome.runtime.getManifest()

Returns details about the app or extension from the manifest. The object
returned is a serialization of the full manifest
file<http://developer.chrome.com/extensions/manifest.html>.

Returns
The manifest details.

There seems to be some need for meta/runtime information about an app but
not standard way to access it...

What is the W3C way to get such information?

-Axel



2014-03-03 21:24 GMT+01:00 Jonathan Bond-Caron <jb...@gdesolutions.com>:

> On Mon Mar 3 12:45 PM, Brian LeRoux wrote:
> > sure, but that is most certainly a user space instrumentation and done
> > very easily
> > with a hook
> >
> > do ALL apps need that instrumentation? probably not
> >
>
> Fair enough, don't have a strong opinion about it.
>
> Is the list of installed plugins & versions in cordova_plugins.js more
> 'core' ?
>
>
>
>
>

RE: get config.xml data from js

Posted by Jonathan Bond-Caron <jb...@gdesolutions.com>.
On Mon Mar 3 12:45 PM, Brian LeRoux wrote:
> sure, but that is most certainly a user space instrumentation and done
> very easily
> with a hook
> 
> do ALL apps need that instrumentation? probably not
> 

Fair enough, don't have a strong opinion about it. 

Is the list of installed plugins & versions in cordova_plugins.js more 'core' ?





Re: get config.xml data from js

Posted by Brian LeRoux <b...@brian.io>.
sure, but that is most certainly a user space instrumentation and done very
easily with a hook

do ALL apps need that instrumentation? probably not


On Mon, Mar 3, 2014 at 7:35 AM, Jonathan Bond-Caron <jbondc@gdesolutions.com
> wrote:

> On Sat Mar 1 02:19 PM, Brian LeRoux wrote:
> > No, no, I'm suggesting this is a user space problem. Easily solved by
> > the user.
> > (Certainly the first/only time I've heard a desire for this
> > feature.)
>
> Here's a very common use case:
>
> - error occurs
> - send application info to a central server
>   Usually here you need app name, version and other config params (e.g.
> android hardware acceleration)
>
> Seems like a core kind of thing not something users should figure out.
>
> You probably don't need to expose all the configuration params in the
> webview, but a couple of them are useful.
>
>

RE: get config.xml data from js

Posted by Jonathan Bond-Caron <jb...@gdesolutions.com>.
On Sat Mar 1 02:19 PM, Brian LeRoux wrote:
> No, no, I'm suggesting this is a user space problem. Easily solved by
> the user.
> (Certainly the first/only time I've heard a desire for this
> feature.) 

Here's a very common use case:

- error occurs
- send application info to a central server
  Usually here you need app name, version and other config params (e.g. android hardware acceleration)

Seems like a core kind of thing not something users should figure out.

You probably don't need to expose all the configuration params in the webview, but a couple of them are useful.


Re: get config.xml data from js

Posted by Ken Wallis <kw...@blackberry.com>.
‎We have had a couple of requests around this for BlackBerry. Particularly in the scenario where it is in combination with a custom solution/environment that puts custom tags into the config. In the case I remember the dev made changes to our app plugin [1] to expose arbitrary elements in the config.

It doesn't happen often, but for every one that we hear about, I am sure there are a few more that we don't.

[1] ‎http://plugins.cordova.io/#/com.blackberry.app

Sent from my BlackBerry 10 smartphone.
  Original Message
From: Brian LeRoux
Sent: Saturday, March 1, 2014 11:20 AM
To: dev@cordova.apache.org
Reply To: dev@cordova.apache.org
Subject: Re: get config.xml data from js


No, no, I'm suggesting this is a user space problem. Easily solved by the
user. (Certainly the first/only time I've heard a desire for this feature.)
On Feb 28, 2014 3:34 PM, "Jesse" <pu...@gmail.com> wrote:

> Yes, but then we have to agree on the format of config.json, which could
> take weeks.
>
> Something like this [1] should handle it.  Untested ...
>
>
> [1] https://gist.github.com/purplecabbage/9282132
>
>
>
> @purplecabbage
> risingj.com
>
>
> On Fri, Feb 28, 2014 at 3:14 PM, Brian LeRoux <b...@brian.io> wrote:
>
> > So, before we go too much farther with this...what is the usecase? Could
> a
> > build step hook address the idea? (Eg write a file called config.json)
> >
> >
> > On Fri, Feb 28, 2014 at 2:57 PM, Axel Nennker <ig...@gmail.com>
> > wrote:
> >
> > > cordova.js is platform specific anyway.
> > >  Am 28.02.2014 23:16 schrieb "Jesse" <pu...@gmail.com>:
> > >
> > > > So I guess things are not as standardized as we thought.
> > > >
> > > > iOS, WP7, WP8, Windows8, Ubuntu?[1] :
> > > > ../config.xml
> > > > Android :
> > > > ../../android_res/xml/config.xml
> > > > bb10 :
> > > > config.xml
> > > >
> > > >
> > > > [1]
> > > >
> > > >
> > >
> >
> https://github.com/apache/cordova-ubuntu/blob/cd6b3d11b58f38932797f1f4130ce40f772bdcd5/main.cpp#L66
> > > >
> > > > Still completely manageable from JavaScript; IMHO
> > > > just switch on cordova.platformId ...
> > > >
> > > > @purplecabbage
> > > > risingj.com
> > > >
> > > >
> > > > On Fri, Feb 28, 2014 at 2:06 PM, Axel Nennker <ignisvulpis@gmail.com
> >
> > > > wrote:
> > > >
> > > > > Looks better than it works.
> > > > > This does not trigger the alert. Neither with two / or three /
> after
> > > > > "file:"
> > > > > while "config.xml" alone works after I have put config.xml in www
> > > > >
> > > > >                                 document.addEventListener(
> > > "deviceready",
> > > > > function() {
> > > > > function readConfig() {
> > > > >     var xhr = new XMLHttpRequest();
> > > > >     xhr.addEventListener("load", function () {
> > > > >         var parser = new DOMParser();
> > > > >         var doc = parser.parseFromString(xhr.responseText,
> > > > > "application/xml");
> > > > >         alert("Description : " +
> > > > > doc.getElementsByTagName("description").item(0).textContent);
> > > > >     });
> > > > >     xhr.open("get", "file:///android_res/xml/config.xml", true);
> > > > >     xhr.send();
> > > > > }
> > > > > readConfig();
> > > > >
> > > > > Anyway this is not very cross platform.
> > > > >
> > > > >
> > > > >
> > > > > 2014-02-28 22:57 GMT+01:00 Joe Bowser <bo...@gmail.com>:
> > > > >
> > > > > > BTW: android_res and android_assets are special Android URIs that
> > > > > > access the APK directly.  They are read-only directories, and
> they
> > > > > > basically are used to access static files.  They also tend to be
> > > buggy
> > > > > > as all hell, so YMMV.
> > > > > >
> > > > > > On Fri, Feb 28, 2014 at 1:54 PM, Joe Bowser <bo...@gmail.com>
> > > wrote:
> > > > > > > Can't you just use an XHR to this URI:
> > > > > > > file://android_res/xml/config.xml?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On Fri, Feb 28, 2014 at 1:48 PM, Jesse <
> purplecabbage@gmail.com>
> > > > > wrote:
> > > > > > >> They seem to be in the root iOS, android, and windows phone.
> > > > > > >>
> > > > > > >> NSString* path = [[NSBundle mainBundle] pathForResource:@
> > "config"
> > > > > > ofType:
> > > > > > >> @"xml"];
> > > > > > >>
> > > > > > >> int id = action.getResources().getIdentifier("config", "xml",
> > > > action.
> > > > > > >> getClass().getPackage().getName());
> > > > > > >>
> > > > > > >> *StreamResourceInfo streamInfo =
> > Application.GetResourceStream(new
> > > > > > >> Uri("config.xml", UriKind.Relative));*
> > > > > > >>
> > > > > > >>
> > > > > > >>
> > > > > > >> @purplecabbage
> > > > > > >> risingj.com
> > > > > > >>
> > > > > > >>
> > > > > > >> On Fri, Feb 28, 2014 at 1:21 PM, Andrew Grieve <
> > > > agrieve@chromium.org>
> > > > > > wrote:
> > > > > > >>
> > > > > > >>> config.xml isn't in the www/ on all platforms.
> > > > > > >>>
> > > > > > >>>
> > > > > > >>> On Fri, Feb 28, 2014 at 4:15 PM, Jesse <
> > purplecabbage@gmail.com>
> > > > > > wrote:
> > > > > > >>>
> > > > > > >>> > function readConfig() {
> > > > > > >>> >     var xhr = new XMLHttpRequest();
> > > > > > >>> >     xhr.addEventListener("load", function () {
> > > > > > >>> >         var parser = new DOMParser();
> > > > > > >>> >         var doc = parser.parseFromString(xhr.responseText,
> > > > > > >>> > "application/xml");
> > > > > > >>> >         alert("Description : " +
> > > > > > >>> >
> doc.getElementsByTagName("description").item(0).textContent);
> > > > > > >>> >     });
> > > > > > >>> >     xhr.open("get", "../config.xml", true);
> > > > > > >>> >     xhr.send();
> > > > > > >>> > }
> > > > > > >>> >
> > > > > > >>> > @purplecabbage
> > > > > > >>> > risingj.com
> > > > > > >>> >
> > > > > > >>> >
> > > > > > >>> > On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <
> > > > mmocny@chromium.org
> > > > > >
> > > > > > >>> wrote:
> > > > > > >>> >
> > > > > > >>> > > Now that I look a bit deeper, that plugin I only returns
> > > > > > <preferences>
> > > > > > >>> > > specifically, not the entire contents of config.xml (name
> > is
> > > > not
> > > > > a
> > > > > > >>> > > <preference>).
> > > > > > >>> > >
> > > > > > >>> > > It also does not currently implement a way to inspect all
> > > > > > preferences,
> > > > > > >>> > just
> > > > > > >>> > > has a way to get the value for a specific one.
> > > > > > >>> > >
> > > > > > >>> > > I do think it would be a good idea to just have one core
> > > plugin
> > > > > > >>> (perhaps
> > > > > > >>> > > extend that one I linked) to include all config file
> > values.
> > > > > > >>> > >
> > > > > > >>> > > Filed: https://issues.apache.org/jira/browse/CB-6139
> > > > > > >>> > >
> > > > > > >>> > > -Michal
> > > > > > >>> > >
> > > > > > >>> > >
> > > > > > >>> > > On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <
> > > > > mmocny@chromium.org
> > > > > > >
> > > > > > >>> > wrote:
> > > > > > >>> > >
> > > > > > >>> > > > David already wrote a plugin for this a few months ago
> > for
> > > us
> > > > > to
> > > > > > use
> > > > > > >>> in
> > > > > > >>> > > > the test harness:
> > > > > > >>> > > >
> > > > > > >>> > >
> > > > > > >>> >
> > > > > > >>>
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
> > > > > > >>> > > >
> > > > > > >>> > > > I think he planned on proposing it for core but there
> was
> > > > never
> > > > > > >>> really
> > > > > > >>> > a
> > > > > > >>> > > > reason for it.  I guess now's a good time to get that
> > > going.
> > > > > > >>> > > >
> > > > > > >>> > > > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <
> > > > > > agrieve@chromium.org
> > > > > > >>> > > >wrote:
> > > > > > >>> > > >
> > > > > > >>> > > >> Certainly a reasonable thing to want to do, but
> there's
> > no
> > > > way
> > > > > > >>> > currently
> > > > > > >>> > > >> short of writing a custom plugin, or a post-prepare
> > hook.
> > > > > > >>> > > >>
> > > > > > >>> > > >>
> > > > > > >>> > > >>
> > > > > > >>> > > >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <
> > > > > > >>> ignisvulpis@gmail.com>
> > > > > > >>> > > >> wrote:
> > > > > > >>> > > >>
> > > > > > >>> > > >> > Hi,
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > I fear this is a stupid question but I could not
> find
> > > the
> > > > > > answer
> > > > > > >>> in
> > > > > > >>> > > the
> > > > > > >>> > > >> > cordova docs or on the net or reading the source
> > (Luke).
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > As an app developer and cordova user how do I get
> data
> > > > from
> > > > > > >>> > > config.xml?
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > We want to add an "about" page to an cordova app and
> > > could
> > > > > not
> > > > > > >>> find
> > > > > > >>> > a
> > > > > > >>> > > >> > simple javascript way to get to things like author,
> > id,
> > > > > > version,
> > > > > > >>> > name
> > > > > > >>> > > or
> > > > > > >>> > > >> > description from config.xml.
> > > > > > >>> > > >> > Writing a plugin seems to be overkill. Using the
> file
> > or
> > > > > > >>> > file-transfer
> > > > > > >>> > > >> > plugins is heavy lifting too.
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > Shouldn't there be a way to write
> > cordova.config.nameto
> > > > > get
> > > > > > the
> > > > > > >>> > > >> contents
> > > > > > >>> > > >> > of the name element in config.xml?
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > Someone added "metadata" to cordova_plugins.js.
> > > > > > >>> > > >> > Maybe we could add something similar to cordova.js
> > too?
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > Does this make sense?
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > Thanks
> > > > > > >>> > > >> > Axel
> > > > > > >>> > > >> >
> > > > > > >>> > > >>
> > > > > > >>> > > >
> > > > > > >>> > > >
> > > > > > >>> > >
> > > > > > >>> >
> > > > > > >>>
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: get config.xml data from js

Posted by Brian LeRoux <b...@brian.io>.
No, no, I'm suggesting this is a user space problem. Easily solved by the
user. (Certainly the first/only time I've heard a desire for this feature.)
On Feb 28, 2014 3:34 PM, "Jesse" <pu...@gmail.com> wrote:

> Yes, but then we have to agree on the format of config.json, which could
> take weeks.
>
> Something like this [1] should handle it.  Untested ...
>
>
> [1] https://gist.github.com/purplecabbage/9282132
>
>
>
> @purplecabbage
> risingj.com
>
>
> On Fri, Feb 28, 2014 at 3:14 PM, Brian LeRoux <b...@brian.io> wrote:
>
> > So, before we go too much farther with this...what is the usecase? Could
> a
> > build step hook address the idea? (Eg write a file called config.json)
> >
> >
> > On Fri, Feb 28, 2014 at 2:57 PM, Axel Nennker <ig...@gmail.com>
> > wrote:
> >
> > > cordova.js is platform specific anyway.
> > >  Am 28.02.2014 23:16 schrieb "Jesse" <pu...@gmail.com>:
> > >
> > > > So I guess things are not as standardized as we thought.
> > > >
> > > > iOS, WP7, WP8, Windows8, Ubuntu?[1] :
> > > > ../config.xml
> > > > Android :
> > > > ../../android_res/xml/config.xml
> > > > bb10 :
> > > > config.xml
> > > >
> > > >
> > > > [1]
> > > >
> > > >
> > >
> >
> https://github.com/apache/cordova-ubuntu/blob/cd6b3d11b58f38932797f1f4130ce40f772bdcd5/main.cpp#L66
> > > >
> > > > Still completely manageable from JavaScript; IMHO
> > > > just switch on cordova.platformId ...
> > > >
> > > > @purplecabbage
> > > > risingj.com
> > > >
> > > >
> > > > On Fri, Feb 28, 2014 at 2:06 PM, Axel Nennker <ignisvulpis@gmail.com
> >
> > > > wrote:
> > > >
> > > > > Looks better than it works.
> > > > > This does not trigger the alert. Neither with two / or three /
> after
> > > > > "file:"
> > > > > while "config.xml" alone works after I have put config.xml in www
> > > > >
> > > > >                                 document.addEventListener(
> > > "deviceready",
> > > > > function() {
> > > > > function readConfig() {
> > > > >     var xhr = new XMLHttpRequest();
> > > > >     xhr.addEventListener("load", function () {
> > > > >         var parser = new DOMParser();
> > > > >         var doc = parser.parseFromString(xhr.responseText,
> > > > > "application/xml");
> > > > >         alert("Description : " +
> > > > > doc.getElementsByTagName("description").item(0).textContent);
> > > > >     });
> > > > >     xhr.open("get", "file:///android_res/xml/config.xml", true);
> > > > >     xhr.send();
> > > > > }
> > > > > readConfig();
> > > > >
> > > > > Anyway this is not very cross platform.
> > > > >
> > > > >
> > > > >
> > > > > 2014-02-28 22:57 GMT+01:00 Joe Bowser <bo...@gmail.com>:
> > > > >
> > > > > > BTW: android_res and android_assets are special Android URIs that
> > > > > > access the APK directly.  They are read-only directories, and
> they
> > > > > > basically are used to access static files.  They also tend to be
> > > buggy
> > > > > > as all hell, so YMMV.
> > > > > >
> > > > > > On Fri, Feb 28, 2014 at 1:54 PM, Joe Bowser <bo...@gmail.com>
> > > wrote:
> > > > > > > Can't you just use an XHR to this URI:
> > > > > > > file://android_res/xml/config.xml?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On Fri, Feb 28, 2014 at 1:48 PM, Jesse <
> purplecabbage@gmail.com>
> > > > > wrote:
> > > > > > >> They seem to be in the root iOS, android, and windows phone.
> > > > > > >>
> > > > > > >> NSString* path = [[NSBundle mainBundle] pathForResource:@
> > "config"
> > > > > > ofType:
> > > > > > >> @"xml"];
> > > > > > >>
> > > > > > >> int id = action.getResources().getIdentifier("config", "xml",
> > > > action.
> > > > > > >> getClass().getPackage().getName());
> > > > > > >>
> > > > > > >> *StreamResourceInfo streamInfo =
> > Application.GetResourceStream(new
> > > > > > >> Uri("config.xml", UriKind.Relative));*
> > > > > > >>
> > > > > > >>
> > > > > > >>
> > > > > > >> @purplecabbage
> > > > > > >> risingj.com
> > > > > > >>
> > > > > > >>
> > > > > > >> On Fri, Feb 28, 2014 at 1:21 PM, Andrew Grieve <
> > > > agrieve@chromium.org>
> > > > > > wrote:
> > > > > > >>
> > > > > > >>> config.xml isn't in the www/ on all platforms.
> > > > > > >>>
> > > > > > >>>
> > > > > > >>> On Fri, Feb 28, 2014 at 4:15 PM, Jesse <
> > purplecabbage@gmail.com>
> > > > > > wrote:
> > > > > > >>>
> > > > > > >>> > function readConfig() {
> > > > > > >>> >     var xhr = new XMLHttpRequest();
> > > > > > >>> >     xhr.addEventListener("load", function () {
> > > > > > >>> >         var parser = new DOMParser();
> > > > > > >>> >         var doc = parser.parseFromString(xhr.responseText,
> > > > > > >>> > "application/xml");
> > > > > > >>> >         alert("Description : " +
> > > > > > >>> >
> doc.getElementsByTagName("description").item(0).textContent);
> > > > > > >>> >     });
> > > > > > >>> >     xhr.open("get", "../config.xml", true);
> > > > > > >>> >     xhr.send();
> > > > > > >>> > }
> > > > > > >>> >
> > > > > > >>> > @purplecabbage
> > > > > > >>> > risingj.com
> > > > > > >>> >
> > > > > > >>> >
> > > > > > >>> > On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <
> > > > mmocny@chromium.org
> > > > > >
> > > > > > >>> wrote:
> > > > > > >>> >
> > > > > > >>> > > Now that I look a bit deeper, that plugin I only returns
> > > > > > <preferences>
> > > > > > >>> > > specifically, not the entire contents of config.xml (name
> > is
> > > > not
> > > > > a
> > > > > > >>> > > <preference>).
> > > > > > >>> > >
> > > > > > >>> > > It also does not currently implement a way to inspect all
> > > > > > preferences,
> > > > > > >>> > just
> > > > > > >>> > > has a way to get the value for a specific one.
> > > > > > >>> > >
> > > > > > >>> > > I do think it would be a good idea to just have one core
> > > plugin
> > > > > > >>> (perhaps
> > > > > > >>> > > extend that one I linked) to include all config file
> > values.
> > > > > > >>> > >
> > > > > > >>> > > Filed: https://issues.apache.org/jira/browse/CB-6139
> > > > > > >>> > >
> > > > > > >>> > > -Michal
> > > > > > >>> > >
> > > > > > >>> > >
> > > > > > >>> > > On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <
> > > > > mmocny@chromium.org
> > > > > > >
> > > > > > >>> > wrote:
> > > > > > >>> > >
> > > > > > >>> > > > David already wrote a plugin for this a few months ago
> > for
> > > us
> > > > > to
> > > > > > use
> > > > > > >>> in
> > > > > > >>> > > > the test harness:
> > > > > > >>> > > >
> > > > > > >>> > >
> > > > > > >>> >
> > > > > > >>>
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
> > > > > > >>> > > >
> > > > > > >>> > > > I think he planned on proposing it for core but there
> was
> > > > never
> > > > > > >>> really
> > > > > > >>> > a
> > > > > > >>> > > > reason for it.  I guess now's a good time to get that
> > > going.
> > > > > > >>> > > >
> > > > > > >>> > > > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <
> > > > > > agrieve@chromium.org
> > > > > > >>> > > >wrote:
> > > > > > >>> > > >
> > > > > > >>> > > >> Certainly a reasonable thing to want to do, but
> there's
> > no
> > > > way
> > > > > > >>> > currently
> > > > > > >>> > > >> short of writing a custom plugin, or a post-prepare
> > hook.
> > > > > > >>> > > >>
> > > > > > >>> > > >>
> > > > > > >>> > > >>
> > > > > > >>> > > >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <
> > > > > > >>> ignisvulpis@gmail.com>
> > > > > > >>> > > >> wrote:
> > > > > > >>> > > >>
> > > > > > >>> > > >> > Hi,
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > I fear this is a stupid question but I could not
> find
> > > the
> > > > > > answer
> > > > > > >>> in
> > > > > > >>> > > the
> > > > > > >>> > > >> > cordova docs or on the net or reading the source
> > (Luke).
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > As an app developer and cordova user how do I get
> data
> > > > from
> > > > > > >>> > > config.xml?
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > We want to add an "about" page to an cordova app and
> > > could
> > > > > not
> > > > > > >>> find
> > > > > > >>> > a
> > > > > > >>> > > >> > simple javascript way to get to things like author,
> > id,
> > > > > > version,
> > > > > > >>> > name
> > > > > > >>> > > or
> > > > > > >>> > > >> > description from config.xml.
> > > > > > >>> > > >> > Writing a plugin seems to be overkill. Using the
> file
> > or
> > > > > > >>> > file-transfer
> > > > > > >>> > > >> > plugins is heavy lifting too.
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > Shouldn't there be a way to write
> > cordova.config.nameto
> > > > > get
> > > > > > the
> > > > > > >>> > > >> contents
> > > > > > >>> > > >> > of the name element in config.xml?
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > Someone added "metadata" to cordova_plugins.js.
> > > > > > >>> > > >> > Maybe we could add something similar to cordova.js
> > too?
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > Does this make sense?
> > > > > > >>> > > >> >
> > > > > > >>> > > >> > Thanks
> > > > > > >>> > > >> > Axel
> > > > > > >>> > > >> >
> > > > > > >>> > > >>
> > > > > > >>> > > >
> > > > > > >>> > > >
> > > > > > >>> > >
> > > > > > >>> >
> > > > > > >>>
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: get config.xml data from js

Posted by Jesse <pu...@gmail.com>.
Yes, but then we have to agree on the format of config.json, which could
take weeks.

Something like this [1] should handle it.  Untested ...


[1] https://gist.github.com/purplecabbage/9282132



@purplecabbage
risingj.com


On Fri, Feb 28, 2014 at 3:14 PM, Brian LeRoux <b...@brian.io> wrote:

> So, before we go too much farther with this...what is the usecase? Could a
> build step hook address the idea? (Eg write a file called config.json)
>
>
> On Fri, Feb 28, 2014 at 2:57 PM, Axel Nennker <ig...@gmail.com>
> wrote:
>
> > cordova.js is platform specific anyway.
> >  Am 28.02.2014 23:16 schrieb "Jesse" <pu...@gmail.com>:
> >
> > > So I guess things are not as standardized as we thought.
> > >
> > > iOS, WP7, WP8, Windows8, Ubuntu?[1] :
> > > ../config.xml
> > > Android :
> > > ../../android_res/xml/config.xml
> > > bb10 :
> > > config.xml
> > >
> > >
> > > [1]
> > >
> > >
> >
> https://github.com/apache/cordova-ubuntu/blob/cd6b3d11b58f38932797f1f4130ce40f772bdcd5/main.cpp#L66
> > >
> > > Still completely manageable from JavaScript; IMHO
> > > just switch on cordova.platformId ...
> > >
> > > @purplecabbage
> > > risingj.com
> > >
> > >
> > > On Fri, Feb 28, 2014 at 2:06 PM, Axel Nennker <ig...@gmail.com>
> > > wrote:
> > >
> > > > Looks better than it works.
> > > > This does not trigger the alert. Neither with two / or three / after
> > > > "file:"
> > > > while "config.xml" alone works after I have put config.xml in www
> > > >
> > > >                                 document.addEventListener(
> > "deviceready",
> > > > function() {
> > > > function readConfig() {
> > > >     var xhr = new XMLHttpRequest();
> > > >     xhr.addEventListener("load", function () {
> > > >         var parser = new DOMParser();
> > > >         var doc = parser.parseFromString(xhr.responseText,
> > > > "application/xml");
> > > >         alert("Description : " +
> > > > doc.getElementsByTagName("description").item(0).textContent);
> > > >     });
> > > >     xhr.open("get", "file:///android_res/xml/config.xml", true);
> > > >     xhr.send();
> > > > }
> > > > readConfig();
> > > >
> > > > Anyway this is not very cross platform.
> > > >
> > > >
> > > >
> > > > 2014-02-28 22:57 GMT+01:00 Joe Bowser <bo...@gmail.com>:
> > > >
> > > > > BTW: android_res and android_assets are special Android URIs that
> > > > > access the APK directly.  They are read-only directories, and they
> > > > > basically are used to access static files.  They also tend to be
> > buggy
> > > > > as all hell, so YMMV.
> > > > >
> > > > > On Fri, Feb 28, 2014 at 1:54 PM, Joe Bowser <bo...@gmail.com>
> > wrote:
> > > > > > Can't you just use an XHR to this URI:
> > > > > > file://android_res/xml/config.xml?
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Fri, Feb 28, 2014 at 1:48 PM, Jesse <pu...@gmail.com>
> > > > wrote:
> > > > > >> They seem to be in the root iOS, android, and windows phone.
> > > > > >>
> > > > > >> NSString* path = [[NSBundle mainBundle] pathForResource:@
> "config"
> > > > > ofType:
> > > > > >> @"xml"];
> > > > > >>
> > > > > >> int id = action.getResources().getIdentifier("config", "xml",
> > > action.
> > > > > >> getClass().getPackage().getName());
> > > > > >>
> > > > > >> *StreamResourceInfo streamInfo =
> Application.GetResourceStream(new
> > > > > >> Uri("config.xml", UriKind.Relative));*
> > > > > >>
> > > > > >>
> > > > > >>
> > > > > >> @purplecabbage
> > > > > >> risingj.com
> > > > > >>
> > > > > >>
> > > > > >> On Fri, Feb 28, 2014 at 1:21 PM, Andrew Grieve <
> > > agrieve@chromium.org>
> > > > > wrote:
> > > > > >>
> > > > > >>> config.xml isn't in the www/ on all platforms.
> > > > > >>>
> > > > > >>>
> > > > > >>> On Fri, Feb 28, 2014 at 4:15 PM, Jesse <
> purplecabbage@gmail.com>
> > > > > wrote:
> > > > > >>>
> > > > > >>> > function readConfig() {
> > > > > >>> >     var xhr = new XMLHttpRequest();
> > > > > >>> >     xhr.addEventListener("load", function () {
> > > > > >>> >         var parser = new DOMParser();
> > > > > >>> >         var doc = parser.parseFromString(xhr.responseText,
> > > > > >>> > "application/xml");
> > > > > >>> >         alert("Description : " +
> > > > > >>> > doc.getElementsByTagName("description").item(0).textContent);
> > > > > >>> >     });
> > > > > >>> >     xhr.open("get", "../config.xml", true);
> > > > > >>> >     xhr.send();
> > > > > >>> > }
> > > > > >>> >
> > > > > >>> > @purplecabbage
> > > > > >>> > risingj.com
> > > > > >>> >
> > > > > >>> >
> > > > > >>> > On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <
> > > mmocny@chromium.org
> > > > >
> > > > > >>> wrote:
> > > > > >>> >
> > > > > >>> > > Now that I look a bit deeper, that plugin I only returns
> > > > > <preferences>
> > > > > >>> > > specifically, not the entire contents of config.xml (name
> is
> > > not
> > > > a
> > > > > >>> > > <preference>).
> > > > > >>> > >
> > > > > >>> > > It also does not currently implement a way to inspect all
> > > > > preferences,
> > > > > >>> > just
> > > > > >>> > > has a way to get the value for a specific one.
> > > > > >>> > >
> > > > > >>> > > I do think it would be a good idea to just have one core
> > plugin
> > > > > >>> (perhaps
> > > > > >>> > > extend that one I linked) to include all config file
> values.
> > > > > >>> > >
> > > > > >>> > > Filed: https://issues.apache.org/jira/browse/CB-6139
> > > > > >>> > >
> > > > > >>> > > -Michal
> > > > > >>> > >
> > > > > >>> > >
> > > > > >>> > > On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <
> > > > mmocny@chromium.org
> > > > > >
> > > > > >>> > wrote:
> > > > > >>> > >
> > > > > >>> > > > David already wrote a plugin for this a few months ago
> for
> > us
> > > > to
> > > > > use
> > > > > >>> in
> > > > > >>> > > > the test harness:
> > > > > >>> > > >
> > > > > >>> > >
> > > > > >>> >
> > > > > >>>
> > > > >
> > > >
> > >
> >
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
> > > > > >>> > > >
> > > > > >>> > > > I think he planned on proposing it for core but there was
> > > never
> > > > > >>> really
> > > > > >>> > a
> > > > > >>> > > > reason for it.  I guess now's a good time to get that
> > going.
> > > > > >>> > > >
> > > > > >>> > > > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <
> > > > > agrieve@chromium.org
> > > > > >>> > > >wrote:
> > > > > >>> > > >
> > > > > >>> > > >> Certainly a reasonable thing to want to do, but there's
> no
> > > way
> > > > > >>> > currently
> > > > > >>> > > >> short of writing a custom plugin, or a post-prepare
> hook.
> > > > > >>> > > >>
> > > > > >>> > > >>
> > > > > >>> > > >>
> > > > > >>> > > >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <
> > > > > >>> ignisvulpis@gmail.com>
> > > > > >>> > > >> wrote:
> > > > > >>> > > >>
> > > > > >>> > > >> > Hi,
> > > > > >>> > > >> >
> > > > > >>> > > >> > I fear this is a stupid question but I could not find
> > the
> > > > > answer
> > > > > >>> in
> > > > > >>> > > the
> > > > > >>> > > >> > cordova docs or on the net or reading the source
> (Luke).
> > > > > >>> > > >> >
> > > > > >>> > > >> > As an app developer and cordova user how do I get data
> > > from
> > > > > >>> > > config.xml?
> > > > > >>> > > >> >
> > > > > >>> > > >> > We want to add an "about" page to an cordova app and
> > could
> > > > not
> > > > > >>> find
> > > > > >>> > a
> > > > > >>> > > >> > simple javascript way to get to things like author,
> id,
> > > > > version,
> > > > > >>> > name
> > > > > >>> > > or
> > > > > >>> > > >> > description from config.xml.
> > > > > >>> > > >> > Writing a plugin seems to be overkill. Using the file
> or
> > > > > >>> > file-transfer
> > > > > >>> > > >> > plugins is heavy lifting too.
> > > > > >>> > > >> >
> > > > > >>> > > >> > Shouldn't there be a way to write
> cordova.config.nameto
> > > > get
> > > > > the
> > > > > >>> > > >> contents
> > > > > >>> > > >> > of the name element in config.xml?
> > > > > >>> > > >> >
> > > > > >>> > > >> > Someone added "metadata" to cordova_plugins.js.
> > > > > >>> > > >> > Maybe we could add something similar to cordova.js
> too?
> > > > > >>> > > >> >
> > > > > >>> > > >> > Does this make sense?
> > > > > >>> > > >> >
> > > > > >>> > > >> > Thanks
> > > > > >>> > > >> > Axel
> > > > > >>> > > >> >
> > > > > >>> > > >>
> > > > > >>> > > >
> > > > > >>> > > >
> > > > > >>> > >
> > > > > >>> >
> > > > > >>>
> > > > >
> > > >
> > >
> >
>

Re: get config.xml data from js

Posted by Brian LeRoux <b...@brian.io>.
So, before we go too much farther with this...what is the usecase? Could a
build step hook address the idea? (Eg write a file called config.json)


On Fri, Feb 28, 2014 at 2:57 PM, Axel Nennker <ig...@gmail.com> wrote:

> cordova.js is platform specific anyway.
>  Am 28.02.2014 23:16 schrieb "Jesse" <pu...@gmail.com>:
>
> > So I guess things are not as standardized as we thought.
> >
> > iOS, WP7, WP8, Windows8, Ubuntu?[1] :
> > ../config.xml
> > Android :
> > ../../android_res/xml/config.xml
> > bb10 :
> > config.xml
> >
> >
> > [1]
> >
> >
> https://github.com/apache/cordova-ubuntu/blob/cd6b3d11b58f38932797f1f4130ce40f772bdcd5/main.cpp#L66
> >
> > Still completely manageable from JavaScript; IMHO
> > just switch on cordova.platformId ...
> >
> > @purplecabbage
> > risingj.com
> >
> >
> > On Fri, Feb 28, 2014 at 2:06 PM, Axel Nennker <ig...@gmail.com>
> > wrote:
> >
> > > Looks better than it works.
> > > This does not trigger the alert. Neither with two / or three / after
> > > "file:"
> > > while "config.xml" alone works after I have put config.xml in www
> > >
> > >                                 document.addEventListener(
> "deviceready",
> > > function() {
> > > function readConfig() {
> > >     var xhr = new XMLHttpRequest();
> > >     xhr.addEventListener("load", function () {
> > >         var parser = new DOMParser();
> > >         var doc = parser.parseFromString(xhr.responseText,
> > > "application/xml");
> > >         alert("Description : " +
> > > doc.getElementsByTagName("description").item(0).textContent);
> > >     });
> > >     xhr.open("get", "file:///android_res/xml/config.xml", true);
> > >     xhr.send();
> > > }
> > > readConfig();
> > >
> > > Anyway this is not very cross platform.
> > >
> > >
> > >
> > > 2014-02-28 22:57 GMT+01:00 Joe Bowser <bo...@gmail.com>:
> > >
> > > > BTW: android_res and android_assets are special Android URIs that
> > > > access the APK directly.  They are read-only directories, and they
> > > > basically are used to access static files.  They also tend to be
> buggy
> > > > as all hell, so YMMV.
> > > >
> > > > On Fri, Feb 28, 2014 at 1:54 PM, Joe Bowser <bo...@gmail.com>
> wrote:
> > > > > Can't you just use an XHR to this URI:
> > > > > file://android_res/xml/config.xml?
> > > > >
> > > > >
> > > > >
> > > > > On Fri, Feb 28, 2014 at 1:48 PM, Jesse <pu...@gmail.com>
> > > wrote:
> > > > >> They seem to be in the root iOS, android, and windows phone.
> > > > >>
> > > > >> NSString* path = [[NSBundle mainBundle] pathForResource:@"config"
> > > > ofType:
> > > > >> @"xml"];
> > > > >>
> > > > >> int id = action.getResources().getIdentifier("config", "xml",
> > action.
> > > > >> getClass().getPackage().getName());
> > > > >>
> > > > >> *StreamResourceInfo streamInfo = Application.GetResourceStream(new
> > > > >> Uri("config.xml", UriKind.Relative));*
> > > > >>
> > > > >>
> > > > >>
> > > > >> @purplecabbage
> > > > >> risingj.com
> > > > >>
> > > > >>
> > > > >> On Fri, Feb 28, 2014 at 1:21 PM, Andrew Grieve <
> > agrieve@chromium.org>
> > > > wrote:
> > > > >>
> > > > >>> config.xml isn't in the www/ on all platforms.
> > > > >>>
> > > > >>>
> > > > >>> On Fri, Feb 28, 2014 at 4:15 PM, Jesse <pu...@gmail.com>
> > > > wrote:
> > > > >>>
> > > > >>> > function readConfig() {
> > > > >>> >     var xhr = new XMLHttpRequest();
> > > > >>> >     xhr.addEventListener("load", function () {
> > > > >>> >         var parser = new DOMParser();
> > > > >>> >         var doc = parser.parseFromString(xhr.responseText,
> > > > >>> > "application/xml");
> > > > >>> >         alert("Description : " +
> > > > >>> > doc.getElementsByTagName("description").item(0).textContent);
> > > > >>> >     });
> > > > >>> >     xhr.open("get", "../config.xml", true);
> > > > >>> >     xhr.send();
> > > > >>> > }
> > > > >>> >
> > > > >>> > @purplecabbage
> > > > >>> > risingj.com
> > > > >>> >
> > > > >>> >
> > > > >>> > On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <
> > mmocny@chromium.org
> > > >
> > > > >>> wrote:
> > > > >>> >
> > > > >>> > > Now that I look a bit deeper, that plugin I only returns
> > > > <preferences>
> > > > >>> > > specifically, not the entire contents of config.xml (name is
> > not
> > > a
> > > > >>> > > <preference>).
> > > > >>> > >
> > > > >>> > > It also does not currently implement a way to inspect all
> > > > preferences,
> > > > >>> > just
> > > > >>> > > has a way to get the value for a specific one.
> > > > >>> > >
> > > > >>> > > I do think it would be a good idea to just have one core
> plugin
> > > > >>> (perhaps
> > > > >>> > > extend that one I linked) to include all config file values.
> > > > >>> > >
> > > > >>> > > Filed: https://issues.apache.org/jira/browse/CB-6139
> > > > >>> > >
> > > > >>> > > -Michal
> > > > >>> > >
> > > > >>> > >
> > > > >>> > > On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <
> > > mmocny@chromium.org
> > > > >
> > > > >>> > wrote:
> > > > >>> > >
> > > > >>> > > > David already wrote a plugin for this a few months ago for
> us
> > > to
> > > > use
> > > > >>> in
> > > > >>> > > > the test harness:
> > > > >>> > > >
> > > > >>> > >
> > > > >>> >
> > > > >>>
> > > >
> > >
> >
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
> > > > >>> > > >
> > > > >>> > > > I think he planned on proposing it for core but there was
> > never
> > > > >>> really
> > > > >>> > a
> > > > >>> > > > reason for it.  I guess now's a good time to get that
> going.
> > > > >>> > > >
> > > > >>> > > > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <
> > > > agrieve@chromium.org
> > > > >>> > > >wrote:
> > > > >>> > > >
> > > > >>> > > >> Certainly a reasonable thing to want to do, but there's no
> > way
> > > > >>> > currently
> > > > >>> > > >> short of writing a custom plugin, or a post-prepare hook.
> > > > >>> > > >>
> > > > >>> > > >>
> > > > >>> > > >>
> > > > >>> > > >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <
> > > > >>> ignisvulpis@gmail.com>
> > > > >>> > > >> wrote:
> > > > >>> > > >>
> > > > >>> > > >> > Hi,
> > > > >>> > > >> >
> > > > >>> > > >> > I fear this is a stupid question but I could not find
> the
> > > > answer
> > > > >>> in
> > > > >>> > > the
> > > > >>> > > >> > cordova docs or on the net or reading the source (Luke).
> > > > >>> > > >> >
> > > > >>> > > >> > As an app developer and cordova user how do I get data
> > from
> > > > >>> > > config.xml?
> > > > >>> > > >> >
> > > > >>> > > >> > We want to add an "about" page to an cordova app and
> could
> > > not
> > > > >>> find
> > > > >>> > a
> > > > >>> > > >> > simple javascript way to get to things like author, id,
> > > > version,
> > > > >>> > name
> > > > >>> > > or
> > > > >>> > > >> > description from config.xml.
> > > > >>> > > >> > Writing a plugin seems to be overkill. Using the file or
> > > > >>> > file-transfer
> > > > >>> > > >> > plugins is heavy lifting too.
> > > > >>> > > >> >
> > > > >>> > > >> > Shouldn't there be a way to write cordova.config.nameto
> > > get
> > > > the
> > > > >>> > > >> contents
> > > > >>> > > >> > of the name element in config.xml?
> > > > >>> > > >> >
> > > > >>> > > >> > Someone added "metadata" to cordova_plugins.js.
> > > > >>> > > >> > Maybe we could add something similar to cordova.js too?
> > > > >>> > > >> >
> > > > >>> > > >> > Does this make sense?
> > > > >>> > > >> >
> > > > >>> > > >> > Thanks
> > > > >>> > > >> > Axel
> > > > >>> > > >> >
> > > > >>> > > >>
> > > > >>> > > >
> > > > >>> > > >
> > > > >>> > >
> > > > >>> >
> > > > >>>
> > > >
> > >
> >
>

Re: get config.xml data from js

Posted by Axel Nennker <ig...@gmail.com>.
cordova.js is platform specific anyway.
 Am 28.02.2014 23:16 schrieb "Jesse" <pu...@gmail.com>:

> So I guess things are not as standardized as we thought.
>
> iOS, WP7, WP8, Windows8, Ubuntu?[1] :
> ../config.xml
> Android :
> ../../android_res/xml/config.xml
> bb10 :
> config.xml
>
>
> [1]
>
> https://github.com/apache/cordova-ubuntu/blob/cd6b3d11b58f38932797f1f4130ce40f772bdcd5/main.cpp#L66
>
> Still completely manageable from JavaScript; IMHO
> just switch on cordova.platformId ...
>
> @purplecabbage
> risingj.com
>
>
> On Fri, Feb 28, 2014 at 2:06 PM, Axel Nennker <ig...@gmail.com>
> wrote:
>
> > Looks better than it works.
> > This does not trigger the alert. Neither with two / or three / after
> > "file:"
> > while "config.xml" alone works after I have put config.xml in www
> >
> >                                 document.addEventListener( "deviceready",
> > function() {
> > function readConfig() {
> >     var xhr = new XMLHttpRequest();
> >     xhr.addEventListener("load", function () {
> >         var parser = new DOMParser();
> >         var doc = parser.parseFromString(xhr.responseText,
> > "application/xml");
> >         alert("Description : " +
> > doc.getElementsByTagName("description").item(0).textContent);
> >     });
> >     xhr.open("get", "file:///android_res/xml/config.xml", true);
> >     xhr.send();
> > }
> > readConfig();
> >
> > Anyway this is not very cross platform.
> >
> >
> >
> > 2014-02-28 22:57 GMT+01:00 Joe Bowser <bo...@gmail.com>:
> >
> > > BTW: android_res and android_assets are special Android URIs that
> > > access the APK directly.  They are read-only directories, and they
> > > basically are used to access static files.  They also tend to be buggy
> > > as all hell, so YMMV.
> > >
> > > On Fri, Feb 28, 2014 at 1:54 PM, Joe Bowser <bo...@gmail.com> wrote:
> > > > Can't you just use an XHR to this URI:
> > > > file://android_res/xml/config.xml?
> > > >
> > > >
> > > >
> > > > On Fri, Feb 28, 2014 at 1:48 PM, Jesse <pu...@gmail.com>
> > wrote:
> > > >> They seem to be in the root iOS, android, and windows phone.
> > > >>
> > > >> NSString* path = [[NSBundle mainBundle] pathForResource:@"config"
> > > ofType:
> > > >> @"xml"];
> > > >>
> > > >> int id = action.getResources().getIdentifier("config", "xml",
> action.
> > > >> getClass().getPackage().getName());
> > > >>
> > > >> *StreamResourceInfo streamInfo = Application.GetResourceStream(new
> > > >> Uri("config.xml", UriKind.Relative));*
> > > >>
> > > >>
> > > >>
> > > >> @purplecabbage
> > > >> risingj.com
> > > >>
> > > >>
> > > >> On Fri, Feb 28, 2014 at 1:21 PM, Andrew Grieve <
> agrieve@chromium.org>
> > > wrote:
> > > >>
> > > >>> config.xml isn't in the www/ on all platforms.
> > > >>>
> > > >>>
> > > >>> On Fri, Feb 28, 2014 at 4:15 PM, Jesse <pu...@gmail.com>
> > > wrote:
> > > >>>
> > > >>> > function readConfig() {
> > > >>> >     var xhr = new XMLHttpRequest();
> > > >>> >     xhr.addEventListener("load", function () {
> > > >>> >         var parser = new DOMParser();
> > > >>> >         var doc = parser.parseFromString(xhr.responseText,
> > > >>> > "application/xml");
> > > >>> >         alert("Description : " +
> > > >>> > doc.getElementsByTagName("description").item(0).textContent);
> > > >>> >     });
> > > >>> >     xhr.open("get", "../config.xml", true);
> > > >>> >     xhr.send();
> > > >>> > }
> > > >>> >
> > > >>> > @purplecabbage
> > > >>> > risingj.com
> > > >>> >
> > > >>> >
> > > >>> > On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <
> mmocny@chromium.org
> > >
> > > >>> wrote:
> > > >>> >
> > > >>> > > Now that I look a bit deeper, that plugin I only returns
> > > <preferences>
> > > >>> > > specifically, not the entire contents of config.xml (name is
> not
> > a
> > > >>> > > <preference>).
> > > >>> > >
> > > >>> > > It also does not currently implement a way to inspect all
> > > preferences,
> > > >>> > just
> > > >>> > > has a way to get the value for a specific one.
> > > >>> > >
> > > >>> > > I do think it would be a good idea to just have one core plugin
> > > >>> (perhaps
> > > >>> > > extend that one I linked) to include all config file values.
> > > >>> > >
> > > >>> > > Filed: https://issues.apache.org/jira/browse/CB-6139
> > > >>> > >
> > > >>> > > -Michal
> > > >>> > >
> > > >>> > >
> > > >>> > > On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <
> > mmocny@chromium.org
> > > >
> > > >>> > wrote:
> > > >>> > >
> > > >>> > > > David already wrote a plugin for this a few months ago for us
> > to
> > > use
> > > >>> in
> > > >>> > > > the test harness:
> > > >>> > > >
> > > >>> > >
> > > >>> >
> > > >>>
> > >
> >
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
> > > >>> > > >
> > > >>> > > > I think he planned on proposing it for core but there was
> never
> > > >>> really
> > > >>> > a
> > > >>> > > > reason for it.  I guess now's a good time to get that going.
> > > >>> > > >
> > > >>> > > > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <
> > > agrieve@chromium.org
> > > >>> > > >wrote:
> > > >>> > > >
> > > >>> > > >> Certainly a reasonable thing to want to do, but there's no
> way
> > > >>> > currently
> > > >>> > > >> short of writing a custom plugin, or a post-prepare hook.
> > > >>> > > >>
> > > >>> > > >>
> > > >>> > > >>
> > > >>> > > >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <
> > > >>> ignisvulpis@gmail.com>
> > > >>> > > >> wrote:
> > > >>> > > >>
> > > >>> > > >> > Hi,
> > > >>> > > >> >
> > > >>> > > >> > I fear this is a stupid question but I could not find the
> > > answer
> > > >>> in
> > > >>> > > the
> > > >>> > > >> > cordova docs or on the net or reading the source (Luke).
> > > >>> > > >> >
> > > >>> > > >> > As an app developer and cordova user how do I get data
> from
> > > >>> > > config.xml?
> > > >>> > > >> >
> > > >>> > > >> > We want to add an "about" page to an cordova app and could
> > not
> > > >>> find
> > > >>> > a
> > > >>> > > >> > simple javascript way to get to things like author, id,
> > > version,
> > > >>> > name
> > > >>> > > or
> > > >>> > > >> > description from config.xml.
> > > >>> > > >> > Writing a plugin seems to be overkill. Using the file or
> > > >>> > file-transfer
> > > >>> > > >> > plugins is heavy lifting too.
> > > >>> > > >> >
> > > >>> > > >> > Shouldn't there be a way to write cordova.config.name to
> > get
> > > the
> > > >>> > > >> contents
> > > >>> > > >> > of the name element in config.xml?
> > > >>> > > >> >
> > > >>> > > >> > Someone added "metadata" to cordova_plugins.js.
> > > >>> > > >> > Maybe we could add something similar to cordova.js too?
> > > >>> > > >> >
> > > >>> > > >> > Does this make sense?
> > > >>> > > >> >
> > > >>> > > >> > Thanks
> > > >>> > > >> > Axel
> > > >>> > > >> >
> > > >>> > > >>
> > > >>> > > >
> > > >>> > > >
> > > >>> > >
> > > >>> >
> > > >>>
> > >
> >
>

Re: get config.xml data from js

Posted by Jesse <pu...@gmail.com>.
So I guess things are not as standardized as we thought.

iOS, WP7, WP8, Windows8, Ubuntu?[1] :
../config.xml
Android :
../../android_res/xml/config.xml
bb10 :
config.xml


[1]
https://github.com/apache/cordova-ubuntu/blob/cd6b3d11b58f38932797f1f4130ce40f772bdcd5/main.cpp#L66

Still completely manageable from JavaScript; IMHO
just switch on cordova.platformId ...

@purplecabbage
risingj.com


On Fri, Feb 28, 2014 at 2:06 PM, Axel Nennker <ig...@gmail.com> wrote:

> Looks better than it works.
> This does not trigger the alert. Neither with two / or three / after
> "file:"
> while "config.xml" alone works after I have put config.xml in www
>
>                                 document.addEventListener( "deviceready",
> function() {
> function readConfig() {
>     var xhr = new XMLHttpRequest();
>     xhr.addEventListener("load", function () {
>         var parser = new DOMParser();
>         var doc = parser.parseFromString(xhr.responseText,
> "application/xml");
>         alert("Description : " +
> doc.getElementsByTagName("description").item(0).textContent);
>     });
>     xhr.open("get", "file:///android_res/xml/config.xml", true);
>     xhr.send();
> }
> readConfig();
>
> Anyway this is not very cross platform.
>
>
>
> 2014-02-28 22:57 GMT+01:00 Joe Bowser <bo...@gmail.com>:
>
> > BTW: android_res and android_assets are special Android URIs that
> > access the APK directly.  They are read-only directories, and they
> > basically are used to access static files.  They also tend to be buggy
> > as all hell, so YMMV.
> >
> > On Fri, Feb 28, 2014 at 1:54 PM, Joe Bowser <bo...@gmail.com> wrote:
> > > Can't you just use an XHR to this URI:
> > > file://android_res/xml/config.xml?
> > >
> > >
> > >
> > > On Fri, Feb 28, 2014 at 1:48 PM, Jesse <pu...@gmail.com>
> wrote:
> > >> They seem to be in the root iOS, android, and windows phone.
> > >>
> > >> NSString* path = [[NSBundle mainBundle] pathForResource:@"config"
> > ofType:
> > >> @"xml"];
> > >>
> > >> int id = action.getResources().getIdentifier("config", "xml", action.
> > >> getClass().getPackage().getName());
> > >>
> > >> *StreamResourceInfo streamInfo = Application.GetResourceStream(new
> > >> Uri("config.xml", UriKind.Relative));*
> > >>
> > >>
> > >>
> > >> @purplecabbage
> > >> risingj.com
> > >>
> > >>
> > >> On Fri, Feb 28, 2014 at 1:21 PM, Andrew Grieve <ag...@chromium.org>
> > wrote:
> > >>
> > >>> config.xml isn't in the www/ on all platforms.
> > >>>
> > >>>
> > >>> On Fri, Feb 28, 2014 at 4:15 PM, Jesse <pu...@gmail.com>
> > wrote:
> > >>>
> > >>> > function readConfig() {
> > >>> >     var xhr = new XMLHttpRequest();
> > >>> >     xhr.addEventListener("load", function () {
> > >>> >         var parser = new DOMParser();
> > >>> >         var doc = parser.parseFromString(xhr.responseText,
> > >>> > "application/xml");
> > >>> >         alert("Description : " +
> > >>> > doc.getElementsByTagName("description").item(0).textContent);
> > >>> >     });
> > >>> >     xhr.open("get", "../config.xml", true);
> > >>> >     xhr.send();
> > >>> > }
> > >>> >
> > >>> > @purplecabbage
> > >>> > risingj.com
> > >>> >
> > >>> >
> > >>> > On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <mmocny@chromium.org
> >
> > >>> wrote:
> > >>> >
> > >>> > > Now that I look a bit deeper, that plugin I only returns
> > <preferences>
> > >>> > > specifically, not the entire contents of config.xml (name is not
> a
> > >>> > > <preference>).
> > >>> > >
> > >>> > > It also does not currently implement a way to inspect all
> > preferences,
> > >>> > just
> > >>> > > has a way to get the value for a specific one.
> > >>> > >
> > >>> > > I do think it would be a good idea to just have one core plugin
> > >>> (perhaps
> > >>> > > extend that one I linked) to include all config file values.
> > >>> > >
> > >>> > > Filed: https://issues.apache.org/jira/browse/CB-6139
> > >>> > >
> > >>> > > -Michal
> > >>> > >
> > >>> > >
> > >>> > > On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <
> mmocny@chromium.org
> > >
> > >>> > wrote:
> > >>> > >
> > >>> > > > David already wrote a plugin for this a few months ago for us
> to
> > use
> > >>> in
> > >>> > > > the test harness:
> > >>> > > >
> > >>> > >
> > >>> >
> > >>>
> >
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
> > >>> > > >
> > >>> > > > I think he planned on proposing it for core but there was never
> > >>> really
> > >>> > a
> > >>> > > > reason for it.  I guess now's a good time to get that going.
> > >>> > > >
> > >>> > > > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <
> > agrieve@chromium.org
> > >>> > > >wrote:
> > >>> > > >
> > >>> > > >> Certainly a reasonable thing to want to do, but there's no way
> > >>> > currently
> > >>> > > >> short of writing a custom plugin, or a post-prepare hook.
> > >>> > > >>
> > >>> > > >>
> > >>> > > >>
> > >>> > > >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <
> > >>> ignisvulpis@gmail.com>
> > >>> > > >> wrote:
> > >>> > > >>
> > >>> > > >> > Hi,
> > >>> > > >> >
> > >>> > > >> > I fear this is a stupid question but I could not find the
> > answer
> > >>> in
> > >>> > > the
> > >>> > > >> > cordova docs or on the net or reading the source (Luke).
> > >>> > > >> >
> > >>> > > >> > As an app developer and cordova user how do I get data from
> > >>> > > config.xml?
> > >>> > > >> >
> > >>> > > >> > We want to add an "about" page to an cordova app and could
> not
> > >>> find
> > >>> > a
> > >>> > > >> > simple javascript way to get to things like author, id,
> > version,
> > >>> > name
> > >>> > > or
> > >>> > > >> > description from config.xml.
> > >>> > > >> > Writing a plugin seems to be overkill. Using the file or
> > >>> > file-transfer
> > >>> > > >> > plugins is heavy lifting too.
> > >>> > > >> >
> > >>> > > >> > Shouldn't there be a way to write cordova.config.name to
> get
> > the
> > >>> > > >> contents
> > >>> > > >> > of the name element in config.xml?
> > >>> > > >> >
> > >>> > > >> > Someone added "metadata" to cordova_plugins.js.
> > >>> > > >> > Maybe we could add something similar to cordova.js too?
> > >>> > > >> >
> > >>> > > >> > Does this make sense?
> > >>> > > >> >
> > >>> > > >> > Thanks
> > >>> > > >> > Axel
> > >>> > > >> >
> > >>> > > >>
> > >>> > > >
> > >>> > > >
> > >>> > >
> > >>> >
> > >>>
> >
>

Re: get config.xml data from js

Posted by Axel Nennker <ig...@gmail.com>.
Looks better than it works.
This does not trigger the alert. Neither with two / or three / after
"file:"
while "config.xml" alone works after I have put config.xml in www

                                document.addEventListener( "deviceready",
function() {
function readConfig() {
    var xhr = new XMLHttpRequest();
    xhr.addEventListener("load", function () {
        var parser = new DOMParser();
        var doc = parser.parseFromString(xhr.responseText,
"application/xml");
        alert("Description : " +
doc.getElementsByTagName("description").item(0).textContent);
    });
    xhr.open("get", "file:///android_res/xml/config.xml", true);
    xhr.send();
}
readConfig();

Anyway this is not very cross platform.



2014-02-28 22:57 GMT+01:00 Joe Bowser <bo...@gmail.com>:

> BTW: android_res and android_assets are special Android URIs that
> access the APK directly.  They are read-only directories, and they
> basically are used to access static files.  They also tend to be buggy
> as all hell, so YMMV.
>
> On Fri, Feb 28, 2014 at 1:54 PM, Joe Bowser <bo...@gmail.com> wrote:
> > Can't you just use an XHR to this URI:
> > file://android_res/xml/config.xml?
> >
> >
> >
> > On Fri, Feb 28, 2014 at 1:48 PM, Jesse <pu...@gmail.com> wrote:
> >> They seem to be in the root iOS, android, and windows phone.
> >>
> >> NSString* path = [[NSBundle mainBundle] pathForResource:@"config"
> ofType:
> >> @"xml"];
> >>
> >> int id = action.getResources().getIdentifier("config", "xml", action.
> >> getClass().getPackage().getName());
> >>
> >> *StreamResourceInfo streamInfo = Application.GetResourceStream(new
> >> Uri("config.xml", UriKind.Relative));*
> >>
> >>
> >>
> >> @purplecabbage
> >> risingj.com
> >>
> >>
> >> On Fri, Feb 28, 2014 at 1:21 PM, Andrew Grieve <ag...@chromium.org>
> wrote:
> >>
> >>> config.xml isn't in the www/ on all platforms.
> >>>
> >>>
> >>> On Fri, Feb 28, 2014 at 4:15 PM, Jesse <pu...@gmail.com>
> wrote:
> >>>
> >>> > function readConfig() {
> >>> >     var xhr = new XMLHttpRequest();
> >>> >     xhr.addEventListener("load", function () {
> >>> >         var parser = new DOMParser();
> >>> >         var doc = parser.parseFromString(xhr.responseText,
> >>> > "application/xml");
> >>> >         alert("Description : " +
> >>> > doc.getElementsByTagName("description").item(0).textContent);
> >>> >     });
> >>> >     xhr.open("get", "../config.xml", true);
> >>> >     xhr.send();
> >>> > }
> >>> >
> >>> > @purplecabbage
> >>> > risingj.com
> >>> >
> >>> >
> >>> > On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <mm...@chromium.org>
> >>> wrote:
> >>> >
> >>> > > Now that I look a bit deeper, that plugin I only returns
> <preferences>
> >>> > > specifically, not the entire contents of config.xml (name is not a
> >>> > > <preference>).
> >>> > >
> >>> > > It also does not currently implement a way to inspect all
> preferences,
> >>> > just
> >>> > > has a way to get the value for a specific one.
> >>> > >
> >>> > > I do think it would be a good idea to just have one core plugin
> >>> (perhaps
> >>> > > extend that one I linked) to include all config file values.
> >>> > >
> >>> > > Filed: https://issues.apache.org/jira/browse/CB-6139
> >>> > >
> >>> > > -Michal
> >>> > >
> >>> > >
> >>> > > On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <mmocny@chromium.org
> >
> >>> > wrote:
> >>> > >
> >>> > > > David already wrote a plugin for this a few months ago for us to
> use
> >>> in
> >>> > > > the test harness:
> >>> > > >
> >>> > >
> >>> >
> >>>
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
> >>> > > >
> >>> > > > I think he planned on proposing it for core but there was never
> >>> really
> >>> > a
> >>> > > > reason for it.  I guess now's a good time to get that going.
> >>> > > >
> >>> > > > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <
> agrieve@chromium.org
> >>> > > >wrote:
> >>> > > >
> >>> > > >> Certainly a reasonable thing to want to do, but there's no way
> >>> > currently
> >>> > > >> short of writing a custom plugin, or a post-prepare hook.
> >>> > > >>
> >>> > > >>
> >>> > > >>
> >>> > > >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <
> >>> ignisvulpis@gmail.com>
> >>> > > >> wrote:
> >>> > > >>
> >>> > > >> > Hi,
> >>> > > >> >
> >>> > > >> > I fear this is a stupid question but I could not find the
> answer
> >>> in
> >>> > > the
> >>> > > >> > cordova docs or on the net or reading the source (Luke).
> >>> > > >> >
> >>> > > >> > As an app developer and cordova user how do I get data from
> >>> > > config.xml?
> >>> > > >> >
> >>> > > >> > We want to add an "about" page to an cordova app and could not
> >>> find
> >>> > a
> >>> > > >> > simple javascript way to get to things like author, id,
> version,
> >>> > name
> >>> > > or
> >>> > > >> > description from config.xml.
> >>> > > >> > Writing a plugin seems to be overkill. Using the file or
> >>> > file-transfer
> >>> > > >> > plugins is heavy lifting too.
> >>> > > >> >
> >>> > > >> > Shouldn't there be a way to write cordova.config.name to get
> the
> >>> > > >> contents
> >>> > > >> > of the name element in config.xml?
> >>> > > >> >
> >>> > > >> > Someone added "metadata" to cordova_plugins.js.
> >>> > > >> > Maybe we could add something similar to cordova.js too?
> >>> > > >> >
> >>> > > >> > Does this make sense?
> >>> > > >> >
> >>> > > >> > Thanks
> >>> > > >> > Axel
> >>> > > >> >
> >>> > > >>
> >>> > > >
> >>> > > >
> >>> > >
> >>> >
> >>>
>

Re: get config.xml data from js

Posted by Joe Bowser <bo...@gmail.com>.
BTW: android_res and android_assets are special Android URIs that
access the APK directly.  They are read-only directories, and they
basically are used to access static files.  They also tend to be buggy
as all hell, so YMMV.

On Fri, Feb 28, 2014 at 1:54 PM, Joe Bowser <bo...@gmail.com> wrote:
> Can't you just use an XHR to this URI:
> file://android_res/xml/config.xml?
>
>
>
> On Fri, Feb 28, 2014 at 1:48 PM, Jesse <pu...@gmail.com> wrote:
>> They seem to be in the root iOS, android, and windows phone.
>>
>> NSString* path = [[NSBundle mainBundle] pathForResource:@"config" ofType:
>> @"xml"];
>>
>> int id = action.getResources().getIdentifier("config", "xml", action.
>> getClass().getPackage().getName());
>>
>> *StreamResourceInfo streamInfo = Application.GetResourceStream(new
>> Uri("config.xml", UriKind.Relative));*
>>
>>
>>
>> @purplecabbage
>> risingj.com
>>
>>
>> On Fri, Feb 28, 2014 at 1:21 PM, Andrew Grieve <ag...@chromium.org> wrote:
>>
>>> config.xml isn't in the www/ on all platforms.
>>>
>>>
>>> On Fri, Feb 28, 2014 at 4:15 PM, Jesse <pu...@gmail.com> wrote:
>>>
>>> > function readConfig() {
>>> >     var xhr = new XMLHttpRequest();
>>> >     xhr.addEventListener("load", function () {
>>> >         var parser = new DOMParser();
>>> >         var doc = parser.parseFromString(xhr.responseText,
>>> > "application/xml");
>>> >         alert("Description : " +
>>> > doc.getElementsByTagName("description").item(0).textContent);
>>> >     });
>>> >     xhr.open("get", "../config.xml", true);
>>> >     xhr.send();
>>> > }
>>> >
>>> > @purplecabbage
>>> > risingj.com
>>> >
>>> >
>>> > On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <mm...@chromium.org>
>>> wrote:
>>> >
>>> > > Now that I look a bit deeper, that plugin I only returns <preferences>
>>> > > specifically, not the entire contents of config.xml (name is not a
>>> > > <preference>).
>>> > >
>>> > > It also does not currently implement a way to inspect all preferences,
>>> > just
>>> > > has a way to get the value for a specific one.
>>> > >
>>> > > I do think it would be a good idea to just have one core plugin
>>> (perhaps
>>> > > extend that one I linked) to include all config file values.
>>> > >
>>> > > Filed: https://issues.apache.org/jira/browse/CB-6139
>>> > >
>>> > > -Michal
>>> > >
>>> > >
>>> > > On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <mm...@chromium.org>
>>> > wrote:
>>> > >
>>> > > > David already wrote a plugin for this a few months ago for us to use
>>> in
>>> > > > the test harness:
>>> > > >
>>> > >
>>> >
>>> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
>>> > > >
>>> > > > I think he planned on proposing it for core but there was never
>>> really
>>> > a
>>> > > > reason for it.  I guess now's a good time to get that going.
>>> > > >
>>> > > > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <agrieve@chromium.org
>>> > > >wrote:
>>> > > >
>>> > > >> Certainly a reasonable thing to want to do, but there's no way
>>> > currently
>>> > > >> short of writing a custom plugin, or a post-prepare hook.
>>> > > >>
>>> > > >>
>>> > > >>
>>> > > >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <
>>> ignisvulpis@gmail.com>
>>> > > >> wrote:
>>> > > >>
>>> > > >> > Hi,
>>> > > >> >
>>> > > >> > I fear this is a stupid question but I could not find the answer
>>> in
>>> > > the
>>> > > >> > cordova docs or on the net or reading the source (Luke).
>>> > > >> >
>>> > > >> > As an app developer and cordova user how do I get data from
>>> > > config.xml?
>>> > > >> >
>>> > > >> > We want to add an "about" page to an cordova app and could not
>>> find
>>> > a
>>> > > >> > simple javascript way to get to things like author, id, version,
>>> > name
>>> > > or
>>> > > >> > description from config.xml.
>>> > > >> > Writing a plugin seems to be overkill. Using the file or
>>> > file-transfer
>>> > > >> > plugins is heavy lifting too.
>>> > > >> >
>>> > > >> > Shouldn't there be a way to write cordova.config.name to get the
>>> > > >> contents
>>> > > >> > of the name element in config.xml?
>>> > > >> >
>>> > > >> > Someone added "metadata" to cordova_plugins.js.
>>> > > >> > Maybe we could add something similar to cordova.js too?
>>> > > >> >
>>> > > >> > Does this make sense?
>>> > > >> >
>>> > > >> > Thanks
>>> > > >> > Axel
>>> > > >> >
>>> > > >>
>>> > > >
>>> > > >
>>> > >
>>> >
>>>

Re: get config.xml data from js

Posted by Joe Bowser <bo...@gmail.com>.
Can't you just use an XHR to this URI:
file://android_res/xml/config.xml?



On Fri, Feb 28, 2014 at 1:48 PM, Jesse <pu...@gmail.com> wrote:
> They seem to be in the root iOS, android, and windows phone.
>
> NSString* path = [[NSBundle mainBundle] pathForResource:@"config" ofType:
> @"xml"];
>
> int id = action.getResources().getIdentifier("config", "xml", action.
> getClass().getPackage().getName());
>
> *StreamResourceInfo streamInfo = Application.GetResourceStream(new
> Uri("config.xml", UriKind.Relative));*
>
>
>
> @purplecabbage
> risingj.com
>
>
> On Fri, Feb 28, 2014 at 1:21 PM, Andrew Grieve <ag...@chromium.org> wrote:
>
>> config.xml isn't in the www/ on all platforms.
>>
>>
>> On Fri, Feb 28, 2014 at 4:15 PM, Jesse <pu...@gmail.com> wrote:
>>
>> > function readConfig() {
>> >     var xhr = new XMLHttpRequest();
>> >     xhr.addEventListener("load", function () {
>> >         var parser = new DOMParser();
>> >         var doc = parser.parseFromString(xhr.responseText,
>> > "application/xml");
>> >         alert("Description : " +
>> > doc.getElementsByTagName("description").item(0).textContent);
>> >     });
>> >     xhr.open("get", "../config.xml", true);
>> >     xhr.send();
>> > }
>> >
>> > @purplecabbage
>> > risingj.com
>> >
>> >
>> > On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <mm...@chromium.org>
>> wrote:
>> >
>> > > Now that I look a bit deeper, that plugin I only returns <preferences>
>> > > specifically, not the entire contents of config.xml (name is not a
>> > > <preference>).
>> > >
>> > > It also does not currently implement a way to inspect all preferences,
>> > just
>> > > has a way to get the value for a specific one.
>> > >
>> > > I do think it would be a good idea to just have one core plugin
>> (perhaps
>> > > extend that one I linked) to include all config file values.
>> > >
>> > > Filed: https://issues.apache.org/jira/browse/CB-6139
>> > >
>> > > -Michal
>> > >
>> > >
>> > > On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <mm...@chromium.org>
>> > wrote:
>> > >
>> > > > David already wrote a plugin for this a few months ago for us to use
>> in
>> > > > the test harness:
>> > > >
>> > >
>> >
>> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
>> > > >
>> > > > I think he planned on proposing it for core but there was never
>> really
>> > a
>> > > > reason for it.  I guess now's a good time to get that going.
>> > > >
>> > > > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <agrieve@chromium.org
>> > > >wrote:
>> > > >
>> > > >> Certainly a reasonable thing to want to do, but there's no way
>> > currently
>> > > >> short of writing a custom plugin, or a post-prepare hook.
>> > > >>
>> > > >>
>> > > >>
>> > > >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <
>> ignisvulpis@gmail.com>
>> > > >> wrote:
>> > > >>
>> > > >> > Hi,
>> > > >> >
>> > > >> > I fear this is a stupid question but I could not find the answer
>> in
>> > > the
>> > > >> > cordova docs or on the net or reading the source (Luke).
>> > > >> >
>> > > >> > As an app developer and cordova user how do I get data from
>> > > config.xml?
>> > > >> >
>> > > >> > We want to add an "about" page to an cordova app and could not
>> find
>> > a
>> > > >> > simple javascript way to get to things like author, id, version,
>> > name
>> > > or
>> > > >> > description from config.xml.
>> > > >> > Writing a plugin seems to be overkill. Using the file or
>> > file-transfer
>> > > >> > plugins is heavy lifting too.
>> > > >> >
>> > > >> > Shouldn't there be a way to write cordova.config.name to get the
>> > > >> contents
>> > > >> > of the name element in config.xml?
>> > > >> >
>> > > >> > Someone added "metadata" to cordova_plugins.js.
>> > > >> > Maybe we could add something similar to cordova.js too?
>> > > >> >
>> > > >> > Does this make sense?
>> > > >> >
>> > > >> > Thanks
>> > > >> > Axel
>> > > >> >
>> > > >>
>> > > >
>> > > >
>> > >
>> >
>>

Re: get config.xml data from js

Posted by Jesse <pu...@gmail.com>.
They seem to be in the root iOS, android, and windows phone.

NSString* path = [[NSBundle mainBundle] pathForResource:@"config" ofType:
@"xml"];

int id = action.getResources().getIdentifier("config", "xml", action.
getClass().getPackage().getName());

*StreamResourceInfo streamInfo = Application.GetResourceStream(new
Uri("config.xml", UriKind.Relative));*



@purplecabbage
risingj.com


On Fri, Feb 28, 2014 at 1:21 PM, Andrew Grieve <ag...@chromium.org> wrote:

> config.xml isn't in the www/ on all platforms.
>
>
> On Fri, Feb 28, 2014 at 4:15 PM, Jesse <pu...@gmail.com> wrote:
>
> > function readConfig() {
> >     var xhr = new XMLHttpRequest();
> >     xhr.addEventListener("load", function () {
> >         var parser = new DOMParser();
> >         var doc = parser.parseFromString(xhr.responseText,
> > "application/xml");
> >         alert("Description : " +
> > doc.getElementsByTagName("description").item(0).textContent);
> >     });
> >     xhr.open("get", "../config.xml", true);
> >     xhr.send();
> > }
> >
> > @purplecabbage
> > risingj.com
> >
> >
> > On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <mm...@chromium.org>
> wrote:
> >
> > > Now that I look a bit deeper, that plugin I only returns <preferences>
> > > specifically, not the entire contents of config.xml (name is not a
> > > <preference>).
> > >
> > > It also does not currently implement a way to inspect all preferences,
> > just
> > > has a way to get the value for a specific one.
> > >
> > > I do think it would be a good idea to just have one core plugin
> (perhaps
> > > extend that one I linked) to include all config file values.
> > >
> > > Filed: https://issues.apache.org/jira/browse/CB-6139
> > >
> > > -Michal
> > >
> > >
> > > On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <mm...@chromium.org>
> > wrote:
> > >
> > > > David already wrote a plugin for this a few months ago for us to use
> in
> > > > the test harness:
> > > >
> > >
> >
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
> > > >
> > > > I think he planned on proposing it for core but there was never
> really
> > a
> > > > reason for it.  I guess now's a good time to get that going.
> > > >
> > > > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <agrieve@chromium.org
> > > >wrote:
> > > >
> > > >> Certainly a reasonable thing to want to do, but there's no way
> > currently
> > > >> short of writing a custom plugin, or a post-prepare hook.
> > > >>
> > > >>
> > > >>
> > > >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <
> ignisvulpis@gmail.com>
> > > >> wrote:
> > > >>
> > > >> > Hi,
> > > >> >
> > > >> > I fear this is a stupid question but I could not find the answer
> in
> > > the
> > > >> > cordova docs or on the net or reading the source (Luke).
> > > >> >
> > > >> > As an app developer and cordova user how do I get data from
> > > config.xml?
> > > >> >
> > > >> > We want to add an "about" page to an cordova app and could not
> find
> > a
> > > >> > simple javascript way to get to things like author, id, version,
> > name
> > > or
> > > >> > description from config.xml.
> > > >> > Writing a plugin seems to be overkill. Using the file or
> > file-transfer
> > > >> > plugins is heavy lifting too.
> > > >> >
> > > >> > Shouldn't there be a way to write cordova.config.name to get the
> > > >> contents
> > > >> > of the name element in config.xml?
> > > >> >
> > > >> > Someone added "metadata" to cordova_plugins.js.
> > > >> > Maybe we could add something similar to cordova.js too?
> > > >> >
> > > >> > Does this make sense?
> > > >> >
> > > >> > Thanks
> > > >> > Axel
> > > >> >
> > > >>
> > > >
> > > >
> > >
> >
>

Re: get config.xml data from js

Posted by Andrew Grieve <ag...@chromium.org>.
config.xml isn't in the www/ on all platforms.


On Fri, Feb 28, 2014 at 4:15 PM, Jesse <pu...@gmail.com> wrote:

> function readConfig() {
>     var xhr = new XMLHttpRequest();
>     xhr.addEventListener("load", function () {
>         var parser = new DOMParser();
>         var doc = parser.parseFromString(xhr.responseText,
> "application/xml");
>         alert("Description : " +
> doc.getElementsByTagName("description").item(0).textContent);
>     });
>     xhr.open("get", "../config.xml", true);
>     xhr.send();
> }
>
> @purplecabbage
> risingj.com
>
>
> On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <mm...@chromium.org> wrote:
>
> > Now that I look a bit deeper, that plugin I only returns <preferences>
> > specifically, not the entire contents of config.xml (name is not a
> > <preference>).
> >
> > It also does not currently implement a way to inspect all preferences,
> just
> > has a way to get the value for a specific one.
> >
> > I do think it would be a good idea to just have one core plugin (perhaps
> > extend that one I linked) to include all config file values.
> >
> > Filed: https://issues.apache.org/jira/browse/CB-6139
> >
> > -Michal
> >
> >
> > On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <mm...@chromium.org>
> wrote:
> >
> > > David already wrote a plugin for this a few months ago for us to use in
> > > the test harness:
> > >
> >
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
> > >
> > > I think he planned on proposing it for core but there was never really
> a
> > > reason for it.  I guess now's a good time to get that going.
> > >
> > > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <agrieve@chromium.org
> > >wrote:
> > >
> > >> Certainly a reasonable thing to want to do, but there's no way
> currently
> > >> short of writing a custom plugin, or a post-prepare hook.
> > >>
> > >>
> > >>
> > >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <ig...@gmail.com>
> > >> wrote:
> > >>
> > >> > Hi,
> > >> >
> > >> > I fear this is a stupid question but I could not find the answer in
> > the
> > >> > cordova docs or on the net or reading the source (Luke).
> > >> >
> > >> > As an app developer and cordova user how do I get data from
> > config.xml?
> > >> >
> > >> > We want to add an "about" page to an cordova app and could not find
> a
> > >> > simple javascript way to get to things like author, id, version,
> name
> > or
> > >> > description from config.xml.
> > >> > Writing a plugin seems to be overkill. Using the file or
> file-transfer
> > >> > plugins is heavy lifting too.
> > >> >
> > >> > Shouldn't there be a way to write cordova.config.name to get the
> > >> contents
> > >> > of the name element in config.xml?
> > >> >
> > >> > Someone added "metadata" to cordova_plugins.js.
> > >> > Maybe we could add something similar to cordova.js too?
> > >> >
> > >> > Does this make sense?
> > >> >
> > >> > Thanks
> > >> > Axel
> > >> >
> > >>
> > >
> > >
> >
>

Re: get config.xml data from js

Posted by Axel Nennker <ig...@gmail.com>.
Jesse. Thanks that works after I put config.xml back into www and removed
the ../ from your code.
But I had just changed my project's structure to remove config.xml from www.
I think it is better to have some cli script to handle this without the
need for a platform dependent plugin.
Maybe prepare.js?



2014-02-28 22:15 GMT+01:00 Jesse <pu...@gmail.com>:

> function readConfig() {
>     var xhr = new XMLHttpRequest();
>     xhr.addEventListener("load", function () {
>         var parser = new DOMParser();
>         var doc = parser.parseFromString(xhr.responseText,
> "application/xml");
>         alert("Description : " +
> doc.getElementsByTagName("description").item(0).textContent);
>     });
>     xhr.open("get", "../config.xml", true);
>     xhr.send();
> }
>
> @purplecabbage
> risingj.com
>
>
> On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <mm...@chromium.org> wrote:
>
> > Now that I look a bit deeper, that plugin I only returns <preferences>
> > specifically, not the entire contents of config.xml (name is not a
> > <preference>).
> >
> > It also does not currently implement a way to inspect all preferences,
> just
> > has a way to get the value for a specific one.
> >
> > I do think it would be a good idea to just have one core plugin (perhaps
> > extend that one I linked) to include all config file values.
> >
> > Filed: https://issues.apache.org/jira/browse/CB-6139
> >
> > -Michal
> >
> >
> > On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <mm...@chromium.org>
> wrote:
> >
> > > David already wrote a plugin for this a few months ago for us to use in
> > > the test harness:
> > >
> >
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
> > >
> > > I think he planned on proposing it for core but there was never really
> a
> > > reason for it.  I guess now's a good time to get that going.
> > >
> > > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <agrieve@chromium.org
> > >wrote:
> > >
> > >> Certainly a reasonable thing to want to do, but there's no way
> currently
> > >> short of writing a custom plugin, or a post-prepare hook.
> > >>
> > >>
> > >>
> > >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <ig...@gmail.com>
> > >> wrote:
> > >>
> > >> > Hi,
> > >> >
> > >> > I fear this is a stupid question but I could not find the answer in
> > the
> > >> > cordova docs or on the net or reading the source (Luke).
> > >> >
> > >> > As an app developer and cordova user how do I get data from
> > config.xml?
> > >> >
> > >> > We want to add an "about" page to an cordova app and could not find
> a
> > >> > simple javascript way to get to things like author, id, version,
> name
> > or
> > >> > description from config.xml.
> > >> > Writing a plugin seems to be overkill. Using the file or
> file-transfer
> > >> > plugins is heavy lifting too.
> > >> >
> > >> > Shouldn't there be a way to write cordova.config.name to get the
> > >> contents
> > >> > of the name element in config.xml?
> > >> >
> > >> > Someone added "metadata" to cordova_plugins.js.
> > >> > Maybe we could add something similar to cordova.js too?
> > >> >
> > >> > Does this make sense?
> > >> >
> > >> > Thanks
> > >> > Axel
> > >> >
> > >>
> > >
> > >
> >
>

Re: get config.xml data from js

Posted by Jesse <pu...@gmail.com>.
function readConfig() {
    var xhr = new XMLHttpRequest();
    xhr.addEventListener("load", function () {
        var parser = new DOMParser();
        var doc = parser.parseFromString(xhr.responseText,
"application/xml");
        alert("Description : " +
doc.getElementsByTagName("description").item(0).textContent);
    });
    xhr.open("get", "../config.xml", true);
    xhr.send();
}

@purplecabbage
risingj.com


On Fri, Feb 28, 2014 at 1:06 PM, Michal Mocny <mm...@chromium.org> wrote:

> Now that I look a bit deeper, that plugin I only returns <preferences>
> specifically, not the entire contents of config.xml (name is not a
> <preference>).
>
> It also does not currently implement a way to inspect all preferences, just
> has a way to get the value for a specific one.
>
> I do think it would be a good idea to just have one core plugin (perhaps
> extend that one I linked) to include all config file values.
>
> Filed: https://issues.apache.org/jira/browse/CB-6139
>
> -Michal
>
>
> On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <mm...@chromium.org> wrote:
>
> > David already wrote a plugin for this a few months ago for us to use in
> > the test harness:
> >
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
> >
> > I think he planned on proposing it for core but there was never really a
> > reason for it.  I guess now's a good time to get that going.
> >
> > On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <agrieve@chromium.org
> >wrote:
> >
> >> Certainly a reasonable thing to want to do, but there's no way currently
> >> short of writing a custom plugin, or a post-prepare hook.
> >>
> >>
> >>
> >> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <ig...@gmail.com>
> >> wrote:
> >>
> >> > Hi,
> >> >
> >> > I fear this is a stupid question but I could not find the answer in
> the
> >> > cordova docs or on the net or reading the source (Luke).
> >> >
> >> > As an app developer and cordova user how do I get data from
> config.xml?
> >> >
> >> > We want to add an "about" page to an cordova app and could not find a
> >> > simple javascript way to get to things like author, id, version, name
> or
> >> > description from config.xml.
> >> > Writing a plugin seems to be overkill. Using the file or file-transfer
> >> > plugins is heavy lifting too.
> >> >
> >> > Shouldn't there be a way to write cordova.config.name to get the
> >> contents
> >> > of the name element in config.xml?
> >> >
> >> > Someone added "metadata" to cordova_plugins.js.
> >> > Maybe we could add something similar to cordova.js too?
> >> >
> >> > Does this make sense?
> >> >
> >> > Thanks
> >> > Axel
> >> >
> >>
> >
> >
>

RE: get config.xml data from js

Posted by Jonathan Bond-Caron <jb...@gdesolutions.com>.
On Fri Feb 28 04:06 PM, Michal Mocny wrote:
> Now that I look a bit deeper, that plugin I only returns <preferences>
> specifically,
> not the entire contents of config.xml (name is not a
> <preference>).
> 
> It also does not currently implement a way to inspect all preferences,
> just has a
> way to get the value for a specific one.
> 
> I do think it would be a good idea to just have one core plugin (perhaps
> extend
> that one I linked) to include all config file values.
> 
> Filed: https://issues.apache.org/jira/browse/CB-6139
> 

Could also be added cordova_plugins.js
https://github.com/apache/cordova-plugman/blob/master/src/prepare.js#L220

pluginMetadata['config'] = {...}

See part about "runtime meta":
https://wiki.apache.org/cordova/config/cordova.xml

Note change for "icons" to align with:
http://www.w3.org/TR/2013/WD-appmanifest-20131217/



Re: get config.xml data from js

Posted by Michal Mocny <mm...@chromium.org>.
Now that I look a bit deeper, that plugin I only returns <preferences>
specifically, not the entire contents of config.xml (name is not a
<preference>).

It also does not currently implement a way to inspect all preferences, just
has a way to get the value for a specific one.

I do think it would be a good idea to just have one core plugin (perhaps
extend that one I linked) to include all config file values.

Filed: https://issues.apache.org/jira/browse/CB-6139

-Michal


On Fri, Feb 28, 2014 at 3:57 PM, Michal Mocny <mm...@chromium.org> wrote:

> David already wrote a plugin for this a few months ago for us to use in
> the test harness:
> https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings
>
> I think he planned on proposing it for core but there was never really a
> reason for it.  I guess now's a good time to get that going.
>
> On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <ag...@chromium.org>wrote:
>
>> Certainly a reasonable thing to want to do, but there's no way currently
>> short of writing a custom plugin, or a post-prepare hook.
>>
>>
>>
>> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <ig...@gmail.com>
>> wrote:
>>
>> > Hi,
>> >
>> > I fear this is a stupid question but I could not find the answer in the
>> > cordova docs or on the net or reading the source (Luke).
>> >
>> > As an app developer and cordova user how do I get data from config.xml?
>> >
>> > We want to add an "about" page to an cordova app and could not find a
>> > simple javascript way to get to things like author, id, version, name or
>> > description from config.xml.
>> > Writing a plugin seems to be overkill. Using the file or file-transfer
>> > plugins is heavy lifting too.
>> >
>> > Shouldn't there be a way to write cordova.config.name to get the
>> contents
>> > of the name element in config.xml?
>> >
>> > Someone added "metadata" to cordova_plugins.js.
>> > Maybe we could add something similar to cordova.js too?
>> >
>> > Does this make sense?
>> >
>> > Thanks
>> > Axel
>> >
>>
>
>

Re: get config.xml data from js

Posted by Michal Mocny <mm...@chromium.org>.
David already wrote a plugin for this a few months ago for us to use in the
test harness:
https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appsettings

I think he planned on proposing it for core but there was never really a
reason for it.  I guess now's a good time to get that going.

On Fri, Feb 28, 2014 at 3:39 PM, Andrew Grieve <ag...@chromium.org> wrote:

> Certainly a reasonable thing to want to do, but there's no way currently
> short of writing a custom plugin, or a post-prepare hook.
>
>
>
> On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <ig...@gmail.com>
> wrote:
>
> > Hi,
> >
> > I fear this is a stupid question but I could not find the answer in the
> > cordova docs or on the net or reading the source (Luke).
> >
> > As an app developer and cordova user how do I get data from config.xml?
> >
> > We want to add an "about" page to an cordova app and could not find a
> > simple javascript way to get to things like author, id, version, name or
> > description from config.xml.
> > Writing a plugin seems to be overkill. Using the file or file-transfer
> > plugins is heavy lifting too.
> >
> > Shouldn't there be a way to write cordova.config.name to get the
> contents
> > of the name element in config.xml?
> >
> > Someone added "metadata" to cordova_plugins.js.
> > Maybe we could add something similar to cordova.js too?
> >
> > Does this make sense?
> >
> > Thanks
> > Axel
> >
>

Re: get config.xml data from js

Posted by Andrew Grieve <ag...@chromium.org>.
Certainly a reasonable thing to want to do, but there's no way currently
short of writing a custom plugin, or a post-prepare hook.



On Fri, Feb 28, 2014 at 3:34 PM, Axel Nennker <ig...@gmail.com> wrote:

> Hi,
>
> I fear this is a stupid question but I could not find the answer in the
> cordova docs or on the net or reading the source (Luke).
>
> As an app developer and cordova user how do I get data from config.xml?
>
> We want to add an "about" page to an cordova app and could not find a
> simple javascript way to get to things like author, id, version, name or
> description from config.xml.
> Writing a plugin seems to be overkill. Using the file or file-transfer
> plugins is heavy lifting too.
>
> Shouldn't there be a way to write cordova.config.name to get the contents
> of the name element in config.xml?
>
> Someone added "metadata" to cordova_plugins.js.
> Maybe we could add something similar to cordova.js too?
>
> Does this make sense?
>
> Thanks
> Axel
>