webgen 1.0.0.beta2 → 1.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. data/COPYING +34 -1
  2. data/Rakefile +1 -8
  3. data/data/webgen/passive_sources/default.metainfo +5 -0
  4. data/data/webgen/passive_sources/stylesheets/api.css +284 -0
  5. data/data/webgen/passive_sources/templates/api.template +151 -0
  6. data/data/webgen/passive_sources/templates/feed.template +4 -0
  7. data/lib/webgen/bundle/built-in/init.rb +12 -3
  8. data/lib/webgen/bundle_loader.rb +8 -2
  9. data/lib/webgen/cli/create_command.rb +3 -1
  10. data/lib/webgen/cli/show_tree_command.rb +4 -3
  11. data/lib/webgen/content_processor.rb +2 -2
  12. data/lib/webgen/content_processor/blocks.rb +2 -2
  13. data/lib/webgen/content_processor/haml.rb +1 -1
  14. data/lib/webgen/content_processor/html_head.rb +5 -4
  15. data/lib/webgen/content_processor/kramdown.rb +3 -1
  16. data/lib/webgen/content_processor/r_doc.rb +16 -3
  17. data/lib/webgen/content_processor/sass.rb +3 -3
  18. data/lib/webgen/content_processor/scss.rb +1 -1
  19. data/lib/webgen/content_processor/tikz.rb +2 -2
  20. data/lib/webgen/context/html_head.rb +1 -1
  21. data/lib/webgen/destination/file_system.rb +2 -1
  22. data/lib/webgen/item_tracker/node_content.rb +4 -4
  23. data/lib/webgen/item_tracker/node_meta_info.rb +6 -6
  24. data/lib/webgen/item_tracker/nodes.rb +1 -1
  25. data/lib/webgen/node.rb +5 -7
  26. data/lib/webgen/node_finder.rb +40 -17
  27. data/lib/webgen/page.rb +10 -0
  28. data/lib/webgen/path.rb +14 -14
  29. data/lib/webgen/path_handler.rb +19 -13
  30. data/lib/webgen/path_handler/api.rb +173 -0
  31. data/lib/webgen/path_handler/base.rb +33 -11
  32. data/lib/webgen/path_handler/copy.rb +2 -27
  33. data/lib/webgen/path_handler/feed.rb +4 -3
  34. data/lib/webgen/path_handler/meta_info.rb +1 -1
  35. data/lib/webgen/path_handler/page_utils.rb +4 -3
  36. data/lib/webgen/path_handler/sitemap.rb +3 -2
  37. data/lib/webgen/path_handler/virtual.rb +7 -2
  38. data/lib/webgen/tag.rb +5 -5
  39. data/lib/webgen/tag/execute_command.rb +1 -1
  40. data/lib/webgen/tag/include_file.rb +1 -1
  41. data/lib/webgen/tag/link.rb +2 -2
  42. data/lib/webgen/tag/menu.rb +1 -1
  43. data/lib/webgen/tag/meta_info.rb +1 -0
  44. data/lib/webgen/tag/relocatable.rb +1 -1
  45. data/lib/webgen/tag/tikz.rb +2 -2
  46. data/lib/webgen/task/create_website.rb +1 -1
  47. data/lib/webgen/test_helper.rb +20 -16
  48. data/lib/webgen/tree.rb +5 -1
  49. data/lib/webgen/version.rb +1 -1
  50. data/lib/webgen/website.rb +8 -8
  51. data/test/webgen/content_processor/test_kramdown.rb +7 -5
  52. data/test/webgen/content_processor/test_sass.rb +4 -0
  53. data/test/webgen/content_processor/test_scss.rb +4 -0
  54. data/test/webgen/content_processor/test_tikz.rb +6 -2
  55. data/test/webgen/destination/test_file_system.rb +3 -4
  56. data/test/webgen/item_tracker/test_missing_node.rb +3 -3
  57. data/test/webgen/item_tracker/test_node_content.rb +9 -12
  58. data/test/webgen/item_tracker/test_node_meta_info.rb +7 -11
  59. data/test/webgen/item_tracker/test_nodes.rb +11 -5
  60. data/test/webgen/path_handler/test_api.rb +111 -0
  61. data/test/webgen/path_handler/test_page_utils.rb +1 -1
  62. data/test/webgen/source/test_file_system.rb +3 -3
  63. data/test/webgen/tag/test_coderay.rb +3 -4
  64. data/test/webgen/tag/test_meta_info.rb +3 -0
  65. data/test/webgen/task/test_create_website.rb +2 -2
  66. data/test/webgen/test_item_tracker.rb +11 -16
  67. data/test/webgen/test_node.rb +2 -0
  68. data/test/webgen/test_node_finder.rb +30 -2
  69. data/test/webgen/test_page.rb +8 -0
  70. data/test/webgen/test_source.rb +11 -18
  71. data/test/webgen/test_tag.rb +1 -1
  72. data/test/webgen/test_tree.rb +8 -8
  73. metadata +8 -88
  74. data/ChangeLog +0 -23710
  75. data/data/webgen/website_bundles/default/README +0 -6
  76. data/data/webgen/website_bundles/default/src/index.page +0 -15
  77. data/data/webgen/website_bundles/style/1024px/README +0 -13
  78. data/data/webgen/website_bundles/style/1024px/src/default.css +0 -188
  79. data/data/webgen/website_bundles/style/1024px/src/default.template +0 -60
  80. data/data/webgen/website_bundles/style/1024px/src/images/background.gif +0 -0
  81. data/data/webgen/website_bundles/style/andreas00/README +0 -13
  82. data/data/webgen/website_bundles/style/andreas00/src/default.css +0 -290
  83. data/data/webgen/website_bundles/style/andreas00/src/default.template +0 -60
  84. data/data/webgen/website_bundles/style/andreas00/src/images/bg.gif +0 -0
  85. data/data/webgen/website_bundles/style/andreas00/src/images/front.jpg +0 -0
  86. data/data/webgen/website_bundles/style/andreas00/src/images/menubg.gif +0 -0
  87. data/data/webgen/website_bundles/style/andreas00/src/images/menubg2.gif +0 -0
  88. data/data/webgen/website_bundles/style/andreas01/README +0 -14
  89. data/data/webgen/website_bundles/style/andreas01/src/default.css +0 -310
  90. data/data/webgen/website_bundles/style/andreas01/src/default.template +0 -62
  91. data/data/webgen/website_bundles/style/andreas01/src/images/bg.gif +0 -0
  92. data/data/webgen/website_bundles/style/andreas01/src/images/front.jpg +0 -0
  93. data/data/webgen/website_bundles/style/andreas01/src/print.css +0 -35
  94. data/data/webgen/website_bundles/style/andreas03/README +0 -14
  95. data/data/webgen/website_bundles/style/andreas03/src/default.css +0 -223
  96. data/data/webgen/website_bundles/style/andreas03/src/default.template +0 -58
  97. data/data/webgen/website_bundles/style/andreas03/src/images/bodybg.png +0 -0
  98. data/data/webgen/website_bundles/style/andreas03/src/images/contbg.png +0 -0
  99. data/data/webgen/website_bundles/style/andreas03/src/images/footerbg.png +0 -0
  100. data/data/webgen/website_bundles/style/andreas03/src/images/gradient1.png +0 -0
  101. data/data/webgen/website_bundles/style/andreas03/src/images/gradient2.png +0 -0
  102. data/data/webgen/website_bundles/style/andreas04/README +0 -15
  103. data/data/webgen/website_bundles/style/andreas04/src/default.css +0 -290
  104. data/data/webgen/website_bundles/style/andreas04/src/default.template +0 -81
  105. data/data/webgen/website_bundles/style/andreas04/src/images/blinkarrow.gif +0 -0
  106. data/data/webgen/website_bundles/style/andreas04/src/images/bodybg.png +0 -0
  107. data/data/webgen/website_bundles/style/andreas04/src/images/contentbg.png +0 -0
  108. data/data/webgen/website_bundles/style/andreas04/src/images/entrybg.png +0 -0
  109. data/data/webgen/website_bundles/style/andreas04/src/images/flash.gif +0 -0
  110. data/data/webgen/website_bundles/style/andreas04/src/images/flash2.gif +0 -0
  111. data/data/webgen/website_bundles/style/andreas04/src/images/globe.gif +0 -0
  112. data/data/webgen/website_bundles/style/andreas04/src/images/globebottom.gif +0 -0
  113. data/data/webgen/website_bundles/style/andreas04/src/images/linkarrow.gif +0 -0
  114. data/data/webgen/website_bundles/style/andreas04/src/images/menuhover.png +0 -0
  115. data/data/webgen/website_bundles/style/andreas05/README +0 -14
  116. data/data/webgen/website_bundles/style/andreas05/src/default.css +0 -33
  117. data/data/webgen/website_bundles/style/andreas05/src/default.template +0 -40
  118. data/data/webgen/website_bundles/style/andreas05/src/images/bodybg.gif +0 -0
  119. data/data/webgen/website_bundles/style/andreas05/src/images/front.png +0 -0
  120. data/data/webgen/website_bundles/style/andreas06/README +0 -14
  121. data/data/webgen/website_bundles/style/andreas06/src/default.css +0 -356
  122. data/data/webgen/website_bundles/style/andreas06/src/default.template +0 -70
  123. data/data/webgen/website_bundles/style/andreas06/src/images/bodybg.gif +0 -0
  124. data/data/webgen/website_bundles/style/andreas06/src/images/boxbg.gif +0 -0
  125. data/data/webgen/website_bundles/style/andreas06/src/images/greypx.gif +0 -0
  126. data/data/webgen/website_bundles/style/andreas06/src/images/header.jpg +0 -0
  127. data/data/webgen/website_bundles/style/andreas06/src/images/innerbg.gif +0 -0
  128. data/data/webgen/website_bundles/style/andreas06/src/images/leaves.jpg +0 -0
  129. data/data/webgen/website_bundles/style/andreas06/src/images/tabs.gif +0 -0
  130. data/data/webgen/website_bundles/style/andreas07/README +0 -15
  131. data/data/webgen/website_bundles/style/andreas07/src/browserfix.css +0 -7
  132. data/data/webgen/website_bundles/style/andreas07/src/default.css +0 -92
  133. data/data/webgen/website_bundles/style/andreas07/src/default.template +0 -42
  134. data/data/webgen/website_bundles/style/andreas07/src/images/bodybg.gif +0 -0
  135. data/data/webgen/website_bundles/style/andreas07/src/images/sidebarbg.gif +0 -0
  136. data/data/webgen/website_bundles/style/andreas08/README +0 -14
  137. data/data/webgen/website_bundles/style/andreas08/src/default.css +0 -224
  138. data/data/webgen/website_bundles/style/andreas08/src/default.template +0 -51
  139. data/data/webgen/website_bundles/style/andreas09/README +0 -14
  140. data/data/webgen/website_bundles/style/andreas09/src/default.css +0 -308
  141. data/data/webgen/website_bundles/style/andreas09/src/default.template +0 -68
  142. data/data/webgen/website_bundles/style/andreas09/src/images/bodybg-black.jpg +0 -0
  143. data/data/webgen/website_bundles/style/andreas09/src/images/bodybg-green.jpg +0 -0
  144. data/data/webgen/website_bundles/style/andreas09/src/images/bodybg-orange.jpg +0 -0
  145. data/data/webgen/website_bundles/style/andreas09/src/images/bodybg-purple.jpg +0 -0
  146. data/data/webgen/website_bundles/style/andreas09/src/images/bodybg-red.jpg +0 -0
  147. data/data/webgen/website_bundles/style/andreas09/src/images/bodybg.jpg +0 -0
  148. data/data/webgen/website_bundles/style/andreas09/src/images/footerbg.jpg +0 -0
  149. data/data/webgen/website_bundles/style/andreas09/src/images/menuhover-black.jpg +0 -0
  150. data/data/webgen/website_bundles/style/andreas09/src/images/menuhover-green.jpg +0 -0
  151. data/data/webgen/website_bundles/style/andreas09/src/images/menuhover-orange.jpg +0 -0
  152. data/data/webgen/website_bundles/style/andreas09/src/images/menuhover-purple.jpg +0 -0
  153. data/data/webgen/website_bundles/style/andreas09/src/images/menuhover-red.jpg +0 -0
  154. data/data/webgen/website_bundles/style/andreas09/src/images/menuhover.jpg +0 -0
  155. data/data/webgen/website_bundles/style/simple/README +0 -6
  156. data/data/webgen/website_bundles/style/simple/src/default.css +0 -84
  157. data/data/webgen/website_bundles/style/simple/src/default.template +0 -36
