【发布时间】:2011-09-10 16:10:12
【问题描述】:
我已经成功地进行了一些将nesta 与rails 3 集成的实验(参见Is it possble include Nesta CMS into Rails3 application? 和Nesta CMS and Rails3 integration: adding blog to an exiting rails 3 application)
但是,我需要博客右侧的菜单,如“Working with menus”中所述
为了试一试,我用nesta demo:content 建立了著名的内容演示站点,但是右侧出现的所有来自 content-demo/menu.txt 的链接都被破坏了,因为与主要Rails 应用程序 (http://example.com) 而不是嵌入式内斯塔博客 (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 Nesta::App, :at => '/blog' 代替match '/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}" 中的url = "http://#{request.host}/blog":
def base_url
url = "http://#{request.host}/blog"
request.port == 80 ? url : url + ":#{request.port}"
end
将 gem 'nesta', :path => 'vendor/gems/nesta-0.9.10' 放在 Gemfile 和 build update 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
如果我尝试在上面放置类似的东西:
/ or /blog or /nesta-blog 菜单消失...
所以我的问题是,它是如何工作的? 您有什么建议/解决方法吗?
提前致谢 卢卡·G·索阿夫
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3 content-management-system nestacms