Backbone.js 应用程序可以逐步增强并可供搜索引擎抓取吗?
我需要为我的下一个项目实现一个 MVC JavaScript 框架,但它既是一个网站,又是一个 Web 应用程序。是否可以公开数据服务器端,然后解析 URL 以显示“JS 版本”?
(我计划使用 Rails 作为服务器端代码)
I need to implement an MVC JavaScript framework for my next project, but it's as much as a website as it is a web app. Is it possible to expose the data server-side, then parse the URL to show the 'JS version'?
(I plan on using Rails for server-side code)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我写了一个关于这个主题的小博客系列...
第一部分介绍了问题和之前的解决方案,以及当前的解决方案:HTML5的PushState(history API)
http://lostechies.com/derickbailey/2011/09/26/seo-and-accessibility-with-html5-pushstate-part-1-introducing-pushstate/
第 2 部分展示了如何使用 Backbone 进行渐进式增强,以便当您让服务器渲染 HTML 时,您可以让 Backbone 代码接管现有 HTML 内容,而不是渲染新内容:
http://lostechies.com/derickbailey/2011/09/26/seo-and-accessibility-with-html5-pushstate-part-2-progressive-enhancement-with-backbone-js/
第 3 部分是我在一次会议上就此主题进行的演示的(有点模糊)视频:
http:// lostechies.com/derickbailey/2011/10/06/seo-and-accessibility-with-html5-pushstate-part-3-the-video/
虽然不是作为这个小系列的一部分,我还写了一篇关于将路由器与 PushState 一起使用的博客文章。该帖子的要点是:您不需要路由器:
http://lostechies.com/derickbailey/2011/10/17/tips-for-using-backbone-js-routers-with-html5-pushstate/
希望有帮助
I wrote a small blog series on exactly this subject...
The first part introduces the problem and the previous solutions, as well as the current solution: HTML5's PushState (history API)
http://lostechies.com/derickbailey/2011/09/26/seo-and-accessibility-with-html5-pushstate-part-1-introducing-pushstate/
Part 2 shows how to use progressive enhancement with Backbone, so that when you have your server render HTML you can then have your Backbone code take over the existing HTML content instead of rendering new content:
http://lostechies.com/derickbailey/2011/09/26/seo-and-accessibility-with-html5-pushstate-part-2-progressive-enhancement-with-backbone-js/
Part 3 is a (slightly blurry) video of a presentation I gave on this subject, at a conference:
http://lostechies.com/derickbailey/2011/10/06/seo-and-accessibility-with-html5-pushstate-part-3-the-video/
And while it's not directly a part of this little series, I also wrote a blog post about using Routers with PushState. The gist of that post is: you don't need a router:
http://lostechies.com/derickbailey/2011/10/17/tips-for-using-backbone-js-routers-with-html5-pushstate/
Hope that helps
我不太确定我是否正确理解了你的问题。我认为您有一些数据,并且希望使用 Rails 在服务器端使用它,然后将其提供给您的 JavaScript 并继续处理数据?这是正确的?
那么是的,这是可能的。假设您有一个名为article的模型,并且您通过以下网址访问一篇文章:
http://site.com/articles /1
然后您可以添加 .xml
http://site.com/articles/1. xml
你会得到 xml 并且 JavaScript 可以解析xml。这是rails 的默认设置。
Im not really sure if I understand your question the right way. I think you have some data and you want to work with it on the server side using rails and then provide it to your javascript and proceed working with the data? Thats right?
Then yes thats possible. Lets say you have a model called article and you access one article by the following url:
http://site.com/articles/1
then you can add an .xml
http://site.com/articles/1.xml
and you will get xml and of cause Javascript can parse xml. This is the default setting of rails.