@@ -14,33 +14,8 @@ module Webgen
14
14
 
15
15
  # Create the node for +path+.
16
16
  #
17
- # The following order is used for finding the (optional) content processor pipeline:
18
- #
19
- # * If the pipeline meta info key is specified, it is used.
20
- #
21
- # * If the +path+ has the names of content processors as parts in the file extension, all
22
- # extension parts until the first non-content processor part will be used for the pipeline
23
- # and removed from the extension.
24
- #
25
- # If the last extension part is a file extension registered with a content processor (using
26
- # the :ext_map facility), the corresponding content processor is appended to the pipeline
27
- # and the post-process file extension name is used.
28
- #
29
- # Here are some examples:
30
- #
31
- # * pipeline = ['erb'] → only erb is used, extension is not modified
32
- #
33
- # * path = 'test.erb.kramdown.html', no pipeline → pipeline is set to ['erb', 'kramdown'] and
34
- # path extension is changed to '.html', ie. path = 'test.html'
35
- #
36
- # * path = 'test.erb.kramdown.unknown.html', no pipeline → pipeline is set ['erb', 'kramdown']
37
- # and path extension is changed to 'unknown.html', ie. path = 'test.unknown.html'
38
- #
39
- # * path = 'test.erb.sass', no pipeline → pipeline is set to ['erb', 'sass'] and path
40
- # extension is changed to '.css', ie. path = 'test.css'
41
- #
42
- # * path = 'test.sass', no pipeline → pipeline is set to ['sass'] and path extension is
43
- # changed to '.css', ie. path = 'test.css'
17
+ # See the user documentation for detailed information about how the content processor pipeline
18
+ # can be specified.
44
19
  def create_nodes(path)
