webgen 0.5.11 → 0.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/ChangeLog +174 -0
  2. data/Rakefile +6 -9
  3. data/VERSION +1 -1
  4. data/data/webgen/website_bundles/style/andreas07/src/default.css +2 -2
  5. data/data/webgen/website_skeleton/Rakefile +27 -2
  6. data/doc/manual.page +9 -2
  7. data/doc/reference_configuration.page +17 -0
  8. data/lib/webgen/cache.rb +1 -0
  9. data/lib/webgen/cli.rb +3 -7
  10. data/lib/webgen/common.rb +5 -0
  11. data/lib/webgen/contentprocessor/blocks.rb +7 -7
  12. data/lib/webgen/contentprocessor/builder.rb +3 -2
  13. data/lib/webgen/contentprocessor/erb.rb +2 -1
  14. data/lib/webgen/contentprocessor/erubis.rb +3 -2
  15. data/lib/webgen/contentprocessor/haml.rb +4 -3
  16. data/lib/webgen/contentprocessor/head.rb +4 -4
  17. data/lib/webgen/contentprocessor/kramdown.rb +2 -2
  18. data/lib/webgen/contentprocessor/less.rb +6 -6
  19. data/lib/webgen/contentprocessor/maruku.rb +2 -2
  20. data/lib/webgen/contentprocessor/rdiscount.rb +1 -1
  21. data/lib/webgen/contentprocessor/rdoc.rb +1 -1
  22. data/lib/webgen/contentprocessor/redcloth.rb +1 -1
  23. data/lib/webgen/contentprocessor/sass.rb +2 -2
  24. data/lib/webgen/contentprocessor/tags.rb +4 -4
  25. data/lib/webgen/contentprocessor/tidy.rb +2 -2
  26. data/lib/webgen/contentprocessor/xmllint.rb +2 -2
  27. data/lib/webgen/default_config.rb +2 -0
  28. data/lib/webgen/error.rb +2 -2
  29. data/lib/webgen/node.rb +6 -1
  30. data/lib/webgen/sourcehandler.rb +2 -2
  31. data/lib/webgen/sourcehandler/base.rb +1 -1
  32. data/lib/webgen/sourcehandler/page.rb +1 -1
  33. data/lib/webgen/sourcehandler/template.rb +2 -2
  34. data/lib/webgen/tag/base.rb +6 -6
  35. data/lib/webgen/tag/breadcrumbtrail.rb +1 -1
  36. data/lib/webgen/tag/coderay.rb +1 -1
  37. data/lib/webgen/tag/link.rb +1 -1
  38. data/lib/webgen/tag/metainfo.rb +3 -1
  39. data/lib/webgen/tag/relocatable.rb +1 -1
  40. data/lib/webgen/tree.rb +1 -1
  41. data/lib/webgen/version.rb +1 -1
  42. data/test/test_contentprocessor_builder.rb +7 -0
  43. data/test/test_contentprocessor_erb.rb +6 -2
  44. data/test/test_contentprocessor_erubis.rb +7 -0
  45. data/test/test_contentprocessor_haml.rb +7 -0
  46. data/test/test_contentprocessor_head.rb +6 -0
  47. data/test/test_error.rb +8 -0
  48. data/test/test_node.rb +5 -0
  49. data/test/test_tag_metainfo.rb +7 -1
  50. metadata +2 -3
