gettalong-webgen 0.5.8.20090507 → 0.5.9.20090620

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/Rakefile +5 -6
  2. data/data/webgen/passive_sources/images/generated_by_webgen.png +0 -0
  3. data/data/webgen/passive_sources/images/webgen_logo.png +0 -0
  4. data/data/webgen/passive_sources/templates/atom_feed.template +38 -0
  5. data/data/webgen/passive_sources/templates/rss_feed.template +28 -0
  6. data/data/webgen/resources.yaml +2 -1
  7. data/doc/contentprocessor/builder.page +1 -1
  8. data/doc/contentprocessor/erb.page +5 -2
  9. data/doc/contentprocessor/erubis.page +2 -2
  10. data/doc/extensions.page +1 -1
  11. data/doc/manual.page +56 -26
  12. data/doc/reference_configuration.page +36 -1
  13. data/doc/reference_website_styles.page +1 -1
  14. data/doc/sourcehandler/feed.page +6 -11
  15. data/doc/tag/includefile.page +1 -1
  16. data/lib/webgen/cli/apply_command.rb +1 -1
  17. data/lib/webgen/cli/utils.rb +2 -2
  18. data/lib/webgen/common.rb +0 -9
  19. data/lib/webgen/contentprocessor/blocks.rb +60 -36
  20. data/lib/webgen/contentprocessor/builder.rb +2 -2
  21. data/lib/webgen/contentprocessor/erb.rb +3 -2
  22. data/lib/webgen/contentprocessor/erubis.rb +2 -2
  23. data/lib/webgen/contentprocessor/haml.rb +2 -2
  24. data/lib/webgen/contentprocessor/maruku.rb +1 -1
  25. data/lib/webgen/contentprocessor/sass.rb +2 -2
  26. data/lib/webgen/contentprocessor/tags.rb +25 -11
  27. data/lib/webgen/context.rb +4 -1
  28. data/lib/webgen/context/render.rb +32 -0
  29. data/lib/webgen/context/tags.rb +20 -0
  30. data/lib/webgen/default_config.rb +4 -1
  31. data/lib/webgen/deprecated.rb +37 -4
  32. data/lib/webgen/node.rb +37 -38
  33. data/lib/webgen/path.rb +151 -54
  34. data/lib/webgen/source.rb +6 -6
  35. data/lib/webgen/source/stacked.rb +13 -5
  36. data/lib/webgen/sourcehandler.rb +71 -45
  37. data/lib/webgen/sourcehandler/base.rb +51 -21
  38. data/lib/webgen/sourcehandler/copy.rb +4 -4
  39. data/lib/webgen/sourcehandler/directory.rb +3 -9
  40. data/lib/webgen/sourcehandler/feed.rb +23 -49
  41. data/lib/webgen/sourcehandler/fragment.rb +10 -8
  42. data/lib/webgen/sourcehandler/memory.rb +9 -10
  43. data/lib/webgen/sourcehandler/metainfo.rb +9 -9
  44. data/lib/webgen/sourcehandler/page.rb +5 -5
  45. data/lib/webgen/sourcehandler/sitemap.rb +3 -3
  46. data/lib/webgen/sourcehandler/template.rb +6 -6
  47. data/lib/webgen/sourcehandler/virtual.rb +19 -17
  48. data/lib/webgen/tag/base.rb +34 -26
  49. data/lib/webgen/tag/breadcrumbtrail.rb +3 -3
  50. data/lib/webgen/tag/executecommand.rb +3 -3
  51. data/lib/webgen/tag/langbar.rb +2 -2
  52. data/lib/webgen/tag/link.rb +3 -3
  53. data/lib/webgen/tag/menu.rb +2 -2
  54. data/lib/webgen/tag/metainfo.rb +1 -1
  55. data/lib/webgen/tag/relocatable.rb +17 -21
  56. data/lib/webgen/tag/tikz.rb +5 -6
  57. data/lib/webgen/tree.rb +7 -7
  58. data/lib/webgen/version.rb +1 -1
  59. data/lib/webgen/website.rb +4 -2
  60. data/misc/default.css +8 -2
  61. data/misc/default.template +2 -2
  62. data/misc/logo.svg +313 -0
  63. data/misc/style.page +1 -1
  64. data/test/helper.rb +2 -2
  65. data/test/test_common_sitemap.rb +1 -1
  66. data/test/test_contentprocessor_blocks.rb +12 -4
  67. data/test/test_contentprocessor_builder.rb +2 -1
  68. data/test/test_contentprocessor_erb.rb +2 -1
  69. data/test/test_contentprocessor_erubis.rb +1 -1
  70. data/test/test_contentprocessor_fragments.rb +12 -11
  71. data/test/test_contentprocessor_haml.rb +2 -1
  72. data/test/test_contentprocessor_maruku.rb +1 -0
  73. data/test/test_contentprocessor_rdiscount.rb +1 -0
  74. data/test/test_contentprocessor_rdoc.rb +1 -0
  75. data/test/test_contentprocessor_sass.rb +1 -0
  76. data/test/test_contentprocessor_tags.rb +13 -0
  77. data/test/test_context.rb +28 -0
  78. data/test/test_node.rb +40 -20
  79. data/test/test_path.rb +106 -65
  80. data/test/test_source_filesystem.rb +1 -1
  81. data/test/test_source_stacked.rb +19 -6
  82. data/test/test_sourcehandler_base.rb +53 -47
  83. data/test/test_sourcehandler_copy.rb +6 -6
  84. data/test/test_sourcehandler_directory.rb +8 -12
  85. data/test/test_sourcehandler_feed.rb +10 -6
  86. data/test/test_sourcehandler_fragment.rb +6 -5
  87. data/test/test_sourcehandler_main.rb +39 -0
  88. data/test/test_sourcehandler_memory.rb +4 -4
  89. data/test/test_sourcehandler_metainfo.rb +10 -10
  90. data/test/test_sourcehandler_page.rb +9 -9
  91. data/test/test_sourcehandler_sitemap.rb +4 -4
  92. data/test/test_sourcehandler_template.rb +14 -14
  93. data/test/test_sourcehandler_virtual.rb +9 -5
  94. data/test/test_tag_base.rb +2 -2
  95. data/test/test_tag_executecommand.rb +1 -1
  96. data/test/test_tag_link.rb +4 -3
  97. data/test/test_tag_menu.rb +15 -15
  98. data/test/test_tag_metainfo.rb +1 -0
  99. data/test/test_tag_relocatable.rb +2 -1
  100. data/test/test_tag_tikz.rb +3 -3
  101. data/test/test_tree.rb +8 -8
  102. data/test/test_website.rb +15 -0
  103. metadata +14 -14
  104. data/test/test_common.rb +0 -18