45
20
  if !path.meta_info.has_key?('pipeline')
46
21
  pipeline = []
@@ -58,17 +58,18 @@ module Webgen
58
58
  def create_nodes(path, blocks)
59
59
  if MANDATORY_INFOS.any? {|t| path.meta_info[t].nil?}
60
60
  raise Webgen::NodeCreationError.new("At least one of #{MANDATORY_INFOS.join('/')} is missing",
61
- self.class.name, path)
61
+ "path_handler.feed", path)
62
62
  end
63
63
  if !['atom', 'rss'].include?(path['version'])
64
64
  raise Webgen::NodeCreationError.new("Invalid version '#{path['version']}' for feed path specified, only atom and rss allowed",
65
- self.class.name, path)
65
+ "path_handler.feed", path)
66
66
  end
67
67
 
68
68
  path.ext = path['version']
69
69
  path['dest_path'] = '<parent><basename>(.<lang>)<ext>'
70
70
  path['cn'] = '<basename><ext>'
71
- create_node(path, Node) do |node|
71
+ path['node_class'] = Node.to_s
72
+ create_node(path) do |node|
72
73
  set_blocks(node, blocks)
73
74
  node.meta_info['link'] ||= node.parent.alcn
74
75
  @website.ext.item_tracker.add(node, :nodes, :node_finder_option_set,
@@ -50,7 +50,7 @@ module Webgen
50
50
  end
51
51
  entries
52
52
  rescue Exception => e
53
- raise Webgen::NodeCreationError.new("Could not parse block '#{block_name}': #{e.message}", self.class.name)
53
+ raise Webgen::NodeCreationError.new("Could not parse block '#{block_name}': #{e.message}", "path_handler.meta_info")
54
54
  end
55
55
 
56
56
  # Update already existing nodes with meta information from the given meta info node.
@@ -35,7 +35,7 @@ module Webgen
35
35
  end
36
36
 
37
37
  content_processor = context.website.ext.content_processor
38
- context.website.ext.item_tracker.add(context.dest_node, :node_content, alcn)
38
+ context.website.ext.item_tracker.add(context.dest_node, :node_content, self)
39
39
 
40
40
  context.content = blocks[name].dup
41
41
  context[:block_name] = name
@@ -123,7 +123,8 @@ module Webgen
123
123
  end
124
124
 
125
125
 
126
- def create_node(path, node_klass = Node) #:nodoc:
126
+ def create_node(path) #:nodoc:
127
+ path['node_class'] ||= Node.to_s
127
128
  super
128
129
  end
129
130
 
@@ -139,7 +140,7 @@ module Webgen
139
140
  begin
140
141
  page = Webgen::Page.from_data(path.data)
141
142
  rescue Webgen::Page::FormatError => e
142
- raise Webgen::Error.new("Error reading source path: #{e.message}", self.class.name, path)
143
+ raise Webgen::Error.new("Error reading source path: #{e.message}", nil, path)
143
144
  end
144
145
  blocks = page.meta_info.delete('blocks') || {}
145
146
  path.meta_info.merge!(page.meta_info)
@@ -34,11 +34,12 @@ module Webgen
34
34
  def create_nodes(path, blocks)
35
35
  if MANDATORY_INFOS.any? {|t| path.meta_info[t].nil?}
36
36
  raise Webgen::NodeCreationError.new("At least one of #{MANDATORY_INFOS.join('/')} is missing",
37
- self.class.name, path)
37
+ "path_handler.sitemap", path)
38
38
  end
