将 Google Gears 与 Rails 结合使用

发布于 2024-07-15 20:18:59 字数 252 浏览 6 评论 0原文

我的任务是探索离线访问我的网络应用程序的可能性。 人们使用 google gears 和 Rails 的体验如何? 我知道 gearsonrails 项目,但它有一些非常奇怪的结构,而且似乎并不重要,积极发展。

还有其他选择吗? 有人成功地将齿轮添加到现有的 Rails 应用程序中吗? 这是超级痛苦吗?

I have been tasked with exploring the possibility of offline access of my webapp. What are people's experiences using google gears with rails? I am aware of the gearsonrails project, but it has some really strange constructs and doesn't appear to be under significant, active development.

Are there other options? Has anyone added gears to their existing rails app successfully? Is this super-painful?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

や三分注定 2024-07-22 20:18:59

Google Gears 已停止开发,正在开发已经停止了。 您最好尝试使用 HTML5 来解决您的问题,HTML5 实现了使离线访问成为可能的 API(可以使用类似 SQL 的语言和键值存储来查询的客户端数据库)。主要浏览器完全实现(开发中)标准。 因此,您必须做出决定,是针对事实上已过时的插件进行开发,还是针对新兴标准进行开发。

Google Gears is dead, development has ceased. You're better off trying to solve your problem using HTML5, which implements APIs that make offline access possible (a client side database that can be queried using a SQL like language and a key-value store.) At this point, none of the major browsers completely implement the (developing) standard. So you have to make the decision between developing against a de facto obsolete plugin, or targeting an emerging standard.

清风不识月 2024-07-22 20:18:59

我自己正在研究这个 - 一般来说,这个想法是,根据你想要离线使用的内容,你需要在客户端进行设置(注意,这是未经测试的,因此未经验证 - 我只是从我的理解出发我已经阅读过 - 尽管我计划在接下来的几周内进行一些实验...)

我建议使用 Rails 设置标准的 Restful 资源,然后在您的客户端库中执行如下操作:

  1. 在大多数情况下, 加载后,确定 Gears 是否已加载,以及您的数据库在客户端上是否可用。
  2. 如有必要,创建数据库。
  3. 使用工作进程,初始化对 RESTful 控制器的调用以获取所需的数据 - 并在数据返回时将其写入本地数据库(使用工作进程将允许“多线程”体验并确保您不要锁定客户端。
  4. 定期轮询远程服务器以检查数据更改 - 如果需要,则拉取新的数据集并重新加载本地数据缓存。
  5. 当客户端离线时,请切换到使用本地客户端数据库

。 -仅作为示例,并依赖于使用 AJAX 客户端调用来填充页面中的数据等的现有架构。

您的方法可能会有所不同,但我建议您尝试一下 - 请记住您没有使用 Rails 插件等来做到这一点 - 你可以自己滚动客户端脚本 - 你永远不知道,一旦你完成了,你可能能够将你的工作重构为一个很棒的小 gem 或类似的东西......

I am looking into this myself - generally the idea is that depending on what you want to make available offline you need to setup on the client side (note, this is untested, and hence unverified - I'm just going from my understanding of what I have read - although I am planning on doing some experimentation in the next few weeks...)

In most situations I would recommend setting up standard restful resources with Rails, and then in your client library do something like the following:

  1. When the page is loaded, determine if Gears has loaded, and if your database is available on the client.
  2. Create the database if necessary.
  3. Using the worker process, intialize a call into your RESTful controller to obtain the data you need - and on the return of the data write it into the local database (using the worker process will allow for a 'multi threaded' experience and make sure you dont lock up the client.
  4. Periodically poll the remote server checking for changes in the data - if needed pull down a fresh set and reload the local data cache.
  5. When the client is offline switch to using the local client database.

Obviously this is a read-only example, and relies on the existing architecture using AJAX client side calls to populate data in the page etc.

Your means might vary, but I recommend just having a play around - remember you don't have to use Rails plugins etc to do this - you can just roll the client side script by yourself - and you never know, once your done you might be able to refactor your work out into a great little gem or similar...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文