Nesta CMS 和 Rails3 集成:菜单不起作用

发布于 2024-12-04 02:28:46 字数 2877 浏览 1 评论 0 原文

我已经成功地进行了一些将nesta与rails 3集成的实验(参见Is是否可以将 Nesta CMS 包含到 Rails3 应用程序中?Nesta CMS 和 Rails3 集成:添加博客到现有的 Rails 3 应用程序

但是,我需要在博客右侧有一个菜单,如“使用菜单"

为了尝试一下,我使用 < 构建了著名的内容演示网站code>nesta demo:content,但右侧出现的所有来自 content-demo/menu.txt 的链接都已损坏,因为与主 Rails 应用程序相关 (http://example.com),而不是嵌入的nesta博客(http ://example.com/blog

这是我当前的文件配置,Rails 3.0.10 和 Nesta 0.9.10 之间的集成:

config/routes.rb

  match '/blog' => Nesta::App
  match '/css/*style.css' => Nesta::App
  match '/attachments/*file' => Nesta::App
  root :to => "home#index"

更新:

使用 mount内斯塔::应用程序,:at => '/blog' 而不是匹配 '/blog' => Nesta::App 丰富相同的结果...

config/initializers/nesta.rb

require "nesta/env"
require "nesta/app"
Nesta::Env.root = ::File.expand_path("../../nesta-blog", File.dirname(__FILE__))
Nesta::App.root = ::File.expand_path("../../nesta-blog", File.dirname(__FILE__))

nesta-blog/config/config.yml

...
content: nesta-blog/content-demo
...

我认为取决于nesta如何构建菜单喜欢的相对路径,这取决于nesta-0.9.10/lib/nesta/app.rb 中的 base_url 方法。

比我尝试在本地解压nesta-0.9.10,更改 url = "http://#{request.host}" in url = "http://#{request.host}/ blog":

  def base_url
    url = "http://#{request.host}/blog"
    request.port == 80 ? url : url + ":#{request.port}"
  end

put gem 'nesta', :path =>; Gemfile 上的“vendor/gems/nesta-0.9.10”构建更新 nesta 但不,不起作用。

更新:

./vendor/gems/nesta-0.9.10/lib/nesta/app.rb 中也尝试过使用 Nesta::Menu.for_path('/') >

  def set_common_variables
    @menu_items = Nesta::Menu.for_path('/')
    @site_title = Nesta::Config.title
    set_from_config(:title, :subtitle, :google_analytics_code)
    @heading = @title
  end

没有得到结果。

我的nesta-blog/content-demo/menu.txt当前不引用主页(就像在使用nesta demo:content的默认生成中一样):

marking-up-pages
  examples/using-markdown
  examples/using-textile
  examples/using-haml
  adding-attachments
menu-editing
publishing-a-feed

如果我尝试在上面放置类似的内容:

//blog/nesta-blog 菜单消失......

所以我的问题是,它是如何工作的? 您有什么建议/解决方法吗?

提前致谢 卢卡·G·索阿夫

I already made some successfully experiments integrating nesta with rails 3 (see Is it possble include Nesta CMS into Rails3 application? and Nesta CMS and Rails3 integration: adding blog to an exiting rails 3 application)

But than, I needed a menu on the right side of the blog, like explained in "Working with menus"

To give it a try, I built the famous content-demo site with nesta demo:content, but all links appearing on the right side, which are coming from content-demo/menu.txt, are broken because related to the main Rails app (http://example.com) and not to the embedded nesta blog (http://example.com/blog)

Here it is my current file configs, the integration is between Rails 3.0.10 and Nesta 0.9.10 :

config/routes.rb

  match '/blog' => Nesta::App
  match '/css/*style.css' => Nesta::App
  match '/attachments/*file' => Nesta::App
  root :to => "home#index"

UPDATE:

using mount Nesta::App, :at => '/blog' instead of match '/blog' => Nesta::App rich the same result ...

config/initializers/nesta.rb

require "nesta/env"
require "nesta/app"
Nesta::Env.root = ::File.expand_path("../../nesta-blog", File.dirname(__FILE__))
Nesta::App.root = ::File.expand_path("../../nesta-blog", File.dirname(__FILE__))

nesta-blog/config/config.yml

...
content: nesta-blog/content-demo
...

I thought was depending by how nesta built the relative path of menu's liks and that was depending on base_url method in nesta-0.9.10/lib/nesta/app.rb.

Than I tried unpacking locally nesta-0.9.10 changing url = "http://#{request.host}" in url = "http://#{request.host}/blog":

  def base_url
    url = "http://#{request.host}/blog"
    request.port == 80 ? url : url + ":#{request.port}"
  end

put gem 'nesta', :path => 'vendor/gems/nesta-0.9.10' on Gemfile and build update nesta but no, doesn't work.

UPDATE:

Also few tries with Nesta::Menu.for_path('/') in ./vendor/gems/nesta-0.9.10/lib/nesta/app.rb

  def set_common_variables
    @menu_items = Nesta::Menu.for_path('/')
    @site_title = Nesta::Config.title
    set_from_config(:title, :subtitle, :google_analytics_code)
    @heading = @title
  end

didn't get results.

My nesta-blog/content-demo/menu.txt don't currently refers to the home page (like in default generation with nesta demo:content):

marking-up-pages
  examples/using-markdown
  examples/using-textile
  examples/using-haml
  adding-attachments
menu-editing
publishing-a-feed

and if I try putting on top something like :

/ or /blog or /nesta-blog the menu disappear ...

So my question is, how does it work ?
Do you have any suggestion / workaround ?

Thanks in advance
Luca G. Soave

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

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

发布评论

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

评论(1

像极了他 2024-12-11 02:28:46

您是否尝试安装 Nesta,而不是仅匹配路线(如 Nesta CMS 和 Rails3 集成:将博客添加到现有的 Rails 3 应用程序)?

我希望 routes.rb 中的 mount 可以为您处理所有这些相对路径问题。

我认为堆栈溢出很棒,但我怀疑您使用 Nesta 邮件列表上的这些东西会做得更好。使用Nesta看到你的帖子的人会相对较少......

Did you try mounting Nesta, instead of justing matching a route (as described in Nesta CMS and Rails3 integration: adding blog to an exiting rails 3 application)?

I would expect that mount in routes.rb might deal with all these relative path issues for you.

I think stack overflow is great, but I suspect you'll do better with this stuff on the Nesta mailing list. The number of people who use Nesta who see your posts on here will be relatively small...

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