39
39
 
40
40
  path.ext = 'xml'
41
- create_node(path, Node) do |node|
41
+ path['node_class'] = Node.to_s
42
+ create_node(path) do |node|
42
43
  set_blocks(node, blocks)
43
44
  node.node_info[:entries] = {:flatten => true, :and => node['entries']}
44
45
  @website.ext.item_tracker.add(node, :nodes, :node_finder_option_set,
@@ -32,8 +32,13 @@ module Webgen
32
32
  parent_path = create_directories(File.dirname(key), 'modified_at' => meta_info['modified_at'])
33
33
 
34
34
  dest_path = meta_info.delete('dest_path') || key
35
- dest_path = (URI::parse(dest_path).absolute? || dest_path =~ /^\// ?
36
- dest_path : File.join(parent_path, dest_path))
35
+ dest_path = if URI::parse(dest_path).absolute?
36
+ dest_path
37
+ elsif dest_path =~ /^\//
38
+ "webgen:#{dest_path}"
39
+ else
40
+ "webgen:#{File.join(parent_path, dest_path)}"
41
+ end
37
42
  meta_info['dest_path'] = dest_path
38
43
  entry_path = Webgen::Path.new(key, meta_info)
39
44
 
@@ -160,16 +160,16 @@ module Webgen
160
160
  result, process_output = tdata.object.call(tag, body, context)
161
161
  result = context.website.ext.content_processor.call('tags', context.clone(:content => result)).content if process_output
162
162
  else
163
- raise Webgen::RenderError.new("No tag processor for '#{tag}' found", self.class.name,
163
+ raise Webgen::RenderError.new("No tag processor for '#{tag}' found", 'tag',
164
164
  context.dest_node, context.ref_node)
165
165
  end
166
166
  result
167
167
  rescue Webgen::Error => e
168
168
  e.path = context.dest_node if e.path.to_s.empty?
169
+ e.location = "tag.#{tag}" unless e.location
169
170
  raise
170
171
  rescue Exception => e
171
- raise Webgen::RenderError.new(e, (tdata && tdata.object.respond_to?(:name) ? tdata.object.name : "tag '#{tag}'"),
172
- context.dest_node, context.ref_node)
172
+ raise Webgen::RenderError.new(e, "tag.#{tag}", context.dest_node, context.ref_node)
173
173
  end
174
174
 
175
175
  # See Webgen::Utils::TagParser#replace_tags.
@@ -190,11 +190,11 @@ module Webgen
190
190
  when NilClass then {}
191
191
  else
192
192
  raise Webgen::RenderError.new("Invalid parameter type (#{params.class})",
193
- self.class.name, context.dest_node, context.ref_node)
193
+ "tag", context.dest_node, context.ref_node)
194
194
  end
195
195
 
196
196
  if !tdata.mandatory.all? {|k| values.has_key?(k)}
197
- raise Webgen::RenderError.new("Not all mandatory parameters set", self.class.name, context.dest_node, context.ref_node)
197
+ raise Webgen::RenderError.new("Not all mandatory parameters set", "tag", context.dest_node, context.ref_node)
198
198
  end
199
199
  config = context.website.config.dup
200
200
  config.set_values(values)
@@ -19,7 +19,7 @@ module Webgen
19
19
  output = `#{command} 2> #{BIT_BUCKET}`
20
20
  if $?.exitstatus != 0
21
21
  raise Webgen::RenderError.new("Command '#{command}' has return value != 0: #{output}",
22
- self.name, context.dest_node, context.ref_node)
22
+ "tag.#{tag}", context.dest_node, context.ref_node)
23
23
  end