@@ -14,12 +14,12 @@ module Webgen::SourceHandler
14
14
  include Webgen::WebsiteAccess
15
15
  include Base
16
16
 
17
- # Create an XML sitemap from +parent+ and +path+.
18
- def create_node(parent, path)
17
+ # Create an XML sitemap from +path+.
18
+ def create_node(path)
19
19
  page_from_path(path)
20
20
  path.ext = 'xml'
21
21
  raise "Needed information site_url missing for sitemap <#{path}>" if path.meta_info['site_url'].nil?
22
- super(parent, path)
22
+ super(path)
23
23
  end
24
24
 
25
25
  # Return the rendered feed represented by +node+.
@@ -9,30 +9,30 @@ module Webgen::SourceHandler
9
9
  include Webgen::Loggable
10
10
  include Base
11
11
 
12
- # Create a template node in +parent+ for +path+.
13
- def create_node(parent, path)
12
+ # Create a template node for +path+.
13
+ def create_node(path)
14
14
  page = page_from_path(path)
15
- super(parent, path) do |node|
15
+ super(path) do |node|
16
16
  node.node_info[:page] = page
17
17
  end
18
18
  end
19
19
 
20
20
  # Return the template chain for +node+.
21
21
  def templates_for_node(node, lang = node.lang)