data/ChangeLog CHANGED
@@ -1,3 +1,177 @@
1
+ commit 2edda2dbb4de4c0d4c7d2111f2636b238c1ce630
2
+ Author: Thomas Leitner <t_leitner@gmx.at>
3
+ Date: Wed Apr 14 08:05:43 2010 +0200
4
+
5
+ Updated website for release
6
+
7
+ website/src/index.page
8
+ website/src/news/index.page
9
+ website/src/news/release_0_5_12.page
10
+
11
+ commit fa69cc25564db37003613b087b510f35186404ae
12
+ Author: Thomas Leitner <t_leitner@gmx.at>
13
+ Date: Wed Apr 14 07:28:35 2010 +0200
14
+
15
+ Fixed problem where incorrect error file names were shown
16
+
17
+ lib/webgen/common.rb
18
+ lib/webgen/contentprocessor/builder.rb
19
+ lib/webgen/contentprocessor/erb.rb
20
+ lib/webgen/contentprocessor/erubis.rb
21
+ lib/webgen/contentprocessor/haml.rb
22
+ test/test_contentprocessor_builder.rb
23
+ test/test_contentprocessor_erb.rb
24
+ test/test_contentprocessor_erubis.rb
25
+ test/test_contentprocessor_haml.rb
26
+ website/src/news/release_0_5_12.page
27
+
28
+ commit 66f78fa92704134bc8eb4b68e8e8f26fa3f4f8b1
29
+ Author: Thomas Leitner <t_leitner@gmx.at>
30
+ Date: Sat Feb 27 09:01:01 2010 +0100
31
+
32
+ Fixed problem where commands were not shown correctly on --help
33
+
34
+ lib/webgen/cli.rb
35
+ website/src/news/release_0_5_12.page
36
+
37
+ commit aa374e66016e8f0f244a2fc3555f4df955a0610b
38
+ Author: Thomas Leitner <t_leitner@gmx.at>
39
+ Date: Fri Feb 26 15:13:24 2010 +0100
40
+
41
+ Added an option for dis-/enabling the escaping of meta info values by the meta info tag
42
+
43
+ doc/reference_configuration.page
44
+ lib/webgen/default_config.rb
45
+ lib/webgen/tag/metainfo.rb
46
+ test/test_tag_metainfo.rb
47
+ website/src/news/release_0_5_12.page
48
+
49
+ commit 4975d97270d32e7b29ecfed866f907e7d8fff605
50
+ Author: Thomas Leitner <t_leitner@gmx.at>
51
+ Date: Tue Feb 23 07:39:39 2010 +0100
52
+
53
+ Fixed bug in Tag::Metainfo where output was not correctly escaped
54
+
55
+ lib/webgen/tag/metainfo.rb
56
+ test/test_tag_metainfo.rb
57
+ website/src/news/release_0_5_12.page
58
+
59
+ commit 2e7c816f7551e4a8c9bd9b3f0f5e02c31e6bf079
60
+ Author: Thomas Leitner <t_leitner@gmx.at>
61
+ Date: Mon Feb 22 14:09:41 2010 +0100
62
+
63
+ Fixed problem with unintentionally modified link metainfo
64
+
65
+ lib/webgen/contentprocessor/head.rb
66
+ test/test_contentprocessor_head.rb
67
+ website/src/news/release_0_5_12.page
68
+
69
+ commit 7e0cafa7f3e9eb5d7c51525b66240ce487ccf26f
70
+ Author: Thomas Leitner <t_leitner@gmx.at>
71
+ Date: Fri Feb 19 15:41:01 2010 +0100
72
+
73
+ Updated release notes
74
+
75
+ website/src/news/release_0_5_12.page
76
+
77
+ commit f1851260d9fc44a6a2515ab6991d5e86e0ac403a
78
+ Author: Thomas Leitner <t_leitner@gmx.at>
79
+ Date: Fri Feb 19 15:38:47 2010 +0100
80
+
81
+ Added a Rakefile task to show outdated translations of pages
82
+
83
+ data/webgen/website_skeleton/Rakefile
84
+
85
+ commit 9615064f5efabf517a8ee7a0d41e148fc7e4bf1f
86
+ Author: Thomas Leitner <t_leitner@gmx.at>
87
+ Date: Fri Feb 19 15:11:15 2010 +0100
88
+
89
+ Small update to the style bundle creation documentation
90
+
91
+ doc/manual.page
92
+
93
+ commit 99ec6f4658a390be6469bd3946805e722ebc9574
94
+ Author: Thomas Leitner <t_leitner@gmx.at>
95
+ Date: Tue Feb 16 18:04:03 2010 +0100
96
+
97
+ Fixed CSS of style andreas07, again
98
+
99
+ data/webgen/website_bundles/style/andreas07/src/default.css
100
+
101
+ commit 7a04abbf49245b85b77856e07893cf9b20741882
102
+ Author: Thomas Leitner <t_leitner@gmx.at>
103
+ Date: Tue Feb 16 16:56:48 2010 +0100
104
+
105
+ Bumped version number and added release notes file
106
+
107
+ lib/webgen/version.rb
108
+ website/src/news/release_0_5_12.page
109
+
110
+ commit eff54bac30139c9f76f6e4b4c70f7d149f0a6721
111
+ Author: Thomas Leitner <t_leitner@gmx.at>
112
+ Date: Tue Feb 16 16:53:42 2010 +0100
113
+
114
+ Added Node#to_s, error classes now also accept nodes instead of alcns
115
+
116
+ lib/webgen/contentprocessor/blocks.rb
117
+ lib/webgen/contentprocessor/builder.rb
118
+ lib/webgen/contentprocessor/erb.rb
119
+ lib/webgen/contentprocessor/erubis.rb
120
+ lib/webgen/contentprocessor/haml.rb
121
+ lib/webgen/contentprocessor/head.rb
122
+ lib/webgen/contentprocessor/kramdown.rb
123
+ lib/webgen/contentprocessor/less.rb
124
+ lib/webgen/contentprocessor/maruku.rb
125
+ lib/webgen/contentprocessor/rdiscount.rb
126
+ lib/webgen/contentprocessor/rdoc.rb
127
+ lib/webgen/contentprocessor/redcloth.rb
128
+ lib/webgen/contentprocessor/sass.rb
129
+ lib/webgen/contentprocessor/tags.rb
130
+ lib/webgen/contentprocessor/tidy.rb
131
+ lib/webgen/contentprocessor/xmllint.rb
132
+ lib/webgen/error.rb
133
+ lib/webgen/node.rb
134
+ lib/webgen/sourcehandler.rb
135
+ lib/webgen/sourcehandler/base.rb
136
+ lib/webgen/sourcehandler/page.rb
137
+ lib/webgen/sourcehandler/template.rb
138
+ lib/webgen/tag/base.rb
139
+ lib/webgen/tag/breadcrumbtrail.rb
140
+ lib/webgen/tag/coderay.rb
141
+ lib/webgen/tag/link.rb
142
+ lib/webgen/tag/metainfo.rb
143
+ lib/webgen/tag/relocatable.rb
144
+ lib/webgen/tree.rb
145
+ test/test_error.rb
146
+ test/test_node.rb
147
+
148
+ commit e36a497c63a64500b276e584de2be09e8b857158
149
+ Author: Thomas Leitner <t_leitner@gmx.at>
150
+ Date: Tue Feb 16 08:07:48 2010 +0100
151
+
152
+ Updated Rakefile
153
+
154
+ * Merged release and announce tasks
155
+ * Some other small fixes
156
+
157
+ Rakefile
158
+
159
+ commit a966b141e1ec09fcac70d540cee33c958a847089
160
+ Author: Thomas Leitner <t_leitner@gmx.at>
161
+ Date: Tue Feb 16 08:06:31 2010 +0100
162
+
163
+ Fixed stand-alone test failure
164
+
165
+ lib/webgen/cache.rb
166
+
167
+ commit 38e7aa38dfc0f811bea02d5b38918362fd422294
168
+ Author: Thomas Leitner <t_leitner@gmx.at>
169
+ Date: Tue Feb 16 07:59:57 2010 +0100
170
+
171
+ Fixed a warning message
172
+
173
+ lib/webgen/tag/base.rb
174
+
1
175
  commit a80a2fea9db04394d580db0cfe49306b4e1ea820
2
176
  Author: Thomas Leitner <t_leitner@gmx.at>
3
177
  Date: Mon Feb 15 10:49:52 2010 +0100
data/Rakefile CHANGED
@@ -8,6 +8,7 @@ rescue LoadError
8
8
  end
9
9
 
10
10
  require 'rdoc/task'
11
+ require 'rdoc/rdoc'
11
12
 
12
13
  begin
13
14
  require 'rubyforge'
@@ -72,7 +73,7 @@ rd = RDoc::Task.new do |rdoc|
72
73
  rdoc.rdoc_dir = 'htmldoc/rdoc'
73
74
  rdoc.title = 'webgen'
74
75
  rdoc.main = 'lib/webgen/website.rb'
75
- rdoc.options << '--line-numbers' << '--all'
76
+ rdoc.options << '--line-numbers'
76
77
  rdoc.rdoc_files.include('lib')
77
78
  end
78
79
 
@@ -185,7 +186,7 @@ EOF
185
186
  #### Documentation
186
187
 
187
188
  s.has_rdoc = true
188
- s.rdoc_options = ['--line-numbers', '--all', '--main', 'lib/webgen/website.rb']
189
+ s.rdoc_options = ['--line-numbers', '--main', 'lib/webgen/website.rb']
189
190
 
190
191
  #### Author and project details
191
192
 
@@ -202,17 +203,14 @@ EOF
202
203
 
203
204
  end
204
205
 
206
+ desc 'Release webgen version ' + Webgen::VERSION
207
+ task :release => [:clobber, :package, :publish_files, :publish_doc, :website, :publish_website, :post_news]
208
+
205
209
  desc "Upload webgen documentation to Rubyforge homepage"
206
210
  task :publish_doc => [:doc] do
207
211
  sh "rsync -avc --delete htmldoc/ gettalong@rubyforge.org:/var/www/gforge-projects/webgen/documentation/#{(Webgen::VERSION.split('.')[0..-2] + ['x']).join('.')}"
208
212
  end
209
213
 
210
- desc 'Release webgen version ' + Webgen::VERSION
211
- task :release => [:clobber, :package, :publish_files, :publish_doc]
212
-
213
- desc 'Announce webgen version ' + Webgen::VERSION
214
- task :announce => [:clobber, :post_news, :website, :publish_website]
215
-
216
214
  if defined? RubyForge
217
215
  desc "Upload the release to Rubyforge"
218
216
  task :publish_files => [:package] do
@@ -231,7 +229,6 @@ EOF
231
229
 
232
230
  rf.add_release('webgen', 'webgen', Webgen::VERSION, *files)
233
231
 
234
- print 'Pushing gem to gemcutter'
235
232
  sh "gem push pkg/webgen-#{Webgen::VERSION}.gem"
236
233
 
237
234
  puts 'done'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.11
1
+ 0.5.12
@@ -71,10 +71,10 @@ body > #sidebar
71
71
  #menu a:hover, #menu span:hover