24
24
  output = CGI::escapeHTML(output) if context[:config]['tag.execute_command.escape_html']
25
25
  [output, context[:config]['tag.execute_command.process_output']]
@@ -16,7 +16,7 @@ module Webgen
16
16
  filename = File.join(context.website.directory, filename) unless filename =~ /^(\/|\w:)/
17
17
  if !File.exists?(filename)
18
18
  raise Webgen::RenderError.new("File '#{filename}' cannot be included because it does not exist",
19
- self.name, context.dest_node, context.ref_node)
19
+ "tag.#{tag}", context.dest_node, context.ref_node)
20
20
  end
21
21
 
22
22
  content = File.read(filename)
@@ -10,14 +10,14 @@ module Webgen
10
10
  def self.call(tag, body, context)
11
11
  path = context[:config]['tag.link.path'].to_s
12
12
  if (dest_node = context.ref_node.resolve(path, context.dest_node.lang, true))
13
- context.website.ext.item_tracker.add(context.dest_node, :node_meta_info, dest_node.alcn)
13
+ context.website.ext.item_tracker.add(context.dest_node, :node_meta_info, dest_node)
14
14
  context.dest_node.link_to(dest_node, context.content_node.lang, context[:config]['tag.link.attr'])
15
15
  else
16
16
  ''