22
- cached_template = (website.cache.volatile[[node.absolute_lcn, :templates]] ||= {})
22
+ cached_template = (website.cache.volatile[[node.alcn, :templates]] ||= {})
23
23
  if cached_template[lang]
24
24
  template_node = cached_template[lang]
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.absolute_lcn}> not found, using default template!" }
28
+ log(:warn) { "Specified template '#{node['template']}' for <#{node.alcn}> 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.absolute_lcn}>" }
35
+ log(:info) { "Using default template in language '#{lang}' for <#{node.alcn}>" }
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)
@@ -19,26 +19,25 @@ module Webgen::SourceHandler
19
19
  @path_data = {}
20
20
  end
21
21
 
22
- # Create all virtual nodes under +parent+ which are specified in +path+.
23
- def create_node(parent, path)
22
+ # Create all virtual nodes which are specified in +path+.
23
+ def create_node(path)
24
24
  nodes = []
25
25
  read_data(path).each do |key, meta_info|
26
26
  cache_data = [key, meta_info.dup]
27
27
 
28
- key = Webgen::Common.absolute_path(key, parent.absolute_lcn) + (key =~ /\/$/ ? '/' : '')
29
- temp_parent = create_directories(parent.tree.root, File.dirname(key), path)
28
+ key = Webgen::Path.make_absolute(path.parent_path, key) + (key =~ /\/$/ ? '/' : '')
29
+ temp_parent = create_directories(File.dirname(key), path)
30
30
 
31
31
  output_path = meta_info.delete('url') || key
32
32
  output_path = (URI::parse(output_path).absolute? || output_path =~ /^\// ?
33
- output_path : File.join(temp_parent.absolute_lcn, output_path))
33
+ output_path : File.join(temp_parent.alcn, output_path))
34
34
 
35
35
  if key =~ /\/$/
36
- nodes << create_directory(temp_parent, key, path, meta_info)
36
+ nodes << create_directory(key, path, meta_info)
37
37
  else
38
- nodes += website.blackboard.invoke(:create_nodes, parent.tree, temp_parent.absolute_lcn,
39
- Webgen::Path.new(key, path.source_path), self) do |cn_parent, cn_path|
38
+ nodes += website.blackboard.invoke(:create_nodes, Webgen::Path.new(key, path.source_path), self) do |cn_path|
40
39
  cn_path.meta_info.update(meta_info)
41
- super(cn_parent, cn_path, output_path) do |n|
40
+ super(cn_path, :output_path => output_path) do |n|
42
41
  n.node_info[:sh_virtual_cache_data] = cache_data
43
42
  end
44
43
  end
@@ -69,25 +68,28 @@ module Webgen::SourceHandler
69
68
  end
70
69
 
71
70
  # Create the needed parent directories for a virtual node.