72
72
  {color:#303030; background:#f0f0f0 url(images/sidebarbg.gif) top right repeat-y;}
73
73
 
74
- #menu li.webgen-menu-item-selected a, #menu li.webgen-menu-item-selected span, #menu li.webgen-menu-submenu-inhierarchy span
74
+ #menu li.webgen-menu-item-selected a, #menu li.webgen-menu-item-selected span, #menu li.webgen-menu-submenu-inhierarchy span, #menu li.webgen-menu-submenu-inhierarchy a
75
75
  {padding:5px 18px 5px 0; background:#fafafa; border-top:2px solid #c0c0c0; border-bottom:2px solid #c0c0c0;}
76
76
 
77
- #menu li.webgen-menu-item-selected a:hover, #menu li.webgen-menu-item-selected span:hover, #menu li.webgen-menu-submenu-inhierarchy span:hover
77
+ #menu li.webgen-menu-item-selected a:hover, #menu li.webgen-menu-item-selected span:hover, #menu li.webgen-menu-submenu-inhierarchy span:hover, #menu li.webgen-menu-submenu-inhierarchy a:hover
78
78
  {color:#505050; background:#fafafa;}
79
79
 
80
80
  /**************** Content area styles ****************/
@@ -9,13 +9,38 @@
9
9
  #
10
10
 
11
11
  require 'webgen/webgentask'
12
+ require 'webgen/website'
12
13
 
13
14
  task :default => :webgen
14
15
 
16
+ webgen_config = lambda do |config|
17
+ # you can set configuration options here
18
+ end
19
+
15
20
  Webgen::WebgenTask.new do |website|
16
21
  website.clobber_outdir = true
17
- website.config_block = lambda do |config|
18
- # you can set configuration options here
22
+ website.config_block = webgen_config
23
+ end
24
+
25
+ desc "Show outdated translations"
26
+ task :outdated do
27
+ puts "Listing outdated translations"
28
+ puts
29
+ puts "(Note: Information is taken from the last webgen run. To get the"
30
+ puts " useful information, run webgen once before this task!)"
31
+ puts
32
+
33
+ website = Webgen::Website.new(Dir.pwd, Webgen::Logger.new($stdout), &webgen_config)
34
+ website.execute_in_env do
35
+ website.init
36
+ website.tree.node_access[:acn].each do |acn, versions|
37
+ main = versions.find {|v| v.lang == website.config['website.lang']}
38
+ next unless main
39
+ outdated = versions.select do |v|
40
+ main != v && main['modified_at'] > v['modified_at']
41
+ end.map {|v| v.lang}.join(', ')
42
+ puts "ACN #{acn}: #{outdated}" if outdated.length > 0
43
+ end
19
44
  end
20
45
  end
21
46
 
data/doc/manual.page CHANGED
@@ -701,8 +701,8 @@ from <http://www.openwebdesign.org/>.
701
701
  * Unzip the the archive from OSWD and move the extracted files into the `BUNDLE/src` directory.
702
702
 
703
703
  * Rename the file `BUNDLE/src/index.html` (or whatever the main HTML file is called) to
704
- `default.template`. Now go through this file and augment relative URLs to style sheets and images
705
- with [relocatable tags](tag/relocatable.html).
704
+ `default.template`. Now go through this file and augment relative URLs to style sheets, images and
705
+ other files with [relocatable tags](tag/relocatable.html).
706
706
 
707
707
  * Identify the location of the main menu items, remove them and and use a [menu tag](tag/menu.html)
708
708
  instead. You may need to restrict the shown menu levels to a single level if the template is built
@@ -715,6 +715,13 @@ from <http://www.openwebdesign.org/>.
715
715
  * Adjust the `<title>` tag in the `<head>` section of the `default.template` file -- you can use the
716
716
  `\{title:}` to insert the title of the processed page file.
717
717
 
718
+ * Identify the location where the page content should go and put `<webgen:block name="content' />`
719
+ there. This tells webgen to insert the block named `content` of the page file that uses the
720
+ template at this location.
721
+
722
+ * If the template features a breadcrumb trail area, use the [breadcrumb trail
723
+ tag](tag/breadcrumbtrail.html) so that the breadcrumb trail gets created automatically.
724
+
718
725
  The BUNDLE directory can now be directly used since it is a valid webgen website directory. If you
719
726
  want to publish your style bundle, just create a (gzipped) tar archive from the contents of the
720
727
  BUNDLE directory.
@@ -959,6 +959,23 @@ shows how to set the option in the configuration file.
959
959
  You will find more info on the \{link: {path: docu.html, attr: {title: DocuPage}}} page!
960
960
 
961
961
 
962
+ * ### tag.metainfo.escape_html
963
+
964
+ Specifies whether special HTML characters in the meta information value should be escaped.
965
+
966
+ * Syntax: `BOOLEAN` where `BOOLEAN` is either `true` or `false`.
967
+
968
+ <%= show_default['tag.metainfo.escape_html'] %>
969
+
970
+ * Example for setting the option in the configuration file:
971
+
972
+ tag.metainfo.escape_html: false
973
+
974
+ Example for setting the option directly in a tag:
975
+
976
+ value of meta info `title` is not escaped \{title: {escape_html: false}}
977
+
978
+
962
979
  * ### tag.menu.used_nodes
963
980
 
964
981
  Specifies the type of nodes that should be used for menu generation. If `all` is specified then
data/lib/webgen/cache.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  require 'set'
4
+ require 'webgen/common'
4
5
 
5
6
  module Webgen
6
7
 
data/lib/webgen/cli.rb CHANGED
@@ -119,14 +119,10 @@ module Webgen
119
119
 
120
120
  # :nodoc:
121
121
  def parse(argv = ARGV)
122
- super do |level, cmd_name|
123
- if level == 0
124
- create_website.init
125
- Webgen::CLI.constants.select {|c| c =~ /.+Command$/ }.each do |c|
126
- self.add_command(Webgen::CLI.const_get(c).new, (c.to_s == 'RunCommand' ? true : false))
127
- end
128
- end
122
+ Webgen::CLI.constants.select {|c| c =~ /.+Command$/ }.each do |c|
123
+ self.add_command(Webgen::CLI.const_get(c).new, (c.to_s == 'RunCommand' ? true : false))
129
124
  end
125
+ super
130
126
  end
131
127
 
132
128
  end
data/lib/webgen/common.rb CHANGED
@@ -17,6 +17,11 @@ module Webgen
17
17
  (error.is_a?(::SyntaxError) ? error.message : error.backtrace[0]).scan(/:(\d+)/).first.first.to_i rescue nil
18
18
  end
19
19
 
20
+ # Return the file name where the error occured.
21
+ def self.error_file(error)
22
+ (error.is_a?(::SyntaxError) ? error.message : error.backtrace[0]).scan(/(?:^|\s)(.*?):(\d+)/).first.first
23
+ end
24
+
20
25
  end
21
26
 
22
27
  end
@@ -52,8 +52,8 @@ module Webgen::ContentProcessor
52
52
  temp_node = context.ref_node.resolve(path.strip, context.dest_node.lang)
53
53
  if temp_node.nil?
54
54
  raise Webgen::RenderError.new("Could not resolve <#{path.strip}>",
55
- self.class.name, context.dest_node.alcn,
56
- context.ref_node.alcn, (options[:line_nr_proc].call if options[:line_nr_proc]))
55
+ self.class.name, context.dest_node,
56
+ context.ref_node, (options[:line_nr_proc].call if options[:line_nr_proc]))
57
57
  end
58
58
  temp_node
59
59
  end.compact
@@ -72,13 +72,13 @@ module Webgen::ContentProcessor
72
72
  if options[:notfound] == 'ignore'
73
73
  return ''
74
74
  elsif block_node
75
- raise Webgen::RenderError.new("No block named '#{options[:name]}' found in <#{block_node.alcn}>",
76
- self.class.name, context.dest_node.alcn,
77
- context.ref_node.alcn, (options[:line_nr_proc].call if options[:line_nr_proc]))
75
+ raise Webgen::RenderError.new("No block named '#{options[:name]}' found in <#{block_node}>",
76
+ self.class.name, context.dest_node,
77
+ context.ref_node, (options[:line_nr_proc].call if options[:line_nr_proc]))
78
78
  else
79
79
  raise Webgen::RenderError.new("No node in the render chain has a block named '#{options[:name]}'",
80
- self.class.name, context.dest_node.alcn,
81
- context.ref_node.alcn, (options[:line_nr_proc].call if options[:line_nr_proc]))
80
+ self.class.name, context.dest_node,
81
+ context.ref_node, (options[:line_nr_proc].call if options[:line_nr_proc]))
82
82
  end
83
83
  end
84
84
 
@@ -18,9 +18,10 @@ module Webgen::ContentProcessor
18
18
  context.content = xml.target!
19
19
  context
20
20
  rescue LoadError
21
- raise Webgen::LoadError.new('builder', self.class.name, context.dest_node.alcn, 'builder')
21
+ raise Webgen::LoadError.new('builder', self.class.name, context.dest_node, 'builder')
22
22
  rescue Exception => e
23
- raise Webgen::RenderError.new(e, self.class.name, context.dest_node.alcn, context.ref_node.alcn, Webgen::Common.error_line(e))
23
+ raise Webgen::RenderError.new(e, self.class.name, context.dest_node,
24
+ Webgen::Common.error_file(e), Webgen::Common.error_line(e))
24
25
  end
25
26
 
26
27
  end
@@ -17,7 +17,8 @@ module Webgen::ContentProcessor
17
17
  context.content = erb.result(binding)
18
18
  context
19
19
  rescue Exception => e
20
- raise Webgen::RenderError.new(e, self.class.name, context.dest_node.alcn, context.ref_node.alcn, Webgen::Common.error_line(e))
20
+ raise Webgen::RenderError.new(e, self.class.name, context.dest_node,
21
+ Webgen::Common.error_file(e), Webgen::Common.error_line(e))
21
22
  end
22
23
 
23
24
  end
@@ -28,9 +28,10 @@ module Webgen::ContentProcessor
28
28
  context.content = erubis.result(binding)
29
29
  context
30
30
  rescue LoadError
31
- raise Webgen::LoadError.new('erubis', self.class.name, context.dest_node.alcn, 'erubis')
31
+ raise Webgen::LoadError.new('erubis', self.class.name, context.dest_node, 'erubis')
32
32
  rescue Exception => e
33
- raise Webgen::RenderError.new(e, self.class.name, context.dest_node.alcn, context.ref_node.alcn, Webgen::Common.error_line(e))
33
+ raise Webgen::RenderError.new(e, self.class.name, context.dest_node,
34
+ Webgen::Common.error_file(e), Webgen::Common.error_line(e))
34
35
  end
35
36
 
36
37
  end
@@ -16,16 +16,17 @@ module Webgen::ContentProcessor
16
16
  render(Object.new, locals)
17
17
  context
18
18
  rescue LoadError
19
- raise Webgen::LoadError.new('haml', self.class.name, context.dest_node.alcn, 'haml')
19
+ raise Webgen::LoadError.new('haml', self.class.name, context.dest_node, 'haml')
20
20
  rescue ::Haml::Error => e
21
21
  line = if e.line
22
22
  e.line + 1
23
23
  else
24
24
  Webgen::Common.error_line(e)
25
25
  end
26
- raise Webgen::RenderError.new(e, self.class.name, context.dest_node.alcn, context.ref_node.alcn, line)
26
+ raise Webgen::RenderError.new(e, self.class.name, context.dest_node, context.ref_node, line)
27
27
  rescue Exception => e
28
- raise Webgen::RenderError.new(e, self.class.name, context.dest_node.alcn, context.ref_node.alcn, Webgen::Common.error_line(e))
28
+ raise Webgen::RenderError.new(e, self.class.name, context.dest_node,
29
+ Webgen::Common.error_file(e), Webgen::Common.error_line(e))
29
30
  end
30
31
 
31
32
  end
@@ -72,7 +72,7 @@ module Webgen::ContentProcessor
72
72
  result += "/>"
73
73
  end
74
74
 
75
- link = (context.node['link'] || {}).dup
75
+ link = Marshal.load(Marshal.dump(context.node['link'] || {}))
76
76
 
77
77
  handle_files = lambda do |files|
78
78
  [files].flatten.compact.collect do |file|
@@ -82,7 +82,7 @@ module Webgen::ContentProcessor
82
82
  context.dest_node.node_info[:used_meta_info_nodes] << file.alcn
83
83
  file = context.dest_node.route_to(file)
84
84
  else
85
- log(:error) { "Could not resolve path '#{file}' used in 'link' meta information in <#{context.node.alcn}>" }
85
+ log(:error) { "Could not resolve path '#{file}' used in 'link' meta information in <#{context.node}>" }
86
86
  context.dest_node.flag(:dirty)
87
87
  end
88
88
  end
@@ -101,14 +101,14 @@ module Webgen::ContentProcessor
101
101
  # add generic links specified via the +link+ meta information
102
102
  link.sort.each do |link_type, vals|
103
103
  link_type = link_type.downcase
104
- [vals.dup].flatten.each do |val|
104
+ [vals].flatten.each do |val|
105
105
  val = {'href' => val} if val.kind_of?(String)
106
106
  val['rel'] ||= link_type
107
107
  val = LINK_DOCUMENT_ATTRS.merge(val) if LINK_DOCUMENT_TYPES.include?(link_type)
108
108
  if href = val.delete('href')
109
109
  href = handle_files.call(href).first
110
110
  else
111
- log(:error) { "No link target specified for link type '#{link_type}' in 'link' meta information in <#{context.node.alcn}>" }
111
+ log(:error) { "No link target specified for link type '#{link_type}' in 'link' meta information in <#{context.node}>" }
112
112
  end
113
113
  if href
114
114
  s = "\n<link href=\"#{href}\" "
@@ -14,11 +14,11 @@ module Webgen::ContentProcessor
14
14
  doc = ::Kramdown::Document.new(context.content, context.website.config['contentprocessor.kramdown.options'])
15
15
  context.content = KramdownHtmlConverter.convert(doc, context)
16
16
  doc.warnings.each do |warn|
17
- log(:warn) { "Warning while parsing <#{context.ref_node.alcn}> with kramdown: #{warn}" }
17
+ log(:warn) { "Warning while parsing <#{context.ref_node}> with kramdown: #{warn}" }
18
18
  end
19
19
  context
20
20
  rescue LoadError
21
- raise Webgen::LoadError.new('kramdown', self.class.name, context.dest_node.alcn, 'kramdown')
21
+ raise Webgen::LoadError.new('kramdown', self.class.name, context.dest_node, 'kramdown')
22
22
  end
23
23
 
24
24
  end
@@ -14,20 +14,20 @@ module Webgen::ContentProcessor
14
14
  context
15
15
  rescue ::Less::SyntaxError => e
16
16
  line = e.message.scan(/on line (\d+):/).first.first.to_i rescue nil
17
- raise Webgen::RenderError.new(e, self.class.name, context.dest_node.alcn, context.ref_node.alcn, line)
17
+ raise Webgen::RenderError.new(e, self.class.name, context.dest_node, context.ref_node, line)
18
18
  rescue ::Less::MixedUnitsError => e
19
19
  raise Webgen::RenderError.new("Can't mix different units together: #{e}",
20
- self.class.name, context.dest_node.alcn, context.ref_node.alcn)
20
+ self.class.name, context.dest_node, context.ref_node)
21
21
  rescue ::Less::VariableNameError => e