17
17
  end
18
18
  rescue URI::InvalidURIError => e
19
19
  raise Webgen::RenderError.new("Error while parsing path '#{path}': #{e.message}",
20
- self.name, context.dest_node, context.ref_node)
20
+ "tag.#{tag}", context.dest_node, context.ref_node)
21
21
  end
22
22
 
23
23
  end
@@ -30,7 +30,7 @@ module Webgen
30
30
  def self.menu_item_details(dest_node, node, lang, level, has_submenu)
31
31
  styles = ['webgen-menu-level' + level.to_s]
32
32
  styles << 'webgen-menu-submenu' if has_submenu
33
- styles << 'webgen-menu-submenu-inhierarchy' if has_submenu && node.is_ancestor_of?(dest_node)
33
+ styles << 'webgen-menu-submenu-inhierarchy' if node.is_ancestor_of?(dest_node)
34
34
  styles << 'webgen-menu-item-selected' if node == dest_node
35
35
  style = "class=\"#{styles.join(' ')}\"" if styles.length > 0
36
36
 
@@ -9,6 +9,7 @@ module Webgen
9
9
 
10
10
  # Treat +tag+ as a meta information key and return its value from the content node.
11
11
  def self.call(tag, body, context)
12
+ tag = context[:config]['tag.meta_info.mi'] if tag == 'meta_info'
12
13
  output = ''
13
14
  if tag == 'lang'
14
15
  output = context.content_node.lang
@@ -46,7 +46,7 @@ module Webgen
46
46
  end
47
47
 
48
48
  if dest_node
49
- context.website.ext.item_tracker.add(context.dest_node, :node_meta_info, dest_node.alcn)
49
+ context.website.ext.item_tracker.add(context.dest_node, :node_meta_info, dest_node)
50
50
  context.dest_node.route_to(dest_node) + fragment
51
51
  else
52
52
  ''
@@ -15,7 +15,6 @@ module Webgen
15
15
  path = Webgen::Path.new(path)
16
16
 
17
17
  add_tikz_options!(path, context)
18
-
19
18
  node = context.website.ext.path_handler.create_secondary_nodes(path, body, context.ref_node.alcn).first
20
19
 
21
20
  attrs = {'alt' => ''}.merge(context[:config]['tag.tikz.img_attr']).collect do |name, value|
@@ -27,7 +26,8 @@ module Webgen
27
26
  # Add all needed options for Webgen::ContentProcessor::Tikz to the given path.
28
27
  def self.add_tikz_options!(path, context)
29
28
  %w[content_processor.tikz.resolution content_processor.tikz.transparent
30
- content_processor.tikz.libraries content_processor.tikz.opts].each do |opt|
29
+ content_processor.tikz.libraries content_processor.tikz.opts
30
+ content_processor.tikz.template].each do |opt|
31
31
  path.meta_info[opt] = context[:config][opt]
32
32
  end
33
33
  path.meta_info['pipeline'] = 'tikz'
@@ -67,7 +67,7 @@ module Webgen
67
67
  ws = Webgen::Website.new(tmpdir) do |ws|
68
68
  ws.config['sources'] = [['/', :file_system, File.join(Webgen::Utils.data_dir, 'basic_website_template')]]
69
69
  if template
70
- ws.config['sources'] = [(['/', :file_system, website.ext.task.data(:create_website)[:templates][template]])]
70
+ ws.config['sources'].unshift(['/', :file_system, website.ext.task.data(:create_website)[:templates][template]])
71
71
  end
72
72
  ws.config['destination'] = [:file_system, File.expand_path(website.directory)]
73
73
  ws.ext.path_handler.registered_extensions.each do |name, data|
@@ -4,6 +4,7 @@ require 'minitest/autorun'
4
4
  require 'ostruct'
5
5
  require 'tmpdir'
6
6
  require 'stringio'
7
+ require 'fileutils'
7
8
  require 'webgen/logger'
8
9
 
9
10
  require 'webgen/blackboard'
@@ -66,7 +67,7 @@ module Webgen
66
67
  @logio.string = ''
67
68
  end
68
69
 
69
- # Creates a basic mock website that is accessible via @website with the following methods:
70
+ # Creates a basic stub website that is accessible via @website with the following methods:
70
71
  #
71
72
  # [@website.config]
72
73
  # The given config object or {} if none specified
