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

发布于 2024-07-14 03:05:29 字数 5872 浏览 12 评论 0 原文

基本路径过滤器重写?

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

有关 基本路径过滤器 的文档.rubyforge.org/" rel="nofollow noreferrer">Webby 在这方面有点“轻”,而且它的内容还不足以让我理解如何使用它。

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

我还了解到,为了使其正常工作,我应该将其重写的 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

Basepath Filter Rewriting?

I'm trying to use the basepath filter in webby to rewrite all of the URLs in my project.

The documentation on the basepath filter for Webby is a little bit "light" concerning this, and there just simply isn't enough of it that I can understand how to use it.

If I find the solution to this, however I plan to contribute some documentation to the project.

I also understand that in order for this to work, I'm supposed to have all of my paths for the URLs it rewrites to start with "/".

I've tried applying the filter like so, to my default.txt template...

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

** - Top of layouts/default.txt**

Then I run the command:

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

** - Running the command from the root directory of the project**

but all I get is an error...

** 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

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

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

发布评论

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

评论(2

淡笑忘祈一世凡恋 2024-07-21 03:05:29

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

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

Try changing your filters section so that it uses valid webby syntax. It should look like this:

---
extension: html
filter:
  - erb
  - basepath
---
依 靠 2024-07-21 03:05:29

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

I confirm that the answer is correct. I would like to explain why, it is because the meta-data of the pages is in yaml ( http://en.wikipedia.org/wiki/YAML#Lists )

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