webby 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/History.txt +20 -0
  2. data/Manifest.txt +46 -2
  3. data/Rakefile +4 -3
  4. data/bin/webby +1 -1
  5. data/data/Rakefile +0 -1
  6. data/data/content/css/blueprint/plugins/buttons/icons/cross.png +0 -0
  7. data/data/content/css/blueprint/plugins/buttons/icons/key.png +0 -0
  8. data/data/content/css/blueprint/plugins/buttons/icons/tick.png +0 -0
  9. data/data/content/s5/blank.gif +0 -0
  10. data/data/content/s5/bodybg.gif +0 -0
  11. data/data/content/s5/framing.css +23 -0
  12. data/data/content/s5/iepngfix.htc +42 -0
  13. data/data/content/s5/opera.css +7 -0
  14. data/data/content/s5/outline.css +15 -0
  15. data/data/content/s5/pretty.css +86 -0
  16. data/data/content/s5/print.css +1 -0
  17. data/data/content/s5/s5-core.css +9 -0
  18. data/data/content/s5/slides.css +3 -0
  19. data/data/content/s5/slides.js +553 -0
  20. data/data/lib/breadcrumbs.rb +0 -0
  21. data/data/tasks/blog.rake +71 -0
  22. data/data/tasks/build.rake +27 -0
  23. data/data/tasks/create.rake +19 -1
  24. data/data/tasks/deploy.rake +2 -2
  25. data/data/tasks/setup.rb +4 -1
  26. data/data/templates/atom_feed.erb +20 -13
  27. data/data/templates/page.erb +1 -1
  28. data/data/templates/presentation.erb +40 -0
  29. data/examples/presentation/Rakefile +14 -0
  30. data/examples/presentation/content/_sample_code.txt +10 -0
  31. data/examples/presentation/content/css/uv/twilight.css +137 -0
  32. data/examples/presentation/content/index.txt +63 -0
  33. data/examples/presentation/content/s5/blank.gif +0 -0
  34. data/examples/presentation/content/s5/bodybg.gif +0 -0
  35. data/examples/presentation/content/s5/framing.css +23 -0
  36. data/examples/presentation/content/s5/iepngfix.htc +42 -0
  37. data/examples/presentation/content/s5/opera.css +7 -0
  38. data/examples/presentation/content/s5/outline.css +15 -0
  39. data/examples/presentation/content/s5/pretty.css +86 -0
  40. data/examples/presentation/content/s5/print.css +1 -0
  41. data/examples/presentation/content/s5/s5-core.css +9 -0
  42. data/examples/presentation/content/s5/slides.css +3 -0
  43. data/examples/presentation/content/s5/slides.js +553 -0
  44. data/examples/presentation/layouts/presentation.rhtml +43 -0
  45. data/examples/presentation/tasks/blog.rake +71 -0
  46. data/examples/presentation/tasks/build.rake +27 -0
  47. data/examples/presentation/tasks/create.rake +22 -0
  48. data/examples/presentation/tasks/deploy.rake +22 -0
  49. data/examples/presentation/tasks/growl.rake +12 -0
  50. data/examples/presentation/tasks/heel.rake +28 -0
  51. data/examples/presentation/tasks/setup.rb +17 -0
  52. data/examples/presentation/tasks/validate.rake +19 -0
  53. data/examples/presentation/templates/_partial.erb +13 -0
  54. data/examples/presentation/templates/presentation.erb +40 -0
  55. data/examples/webby/Rakefile +3 -2
  56. data/examples/webby/content/css/blueprint/screen.css +1 -1
  57. data/examples/webby/content/css/coderay.css +0 -15
  58. data/examples/webby/content/css/site.css +18 -13
  59. data/examples/webby/content/css/uv/twilight.css +137 -0
  60. data/examples/webby/content/index.txt +6 -10
  61. data/examples/webby/content/manual/index.txt +83 -122
  62. data/examples/webby/content/reference/index.txt +161 -16
  63. data/examples/webby/content/script/jquery.js +1 -1
  64. data/examples/webby/content/tips_and_tricks/index.txt +1 -1
  65. data/examples/webby/content/tutorial/index.txt +1 -1
  66. data/examples/webby/layouts/default.rhtml +2 -7
  67. data/examples/webby/tasks/blog.rake +71 -0
  68. data/examples/webby/tasks/build.rake +27 -0
  69. data/examples/webby/tasks/create.rake +19 -1
  70. data/examples/webby/tasks/deploy.rake +2 -2
  71. data/examples/webby/tasks/setup.rb +4 -20
  72. data/examples/webby/templates/page.erb +1 -1
  73. data/lib/webby.rb +30 -5
  74. data/lib/webby/auto_builder.rb +0 -2
  75. data/lib/webby/builder.rb +51 -5
  76. data/lib/webby/filters.rb +3 -3
  77. data/lib/webby/filters/basepath.rb +7 -7
  78. data/lib/webby/filters/erb.rb +0 -2
  79. data/lib/webby/filters/haml.rb +0 -2
  80. data/lib/webby/filters/markdown.rb +0 -2
  81. data/lib/webby/filters/outline.rb +43 -2
  82. data/lib/webby/filters/sass.rb +0 -2
  83. data/lib/webby/filters/slides.rb +56 -0
  84. data/lib/webby/filters/textile.rb +0 -2
  85. data/lib/webby/filters/tidy.rb +0 -2
  86. data/lib/webby/helpers.rb +0 -2
  87. data/lib/webby/helpers/capture_helper.rb +141 -0
  88. data/lib/webby/helpers/coderay_helper.rb +5 -16
  89. data/lib/webby/helpers/graphviz_helper.rb +6 -18
  90. data/lib/webby/helpers/tag_helper.rb +0 -2
  91. data/lib/webby/helpers/tex_img_helper.rb +5 -16
  92. data/lib/webby/helpers/ultraviolet_helper.rb +11 -22
  93. data/lib/webby/helpers/url_helper.rb +2 -4
  94. data/lib/webby/link_validator.rb +0 -2
  95. data/lib/webby/main.rb +0 -2
  96. data/lib/webby/renderer.rb +163 -37
  97. data/lib/webby/resources.rb +0 -2
  98. data/lib/webby/resources/db.rb +37 -27
  99. data/lib/webby/resources/file.rb +0 -2
  100. data/lib/webby/resources/layout.rb +0 -2
  101. data/lib/webby/resources/page.rb +4 -9
  102. data/lib/webby/resources/partial.rb +1 -3
  103. data/lib/webby/resources/resource.rb +10 -2
  104. data/lib/webby/resources/static.rb +0 -2
  105. data/lib/webby/stelan/mktemp.rb +0 -2
  106. data/lib/webby/stelan/spawner.rb +0 -2
  107. data/lib/webby/utils.rb +0 -2
  108. data/spec/spec_helper.rb +1 -4
  109. data/spec/webby/helpers/capture_helper_spec.rb +56 -0
  110. data/spec/webby/resources/file_spec.rb +0 -1
  111. data/tasks/ann.rake +7 -4
  112. data/tasks/bones.rake +2 -2
  113. data/tasks/gem.rake +26 -14
  114. data/tasks/notes.rake +11 -5
  115. data/tasks/post_load.rake +4 -2
  116. data/tasks/rdoc.rake +4 -2
  117. data/tasks/rubyforge.rake +3 -3
  118. data/tasks/setup.rb +24 -9
  119. data/tasks/spec.rake +1 -1
  120. data/tasks/website.rake +1 -1
  121. metadata +51 -7
  122. data/lib/webby/webby_task.rb +0 -134
  123. data/tasks/svn.rake +0 -45
