Couchapp 是 Web 框架的现实替代品吗?

发布于 2024-11-04 18:19:51 字数 1431 浏览 0 评论 0原文

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

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

发布评论

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

评论(2

再浓的妆也掩不了殇 2024-11-11 18:19:51

是的,通常 CouchApp 会在整个应用程序中使用 AJAX,但这不是必需的。可以创建一个 CouchApp,为没有 JS(和搜索引擎)的浏览器提供后备并呈现核心内容。

这通常有点复杂,需要编写两次渲染函数。一旦在设计文档中作为显示或列表功能,然后再次作为客户端代码。不过,我一直在开发一个名为 Kanso 的 CouchApp 框架,它允许您编写一次代码,然后如果可能的话让它在客户端运行,如果不行的话就回退到 CouchDB。

我发现 CouchApps 的另一个问题是,对于较大的应用程序,验证和权限代码可能会很快变得非常复杂。因此 Kanso 还提供了类似于您可能在 Django 或 Rails 中使用的其他模型系统的类型定义。

需要明确的是:如果没有 JS,您将无法在浏览器上获得相同的体验,但是您可以做的是渲染页面的基本内容,然后使用 JavaScript 逐步增强它。

这就是 Kanso 的设计目的:)

Yes, normally a CouchApp would use AJAX for the whole application, though that's not a requirement. It's possible to create a CouchApp that will provide a fallback and render the core content for browsers without JS (and search engines).

This is normally a little complicated and involes writing your rendering functions twice. Once in the design doc as a show or list function, then again for your client-side code. However, I've been working on a CouchApp framework called Kanso, which allows you to write code once and have it run on the client-side when possible and fall-back to CouchDB when that's not.

Another problem I've found with CouchApps is that the validation and permissions code can get very complicated quickly with a bigger app. So Kanso also provides Type definitions similar to other Model systems you might have used in Django or Rails.

Just to be clear: You will not achieve the same experience for browsers without JS, but what you can do is render the basic content of the page and then progressively enhance it with JavaScript.

This is what Kanso was designed for :)

ゝ杯具 2024-11-11 18:19:51

就目前情况而言,CouchApp 本质上要求您对整个应用程序使用 AJAX。一般来说,这对于用户体验来说很差,因为您正在下载骨架标记,运行 JS,通常会再次访问服务器,然后动态添加更多标记。 (而不是预先下载完成的标记)此外,缓存数据在浏览器上与在服务器上是不同的。此外,当您拥有纯 AJAX 内容时,SEO 会变得更加困难。

基本上,您看到人们反对纯 AJAX(即干扰性 JavaScript)Web 应用程序的所有原因都将在这种情况下成立。

另一方面,您将能够复制整个应用程序(以及所有相关数据)到运行 CouchDB 的任何节点。我可以看到您的应用程序的移动版本在离线时仅运行 CouchApp,因为您不一定可以使用完整的 Web 服务器堆栈。此外,与学习 Rails、Django 或 Express.js 等框架相比,使用 CouchApp 可以轻松启动和运行。

我对 CouchApps 最终成为一个完整的 Web 应用程序解决方案寄予厚望,因为我是 CouchDB 作为数据库的超级粉丝。然而,现在这对我来说是不可行的,因为它严重依赖于强制性的 JavaScript。

As it stands, a CouchApp essentially require you to use AJAX for the entire application. Generally speaking, that's poor for user experience, as you are downloading the skeleton markup, running JS, usually hitting the server again, and then adding more markup dynamically. (as opposed to just downloading the finished markup up front) In addition, caching data is a different beast on the browser than it is on a server. Also, SEO is much more difficult when you have AJAX-only content.

Basically, all of the reasons you see people going against AJAX-only (ie. obtrusive JavaScript) web applications, will all hold up in this context.

On the other hand, you would be able to replicate the entire application (as well as all the relevent data) to any node that is running CouchDB. I could see mobile versions of your application running only the CouchApp while offline, since a full web server stack wouldn't necessarily be available to you. In addition, it's easy to get up and running with a CouchApp, as opposed to learning a framework like Rails, Django or Express.js.

I have high-hopes for CouchApps becoming a complete web application solution eventually, as I am a huge fan of CouchDB as a database. However, right now it just isn't feasible for me because of the heavy reliance upon obtrusive JavaScript.

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