Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 17F3010A2D for ; Sat, 1 Mar 2014 19:56:06 +0000 (UTC) Received: (qmail 70799 invoked by uid 500); 1 Mar 2014 19:56:05 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 70775 invoked by uid 500); 1 Mar 2014 19:56:04 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 70766 invoked by uid 99); 1 Mar 2014 19:56:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Mar 2014 19:56:04 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [208.65.78.88] (HELO smtp-p01.blackberry.com) (208.65.78.88) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Mar 2014 19:55:59 +0000 Received: from xct108cnc.rim.net ([10.65.161.208]) by mhs211cnc.rim.net with ESMTP/TLS/AES128-SHA; 01 Mar 2014 14:55:37 -0500 Received: from XCT128CNC.rim.net (10.65.161.228) by XCT108CNC.rim.net (10.65.161.208) with Microsoft SMTP Server (TLS) id 14.3.158.1; Sat, 1 Mar 2014 14:55:37 -0500 Received: from XMB136CNC.rim.net ([fe80::e123:2d0d:9c04:7f59]) by XCT128CNC.rim.net ([fe80::5845:7e40:a55c:b23d%17]) with mapi id 14.03.0158.001; Sat, 1 Mar 2014 14:55:36 -0500 From: Ken Wallis To: "dev@cordova.apache.org" Subject: Re: get config.xml data from js Thread-Topic: get config.xml data from js Thread-Index: AQHPNM+0iSkSd+ezkkWZK5wioi57rJrLinmAgAACUwCAAALagIAAC2EAgAAE9gCAAAOIAIABTRCA//+2OLg= Date: Sat, 1 Mar 2014 19:55:36 +0000 Message-ID: <20140301195534.27099291.62740.2132@blackberry.com> References: , In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="windows-1256" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org =FDWe have had a couple of requests around this for BlackBerry. Particularl= y in the scenario where it is in combination with a custom solution/environ= ment 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 conf= ig. It doesn't happen often, but for every one that we hear about, I am sure th= ere are a few more that we don't. [1] =FDhttp://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" 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 wrote: > > > So, before we go too much farther with this...what is the usecase? Coul= d > 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 > > wrote: > > > > > cordova.js is platform specific anyway. > > > Am 28.02.2014 23:16 schrieb "Jesse" : > > > > > > > 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/cd6b3d11b58f38932797f1f4130= ce40f772bdcd5/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 > > > > > 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 =3D new XMLHttpRequest(); > > > > > xhr.addEventListener("load", function () { > > > > > var parser =3D new DOMParser(); > > > > > var doc =3D 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 : > > > > > > > > > > > BTW: android_res and android_assets are special Android URIs th= at > > > > > > access the APK directly. They are read-only directories, and > they > > > > > > basically are used to access static files. They also tend to b= e > > > buggy > > > > > > as all hell, so YMMV. > > > > > > > > > > > > On Fri, Feb 28, 2014 at 1:54 PM, Joe Bowser > > > 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 =3D [[NSBundle mainBundle] pathForResource:@ > > "config" > > > > > > ofType: > > > > > > >> @"xml"]; > > > > > > >> > > > > > > >> int id =3D action.getResources().getIdentifier("config", "xm= l", > > > > action. > > > > > > >> getClass().getPackage().getName()); > > > > > > >> > > > > > > >> *StreamResourceInfo streamInfo =3D > > 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 =3D new XMLHttpRequest(); > > > > > > >>> > xhr.addEventListener("load", function () { > > > > > > >>> > var parser =3D new DOMParser(); > > > > > > >>> > var doc =3D parser.parseFromString(xhr.responseTe= xt, > > > > > > >>> > "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 return= s > > > > > > > > > > > > >>> > > specifically, not the entire contents of config.xml (na= me > > is > > > > not > > > > > a > > > > > > >>> > > ). > > > > > > >>> > > > > > > > > >>> > > It also does not currently implement a way to inspect a= ll > > > > > > 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 cor= e > > > 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 ag= o > > for > > > us > > > > > to > > > > > > use > > > > > > >>> in > > > > > > >>> > > > the test harness: > > > > > > >>> > > > > > > > > > >>> > > > > > > > > >>> > > > > > > > >>> > > > > > > > > > > > > > > > > > > > > > https://github.com/apache/cordova-labs/tree/cdvtest/cordova-plugin-appset= tings > > > > > > >>> > > > > > > > > > >>> > > > 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 a= nd > > > 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 > > > > > > >>> > > >> > > > > > > > >>> > > >> > > > > > > >>> > > > > > > > > > >>> > > > > > > > > > >>> > > > > > > > > >>> > > > > > > > >>> > > > > > > > > > > > > > > > > > > > > >