@@ -5,7 +5,7 @@
5
5
  * Dual licensed under the MIT (MIT-LICENSE.txt)
6
6
  * and GPL (GPL-LICENSE.txt) licenses.
7
7
  *
8
- * $Date: 2008-01-26 20:30:10 -0700 (Sat, 26 Jan 2008) $
8
+ * $Date$
9
9
  * $Rev: 4454 $
10
10
  */
11
11
  (function(){if(window.jQuery)var _jQuery=window.jQuery;var jQuery=window.jQuery=function(selector,context){return new jQuery.prototype.init(selector,context);};if(window.$)var _$=window.$;window.$=jQuery;var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;var isSimple=/^.[^:#\[\.]*$/;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;return this;}else if(typeof selector=="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1])selector=jQuery.clean([match[1]],context);else{var elem=document.getElementById(match[3]);if(elem)if(elem.id!=match[3])return jQuery().find(selector);else{this[0]=elem;this.length=1;return this;}else
@@ -28,7 +28,7 @@ filter:
28
28
  h2. <%= h(@page.title) %>
29
29
 
30
30
  <%
31
- articles = @pages.find(:limit => :all, :in_directory => "articles",
31
+ articles = @pages.find(:all, :in_directory => "articles",
32
32
  :sort_by => "mtime", :reverse => true)
33
33
  paginate(articles, 10) do |page|
34
34
  %>
@@ -72,7 +72,7 @@ The content of this page is not HTML, but it ends up that way. How? Webby uses _
72
72
 
73
73
  The erb filter (erb stands for "embedded Ruby") allows Webby to process Ruby statements found in the page text and to substitute the output of those Ruby statements back into the page text. The Ruby statements appear between @<%= ruby_code %>@ delimiters. The meta-data found at the top of the page is made available through the @@page@ object. You can see from the index.txt file that the page title, "Home Page", will be substituted on the first line.
74
74
 
75
- The textile filter operates on all page text. It is a human readable markup that gets converted into HTML. For example, the line <notextile><code>h3.&nbsp;Litora&nbsp;Sociis</code></notextile> will be converted into @<h3>Litora Sociis</h3>@ by the textile filter. It is a powerful markup language that simplifies web publishing.
75
+ The textile filter operates on all page text. It is a human readable markup that gets converted into HTML. For example, the line <notextile><code>h2.&nbsp;Litora&nbsp;Sociis</code></notextile> will be converted into @<h2>Litora Sociis</h2>@ by the textile filter. It is a powerful markup language that simplifies web publishing.
76
76
 
77
77
  Okay, back to our regularly scheduled page changes. Go ahead and change the title of the page in the meta-data. Then run rake again.
78
78
 
@@ -14,18 +14,13 @@ filter:
14
14
  <title>Webby :: <%= h(@page.title) %></title>
15
15
  <meta name="author" content="<%= h(@page.author) %>" />
16
16
 
17
- <!--- Blueprint CSS Framework -->
18
- <link rel="stylesheet" href="/css/blueprint/screen.css" type="text/css" media="screen, projection" />
19
17
  <link rel="stylesheet" href="/css/blueprint/print.css" type="text/css" media="print" />
20
-
21
- <!-- Coderay -->
22
- <link rel="stylesheet" href="/css/coderay.css" type="text/css" media="screen, projection" />
23
-
24
- <!-- Homepage CSS -->
25
18
  <link rel="stylesheet" href="/css/site.css" type="text/css" media="screen, projection" />
26
19
 
27
20
  <script type="text/javascript" src="/script/jquery.js"></script>
28
21
  <script type="text/javascript" src="/script/jquery.corner.js"></script>
22
+
23
+ <%= @page.content_for_head %>
29
24
  </head>
30
25
  <body>
31
26
 
@@ -0,0 +1,71 @@
1
+
2
+ namespace :blog do
3
+
4
+ # iterate over all the files in the "templates/blog" folder and create a
5
+ # rake task corresponding to each file found
6
+ FileList["#{Webby.site.template_dir}/blog/*"].each do |template|
7
+ next unless test(?f, template)
8
+ name = template.pathmap('%n')
9
+ next if name =~ %r/^(month|year)$/ # skip month/year blog entries
10
+
11
+ desc "Create a new blog #{name}"
12
+ task name => [:create_year_index, :create_month_index] do |t|
13
+ page, title, dir = Webby::Builder.new_page_info(t)
14
+
15
+ # if no directory was given use the default blog directory (underneath
16
+ # the content directory)
17
+ dir = Webby.site.blog_dir if dir.empty?
18
+ dir = File.join(dir, Time.now.strftime('%Y/%m/%d'))
19
+
20
+ page = File.join(dir, File.basename(page))
21
+ page = Webby::Builder.create(page, :from => template,
22
+ :locals => {:title => title, :directory => dir})
23
+ exec(::Webby.editor, page) unless ::Webby.editor.nil?
24
+ end
25
+ end # each
26
+
27
+ # this task is used to create the year index file (blog/2008/index.txt)
28
+ task :create_year_index do |t|
29
+ # parse out information about the page to create
30
+ _, _, dir = Webby::Builder.new_page_info(t)
31
+ year = Time.now.strftime '%Y'
32
+
33
+ # if no directory was given use the default blog directory (underneath
34
+ # the content directory)
35
+ dir = Webby.site.blog_dir if dir.empty?
36
+ dir = File.join(dir, year)
37
+
38
+ # determine the filename and template name
39
+ fn = File.join(dir, 'index.txt')
40
+ tmpl = Dir.glob(File.join(Webby.site.template_dir, 'blog/year.*')).first.to_s
41
+
42
+ if test(?f, tmpl) and not test(?f, File.join(Webby.site.content_dir, fn))
43
+ Webby::Builder.create(fn, :from => tmpl,
44
+ :locals => {:title => year, :directory => dir})
45
+ end
46
+ end
47
+
48
+ # this task is used to create the month index file (blog/2008/04/index.txt)
49
+ task :create_month_index do |t|
50
+ # parse out information about the page to create
51
+ _, _, dir = Webby::Builder.new_page_info(t)
52
+ now = Time.now
53
+
54
+ # if no directory was given use the default blog directory (underneath
55
+ # the content directory)
56
+ dir = Webby.site.blog_dir if dir.empty?
57
+ dir = File.join(dir, now.strftime('%Y/%m'))
58
+
59
+ # determine the filename and template name
60
+ fn = File.join(dir, 'index.txt')
61
+ tmpl = Dir.glob(File.join(Webby.site.template_dir, 'blog/month.*')).first.to_s
62
+
63
+ if test(?f, tmpl) and not test(?f, File.join(Webby.site.content_dir, fn))
64
+ Webby::Builder.create(fn, :from => tmpl,
65
+ :locals => {:title => year, :directory => dir})
66
+ end
67
+ end
68
+
69
+ end # namespace :blog
70
+
71
+ # EOF
@@ -0,0 +1,27 @@
1
+
2
+ task :configure_basepath do
3
+ Webby.site.base = ENV['BASE'] if ENV.has_key?('BASE')
4
+ end
5
+
6
+ desc "Build the website"
7
+ task :build => :configure_basepath do |t|
8
+ Webby::Builder.run
9
+ end
10
+
11
+ desc "Rebuild the website"
12
+ task :rebuild => :configure_basepath do |t|
13
+ Webby::Builder.run :rebuild => true
14
+ end
15
+
16
+ desc "Continuously build the website"
17
+ task :autobuild => :configure_basepath do |t|
18
+ Webby::AutoBuilder.run
19
+ end
20
+
21
+ desc "Delete the website"
22
+ task :clobber do |t|
23
+ rm_rf Webby.site.output_dir
24
+ mkdir Webby.site.output_dir
25
+ end
26
+
27
+ # EOF
@@ -1,4 +1,22 @@
1
1
 
2
- Rake::WebbyTask.new
2
+ namespace :create do
3
+
4
+ FileList["#{Webby.site.template_dir}/*"].each do |template|
5
+ next unless test(?f, template)
6
+ name = template.pathmap '%n'
7
+
8
+ # if the file is a partial template
9
+ name = $1 if name =~ %r/^_(.*)/
10
+
11
+ desc "Create a new #{name}"
12
+ task name do |t|
13
+ page, title, dir = Webby::Builder.new_page_info(t)
14
+ page = Webby::Builder.create(page, :from => template,
15
+ :locals => {:title => title, :directory => dir})
16
+ exec(::Webby.editor, page) unless ::Webby.editor.nil?
17
+ end
18
+ end # each
19
+
20
+ end # namespace :create
3
21
 
4
22
  # EOF
@@ -6,14 +6,14 @@ namespace :deploy do
6
6
  desc 'Deploy to the server using rsync'
7
7
  task :rsync do
8
8
  cmd = "rsync #{SITE.rsync_args.join(' ')} "
9
- cmd << "#{SITE.output_dir}/ #{SITE.host}:#{SITE.remote_dir}"
9
+ cmd << "#{SITE.output_dir}/ #{SITE.user}@#{SITE.host}:#{SITE.remote_dir}"
10
10
  sh cmd
11
11
  end
12
12
 
13
13
  desc 'Deploy to the server using ssh'
14
14
  task :ssh do
15
15
  Rake::SshDirPublisher.new(
16
- SITE.host, SITE.remote_dir, SITE.output_dir
16
+ "#{SITE.user}@#{SITE.host}", SITE.remote_dir, SITE.output_dir
17
17
  ).upload
18
18
  end
19
19
 
@@ -8,26 +8,10 @@ end
8
8
 
9
9
  SITE = Webby.site
10
10
 
11
- # Webby defaults
12
- SITE.content_dir = 'content'
13
- SITE.output_dir = 'output'
14
- SITE.layout_dir = 'layouts'
15
- SITE.template_dir = 'templates'
16
- SITE.exclude = %w[tmp$ bak$ ~$ CVS \.svn]
17
-
18
- SITE.page_defaults = {
19
- 'layout' => 'default'
20
- }
21
-
22
- # Items used to deploy the webiste
23
- SITE.host = 'user@hostname.tld'
24
- SITE.remote_dir = '/not/a/valid/dir'
25
- SITE.rsync_args = %w(-av --delete)
26
-
27
- # Options passed to the 'tidy' program when the tidy filter is used
28
- SITE.tidy_options = '-indent -wrap 80'
29
-
30
11
  # Load the other rake files in the tasks folder
31
- Dir.glob('tasks/*.rake').sort.each {|fn| import fn}
12
+ Dir.glob(::File.join(%w[tasks *.rake])).sort.each {|fn| import fn}
13
+
14
+ # Load all the ruby files in the lib folder
15
+ Dir.glob(::File.join(%w[lib ** *.rb])).sort.each {|fn| require fn}
32
16
 
33
17
  # EOF
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: New Page
2
+ title: <%= title %>
3
3
  created_at: <%= Time.now.to_y %>
4
4
  filter:
5
5
  - erb
@@ -1,5 +1,3 @@
1
- # $Id: webby.rb 198 2008-03-10 15:25:55Z tim_pease $
2
-
3
1
  # Equivalent to a header guard in C/C++
4
2
  # Used to prevent the spec helper from being loaded more than once
5
3
  unless defined? ::Webby
@@ -20,7 +18,7 @@ Logging::Appender.stdout.layout = Logging::Layouts::Pattern.new(
20
18
  module Webby
21
19
 
22
20
  # :stopdoc:
23
- VERSION = '0.8.2' # :nodoc:
21
+ VERSION = '0.8.3' # :nodoc:
24
22
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
25
23
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
26
24
  # :startdoc:
@@ -48,14 +46,16 @@ module Webby
48
46
  :find_by => 'title',
49
47
  :base => nil,
50
48
  :create_mode => 'page',
49
+ :blog_dir => 'blog',
51
50
 
52
51
  # Items for running the heel webserver
53
52
  :heel_port => 4331,
54
53
 
55
54
  # Items used to deploy the website
56
- :host => 'user@hostname.tld',
55
+ :user => ENV['USER'] || ENV['USERNAME'],
56
+ :host => 'example.com',
57
57
  :remote_dir => '/not/a/valid/dir',
58
- :rsync_args => %w(-av --delete),
58
+ :rsync_args => %w(-av),
59
59
 
60
60
  # Options passed to the 'tidy' program when the tidy filter is used
61
61
  :tidy_options => '-indent -wrap 80',
@@ -126,6 +126,19 @@ module Webby
126
126
  @exclude ||= Regexp.new(site.exclude.join('|'))
127
127
  end
128
128
 
129
+ # call-seq:
130
+ # Webby.editor => string or nil
131
+ #
132
+ # Returns the default editor to use when creating new pages. This editor
133
+ # will be spawned to allow the user to edit the newly created page.
134
+ #
135
+ def self.editor
136
+ return @editor if defined? @editor
137
+
138
+ @editor = if ENV['EDITOR'].nil? or ENV['EDITOR'].empty? then nil
139
+ else ENV['EDITOR'] end
140
+ end
141
+
129
142
  # call-seq:
130
143
  # cairn => filename
131
144
  #
@@ -168,6 +181,18 @@ module Webby
168
181
 
169
182
  Dir.glob(search_me).sort.each {|rb| require rb}
170
183
  end
184
+
185
+ # Prints a deprecation warning using the logger. The message states that
186
+ # the given method is being deprecated. An optional message can be give to
187
+ # -- somthing nice and fuzzy about a new method or why this one has to go
188
+ # away; sniff, we'll miss you little buddy.
189
+ #
190
+ def self.deprecated( method, message = nil )
191
+ msg = "'#{method}' has been deprecated"
192
+ msg << "\n\t#{message}" unless message.nil?
193
+ Logging::Logger['Webby'].warn msg
194
+ end
195
+
171
196
  end # module Webby
172
197
 
173
198
 
@@ -1,5 +1,3 @@
1
- # $Id: auto_builder.rb 167 2008-02-24 00:59:54Z tim_pease $
2
-
3
1
  require 'directory_watcher'
4
2
 
5
3
  module Webby
@@ -1,5 +1,3 @@
1
- # $Id: builder.rb 192 2008-03-08 16:27:29Z tim_pease $
2
-
3
1
  require 'find'
4
2
  require 'fileutils'
5
3
  require 'erb'
@@ -26,7 +24,7 @@ class Builder
26
24
  end
27
25
 
28
26
  # call-seq:
29
- # Builder.create( page, :from => template )
27
+ # Builder.create( page, :from => template, :locals => {} )
30
28
  #
31
29
  # This mehod is used to create a new _page_ in the content folder based
32
30
  # on the specified template. _page_ is the relative path to the new page
@@ -36,15 +34,63 @@ class Builder
36
34
  def create( page, opts = {} )
37
35
  tmpl = opts[:from]
38
36
  raise Error, "template not given" unless tmpl
37
+
38
+ name = ::Webby::Resources::File.basename(page)
39
+ ext = ::Webby::Resources::File.extname(page)
40
+ dir = ::File.dirname(page)
41
+ dir = '' if dir == '.'
42
+
43
+ if tmpl.pathmap('%n') =~ %r/^_/
44
+ page = ::File.join(::Webby.site.content_dir, dir, '_'+name)
45
+ page << '.' << (ext.empty? ? 'txt' : ext)
46
+ elsif ::Webby.site.create_mode == 'directory' and name != 'index'
47
+ page = ::File.join(::Webby.site.content_dir, dir, name, 'index')
48
+ page << '.' << (ext.empty? ? 'txt' : ext)
49
+ else
50
+ page = ::File.join(::Webby.site.content_dir, page)
51
+ page << '.txt' if ext.empty?
52
+ end
39
53
  raise Error, "#{page} already exists" if test ?e, page
40
54
 
41
55
  Logging::Logger[self].info "creating #{page}"
42
56
  FileUtils.mkdir_p ::File.dirname(page)
43
- str = ERB.new(::File.read(tmpl), nil, '-').result
57
+
58
+ context = scope
59
+ opts[:locals].each do |k,v|
60
+ Thread.current[:value] = v
61
+ definition = "#{k} = Thread.current[:value]"
62
+ eval(definition, context)
63
+ end if opts.has_key?(:locals)
64
+
65
+ str = ERB.new(::File.read(tmpl), nil, '-').result(context)
44
66
  ::File.open(page, 'w') {|fd| fd.write str}
45
67
 
46
- return nil
68
+ page
69
+ end
70
+
71
+ # call-seq:
72
+ # Builder.new_page_info( task ) => [page, title, directory]
73
+ #
74
+ def new_page_info( task )
75
+ return @new_page_info if defined? @new_page_info
76
+
77
+ raise "Usage: rake #{ARGV.first} path" unless ARGV.length > 1
78
+ page = task.application.top_level_tasks.slice!(1..-1).join('-')
79
+ title = ::Webby::Resources::File.basename(page).
80
+ split('-').map {|w| w.capitalize}.join(' ')
81
+ dir = ::File.dirname(page)
82
+ dir = '' if dir == '.'
83
+
84
+ @new_page_info = [page, title, dir]
47
85
  end
86
+
87
+
88
+ private
89
+
90
+ # Returns the binding in the scope of the Builder class object.
91
+ #
92
+ def scope() binding end
93
+
48
94
  end # class << self
49
95
 
50
96
  # call-seq:
@@ -1,5 +1,3 @@
1
- # $Id: filters.rb 179 2008-02-29 04:47:19Z tim_pease $
2
-
3
1
  module Webby
4
2
  module Filters
5
3
 
@@ -44,9 +42,11 @@ module Filters
44
42
  @filters = Array(page.filter)
45
43
  @log = Logging::Logger[Webby::Renderer]
46
44
  @processed = 0
45
+ @prev_cursor = nil
47
46
  end
48
47
 
49
48
  def start_for(input)
49
+ @prev_cursor = @renderer.instance_variable_get(:@_cursor)
50
50
  @renderer.instance_variable_set(:@_cursor, self)
51
51
  filters.inject(input) do |result, filter|
52
52
  handler = Filters[filter]
@@ -54,7 +54,7 @@ module Filters
54
54
  handle(filter, handler, *args)
55
55
  end
56
56
  ensure
57
- @renderer.instance_variable_set(:@_cursor, nil)
57
+ @renderer.instance_variable_set(:@_cursor, @prev_cursor)
58
58
  end
59
59
 
60
60
  # The list of filters yet to be processed
@@ -1,5 +1,3 @@
1
- # $Id: basepath.rb 99 2008-01-13 02:38:23Z tim_pease $
2
-
3
1
  require 'hpricot'
4
2
 
5
3
  module Webby
@@ -37,13 +35,15 @@ module Filters
37
35
  class BasePath
38
36
 
39
37
  # call-seq:
40
- # BasePath.new( html )
38
+ # BasePath.new( html, mode )
41
39
  #
42
40
  # Creates a new BasePath filter that will operate on the given _html_
43
- # string.
41
+ # string. The _mode_ is either 'xml' or 'html' and determines how Hpricot
42
+ # will handle the parsing of the input string.
44
43
  #
45
- def initialize( str )
44
+ def initialize( str, mode )
46
45
  @str = str
46
+ @mode = mode.downcase.to_sym
47
47
  end
48
48
 
49
49
  # call-seq:
@@ -64,7 +64,7 @@ class BasePath
64
64
  # <a href="/some/other/directory/link/to/another/page.html">Page</a>
65
65
  #
66
66
  def filter
67
- doc = Hpricot(@str)
67
+ doc = @mode == :xml ? Hpricot.XML(@str) : Hpricot(@str)
68
68
  base_path = ::Webby.site.base
69
69
  attr_rgxp = %r/\[@(\w+)\]$/o
70
70
  sub_rgxp = %r/\A(?=\/)/o
@@ -87,7 +87,7 @@ end # class BasePath
87
87
  # Rewrite base URIs in the input HTML text.
88
88
  #
89
89
  register :basepath do |input, cursor|
90
- if ::Webby.site.base then BasePath.new(input).filter
90
+ if ::Webby.site.base then BasePath.new(input, cursor.page.extension).filter
91
91
  else input end
92
92
  end
93
93