使用基本路径过滤器在Webby中重写URL?

时间:2009-02-25 16:16:51

标签: ruby rake webby

路径过滤器重写?

我正在尝试使用webby中的basepath过滤器来重写项目中的所有URL。

关于basepath filterWebby的文档对此有点“轻松”,而且我只能理解如何使用它。

如果我找到解决方案,但我计划贡献一些文档到项目中。

我也明白,为了使这个工作起作用,我应该把它重写的URL的所有路径都用“/".

开头。

我尝试将这样的过滤器应用到我的default.txt模板......

---
extension: html
filter:    erb
       basepath
---

** - 布局顶部/ default.txt **

然后我运行命令:

leeand00@someHost: webby rebuild BASE='http://www.yahoo.com/bob/'

** - 从项目的根目录运行命令**

但我得到的只是一个错误...

** Invoke rebuild (first_time)
** Invoke configure_basepath (first_time)
** Execute configure_basepath
** Execute rebuild
webby aborted!
syntax error on line 4, col 0: `---'
/usr/lib/ruby/1.8/yaml.rb:133:in `load'
/usr/lib/ruby/1.8/yaml.rb:133:in `load'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/resources/meta_file.rb:164:in `meta_data'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/resources/meta_file.rb:51:in `meta_data'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/resources/meta_file.rb:51:in `open'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/resources/meta_file.rb:51:in `meta_data'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/resources/layout.rb:19:in `initialize'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/resources.rb:41:in `new'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/resources.rb:41:in `new'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/builder.rb:167:in `load_files'
/usr/lib/ruby/1.8/find.rb:39:in `find'
/usr/lib/ruby/1.8/find.rb:38:in `catch'
/usr/lib/ruby/1.8/find.rb:38:in `find'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/builder.rb:164:in `load_files'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/builder.rb:134:in `run'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/builder.rb:23:in `run'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/tasks/build.rake:13
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:615:in `call'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:615:in `execute'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_with_call_chain'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in `invoke_task'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/apps/main.rb:232:in `standard_exception_handling'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in `top_level'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/apps/main.rb:115:in `rake'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/apps/main.rb:33:in `run'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/apps/main.rb:12:in `run'
/var/lib/gems/1.8/gems/webby-0.9.3/bin/webby:39
/var/lib/gems/1.8/bin/webby:19:in `load'
/var/lib/gems/1.8/bin/webby:19
leeand00@U101:~/J62$ webby --trace rebuild BASE='http://www.yahoo.com/bob/'
** Invoke rebuild (first_time)
** Invoke configure_basepath (first_time)
** Execute configure_basepath
** Execute rebuild
webby aborted!
syntax error on line 4, col 0: `---'
/usr/lib/ruby/1.8/yaml.rb:133:in `load'
/usr/lib/ruby/1.8/yaml.rb:133:in `load'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/resources/meta_file.rb:164:in `meta_data'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/resources/meta_file.rb:51:in `meta_data'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/resources/meta_file.rb:51:in `open'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/resources/meta_file.rb:51:in `meta_data'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/resources/layout.rb:19:in `initialize'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/resources.rb:41:in `new'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/resources.rb:41:in `new'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/builder.rb:167:in `load_files'
/usr/lib/ruby/1.8/find.rb:39:in `find'
/usr/lib/ruby/1.8/find.rb:38:in `catch'
/usr/lib/ruby/1.8/find.rb:38:in `find'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/builder.rb:164:in `load_files'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/builder.rb:134:in `run'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/builder.rb:23:in `run'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/tasks/build.rake:13
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:615:in `call'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:615:in `execute'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_with_call_chain'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in `invoke_task'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/apps/main.rb:232:in `standard_exception_handling'
/var/lib/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in `top_level'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/apps/main.rb:115:in `rake'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/apps/main.rb:33:in `run'
/var/lib/gems/1.8/gems/webby-0.9.3/lib/webby/apps/main.rb:12:in `run'
/var/lib/gems/1.8/gems/webby-0.9.3/bin/webby:39
/var/lib/gems/1.8/bin/webby:19:in `load'
/var/lib/gems/1.8/bin/webby:19

2 个答案:

答案 0 :(得分:1)

尝试更改过滤器部分,以便它使用有效的webby语法。它应该是这样的:

---
extension: html
filter:
  - erb
  - basepath
---

答案 1 :(得分:1)

我确认答案是正确的。我想解释一下原因,这是因为页面的元数据是yaml(http://en.wikipedia.org/wiki/YAML#Lists