72
- def create_directories(parent, dirname, path)
73
- dirname.sub(/^\//, '').split('/').each do |dir|
74
- parent = create_directory(parent, File.join(parent.absolute_lcn, dir), path)
71
+ def create_directories(dirname, path)
72
+ parent = website.tree.root
73
+ dirname.sub(/^\//, '').split('/').inject('/') do |parent_path, dir|
74
+ parent_path = File.join(parent_path, dir)
75
+ parent = create_directory(parent_path, path)
75
76
  end
76
77
  parent
77
78
  end
78
79
 
79
80
  # Create a virtual directory if it does not already exist.
80
- def create_directory(parent, dir, path, meta_info = nil)
81
+ def create_directory(dir, path, meta_info = nil)
81
82
  dir_handler = website.cache.instance('Webgen::SourceHandler::Directory')
82
- website.blackboard.invoke(:create_nodes, parent.tree, parent.absolute_lcn,
83
+ parent = website.tree.root
84
+ website.blackboard.invoke(:create_nodes,
83
85
  Webgen::Path.new(File.join(dir, '/'), path.source_path),
84
- dir_handler) do |par, temp_path|
85
- parent = dir_handler.node_exists?(par, temp_path)
86
+ dir_handler) do |temp_path|
87
+ parent = dir_handler.node_exists?(temp_path)
86
88
  if (parent && (parent.node_info[:src] == path.source_path) && !meta_info.nil?) ||
87
89
  !parent
88
90
  temp_path.meta_info.update(meta_info) if meta_info
89
91
  parent.flag(:reinit) if parent
90
- parent = dir_handler.create_node(par, temp_path)
92
+ parent = dir_handler.create_node(temp_path)
91
93
  end
92
94
  parent
93
95
  end
@@ -21,7 +21,7 @@ require 'webgen/websiteaccess'
21
21
  # the actual processing. And the +initialize+ method must not take any parameters!
22
22
  #
23
23
  # Tag classes *can* also choose to not use this module. If they don't use it they have to provide
24
- # the following methods: +set_params+, +create_tag_params+, +call+.
24
+ # the following methods: +set_params+, +create_tag_params+, +create_params_hash+, +call+.
25
25
  #
26
26
  # == Tag parameters
27
27
  #
@@ -50,8 +50,8 @@ require 'webgen/websiteaccess'
50
50
  #
51
51
  # def call(tag, body, context)
52
52
  # result = param('do_reverse') ? body.reverse : body
53
- # result += "Node: " + context.content_node.absolute_lcn + " (" + context.content_node['title'] + ")"
54
- # result += "Reference node: " + context.ref_node.absolute_lcn
53
+ # result += "Node: " + context.content_node.alcn + " (" + context.content_node['title'] + ")"
54
+ # result += "Reference node: " + context.ref_node.alcn
55
55
  # result
56
56
  # end
57
57
  #
@@ -65,17 +65,44 @@ module Webgen::Tag::Base
65
65
  include Webgen::Loggable
66
66
  include Webgen::WebsiteAccess
67
67
 
68
- # Return a hash with parameter values extracted from the string +tag_config+.
68
+ # Create a hash with parameter values extracted from the string +tag_config+.
69
+ #
70
+ # Returns the parameter hash and a boolean which is +true+ if any mandatory parameters are
71
+ # missing.
69
72
  def create_tag_params(tag_config, ref_node)
70
73
  begin
71
74
  config = YAML::load("--- #{tag_config}")
72
75
  rescue ArgumentError => e
73
- log(:error) { "Could not parse the tag params '#{tag_config}' in <#{ref_node.absolute_lcn}>: #{e.message}" }
76
+ log(:error) { "Could not parse the tag params '#{tag_config}' in <#{ref_node.alcn}>: #{e.message}" }
74
77
  config = {}
75
78
  end
76
79
  create_params_hash(config, ref_node)
77
80
  end
78
81
 
82
+ # Create and return the parameter hash from +config+ which needs to be a Hash, a String or +nil+.
83
+ #
84
+ # Returns the parameter hash and a boolean which is +true+ if any mandatory parameters are
85
+ # missing.
86
+ def create_params_hash(config, node)
87
+ params = tag_params_list
88
+ result = case config
89
+ when Hash then create_from_hash(config, params, node)
90
+ when String then create_from_string(config, params, node)
91
+ when NilClass then {}
92
+ else
93
+ log(:error) { "Invalid parameter type (#{config.class}) for tag '#{self.class.name}' in <#{node.alcn}>" }
94
+ {}
95
+ end
96
+
97
+ mandatory_params_missing = false
98
+ unless params.all? {|k| !website.config.meta_info[k][:mandatory] || result.has_key?(k)}
99
+ log(:error) { "Not all mandatory parameters for tag '#{self.class.name}' in <#{node.alcn}> set" }
100
+ mandatory_params_missing = true
101
+ end
102
+
103
+ [result, mandatory_params_missing]
104
+ end
105
+
79
106
  # Set the current parameter configuration to +params+.
80
107
  def set_params(params)
81
108
  @params = params
@@ -122,25 +149,6 @@ module Webgen::Tag::Base
122
149
  website.config.data.keys.select {|key| key =~ regexp}
123
150
  end
124
151
 
125
- # Create the parameter hash from +config+ which needs to be a Hash, a String or +nil+.
126
- def create_params_hash(config, node)
127
- params = tag_params_list
128
- result = case config
129
- when Hash then create_from_hash(config, params, node)
130
- when String then create_from_string(config, params, node)
131
- when NilClass then {}
132
- else
133
- log(:error) { "Invalid parameter type (#{config.class}) for tag '#{self.class.name}' in <#{node.absolute_lcn}>" }
134
- {}
135
- end
136
-
137
- unless params.all? {|k| !website.config.meta_info[k][:mandatory] || result.has_key?(k)}
138
- log(:error) { "Not all mandatory parameters for tag '#{self.class.name}' in <#{node.absolute_lcn}> set" }
139
- end
140
-
141
- result
142
- end
143
-
144
152
  # Return a valid parameter hash taking values from +config+ which has to be a Hash.
145
153
  def create_from_hash(config, params, node)
146
154
  result = {}
@@ -150,7 +158,7 @@ module Webgen::Tag::Base
150
158
  elsif params.include?(tag_config_base + '.' + key)
151
159
  result[tag_config_base + '.' + key] = value
152
160
  else
153
- log(:warn) { "Invalid parameter '#{key}' for tag '#{self.class.name}' in <#{node.absolute_lcn}>" }
161
+ log(:warn) { "Invalid parameter '#{key}' for tag '#{self.class.name}' in <#{node.alcn}>" }
154
162
  end
155
163
  end
156
164
  result
@@ -160,7 +168,7 @@ module Webgen::Tag::Base
160
168
  def create_from_string(value, params, node)
161
169
  param_name = params.find {|k| website.config.meta_info[k][:mandatory] == 'default'}
162
170
  if param_name.nil?
163
- log(:error) { "No default mandatory parameter specified for tag '#{self.class.name}' but set in <#{node.absolute_lcn}>"}
171
+ log(:error) { "No default mandatory parameter specified for tag '#{self.class.name}' but set in <#{node.alcn}>"}
164
172
  {}
165
173
  else
166
174
  {param_name => value}
@@ -16,10 +16,10 @@ module Webgen::Tag
16
16
  # Create the breadcrumb trail.
17
17
  def call(tag, body, context)
18
18
  out = breadcrumb_trail_list(context.content_node)
19
- (context.dest_node.node_info[:tag_breadcrumb_trail] ||= {})[[@params.to_a.sort, context.content_node.absolute_lcn]] = out.map {|n| n.absolute_lcn}
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.absolute_lcn}>: #{out}" }
22
+ log(:debug) { "Breadcrumb trail for <#{context.content_node.alcn}>: #{out}" }
23
23
  out
24
24
  end
25
25
 
@@ -57,7 +57,7 @@ module Webgen::Tag
57
57
  list = breadcrumb_trail_list(cn)
58
58
  set_params({})
59
59
 
60
- if (list.map {|n| n.absolute_lcn} != cached_list) ||
60
+ if (list.map {|n| n.alcn} != cached_list) ||
61
61
  list.any? {|n| (r = n.routing_node(cn.lang)) && r != node && r.meta_info_changed?}
62
62
  node.flag(:dirty)
63
63
  break
@@ -12,14 +12,14 @@ module Webgen::Tag
12
12
 
13
13
  include Webgen::Tag::Base
14
14
 
15
- BIT_BUCKET = (Config::CONFIG['arch'].include?('mswin32') ? "nul" : "/dev/null")
15
+ BIT_BUCKET = (Config::CONFIG['host_os'] =~ /mswin|mingw/ ? "nul" : "/dev/null")
16
16
 
17
17
  # Execute the command and return the standard output.
18
18
  def call(tag, body, context)
19
19
  command = param('tag.executecommand.command')
20
20
  output = `#{command} 2> #{BIT_BUCKET}`
21
- if ($? >> 8) != 0
22
- raise "Command '#{command}' in <#{context.ref_node.absolute_lcn}> has return value != 0: #{output}"
21
+ if $?.exitstatus != 0
22
+ raise "Command '#{command}' in <#{context.ref_node.alcn}> has return value != 0: #{output}"
23
23
  end
24
24
  output = CGI::escapeHTML(output) if param('tag.executecommand.escape_html')
25
25
  [output, param('tag.executecommand.process_output')]
@@ -15,7 +15,7 @@ module Webgen::Tag
15
15
  # Return a list of all translations of the content page.
16
16
  def call(tag, body, context)
17
17
  lang_nodes = all_lang_nodes(context.content_node)
18
- (context.dest_node.node_info[:tag_langbar_data] ||= {})[context.content_node.absolute_cn] = lang_nodes.map {|n| n.absolute_lcn}
18
+ (context.dest_node.node_info[:tag_langbar_data] ||= {})[context.content_node.acn] = lang_nodes.map {|n| n.alcn}
19
19
  result = lang_nodes.
20
20
  reject {|n| (context.content_node.lang == n.lang && !param('tag.langbar.show_own_lang'))}.
21
21
  sort {|a, b| a.lang <=> b.lang}.
@@ -31,7 +31,7 @@ module Webgen::Tag
31
31
 
32
32
  # Return all nodes with the same absolute cn as +node+.
33
33
  def all_lang_nodes(node)
34
- node.tree.node_access[:acn][node.absolute_cn]
34
+ node.tree.node_access[:acn][node.acn]
35
35
  end
36
36
 
37
37
  # Check if the langbar tag for +node+ changed.
@@ -9,14 +9,14 @@ module Webgen::Tag
9
9
 
10
10
  # Return a HTML link to the given (A)LCN.
11
11
  def call(tag, body, context)
12
- if (dest_node = context.ref_node.resolve(param('tag.link.path'), context.dest_node.lang))
13
- context.dest_node.node_info[:used_meta_info_nodes] << dest_node.absolute_lcn
12
+ if (dest_node = context.ref_node.resolve(param('tag.link.path').to_s, context.dest_node.lang))
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
16
  raise ArgumentError, 'Resolving of path failed'
17
17
  end
18
18
  rescue ArgumentError, URI::InvalidURIError => e
19
- log(:error) { "Could not link to path '#{param('tag.link.path')}' in <#{context.ref_node.absolute_lcn}>: #{e.message}" }
19
+ log(:error) { "Could not link to path '#{param('tag.link.path')}' in <#{context.ref_node.alcn}>: #{e.message}" }
20
20
  context.dest_node.flag(:dirty)
21
21
  ''
22
22
  end
@@ -44,7 +44,7 @@ module Webgen::Tag
44
44
 
45
45
  # Return the menu tree under the node as nested list of alcn values.
46
46
  def to_lcn_list
47
- self.children.inject([]) {|temp, n| temp << n.node.absolute_lcn; temp += ((t = n.to_lcn_list).empty? ? [] : [t]) }
47
+ self.children.inject([]) {|temp, n| temp << n.node.alcn; temp += ((t = n.to_lcn_list).empty? ? [] : [t]) }
48
48
  end
49
49
 
50
50
  end
@@ -57,7 +57,7 @@ module Webgen::Tag
57
57
  def call(tag, body, context)
58
58
  tree = specific_menu_tree_for(context.content_node)
59
59
 
60
- (context.dest_node.node_info[:tag_menu_menus] ||= {})[[@params.to_a.sort, context.content_node.absolute_lcn]] = (tree ? tree.to_lcn_list : nil)
60
+ (context.dest_node.node_info[:tag_menu_menus] ||= {})[[@params.to_a.sort, context.content_node.alcn]] = (tree ? tree.to_lcn_list : nil)
61
61
 
62
62
  if !tree || tree.children.empty?
63
63
  ''
@@ -15,7 +15,7 @@ module Webgen::Tag
15
15
  elsif context.content_node[tag]
16
16
  output = context.content_node[tag].to_s
17
17
  else
18
- log(:warn) { "No value for meta info key '#{tag}' in <#{context.ref_node.absolute_lcn}> found in <#{context.content_node.absolute_lcn}>" }
18
+ log(:warn) { "No value for meta info key '#{tag}' in <#{context.ref_node.alcn}> found in <#{context.content_node.alcn}>" }
19
19
  end
20
20
  output
21
21
  end
@@ -16,24 +16,13 @@ module Webgen::Tag
16
16
 
17
17
  # Return the relativized path for the path provided in the tag definition.
18
18
  def call(tag, body, context)
19
- uri_string = param('tag.relocatable.path')
19
+ path = param('tag.relocatable.path')
20
20
  result = ''
21
- unless uri_string.nil?
22
- begin
23
- uri = URI.parse(uri_string)
24
- if uri.absolute?
25
- result = uri_string
26
- else
27
- result = resolve_path(uri_string, context)
28
- end
29
- if result.empty?
30
- log(:error) { "Could not resolve path '#{uri_string}' in <#{context.ref_node.absolute_lcn}>" }
31
- context.dest_node.flag(:dirty)
32
- end
33
- rescue URI::InvalidURIError => e
34
- log(:error) { "Error while parsing path for tag relocatable in <#{context.ref_node.absolute_lcn}>: #{e.message}" }
35
- context.dest_node.flag(:dirty)
36
- end
21
+ begin
22
+ result = (Webgen::Node.url(path, false).absolute? ? path : resolve_path(path, context))
23
+ rescue URI::InvalidURIError => e
24
+ log(:error) { "Error while parsing path for tag relocatable in <#{context.ref_node.alcn}>: #{e.message}" }
25
+ context.dest_node.flag(:dirty)
37
26
  end
38
27
  result
39
28
  end
@@ -42,11 +31,18 @@ module Webgen::Tag
42
31
  private
43
32
  #######
44
33
 
45
- # Resolve the path +uri+ using the reference node and return the correct relative path from the
34
+ # Resolve the path +path+ using the reference node and return the correct relative path from the
46
35
  # destination node.
47
- def resolve_path(uri, context)
48
- dest_node = context.ref_node.resolve(uri, context.dest_node.lang)
49
- (dest_node ? context.dest_node.route_to(dest_node) : '')
36
+ def resolve_path(path, context)
37
+ dest_node = context.ref_node.resolve(path, context.dest_node.lang)
38
+ if dest_node
39
+ context.dest_node.node_info[:used_meta_info_nodes] << dest_node.alcn
40
+ context.dest_node.route_to(dest_node)
41
+ else
42
+ log(:error) { "Could not resolve path '#{path}' in <#{context.ref_node.alcn}>" }
43
+ context.dest_node.flag(:dirty)
44
+ ''
45
+ end
50
46
  end
51
47
 
52
48
  end
@@ -32,16 +32,15 @@ EOF
32
32
  # Create a graphic from the commands in the body of the tag.
33
33
  def call(tag, body, context)
34
34
  path = param('tag.tikz.path')
35
- path = Webgen::Common.absolute_path(path, context.ref_node.parent.absolute_lcn)
35
+ path = Webgen::Path.make_absolute(context.ref_node.parent.alcn, path)
36
36
 
37
37
  mem_handler = website.cache.instance('Webgen::SourceHandler::Memory')
38
38
  src_path = context.ref_node.node_info[:src]
39
39
  parent = website.blackboard.invoke(:create_directories, context.ref_node.tree.root, File.dirname(path), src_path)
40
40
  params = @params
41
41
 
42
- node = website.blackboard.invoke(:create_nodes, parent.tree, parent.absolute_lcn,
43
- Webgen::Path.new(path, src_path), mem_handler) do |node_parent, node_path|
44
- mem_handler.create_node(node_parent, node_path, context.ref_node.absolute_lcn) do |pic_node|
42
+ node = website.blackboard.invoke(:create_nodes, Webgen::Path.new(path, src_path), mem_handler) do |node_path|
43
+ mem_handler.create_node(node_path, context.ref_node.alcn) do |pic_node|
45
44
  set_params(params)
46
45
  document = ERB.new(LATEX_TEMPLATE).result(binding)
47
46
  pic_path = compile(document, File.extname(path), context)
@@ -74,7 +73,7 @@ EOF
74
73
  output = `#{cmd_prefix} pdflatex --shell-escape -interaction=batchmode #{File.basename(file.path)}.tex`
75
74
  if $?.exitstatus != 0
76
75
  errors = output.scan(/^!(.*\n.*)/).join("\n")
77
- log(:error) { "There was an error creating a TikZ picture in <#{context.ref_node.absolute_lcn}>: #{errors}"}
76
+ log(:error) { "There was an error creating a TikZ picture in <#{context.ref_node.alcn}>: #{errors}"}
78
77
  context.dest_node.flag(:dirty)
79
78
  nil
80
79
  else
@@ -106,7 +105,7 @@ EOF
106
105
  def run_command(cmd, context)
107
106
  output = `#{cmd}`
108
107
  if $?.exitstatus != 0
109
- log(:error) { "There was an error running a command for a TikZ picture in <#{context.ref_node.absolute_lcn}>: #{output}"}
108
+ log(:error) { "There was an error running a command for a TikZ picture in <#{context.ref_node.alcn}>: #{output}"}
110
109
  context.dest_node.flag(:dirty)
111
110
  nil
112
111
  else
data/lib/webgen/tree.rb CHANGED
@@ -47,12 +47,12 @@ module Webgen
47
47
 
48
48
  # A utility method called by Node#initialize. This method should not be used directly!
49
49
  def register_node(node)
50
- if @node_access[:alcn].has_key?(node.absolute_lcn)
51
- raise "Can't have two nodes with same absolute lcn: #{node.absolute_lcn}"
50
+ if @node_access[:alcn].has_key?(node.alcn)
51
+ raise "Can't have two nodes with same absolute lcn: #{node.alcn}"
52
52
  else
53
- @node_access[:alcn][node.absolute_lcn] = node
53
+ @node_access[:alcn][node.alcn] = node
54
54
  end
55
- (@node_access[:acn][node.absolute_cn] ||= []) << node
55
+ (@node_access[:acn][node.acn] ||= []) << node
56
56
  register_path(node)
57
57
  end
58
58
 
@@ -78,11 +78,11 @@ module Webgen
78
78
 
79
79
  website.blackboard.dispatch_msg(:before_node_deleted, n)
80
80
  n.parent.children.delete(n)
81
- @node_access[:alcn].delete(n.absolute_lcn)
82
- @node_access[:acn][n.absolute_cn].delete(n)
81
+ @node_access[:alcn].delete(n.alcn)
82
+ @node_access[:acn][n.acn].delete(n)
83
83
  @node_access[:path].delete(n.path)
84
84
 
85
- node_info.delete(n.absolute_lcn)
85
+ node_info.delete(n.alcn)
86
86
  end
87
87
 
88
88
  end