22
22
  raise Webgen::RenderError.new("Variable name is undefined: #{e}",
23
- self.class.name, context.dest_node.alcn, context.ref_node.alcn)
23
+ self.class.name, context.dest_node, context.ref_node)
24
24
  rescue ::Less::MixinNameError => e
25
25
  raise Webgen::RenderError.new("Mixin name is undefined: #{e}",
26
- self.class.name, context.dest_node.alcn, context.ref_node.alcn)
26
+ self.class.name, context.dest_node, context.ref_node)
27
27
  rescue ::Less::ImportError => e
28
- raise Webgen::RenderError.new(e, self.class.name, context.dest_node.alcn, context.ref_node.alcn)
28
+ raise Webgen::RenderError.new(e, self.class.name, context.dest_node, context.ref_node)
29
29
  rescue LoadError
30
- raise Webgen::LoadError.new('less', self.class.name, context.dest_node.alcn, 'less')
30
+ raise Webgen::LoadError.new('less', self.class.name, context.dest_node, 'less')
31
31
  end
32
32
 
33
33
  end
@@ -26,9 +26,9 @@ module Webgen::ContentProcessor
26
26
  context.content = ::Maruku.new(context.content, :on_error => :raise).to_html
27
27
  context
28
28
  rescue LoadError
29
- raise Webgen::LoadError.new('maruku', self.class.name, context.dest_node.alcn, 'maruku')
29
+ raise Webgen::LoadError.new('maruku', self.class.name, context.dest_node, 'maruku')
30
30
  rescue Exception => e