@@ -90,19 +91,22 @@ module Webgen
90
91
  # [@website.tree]
91
92
  # Webgen::Tree instance
92
93
  def setup_website(config = {})
93
- @website = MiniTest::Mock.new
94
- @website.expect(:config, config)
95
- directory = Dir::Tmpname.create("test-webgen-website") {|path| raise Errno::EEXIST if File.directory?(path)}
96
- @website.expect(:directory, directory)
97
- def (@website).tmpdir(path=''); File.join(self.directory, 'tmp', path); end
98
- @website.expect(:ext, OpenStruct.new)
99
- @website.expect(:blackboard, Webgen::Blackboard.new)
100
- @website.expect(:cache, Webgen::Cache.new)
94
+ @website = OpenStruct.new
95
+ @website.config = config
96
+ @website.directory = Dir::Tmpname.create("test-webgen-website") {|path| raise Errno::EEXIST if File.directory?(path)}
97
+ @website.define_singleton_method(:tmpdir) do |path='', create=false|
98
+ tmp = File.join(self.directory, 'tmp')
99
+ FileUtils.mkdir_p(tmp) if create
100
+ File.join(tmp, path)
101
+ end
102
+ @website.ext = OpenStruct.new
103
+ @website.blackboard = Webgen::Blackboard.new
104
+ @website.cache = Webgen::Cache.new
101
105
  @logio = StringIO.new
102
- @website.expect(:logger, Webgen::Logger.new(@logio))
103
- @website.expect(:tree, Webgen::Tree.new(@website))
106
+ @website.logger = Webgen::Logger.new(@logio)
107
+ @website.tree = Webgen::Tree.new(@website)
104
108
  @website.ext.item_tracker = Object.new
105
- def (@website.ext.item_tracker).add(*args); end
109
+ @website.ext.item_tracker.define_singleton_method(:add) {|*args|}
106
110
  end
107
111
 
108
112
  # Adds the following nodes (showing alcn=dest_path, title, other meta info) to the tree which
@@ -111,7 +115,7 @@ module Webgen
111
115
  # /
112
116
  # /file.en.html 'file en' sort_info=3
113
117
  # /file.en.html#frag 'frag'
114
- # /file.en.html#nested 'fragnested'
118
+ # /file.en.html#nested 'fragnested' routing_path="/routed.html"
115
119
  # /file.de.html 'file de' sort_info=5
116
120
  # /file.de.html#frag 'frag'
117
121
  # /other.html 'other'
@@ -130,7 +134,7 @@ module Webgen
130
134
 
131
135
  file_en = Webgen::Node.new(root, 'file.html', '/file.en.html', {'lang' => 'en', 'title' => 'file en', 'sort_info' => 3})
132
136
  frag_en = Webgen::Node.new(file_en, '#frag', '/file.en.html#frag', {'title' => 'frag'})
133
- Webgen::Node.new(frag_en, '#nested', '/file.en.html#nested', {'title' => 'fragnested'})
137
+ Webgen::Node.new(frag_en, '#nested', '/file.en.html#nested', {'title' => 'fragnested', 'routing_path' => '/routed.html'})
134
138
  file_de = Webgen::Node.new(root, 'file.html', '/file.de.html', {'lang' => 'de', 'title' => 'file de', 'sort_info' => 5})
135
139
  Webgen::Node.new(file_de, '#frag', '/file.de.html#frag', {'title' => 'frag'})
136
140
 
@@ -158,8 +162,8 @@ module Webgen
158
162
  # node that responds to :alcn with '/test'.
159
163
  def setup_context
160
164
  setup_website
161
- node = MiniTest::Mock.new
162
- node.expect(:alcn, '/test')
165
+ node = Object.new
166
+ node.define_singleton_method(:alcn) { '/test' }
163
167
  @context = Webgen::Context.new(@website, :chain => [node], :doit => 'hallo')
164
168
  end
165
169
 
@@ -35,6 +35,11 @@ module Webgen
35
35
  @dummy_root.children.first
36
36
  end
37
37
 
38
+ # Access a node via its +:alcn+.
39
+ def [](path)
40
+ @node_access[:alcn][path]
41
+ end
42
+
38
43
  # Access a node via a +path+ of a specific +type+.
39
44
  #
40
45
  # If type is +:alcn+ (default) then +path+ has to be an absolute localized canonical name, if
@@ -51,7 +56,6 @@ module Webgen
51
56
  raise ArgumentError, "Unknown type '#{type}' for resolving path <#{path}>"
52
57
  end
53
58
  end
