7 messages in com.googlegroups.google-gearsRe: [google-gears] Re: allow Google G...| From | Sent On | Attachments |
|---|---|---|
| I. E. Smith-Heisters | 18 Feb 2008 16:42 | |
| Ben Lisbakken | 19 Feb 2008 18:17 | |
| Ian Smith-Heisters | 20 Feb 2008 08:41 | |
| Ian Smith-Heisters | 20 Feb 2008 08:45 | |
| Ben Lisbakken | 20 Feb 2008 09:10 | |
| Ian Smith-Heisters | 20 Feb 2008 09:20 | |
| Ben Lisbakken | 20 Feb 2008 09:29 |
| Subject: | Re: [google-gears] Re: allow Google Gears for local files![]() |
|---|---|
| From: | Ian Smith-Heisters (i....@0x09.com) |
| Date: | 02/20/2008 08:45:58 AM |
| List: | com.googlegroups.google-gears |
Oops, forgot to put gears_init.js in the path for test.html, it works as expected in that case.
I can't go back and look at what I was doing previously since I moved everything around to get it to work w/ mongrel. So I'd just assume that I had something wrong with the paths and that the issue is, well, a non-issue. Sorry to waste your time.
-Ian
On 2/20/08, Ian Smith-Heisters <i....@0x09.com> wrote:
I put the test code from the page you linked (pasted below for clarity) in a test.html file on my HDD, opened Firefox, File -> Open to open test.html, and got this in the Firebug console:
google is not defined var db = google.gears.factory.create('beta.database');
Tools -> Google Gears Settings shows two sites under Allowed Sites, and none under Denied Sites.
FWIW, I got this working by serving it up w/ Mongrel so that I added localhost:3000 to Gears' list of Allowed Sites. But it'd still be nice if I could access the files without needing a webserver.
I'm on Ubuntu Gutsy, Firefox 2.0.0.12.
-Ian
$ cat test.html
<script type="text/javascript" src="gears_init.js"></script>
<script type="text/javascript">
var db = google.gears.factory.create('beta.database');
db.open('database-test');
db.execute('create table if not exists Test' +
' (Phrase text, Timestamp int)');
db.execute('insert into Test values (?, ?)', ['Monkey!', new
Date().getTime()]);
var rs = db.execute('select * from Test order by Timestamp desc');
while (rs.isValidRow()) { alert(rs.field(0) + '@' + rs.field(1)); rs.next(); } rs.close(); </script>
On 2/19/08, Ben Lisbakken <lisb...@google.com> wrote:
Ian --
You are correct that when google.gears.factory.create() is called it should prompt the user to allow the site. What you are trying to do should work. Could you share the code that you are using?
Try using the example code found near the top of this page: http://code.google.com/apis/gears/api_database.html
What browser/OS are you using so I can try to reproduce the problem? Are you using LocalServer or just the database?
-Ben
On Feb 18, 4:43 pm, "I. E. Smith-Heisters" <i....@0x09.com> wrote:
Hi all.
For testing purposes, I want to run google gears in a regular, offline, html file:
file:///foo/bar/testy_test.html
When the tests in that file attempt to access the "google" object, which should have been initialized by loading gears_init.js, nothing happens and the test fails because google is undefined:
>>> google.gears.factory.create('beta.database') google is not defined
I can only guess that this is because my application hasn't been added to the list of allowed applications. My understanding so far is that if your application isn't currently allowed, calling something like google.gears.factory.create() should automatically prompt the user to allow the site. When I serve the file via mongrel at localhost:3000, the allowance prompt works as expected, as does my code that depends on it. Does gears not work when running it from a local file? Is there any way to work around this?
Thanks, Ian