31
- raise Webgen::RenderError.new(e, self.class.name, context.dest_node.alcn, context.ref_node.alcn)
31
+ raise Webgen::RenderError.new(e, self.class.name, context.dest_node, context.ref_node)
32
32
  end
33
33
 
34
34
  end
@@ -11,7 +11,7 @@ module Webgen::ContentProcessor
11
11
  context.content = ::RDiscount.new(context.content).to_html
12
12
  context
13
13
  rescue LoadError
14
- raise Webgen::LoadError.new('rdiscount', self.class.name, context.dest_node.alcn, 'rdiscount')
14
+ raise Webgen::LoadError.new('rdiscount', self.class.name, context.dest_node, 'rdiscount')
15
15
  end
16
16
 
17
17
  end
@@ -12,7 +12,7 @@ module Webgen::ContentProcessor
12
12
  context.content = ::RDoc::Markup::ToHtml.new.convert(context.content)
13
13
  context
14
14
  rescue LoadError
15
- raise Webgen::LoadError.new('rdoc/markup/to_html', self.class.name, context.dest_node.alcn, 'rdoc')
15
+ raise Webgen::LoadError.new('rdoc/markup/to_html', self.class.name, context.dest_node, 'rdoc')
16
16
  end
17
17
 
18
18
  end
@@ -13,7 +13,7 @@ module Webgen::ContentProcessor
13
13
  context.content = doc.to_html
14
14
  context
15
15
  rescue LoadError
16
- raise Webgen::LoadError.new('redcloth', self.class.name, context.dest_node.alcn, 'RedCloth')
16
+ raise Webgen::LoadError.new('redcloth', self.class.name, context.dest_node, 'RedCloth')
17
17
  end
18
18
 
19
19
  end
@@ -12,9 +12,9 @@ module Webgen::ContentProcessor
12
12
  context.content = ::Sass::Engine.new(context.content, :filename => context.ref_node.alcn).render
13
13
  context
14
14
  rescue LoadError
15
- raise Webgen::LoadError.new('sass', self.class.name, context.dest_node.alcn, 'haml')
15
+ raise Webgen::LoadError.new('sass', self.class.name, context.dest_node, 'haml')
16
16
  rescue ::Sass::SyntaxError => e
17
- raise Webgen::RenderError.new(e, self.class.name, context.dest_node.alcn, context.ref_node.alcn, (e.sass_line if e.sass_line))
17
+ raise Webgen::RenderError.new(e, self.class.name, context.dest_node, context.ref_node, (e.sass_line if e.sass_line))
18
18
  end
19
19
 
20
20
  end
@@ -23,7 +23,7 @@ module Webgen::ContentProcessor
23
23
  # Replace all webgen tags in the content of +context+ with the rendered content.
24
24
  def call(context)
25
25
  replace_tags(context) do |tag, param_string, body|
26
- log(:debug) { "Replacing tag #{tag} with data '#{param_string}' and body '#{body}' in <#{context.ref_node.alcn}>" }
26
+ log(:debug) { "Replacing tag #{tag} with data '#{param_string}' and body '#{body}' in <#{context.ref_node}>" }
27
27
  process_tag(tag, param_string, body, context)
28
28
  end
29
29
  context
@@ -48,7 +48,7 @@ module Webgen::ContentProcessor
48
48
  result = call(context.clone(:content => result)).content if process_output
49
49
  else
50
50
  raise Webgen::RenderError.new("No tag processor for '#{tag}' found", self.class.name,
51
- context.dest_node.alcn, context.ref_node.alcn)
51
+ context.dest_node, context.ref_node)
52
52
  end
53
53
  result
54
54
  end
@@ -87,7 +87,7 @@ module Webgen::ContentProcessor
87
87
  data.brackets += (scanner[1] == '{' ? 1 : -1) while data.brackets != 0 && scanner.skip_until(BRACKETS_RE)
88
88
  if data.brackets != 0
89
89
  raise Webgen::RenderError.new("Unbalanced curly brackets for tag '#{data.tag}'", self.class.name,
90
- context.dest_node.alcn, context.ref_node.alcn)
90
+ context.dest_node, context.ref_node)
91
91
  else
92
92
  data.params_end_pos = data.body_end_pos = data.end_pos = scanner.pos - 1
93
93
  data.state = (data.simple_tag ? :process : :in_body)
@@ -139,7 +139,7 @@ module Webgen::ContentProcessor
139
139
  data.body_end_pos = scanner.pos - scanner.matched.length + scanner[1].length / 2
140
140
  else
141
141
  raise Webgen::RenderError.new("Invalid body part - no end tag found for '#{data.tag}'", self.class.name,
142
- context.dest_node.alcn, context.ref_node.alcn)
142
+ context.dest_node, context.ref_node)
143
143
  end
144
144
 
145
145
  when :done
@@ -15,7 +15,7 @@ module Webgen::ContentProcessor
15
15
 