54
- alias_method :[], :node
55
59
 
56
60
  # Return the node representing the given +path+ which can be an alcn/acn/destination path (name
57
61
  # resolution is done in the specified order). The path has to be absolute, i.e. starting with a
@@ -3,6 +3,6 @@
3
3
  module Webgen
4
4
 
5
5
  # The version of webgen.
6
- VERSION = '1.0.0.beta2'
6
+ VERSION = '1.0.0.beta3'
7
7
 
8
8
  end
@@ -181,24 +181,24 @@ module Webgen
181
181
  return if config['website.dry_run']
182
182
  cache_data = [@cache.dump, Webgen::VERSION]
183
183
  if config['website.cache'].first == :file
184
- File.open(cache_file, 'wb') {|f| Marshal.dump(cache_data, f)}
184
+ File.open(cache_file(true), 'wb') {|f| Marshal.dump(cache_data, f)}
185
185
  else
186
186
  config['website.cache'][1] = Marshal.dump(cache_data)
187
187
  end
188
188
  end
189
189
 
190
190
  # The full path of the cache filename.
191
- def cache_file
192
- tmpdir(config['website.cache'].last)
191
+ def cache_file(create_dir = false)
192
+ tmpdir(config['website.cache'].last, create_dir)
193
193
  end
194
194
  private :cache_file
195
195
 
196
196
  # Append the path to the website's temporary directory and return the full path to it.
197
- def tmpdir(path = '')
198
- unless defined?(@_tmpdir)
199
- @_tmpdir = File.absolute_path(config['website.tmpdir'], @directory)
200
- FileUtils.mkdir_p(@_tmpdir)
201
- end
197
+ #
198
+ # Note that the temporary directory is only created if the +create+ parameter is set to true.
199
+ def tmpdir(path = '', create = false)
200
+ @_tmpdir = File.absolute_path(config['website.tmpdir'], @directory) unless defined?(@_tmpdir)
201
+ FileUtils.mkdir_p(@_tmpdir) if create
202
202
  File.join(@_tmpdir, path)
203
203
  end
204
204
 
@@ -16,14 +16,18 @@ class TestContentProcessorKramdown < MiniTest::Unit::TestCase
16
16
  @website.config['content_processor.kramdown.handle_links'] = true
17
17
  @website.config['content_processor.kramdown.ignore_unknown_fragments'] = false
18
18
 
19
- @website.ext.tag = MiniTest::Mock.new
20
- @website.ext.tag.expect(:call, 'hello.en.html', ['relocatable', {'path' => 'hello.html',
21
- 'ignore_unknown_fragment' => false}, '', @context])
19
+ @website.ext.link_definitions = {'hallo' => ['/hello.html', 'Hello you']}
20
+ @website.ext.tag = Object.new
21
+ @website.ext.tag.define_singleton_method(:call) {|*args| 'hello.en.html'}
22
22
 
23
23
  # test normal invocation
24
24
  @context.content = '# header'
25
25
  assert_equal("<h1 id=\"header\">header</h1>\n", cp.call(@context).content)
26
26
 
27
+ # test usage of link definitions
28
+ @context.content = 'Link [hallo]'
29
+ assert_equal("<p>Link <a href=\"hello.en.html\" title=\"Hello you\">hallo</a></p>\n", cp.call(@context).content)
30
+
27
31
  # test automatic handling of links
28
32
  @website.config['content_processor.kramdown.handle_links'] = true
29
33
  @context.content = 'Link [test](hello.html)'
@@ -42,8 +46,6 @@ class TestContentProcessorKramdown < MiniTest::Unit::TestCase
42
46
  cp.call(@context)
43
47
  assert_equal("<p>{::comment}</p>\n", @context.content)
44
48
  assert_log_match(/No stop tag for extension 'comment' found/)
45
-
46
- @website.ext.tag.verify
47
49
  end
48
50
 
49
51
  end
@@ -41,4 +41,8 @@ class TestSass < MiniTest::Unit::TestCase
41
41
  assert_equal("#{result}\n#{result}\n#{result}", cp.call(@context).content)
42
42
  end
43
43
 
44
+ def teardown
45
+ FileUtils.rm_rf(@website.directory)
46
+ end
47
+
44
48
  end
@@ -20,4 +20,8 @@ class TestScss < MiniTest::Unit::TestCase
20
20
  assert_error_on_line(Webgen::RenderError, 2) { cp.call(@context) }
21
21
  end
22
22
 
23
+ def teardown
24
+ FileUtils.rm_rf(@website.directory)
25
+ end
26
+
23
27
  end