16
16
  `tidy -v 2>&1`
17
17
  if $?.exitstatus != 0
18
- raise Webgen::CommandNotFoundError.new('tidy', self.class.name, context.dest_node.alcn)
18
+ raise Webgen::CommandNotFoundError.new('tidy', self.class.name, context.dest_node)
19
19
  end
20
20
 
21
21
  cmd = "tidy -q -f #{error_file.path} #{context.website.config['contentprocessor.tidy.options']}"
@@ -26,7 +26,7 @@ module Webgen::ContentProcessor
26
26
  end
27
27
  if $?.exitstatus != 0
28
28
  File.readlines(error_file.path).each do |line|
29
- log($?.exitstatus == 1 ? :warn : :error) { "Tidy reported problems for <#{context.dest_node.alcn}>: #{line}" }
29
+ log($?.exitstatus == 1 ? :warn : :error) { "Tidy reported problems for <#{context.dest_node}>: #{line}" }
30
30
  end
31
31
  end
32
32
  context.content = result
@@ -15,7 +15,7 @@ module Webgen::ContentProcessor
15
15
 
16
16
  `xmllint --version 2>&1`
17
17
  if $?.exitstatus != 0
18
- raise Webgen::CommandNotFoundError.new('xmllint', self.class.name, context.dest_node.alcn)
18
+ raise Webgen::CommandNotFoundError.new('xmllint', self.class.name, context.dest_node)
19
19
  end
20
20
 
21
21
  cmd = "xmllint #{context.website.config['contentprocessor.xmllint.options']} - 2>'#{error_file.path}'"
@@ -26,7 +26,7 @@ module Webgen::ContentProcessor
26
26
  end
27
27
  if $?.exitstatus != 0
28
28
  File.read(error_file.path).scan(/^-:(\d+):(.*?\n)(.*?\n)/).each do |line, error_msg, line_context|
29
- log(:warn) { "xmllint reported problems for <#{context.dest_node.alcn}:~#{line}>: #{error_msg.strip} (context: #{line_context.strip})" }
29
+ log(:warn) { "xmllint reported problems for <#{context.dest_node}:~#{line}>: #{error_msg.strip} (context: #{line_context.strip})" }
30
30
  end
31
31
  end
32
32
  context
@@ -180,6 +180,8 @@ config.contentprocessor.kramdown.options({:auto_ids => true}, :doc => 'The optio
180
180
  config.contentprocessor.kramdown.handle_links(true, :doc => 'Whether all links in a kramdown document should be handled by webgen')
181
181
 
182
182
 
183
+ config.tag.metainfo.escape_html(true, :doc => 'Special HTML characters in the output will be escaped if true')
184
+
183
185
  config.tag.relocatable.path(nil, :doc => 'The path which should be made relocatable', :mandatory => 'default')
184
186
 
185
187
  config.tag.menu.start_level(1, :doc => 'The level at which the menu starts.')
data/lib/webgen/error.rb CHANGED
@@ -27,7 +27,7 @@ module Webgen
27
27
  set_backtrace(msg_or_error.backtrace)
28
28
  @plain_message = msg_or_error.message
29
29
  end
30
- @class_name, @alcn = class_name, alcn
30
+ @class_name, @alcn = class_name, (alcn.kind_of?(Node) ? alcn.to_s : alcn)
31
31
  end
32
32
 
33
33
  def message # :nodoc:
@@ -68,7 +68,7 @@ module Webgen
68
68
  # exception is wrapped.
69
69
  def initialize(msg_or_error, class_name = nil, alcn = nil, error_alcn = nil, line = nil)
70
70
  super(msg_or_error, class_name, alcn)
71
- @error_alcn, @line = error_alcn, line
71
+ @error_alcn, @line = (error_alcn.kind_of?(Node) ? error_alcn.to_s : error_alcn), line
72
72
  end
73
73
 
74
74
  def message # :nodoc:
data/lib/webgen/node.rb CHANGED
@@ -191,6 +191,11 @@ module Webgen
191
191
  flagged?(:dirty_meta_info)
192
192
  end
193
193
 
194
+ # Return the string representation of the node which is just the alcn.
195
+ def to_s
196
+ @alcn
197
+ end
198
+
194
199
  # Return an informative representation of the node.
195
200
  def inspect
196
201
  "<##{self.class.name}: alcn=#{@alcn}>"
@@ -314,7 +319,7 @@ module Webgen
314
319
  index_node = resolve(index_path, lang)
315
320
  if index_node
316
321
  vcache[key] = index_node
317
- log(:info) { "Directory index path for <#{alcn}> => <#{index_node.alcn}>" }
322
+ log(:info) { "Directory index path for <#{alcn}> => <#{index_node}>" }
318
323
  elsif log_warning
319
324
  vcache[key] = self
320
325
  log(:warn) { "No directory index path found for directory <#{alcn}>" }
@@ -120,7 +120,7 @@ module Webgen
120
120
  e.alcn = node.alcn unless e.alcn
121
121
  raise
122
122
  rescue Exception => e
123
- raise Webgen::Error.new(e, nil, node.alcn)
123
+ raise Webgen::Error.new(e, nil, node)
124
124
  end
125
125
  end
126
126
 
@@ -167,7 +167,7 @@ module Webgen
167
167
  e.alcn = node.alcn unless e.alcn
168
168
  raise
169
169
  rescue Exception => e
170
- raise Webgen::RenderError.new(e, nil, node.alcn)
170
+ raise Webgen::RenderError.new(e, nil, node)
171
171
  end
172
172
  end
173
173
  end
@@ -235,7 +235,7 @@ module Webgen::SourceHandler
235
235
  end
236
236
 
237
237
  if !node['modified_at'].kind_of?(Time)
238
- log(:warn) { "Meta information 'modified_at' set to current time in <#{node.alcn}> since its value '#{node['modified_at']}' was of type #{node['modified_at'].class}" } unless node['modified_at'].nil?
238
+ log(:warn) { "Meta information 'modified_at' set to current time in <#{node}> since its value '#{node['modified_at']}' was of type #{node['modified_at'].class}" } unless node['modified_at'].nil?
239
239
  node['modified_at'] = Time.now
240
240
  end
241
241
  node.node_info[:src] = path.source_path
@@ -36,7 +36,7 @@ module Webgen::SourceHandler
36
36
  context.content
37
37
  else
38
38
  raise Webgen::RenderError.new("No block named '#{block_name}'",
39
- self.class.name, node.alcn, chain.first.alcn)
39
+ self.class.name, node, chain.first)
40
40
  end
41
41
  end
42
42
  alias_method :content, :render_node
@@ -25,14 +25,14 @@ module Webgen::SourceHandler
25
25
  elsif node['template'].kind_of?(String)
26
26
  template_node = node.resolve(node['template'], lang)
27
27
  if template_node.nil?
28
- log(:warn) { "Specified template '#{node['template']}' for <#{node.alcn}> not found, using default template!" }
28
+ log(:warn) { "Specified template '#{node['template']}' for <#{node}> not found, using default template!" }
29
29
  template_node = default_template(node.parent, lang)
30
30
  end
31
31
  cached_template[lang] = template_node
32
32
  elsif node.meta_info.has_key?('template') && node['template'].nil?
33
33
  template_node = cached_template[lang] = nil
34
34
  else
35
- log(:info) { "Using default template in language '#{lang}' for <#{node.alcn}>" }
35
+ log(:info) { "Using default template in language '#{lang}' for <#{node}>" }
36
36
  template_node = default_template(node.parent, lang)
37
37
  if template_node == node && !node.parent.is_root?
38
38
  template_node = default_template(node.parent.parent, lang)
@@ -71,7 +71,7 @@ module Webgen::Tag::Base
71
71
  config = YAML::load("--- #{tag_config}")
72
72
  rescue ArgumentError => e
73
73
  raise Webgen::RenderError.new("Could not parse the tag params '#{tag_config}': #{e.message}",
74
- self.class.name, nil, ref_node.alcn)
74
+ self.class.name, nil, ref_node)
75
75
  end
76
76
  create_params_hash(config, ref_node)
77
77
  end
@@ -85,11 +85,11 @@ module Webgen::Tag::Base
85
85
  when NilClass then {}
86
86
  else
87
87
  raise Webgen::RenderError.new("Invalid parameter type (#{config.class})",
88
- self.class.name, nil, node.alcn)
88
+ self.class.name, nil, node)
89
89
  end
90
90
 
91
91
  unless params.all? {|k| !website.config.meta_info[k][:mandatory] || result.has_key?(k)}
92
- raise Webgen::RenderError.new("Not all mandatory parameters set", self.class.name, nil, node.alcn)
92
+ raise Webgen::RenderError.new("Not all mandatory parameters set", self.class.name, nil, node)
93
93
  end
94
94
 
95
95
  result
@@ -103,7 +103,7 @@ module Webgen::Tag::Base
103
103
  # Retrieve the parameter value for +name+. The value is taken from the current parameter
104
104
  # configuration if the parameter is specified there or from the website configuration otherwise.
105
105
  def param(name)
106
- (@params && @params.has_key?(name) ? @params[name] : website.config[name])
106
+ (defined?(@params) && @params.has_key?(name) ? @params[name] : website.config[name])
107
107
  end
108
108
 
109
109
  # Default implementation for processing a tag. The parameter +tag+ specifies the name of the tag
@@ -150,7 +150,7 @@ module Webgen::Tag::Base
150
150
  elsif params.include?(tag_config_base + '.' + key)
151
151
  result[tag_config_base + '.' + key] = value
152
152
  else
153
- log(:warn) { "Invalid parameter '#{key}' for tag '#{self.class.name}' in <#{node.alcn}>" }
153
+ log(:warn) { "Invalid parameter '#{key}' for tag '#{self.class.name}' in <#{node}>" }
154
154
  end
155
155
  end
156
156
  result
@@ -160,7 +160,7 @@ module Webgen::Tag::Base
160
160
  def create_from_string(value, params, node)
161
161
  param_name = params.find {|k| website.config.meta_info[k][:mandatory] == 'default'}
162
162
  if param_name.nil?
163
- log(:error) { "No default mandatory parameter specified for tag '#{self.class.name}' but set in <#{node.alcn}>"}
163
+ log(:error) { "No default mandatory parameter specified for tag '#{self.class.name}' but set in <#{node}>"}
164
164
  {}
165
165
  else
166
166
  {param_name => value}
@@ -19,7 +19,7 @@ module Webgen::Tag
19
19
  (context.dest_node.node_info[:tag_breadcrumb_trail] ||= {})[[@params.to_a.sort, context.content_node.alcn]] = out.map {|n| n.alcn}
20
20
  out = out.map {|n| context.dest_node.link_to(n, :lang => context.content_node.lang) }.
21
21
  join(param('tag.breadcrumbtrail.separator'))
22
- log(:debug) { "Breadcrumb trail for <#{context.content_node.alcn}>: #{out}" }
22
+ log(:debug) { "Breadcrumb trail for <#{context.content_node}>: #{out}" }
23
23
  out
24
24
  end
25
25
 
@@ -34,7 +34,7 @@ module Webgen::Tag
34
34
  end
35
35
  CodeRay.scan(body, param('tag.coderay.lang').to_sym).html(options)
36
36
  rescue LoadError
37
- raise Webgen::LoadError.new('coderay', self.class.name, context.dest_node.alcn, 'coderay')
37
+ raise Webgen::LoadError.new('coderay', self.class.name, context.dest_node, 'coderay')
38
38
  end
39
39
 
40
40
  end
@@ -13,7 +13,7 @@ module Webgen::Tag
13
13
  context.dest_node.node_info[:used_meta_info_nodes] << dest_node.alcn
14
14
  context.dest_node.link_to(dest_node, param('tag.link.attr').merge(:lang => context.content_node.lang))
15
15
  else
16
- log(:error) { "Could not resolve path '#{param('tag.link.path')}' in <#{context.ref_node.alcn}>" }
16
+ log(:error) { "Could not resolve path '#{param('tag.link.path')}' in <#{context.ref_node}>" }
17
17
  context.dest_node.flag(:dirty)
18
18
  ''
19
19
  end
@@ -1,4 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ require 'cgi'
2
3
 
3
4
  module Webgen::Tag
4
5
 
@@ -14,8 +15,9 @@ module Webgen::Tag
14
15
  output = context.content_node.lang
15
16
  elsif context.content_node[tag]
16
17
  output = context.content_node[tag].to_s
18
+ output = CGI::escapeHTML(output) if param('tag.metainfo.escape_html')
17
19
  else
18
- log(:error) { "No value for meta info key '#{tag}' in <#{context.ref_node.alcn}> found in <#{context.content_node.alcn}>" }
20
+ log(:error) { "No value for meta info key '#{tag}' in <#{context.ref_node}> found in <#{context.content_node}>" }
19
21
  end
20
22
  output
21
23
  end
@@ -39,7 +39,7 @@ module Webgen::Tag
39
39
  context.dest_node.node_info[:used_meta_info_nodes] << dest_node.alcn
40
40
  context.dest_node.route_to(dest_node)
41
41
  else
42
- log(:error) { "Could not resolve path '#{path}' in <#{context.ref_node.alcn}>" }
42
+ log(:error) { "Could not resolve path '#{path}' in <#{context.ref_node}>" }
43
43
  context.dest_node.flag(:dirty)
44
44
  ''
45
45
  end
data/lib/webgen/tree.rb CHANGED
@@ -48,7 +48,7 @@ module Webgen
48
48
  # A utility method called by Node#initialize. This method should not be used directly!
49
49
  def register_node(node)
50
50
  if @node_access[:alcn].has_key?(node.alcn)
51
- raise "Can't have two nodes with same absolute lcn: #{node.alcn}"
51
+ raise "Can't have two nodes with same absolute lcn: #{node}"
52
52
  else
53
53
  @node_access[:alcn][node.alcn] = node
54
54
  end
@@ -3,6 +3,6 @@
3
3
  module Webgen
4
4
 
5
5
  # The version of webgen.
6
- VERSION = '0.5.11'
6
+ VERSION = '0.5.12'
7
7
 
8
8
  end
@@ -27,6 +27,13 @@ class TestContentProcessorBuilder < Test::Unit::TestCase
27
27
  context.content = "xml.div do \n5+5\nunknown\n++6\nend"
28
28
  assert_error_on_line(Webgen::RenderError, 3) { obj.call(context) }
29
29
 
30
+ context.content = "context.node.link_to(nil)"
31
+ begin
32
+ obj.call(context)
33
+ rescue Webgen::RenderError => e
34
+ assert(e.error_alcn =~ /\/lib\/webgen\/node.rb$/)
35
+ end
36
+
30
37
  def obj.require(lib); raise LoadError; end
31
38
  assert_raise(Webgen::LoadError) { obj.call(context) }
32
39
  end
@@ -22,8 +22,12 @@ class TestContentProcessorErb < Test::Unit::TestCase
22
22
  context.content = "\n<%= 5* %>"
23
23
  assert_error_on_line(Webgen::RenderError, 2) { obj.call(context) }
24
24
 
25
- context.content = "\n\n<% unknown %>"
26
- assert_error_on_line(Webgen::RenderError, 3) { obj.call(context) }
25
+ context.content = "<% context.node.link_to(nil) %>"
26
+ begin
27
+ obj.call(context)
28
+ rescue Webgen::RenderError => e
29
+ assert(e.error_alcn =~ /\/lib\/webgen\/node.rb$/)
30
+ end
27
31
  end
28
32
 
29
33
  end
@@ -26,6 +26,13 @@ class TestContentProcessorErubis < Test::Unit::TestCase
26
26
  context.content = "\n\n<% unknown %>"
27
27
  assert_error_on_line(Webgen::RenderError, 3) { obj.call(context) }
28
28
 
29
+ context.content = "<% context.node.link_to(nil) %>"
30
+ begin
31
+ obj.call(context)
32
+ rescue Webgen::RenderError => e
33
+ assert(e.error_alcn =~ /\/lib\/webgen\/node.rb$/)
34
+ end
35
+
29
36
  context.content = "<% for i in [1] %>\n<%= i %>\n<% end %>"
30
37
  assert_equal("1\n", obj.call(context).content)
31
38
  @website.config['contentprocessor.erubis.options'][:trim] = false
@@ -25,6 +25,13 @@ class TestContentProcessorHaml < Test::Unit::TestCase
25
25
  context.content = "#cont\n = unknown"
26
26
  assert_error_on_line(Webgen::RenderError, 2) { obj.call(context) }
27
27
 
28
+ context.content = "#cont\n = context.node.link_to(nil)"
29
+ begin
30
+ obj.call(context)
31
+ rescue Webgen::RenderError => e
32
+ assert(e.error_alcn =~ /\/lib\/webgen\/node.rb$/)
33
+ end
34
+
28
35
  def obj.require(lib); raise LoadError; end
29
36
  assert_raise(Webgen::LoadError) { obj.call(context) }
30
37
  end
@@ -85,6 +85,12 @@ class TestContentProcessorHead < Test::Unit::TestCase
85
85
  "\n<link href=\"test.en\" rel=\"alternate\" type=\"text/html\" />" +
86
86
  "\n<link href=\"test.en\" rel=\"next\" type=\"text/html\" />" +
87
87
  "\n<link href=\"http://example.org\" rel=\"start\" type=\"text/xhtml\" /></head>", context.content)
88
+ context.content = '</head>'
89
+ @obj.call(context)
90
+ assert_equal("\n<link href=\"test.en\" rel=\"alternate\" />" +
91
+ "\n<link href=\"test.en\" rel=\"alternate\" type=\"text/html\" />" +
92
+ "\n<link href=\"test.en\" rel=\"next\" type=\"text/html\" />" +
93
+ "\n<link href=\"http://example.org\" rel=\"start\" type=\"text/xhtml\" /></head>", context.content)
88
94
  end
89
95
 
90
96
  end
data/test/test_error.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  require 'test/unit'
4
+ require 'webgen/tree'
5
+ require 'webgen/node'
4
6
  require 'webgen/error'
5
7
 
6
8
  class TestError < Test::Unit::TestCase
@@ -21,6 +23,9 @@ class TestError < Test::Unit::TestCase
21
23
  assert_equal('/path', e.alcn)
22
24
  assert_match(/Error while working on <\/path> with KlassName:/, e.message)
23
25
 
26
+ e = Webgen::Error.new("test", 'KlassName', Webgen::Node.new(Webgen::Tree.new.dummy_root, '/hallo', '/hallo'))
27
+ assert_equal('/hallo', e.alcn)
28
+
24
29
  e = Webgen::Error.new(Exception.new("test"))
25
30
  assert_equal("test", e.plain_message)
26
31
  assert_match(/Error while working:/, e.message)
@@ -48,6 +53,9 @@ class TestRenderError < Test::Unit::TestCase
48
53
  e = Webgen::RenderError.new("test", 'KlassName', '/path', '/error', 5)
49
54
  assert_equal("/error", e.error_alcn)
50
55
  assert_match(/Error in <\/error:~5> while rendering <\/path>/, e.message)
56
+
57
+ e = Webgen::RenderError.new("test", 'KlassName', '/path', Webgen::Node.new(Webgen::Tree.new.dummy_root, '/hallo', '/hallo'), 5)
58
+ assert_equal('/hallo', e.error_alcn)
51
59
  end
52
60
 
53
61
  end
data/test/test_node.rb CHANGED
@@ -182,6 +182,11 @@ class TestNode < Test::Unit::TestCase
182
182
  assert(node.inspect =~ /alcn=\//)
183
183
  end
184
184
 
185
+ def test_to_s
186
+ node = Webgen::Node.new(@tree.dummy_root, '/', '/', {'lang' => 'de', :test => :value})
187
+ assert_equal(node.alcn, node.to_s)
188
+ end
189
+
185
190
  def test_changed
186
191
  node = Webgen::Node.new(@tree.dummy_root, 'test/', 'test', {'lang' => 'de', :test => :value})
187
192
  node.unflag(:dirty, :dirty_meta_info, :created)
@@ -8,13 +8,19 @@ require 'webgen/tag'
8
8
 
9
9
  class TestTagMetainfo < Test::Unit::TestCase
10
10
 
11
+ include Test::WebsiteHelper
12
+
11
13
  def test_call
12
14
  @obj = Webgen::Tag::Metainfo.new
13
- node = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'hallo.page', 'hallo.page', 'test' => 10, 'lang' => 'en')
15
+ node = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'hallo.page', 'hallo.page', 'test' => 10, 'lang' => 'en',
16
+ 'bad' => 'Something <&>" Bad')
14
17
  c = Webgen::Context.new(:chain => [node])
15
18
  assert_equal('', @obj.call('invalid', '', c))
16
19
  assert_equal('10', @obj.call('test', '', c))
17
20
  assert_equal('en', @obj.call('lang', '', c))
21
+ assert_equal('Something &lt;&amp;&gt;&quot; Bad', @obj.call('bad', '', c))
22
+ @obj.set_params('tag.metainfo.escape_html' => false)
23
+ assert_equal('Something <&>" Bad', @obj.call('bad', '', c))
18
24
  end
19
25
 
20
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webgen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.11
4
+ version: 0.5.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Leitner
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-15 00:00:00 +01:00
12
+ date: 2010-04-14 00:00:00 +02:00
13
13
  default_executable: webgen
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -539,7 +539,6 @@ post_install_message: |+
539
539
 
540
540
  rdoc_options:
541
541
  - --line-numbers
542
- - --all
543
542
  - --main
544
543
  - lib/webgen/website.rb
545
544
  require_paths: