gettalong-webgen 0.5.5.20081010 → 0.5.5.20081012

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
1
+ ---
2
+ title: Webgen::ContentProcessor::Fragments
3
+ ---
4
+ ## Description
5
+
6
+ This processor generates nested fragment nodes from all headers `h1` to `h6` which have an `id`
7
+ attribute set.
8
+
9
+ > This is only done for the block named `content` or if no block is associated with the given render
10
+ > context! This is to ensure that fragment nodes are not created from multiple block of one page
11
+ > file. So this content processor has no effect when used in the pipeline of blocks except if the
12
+ > block is named `content`.
13
+ {.exclamation}
14
+
15
+ The default markup language Maruku automatically generates an `id` attribute for all headers. If you
16
+ use another markup language or plain old HTML, you might need to set the `id` attributes by hand.
17
+
18
+ > The reason why only header tags with an `id` attribute are used is that only those can be
19
+ > referenced and linked to later.
20
+ {.information}
21
+
22
+ The generated fragment nodes can be used like any other node. So you can link to them and use them
23
+ in a menu. Concerning the menu, there is a setting for the `tag.menu.used_nodes` option called
24
+ `fragments` which only uses the fragment node of the current page to generate a menu. This allows to
25
+ generate a nice overview of the page.
data/doc/manual.page CHANGED
@@ -429,21 +429,6 @@ As you might have deduced from the processing list above, it is possible that on
429
429
  multiple source handlers. This can be used, for example, to render an XML file as HTML and copy it
430
430
  verbatim.
431
431
 
432
- Internally a tree structure is created reflecting the source directory hierarchy and each path that
433
- is handled by webgen. Normally a source handler creates one node from one path but it is also
434
- possible that a source handler creates multiple nodes from one path.
435
-
436
- > The name used for describing a directory or file once it is placed in the internal tree structure
437
- > is 'node'.
438
- {.information}
439
-
440
- After this internal tree structure is created, it is traversed and each node is processed. First the
441
- node is checked if has changed (the notion of 'changed' depends on many things but a node is
442
- changed, for example, if its meta information or the associated source path has changed since the
443
- last webgen run). If it has not changed, nothing needs to be written. Otherwise, the information
444
- needed to write out the node is gathered and its content is written to the output path represented
445
- by the node.
446
-
447
432
 
448
433
  ## Path Meta Information {#source-metainfo}
449
434
 
@@ -521,6 +506,39 @@ There are several types of extensions:
521
506
 
522
507
 
523
508
 
509
+ # A webgen Run
510
+
511
+ When webgen is started, it first looks for a cache file and uses it if it exists. The cache file
512
+ provides information on the previous run and allows webgen to render only those paths that have
513
+ changed since the last time.
514
+
515
+ Each webgen run consists of one or more update/write cycles. During the update phase the internal
516
+ tree structure is updated to reflect the current situation:
517
+
518
+ * Nodes are created from newly found source paths.
519
+ * If a source path was deleted since the last webgen run, the nodes created from it will be deleted.
520
+ * All nodes in the tree are checked if they have changed and, if so, are marked for regeneration.
521
+
522
+ > The name used for describing a directory or file once it is placed in the internal tree structure
523
+ > is 'node'.
524
+ {.information}
525
+
526
+ After the update cycle has finished, the internal tree representation is up-to-date and contains all
527
+ necessary information to write its nodes. This is done in the write phase which writes out all
528
+ changed nodes.
529
+
530
+ It is possible that the internal tree structure changes during the write phase. For example, after
531
+ writing a page file fragments node for it may have been generated. After the write phase it is
532
+ checked if something like this has happened. If webgen finds such a condition, a new update/write
533
+ cycle is initiated. This is done as long as needed.
534
+
535
+ Since it is possible that multiple update/write cycles are used in one webgen run, it is shown in
536
+ the log messages when a new cycle started. This is necessary because sometimes some warning or error
537
+ log messages may be generated during an earlier cycle but the error conditions are automatically
538
+ solved in later cycles. By marking where the cycles start a user can compare the log messages of the
539
+ different cycles and see what he needs to solve himself.
540
+
541
+
524
542
  # Extending webgen
525
543
 
526
544
  If you know the programming language Ruby a little bit, you can easily extend webgen and add new
@@ -550,6 +550,19 @@ files in Webgen Page Format.
550
550
  Langbar with single language not shown: \{langbar: {show_single_lang: false}}
551
551
 
552
552
 
553
+ * ### tag.langbar.lang\_names
554
+
555
+ This configuration option can be used to specify the language names that should be displayed
556
+ instead of the language codes.
557
+
558
+ * Syntax: `\{CODE: NAME, ...}` where `CODE` is a language code and `NAME` the associated language
559
+ name of the code.
560
+
561
+ * Examples:
562
+
563
+ Langbar with custom language names: \{langbar: {lang_names: {de: Deutsch, en: English}}}
564
+
565
+
553
566
  * ### tag.menu.used\_nodes
554
567
 
555
568
  Specifies the type of nodes that should be used for menu generation. If `all` is specified then
@@ -60,6 +60,10 @@ never`.
60
60
  Sets the time when the path was created. This information cannot automatically be derived for paths
61
61
  provided by Webgen::Source::FileSystem, so this has to be set manually.
62
62
 
63
+ > Note that the value needs to be a valid [YAML timestamp](http://yaml.org/type/timestamp.html) and
64
+ > needs to include the time part.
65
+ {.information}
66
+
63
67
  ### draft
64
68
 
65
69
  {:miref}
@@ -127,8 +131,13 @@ path.
127
131
  * Any
128
132
 
129
133
  Sets the time when the path was last modified. This information is automatically set for paths
130
- provided by Webgen::Source::FileSystem but can be overridden by setting it manually. If not set to a
131
- valid time, the time when webgen is executed is used for this meta information.
134
+ provided by Webgen::Source::FileSystem (the file modification is used) but can be overridden by
135
+ setting it manually. If not set to a valid time, the time when webgen is executed is used for this
136
+ meta information.
137
+
138
+ > Note that the value needs to be a valid [YAML timestamp](http://yaml.org/type/timestamp.html) and
139
+ > needs to include the time part.
140
+ {.information}
132
141
 
133
142
  ### no\_output
134
143
 
@@ -14,6 +14,11 @@ The following meta information keys are supported:
14
14
  A LCN pattern (or an array of LCN patterns) which specify the page files that should be
15
15
  used. Other matched files are excluded from the list.
16
16
 
17
+ > Be aware that if you want to include a single file or files in a specific language only you
18
+ > need to include the language part since this is a LCN and not a CN pattern, eg. `mypage.html`
19
+ > won't work but `mypage.en.html` will!
20
+ {.information}
21
+
17
22
  * `number_of_entries` (OPTIONAL)
18
23
 
19
24
  The number of entries that should be included in the feed. Defaults to 10.
@@ -26,6 +31,10 @@ The following meta information keys are supported:
26
31
 
27
32
  A RSS feed is generated if this key is set to `true`. Defaults to `true`.
28
33
 
34
+ * `rss_version` (OPTIONAL)
35
+
36
+ The RSS version that should be used for generating the RSS feed. Defaults to `2.0`.
37
+
29
38
  * `site_url` (MANDATORY)
30
39
 
31
40
  The base url of the website for which the feed is generated.
@@ -48,11 +57,14 @@ The following meta information keys are supported:
48
57
 
49
58
  * `created_at` (OPTIONAL)
50
59
 
51
- The time at which this feed was created. Defaults to the current time if not set.
60
+ The time at which this feed was created. Defaults to the current time if not set. Has the same
61
+ format as the meta information `created_at`.
52
62
 
53
- * `icon` (OPTIONAL)
63
+ * `content_block_name` (OPTIONAL)
54
64
 
55
- The absolute localized canonical name of the feed's icon image.
65
+ The name of the block that should be used for the content of the feed entries. If not specified
66
+ the name `content` is used. Be aware that each page file that can appear in the feed needs to
67
+ have such a block!
56
68
 
57
69
  The following meta information keys of page files are used if they are specified:
58
70
 
@@ -65,6 +77,9 @@ The following meta information keys of page files are used if they are specified
65
77
  The time at which the page file was last modified, used as the time at which this feed entry was
66
78
  updated.
67
79
 
80
+ > This is the field that is used to sort the entries.
81
+ {.information}
82
+
68
83
  * `title`
69
84
 
70
85
  The title of the page file, used as title of the feed entry.
@@ -79,4 +94,4 @@ The following meta information keys of page files are used if they are specified
79
94
 
80
95
  The default implementation supports the generation of atom and RSS feeds. You can override the
81
96
  default generation mechanism by adding an `atom_template` and/or `rss_template` block in the feed
82
- file which are then used to generate the atom or the RSS feed respectively.
97
+ file which are then used to generate the atom or the RSS feed respectively.
@@ -12,19 +12,3 @@ meta information.
12
12
  set, the default language specified using the configuration option `website.lang` is used. This
13
13
  means that for the default language set to English and a source path named `index.page`, the
14
14
  language meta information is automatically set to English.
15
-
16
- ## Fragment nodes
17
-
18
- The page handler automatically generates fragment nodes for all found header tags in the block named
19
- `content` (i.e. `h1`, `h2`, ...) that have an `id` attribute set. The default markup language Maruku
20
- automatically generates an `id` attribute for all headers. If you use another markup language or
21
- plain old HTML, you might need to set the `id` attributes by hand.
22
-
23
- > The reason why only header tags with an `id` attribute are used is that only those can be
24
- > referenced and linked to later.
25
- {.information}
26
-
27
- The generated fragment nodes can be used like any other node. So you can link to them and use them
28
- in a menu. Concerning the menu, there is a setting for the `tag.menu.used_nodes` option called
29
- `fragments` which only uses the fragment node of the current page to generate a menu. This allows to
30
- generate a nice overview of the page.
data/doc/tag/langbar.page CHANGED
@@ -4,10 +4,13 @@ used_options:
4
4
  - tag.langbar.separator
5
5
  - tag.langbar.show_own_lang
6
6
  - tag.langbar.show_single_lang
7
+ - tag.langbar.lang_names
7
8
  ---
8
9
  ## Description
9
10
 
10
- This tag is used to display a list of links to translations of the page.
11
+ This tag is used to display a list of links to translations of the page. The text that is displayed
12
+ can be set via the configuration option `tag.langbar.lang_names` (if not set, the language code is
13
+ shown).
11
14
 
12
15
  ## Examples
13
16
 
@@ -19,4 +22,8 @@ This tag is used to display a list of links to translations of the page.
19
22
  <td>\{langbar:}</td>
20
23
  <td>{langbar:}</td>
21
24
  </tr>
25
+ <tr>
26
+ <td>\{langbar: {lang_names: {en: Englisch}}}</td>
27
+ <td>{langbar: {lang_names: {en: Englisch}}}</td>
28
+ </tr>
22
29
  </table>
@@ -65,6 +65,7 @@ module Webgen
65
65
  autoload :Builder, 'webgen/contentprocessor/builder'
66
66
  autoload :Erubis, 'webgen/contentprocessor/erubis'
67
67
  autoload :RDiscount, 'webgen/contentprocessor/rdiscount'
68
+ autoload :Fragments, 'webgen/contentprocessor/fragments'
68
69
 
69
70
  # Return the list of all available content processors.
70
71
  def self.list
@@ -0,0 +1,23 @@
1
+ module Webgen::ContentProcessor
2
+
3
+ # Uses the HTML headers h1, h2, ..., h6 to generate nested fragment nodes.
4
+ class Fragments
5
+
6
+ include Webgen::WebsiteAccess
7
+
8
+ # Generate the nested fragment nodes from <tt>context.content</tt> under
9
+ # <tt>content.content_node</tt> but only if there is no associated <tt>:block</tt> data in
10
+ # +context+ or the block is named +content+.
11
+ def call(context)
12
+ if !context[:block] || context[:block].name == 'content'
13
+ sections = website.blackboard.invoke(:parse_html_headers, context.content)
14
+ website.blackboard.invoke(:create_fragment_nodes, sections, context.content_node,
15
+ website.blackboard.invoke(:source_paths)[context.content_node.node_info[:src]],
16
+ context.content_node.meta_info['fragments_in_menu'])
17
+ end
18
+ context
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -80,7 +80,7 @@ config.sourcehandler.default_meta_info({
80
80
  'Webgen::SourceHandler::Page' => {
81
81
  'kind' => 'page',
82
82
  'fragments_in_menu' => true,
83
- 'blocks' => {'default' => {'pipeline' => 'erb,tags,maruku,blocks'}}
83
+ 'blocks' => {'default' => {'pipeline' => 'erb,tags,maruku,blocks,fragments'}}
84
84
  },
85
85
  'Webgen::SourceHandler::Fragment' => {
86
86
  'kind' => 'fragment'
@@ -131,6 +131,7 @@ config.contentprocessor.map({
131
131
  'builder' => 'Webgen::ContentProcessor::Builder',
132
132
  'erubis' => 'Webgen::ContentProcessor::Erubis',
133
133
  'rdiscount' => 'Webgen::ContentProcessor::RDiscount',
134
+ 'fragments' => 'Webgen::ContentProcessor::Fragments',
134
135
  }, :doc => 'Content processor name to class map')
135
136
 
136
137
  Webgen::WebsiteAccess.website.blackboard.add_service(:content_processor_names, Webgen::ContentProcessor.method(:list))
@@ -172,6 +173,7 @@ config.tag.breadcrumbtrail.end_level(-1, :doc => 'The level at which the breadcr
172
173
  config.tag.langbar.separator(' | ', :doc => 'Separates the languages from each other.')
173
174
  config.tag.langbar.show_single_lang(true, :doc => 'Should the link be shown although the page is only available in one language?')
174
175
  config.tag.langbar.show_own_lang(true, :doc => 'Should the link to the currently displayed language page be shown?')
176
+ config.tag.langbar.lang_names({}, :doc => 'A map from language code to language names')
175
177
 
176
178
  config.tag.includefile.filename(nil, :doc => 'The name of the file which should be included (relative to the website).', :mandatory => 'default')
177
179
  config.tag.includefile.process_output(true, :doc => 'The file content will be scanned for tags if true.')
@@ -50,6 +50,15 @@ module Webgen
50
50
  self.to_s <=> other.to_s
51
51
  end
52
52
 
53
+ def eql?(other) #:nodoc:
54
+ (other.is_a?(self.class) && other.to_s == self.to_s) ||
55
+ (other.is_a?(String) && self.to_s == other)
56
+ end
57
+
58
+ def hash #:nodoc:
59
+ self.to_s.hash
60
+ end
61
+
53
62
  end
54
63
 
55
64
 
data/lib/webgen/logger.rb CHANGED
@@ -27,11 +27,28 @@ module Webgen
27
27
  end
28
28
  self.level = ::Logger::WARN
29
29
  self.verbosity = :normal
30
+ @marks = []
30
31
  end
31
32
 
32
33
  # Returns the output of the logger when #sync is +false+. Otherwise an empty string is returned.
33
34
  def log_output
34
- @sync ? '' : @logio.string
35
+ if @sync
36
+ ''
37
+ else
38
+ out = @logio.string.dup
39
+ @marks.reverse.each_with_index do |mark, index|
40
+ out.insert(mark, " INFO -- Log messages for run #{@marks.length - index} are following\n")
41
+ end if out.length > 0
42
+ out
43
+ end
44
+ end
45
+
46
+ # Only used when #sync is +false: Mark the location in the log stream where a new update/write
47
+ # run begins.
48
+ def mark_new_cycle
49
+ if !@sync
50
+ @marks << @logio.string.length
51
+ end
35
52
  end
36
53
 
37
54
  # The severity threshold level.
data/lib/webgen/node.rb CHANGED
@@ -77,7 +77,7 @@ module Webgen
77
77
  def reinit(path, meta_info = {})
78
78
  old_path = @path
79
79
  @path = path.freeze
80
- @lang = meta_info.delete('lang').freeze
80
+ @lang = Webgen::LanguageManager.language_for_code(meta_info.delete('lang'))
81
81
  @lang = nil unless is_file?
82
82
  @meta_info = meta_info
83
83
  @flags = Set.new([:dirty, :created])
data/lib/webgen/page.rb CHANGED
@@ -106,7 +106,7 @@ module Webgen
106
106
  options, content = *block_data
107
107
  md = RE_BLOCKS_OPTIONS.match(options.to_s)
108
108
  raise(WebgenPageFormatError, "Found invalid blocks starting line for block #{index+1}: #{options}") if content =~ /\A---/ || md.nil?
109
- options = Hash[*md[1].to_s.scan(/(\w+):([^\s]*)/).map {|k,v| [k, YAML::load(v)]}.flatten]
109
+ options = Hash[*md[1].to_s.scan(/(\w+):([^\s]*)/).map {|k,v| [k, (v == '' ? nil : YAML::load(v))]}.flatten]
110
110
  options = (meta_info['blocks']['default'] || {} rescue {}).
111
111
  merge((meta_info['blocks'][index+1] || {} rescue {})).
112
112
  merge(options)
@@ -41,8 +41,11 @@ module Webgen
41
41
  # are checked (nodes for deleted sources are deleted, nodes for new and changed sources).
42
42
  def render(tree)
43
43
  begin
44
+ website.logger.mark_new_cycle if website.logger
45
+
44
46
  puts "Updating tree..."
45
47
  time = Benchmark.measure do
48
+ website.cache.reset_volatile_cache
46
49
  update_tree(tree)
47
50
  end
48
51
  puts "...done in " + ('%2.4f' % time.real) + ' seconds'
@@ -46,8 +46,7 @@ module Webgen::SourceHandler
46
46
  render(Webgen::ContentProcessor::Context.new(:chain => [node])).content
47
47
  else
48
48
  feed = (website.cache.volatile[:sourcehandler_feed] ||= {})[node.node_info[:src]] ||= build_feed_for(node)
49
- feed.feed_type = node.node_info[:feed_type]
50
- feed.build_xml
49
+ feed.build_xml(node.node_info[:feed_type], (node.node_info[:feed_type] == 'rss' ? node['rss_version'] || 2.0 : nil))
51
50
  end
52
51
  end
53
52
 
@@ -58,8 +57,7 @@ module Webgen::SourceHandler
58
57
 
59
58
  node.tree.node_access[:alcn].values.
60
59
  select {|node| patterns.any? {|pat| node =~ pat} && node.node_info[:page]}.
61
- sort {|a,b| a['modified_at'] <=> b['modified_at']}.
62
- reverse[0, nr_items]
60
+ sort {|a,b| a['modified_at'] <=> b['modified_at']}[0, nr_items]
63
61
  end
64
62
 
65
63
  #######
@@ -85,13 +83,12 @@ module Webgen::SourceHandler
85
83
  feed.published = (node['created_at'].kind_of?(Time) ? node['created_at'] : Time.now)
86
84
  feed.updated = Time.now
87
85
  feed.generator = 'webgen - Webgen::SourceHandler::Feed'
88
- feed.icon = File.join(site_url, node.tree[node['icon']].path) if node['icon']
89
86
 
90
87
  node.feed_entries.each do |entry|
91
88
  item = FeedTools::FeedItem.new
92
89
  item.title = entry['title']
93
90
  item.link = File.join(site_url, entry.path)
94
- item.content = entry.node_info[:page].blocks['content'].render(Webgen::ContentProcessor::Context.new(:chain => [entry])).content
91
+ item.content = entry.node_info[:page].blocks[node['content_block_name'] || 'content'].render(Webgen::ContentProcessor::Context.new(:chain => [entry])).content
95
92
  item.updated = entry['modified_at']
96
93
  item.published = entry['created_at'] if entry['created_at'].kind_of?(Time)
97
94
  if entry['author']
@@ -18,23 +18,7 @@ module Webgen::SourceHandler
18
18
 
19
19
  super(parent, path) do |node|
20
20
  node.node_info[:sh_page_node_mi] = Webgen::Page.meta_info_from_data(path.io.data)
21
-
22
21
  node.node_info[:page] = page
23
- tmp_logger = website.logger
24
- website.logger = nil # disabling logging whiling creating fragment nodes
25
-
26
- website.cache.permanent[:page_sections] ||= {}
27
- sections = if path.changed? || !website.cache.permanent[:page_sections][node.absolute_lcn]
28
- website.blackboard.invoke(:parse_html_headers, render_node(node, 'content', []))
29
- else
30
- website.cache.permanent[:page_sections][node.absolute_lcn]
31
- end
32
- website.cache.permanent[:page_sections][node.absolute_lcn] = sections
33
- website.blackboard.invoke(:create_fragment_nodes,
34
- sections,
35
- node, website.blackboard.invoke(:source_paths)[path.source_path],
36
- node.meta_info['fragments_in_menu'])
37
- website.logger = tmp_logger
38
22
  end
39
23
  end
40
24
 
@@ -17,7 +17,7 @@ module Webgen::Tag
17
17
  result = lang_nodes.
18
18
  reject {|n| (context.content_node.lang == n.lang && !param('tag.langbar.show_own_lang'))}.
19
19
  sort {|a, b| a.lang <=> b.lang}.
20
- collect {|n| context.dest_node.link_to(n, :link_text => n.lang, :lang => n.lang)}.
20
+ collect {|n| context.dest_node.link_to(n, :link_text => (param('tag.langbar.lang_names')[n.lang] || n.lang), :lang => n.lang)}.
21
21
  join(param('tag.langbar.separator'))
22
22
  (param('tag.langbar.show_single_lang') || lang_nodes.length > 1 ? result : "")
23
23
  end
data/lib/webgen/tree.rb CHANGED
@@ -56,8 +56,9 @@ module Webgen
56
56
 
57
57
  # A utility method called by Node#reinit. This method should not be used directly!
58
58
  def register_path(node)
59
+ return if node['no_output']
59
60
  if @node_access[:path].has_key?(node.path)
60
- raise "Can't have two nodes with same output path: #{node.path}" unless node['no_output']
61
+ raise "Can't have two nodes with same output path: #{node.path}"
61
62
  else
62
63
  @node_access[:path][node.path] = node
63
64
  end
@@ -0,0 +1,40 @@
1
+ require 'test/unit'
2
+ require 'test/helper'
3
+ require 'webgen/page'
4
+ require 'webgen/tree'
5
+ require 'webgen/contentprocessor'
6
+
7
+ class TestContentProcessorFragments < Test::Unit::TestCase
8
+
9
+ include Test::WebsiteHelper
10
+
11
+ def test_process
12
+ Webgen::SourceHandler::Main.new
13
+ @website.blackboard.del_service(:source_paths)
14
+ @website.blackboard.add_service(:source_paths) { Hash.new(path_with_meta_info('/')) }
15
+
16
+ obj = Webgen::ContentProcessor::Fragments.new
17
+ root = Webgen::Node.new(Webgen::Tree.new.dummy_root, '/', '/')
18
+ root.node_info[:src] = '/'
19
+ processors = { 'fragments' => obj }
20
+
21
+ context = Webgen::ContentProcessor::Context.new(:chain => [root], :processors => processors)
22
+ context.content = '<h1 id="test">Test</h1><h1>Test2</h1>'
23
+ obj.call(context)
24
+ assert(root.tree['/#test'])
25
+ assert_equal(3, root.tree.node_access[:alcn].length)
26
+ root.tree.delete_node('/#test')
27
+
28
+ context[:block] = Webgen::Block.new('content', '', {})
29
+ obj.call(context)
30
+ assert(root.tree['/#test'])
31
+ assert_equal(3, root.tree.node_access[:alcn].length)
32
+ root.tree.delete_node('/#test')
33
+
34
+ context[:block] = Webgen::Block.new('other', '', {})
35
+ obj.call(context)
36
+ assert(!root.tree['/#test'])
37
+ assert_equal(2, root.tree.node_access[:alcn].length)
38
+ end
39
+
40
+ end
@@ -50,4 +50,16 @@ class TestLanguages < Test::Unit::TestCase
50
50
  assert_equal(-1, ace <=> eng)
51
51
  end
52
52
 
53
+ def test_hashing
54
+ de = Webgen::LanguageManager.language_for_code('ger')
55
+ en = Webgen::LanguageManager.language_for_code('en')
56
+ h = {'de' => de, en => en}
57
+ assert_equal(de, h[de])
58
+ assert_equal(de, h['de'])
59
+ assert_equal(en, h[en])
60
+ assert_not_equal(en, h['en']) # bc 'en'.eql?(en) is false
61
+ assert_equal(Webgen::LanguageManager.language_for_code('en'),
62
+ Webgen::LanguageManager.language_for_code(en))
63
+ end
64
+
53
65
  end
data/test/test_logger.rb CHANGED
@@ -70,4 +70,23 @@ class TestLogger < Test::Unit::TestCase
70
70
  assert_equal("ERROR -- hallo\n", l.log_output)
71
71
  end
72
72
 
73
+ def test_run_marks
74
+ l = Webgen::Logger.new(io = StringIO.new, true)
75
+ l.mark_new_cycle
76
+ l.error { 'hallo' }
77
+ assert_equal("", l.log_output)
78
+
79
+ l = Webgen::Logger.new(io = StringIO.new, false)
80
+ l.error { 'hallo' }
81
+ l.mark_new_cycle
82
+ l.error { 'other' }
83
+ l.mark_new_cycle
84
+ assert_equal("ERROR -- hallo\n INFO -- Log messages for run 1 are following\n" +
85
+ "ERROR -- other\n INFO -- Log messages for run 2 are following\n", l.log_output)
86
+
87
+ l = Webgen::Logger.new(io = StringIO.new, false)
88
+ l.mark_new_cycle
89
+ assert_equal("", l.log_output)
90
+ end
91
+
73
92
  end
data/test/test_node.rb CHANGED
@@ -39,6 +39,7 @@ class TestNode < Test::Unit::TestCase
39
39
  assert_equal(lcn, node.lcn)
40
40
  assert_equal(alcn, node.absolute_lcn)
41
41
  assert_equal(lang, node.lang)
42
+ assert_kind_of(Webgen::Language, node.lang) if node.lang
42
43
  assert(node.flagged(:dirty))
43
44
  assert(node.flagged(:created))
44
45
  assert_equal(mi, node.meta_info)
data/test/test_page.rb CHANGED
@@ -97,14 +97,14 @@ class TestPage < Test::Unit::TestCase
97
97
  --- name:block
98
98
  content doing -
99
99
  with?: with some things
100
- --- other:options test1:true test2:false test3:542
100
+ --- other:options test1:true test2:false test3:542 pipeline:
101
101
  meta_info: {}
102
102
  blocks:
103
103
  - name: block
104
104
  content: "content doing -\\nwith?: with some things"
105
105
  - name: block2
106
106
  content: ''
107
- options: {other: options, test1: true, test2: false, test3: 542}
107
+ options: {other: options, test1: true, test2: false, test3: 542, pipeline: ~}
108
108
 
109
109
  # block with seemingly block start line it
110
110
  - in: |
@@ -12,6 +12,7 @@ class TestSourceHandlerFeed < Test::Unit::TestCase
12
12
  site_url: http://example.com
13
13
  entries: *.html
14
14
  author: Thomas Leitner
15
+ content_block_name: abstract
15
16
  --- name:rss_template
16
17
  hallo
17
18
  EOF
@@ -22,7 +23,7 @@ EOF
22
23
  :file1_en => Webgen::Node.new(root, '/file1.en.html', 'file1.html', {'lang' => 'en', 'in_menu' => true, 'modified_at' => Time.now}),
23
24
  :index_en => Webgen::Node.new(root, '/index.en.html', 'index.html', {'lang' => 'en', 'modified_at' => Time.now - 1, 'author' => 'test'}),
24
25
  }
25
- @nodes[:index_en].node_info[:page] = Webgen::Page.from_data("hallo")
26
+ @nodes[:index_en].node_info[:page] = Webgen::Page.from_data("--- name:content\nMyContent\n--- name:abstract\nRealContent")
26
27
  @obj = Webgen::SourceHandler::Feed.new
27
28
  @path = path_with_meta_info('/test.feed', {}, @obj.class.name) {StringIO.new(FEED_CONTENT)}
28
29
  end
@@ -43,6 +44,7 @@ EOF
43
44
  atom_node, rss_node = @obj.create_node(@nodes[:root], @path)
44
45
  assert_equal('hallo', rss_node.content)
45
46
  assert(atom_node.content =~ /Thomas Leitner/)
47
+ assert(atom_node.content =~ /RealContent/)
46
48
  end
47
49
 
48
50
  def test_feed_entries
@@ -10,11 +10,7 @@ class TestSourceHandlerPage < Test::Unit::TestCase
10
10
  def setup
11
11
  super
12
12
  @website.blackboard.del_service(:templates_for_node)
13
- @website.blackboard.del_service(:parse_html_sections)
14
- @website.blackboard.del_service(:create_fragment_nodes)
15
13
  @website.blackboard.add_service(:templates_for_node) {|node| []}
16
- @website.blackboard.add_service(:parse_html_sections) {[]}
17
- @website.blackboard.add_service(:create_fragment_nodes) {nil}
18
14
  @obj = Webgen::SourceHandler::Page.new
19
15
  @root = Webgen::Node.new(Webgen::Tree.new.dummy_root, 'test/', 'test')
20
16
  @path = path_with_meta_info('/index.page') {StringIO.new('content')}
@@ -32,7 +28,6 @@ class TestSourceHandlerPage < Test::Unit::TestCase
32
28
  assert_equal('yes', node['test'])
33
29
  assert_equal(6, node['sort_info'])
34
30
  assert_equal(Webgen::LanguageManager.language_for_code('epo'), node.lang)
35
- assert_not_nil(@website.cache.permanent[:page_sections]['/test/index.eo.html'])
36
31
 
37
32
  assert_equal(node, @obj.create_node(@root, @path.dup))
38
33
 
@@ -31,7 +31,13 @@ class TestTagLangbar < Test::Unit::TestCase
31
31
  check_results(nodes[:file_en], link, '', '', '')
32
32
 
33
33
  @obj.set_params('tag.langbar.show_single_lang' => true, 'tag.langbar.show_own_lang' => true, 'tag.langbar.separator' => ' --- ')
34
- assert_equal("#{de_link} --- #{en_link}", @obj.call('langbar', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:index_en]])))
34
+ assert_equal("#{de_link} --- #{en_link}",
35
+ @obj.call('langbar', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:index_en]])))
36
+
37
+ @obj.set_params('tag.langbar.show_single_lang' => true, 'tag.langbar.show_own_lang' => true,
38
+ 'tag.langbar.lang_names' => {'de' => 'Deutsch'})
39
+ assert_equal("<a href=\"index.de.html\">Deutsch</a> | #{en_link}",
40
+ @obj.call('langbar', '', Webgen::ContentProcessor::Context.new(:chain => [nodes[:index_en]])))
35
41
 
36
42
  nodes[:index_en].unflag(:dirty)
37
43
  @website.blackboard.dispatch_msg(:node_changed?, nodes[:index_en])
data/test/test_tree.rb CHANGED
@@ -20,8 +20,8 @@ class TestTree < Test::Unit::TestCase
20
20
  assert_equal(root, @tree.root)
21
21
  end
22
22
 
23
- def test_register_node
24
- # Tree#register_node is called when creating a node
23
+ def test_register_node_and_register_path
24
+ # Tree#register_node/_path is called when creating a node
25
25
  node = Webgen::Node.new(@tree.dummy_root, 'dummy/', 'dummy')
26
26
  assert_equal(node, @tree['/dummy', :alcn])
27
27
  assert_equal(node, @tree['/dummy', :acn])
@@ -29,6 +29,8 @@ class TestTree < Test::Unit::TestCase
29
29
  assert_raise(RuntimeError) { Webgen::Node.new(@tree.dummy_root, '/', 'dummy') }
30
30
  assert_raise(RuntimeError) { Webgen::Node.new(@tree.dummy_root, 'dummy/', 'other') }
31
31
  assert_nothing_raised { Webgen::Node.new(@tree.dummy_root, 'dummy/', 'unknown', {'no_output' => true}) }
32
+ Webgen::Node.new(@tree.dummy_root, 'new', 'new', {'no_output' => true})
33
+ assert(!@tree['new', :path])
32
34
  end
33
35
 
34
36
  def test_delete_node
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gettalong-webgen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5.20081010
4
+ version: 0.5.5.20081012
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: 2008-10-09 15:00:00 -07:00
12
+ date: 2008-10-11 15:00:00 -07:00
13
13
  default_executable: webgen
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -360,6 +360,7 @@ files:
360
360
  - doc/contentprocessor/builder.page
361
361
  - doc/contentprocessor/erb.page
362
362
  - doc/contentprocessor/erubis.page
363
+ - doc/contentprocessor/fragments.page
363
364
  - doc/contentprocessor/haml.page
364
365
  - doc/contentprocessor/maruku.page
365
366
  - doc/contentprocessor/rdiscount.page
@@ -417,6 +418,7 @@ files:
417
418
  - lib/webgen/contentprocessor/context.rb
418
419
  - lib/webgen/contentprocessor/erb.rb
419
420
  - lib/webgen/contentprocessor/erubis.rb
421
+ - lib/webgen/contentprocessor/fragments.rb
420
422
  - lib/webgen/contentprocessor/haml.rb
421
423
  - lib/webgen/contentprocessor/maruku.rb
422
424
  - lib/webgen/contentprocessor/rdiscount.rb
@@ -492,6 +494,7 @@ files:
492
494
  - test/test_contentprocessor_context.rb
493
495
  - test/test_contentprocessor_erb.rb
494
496
  - test/test_contentprocessor_erubis.rb
497
+ - test/test_contentprocessor_fragments.rb
495
498
  - test/test_contentprocessor_haml.rb
496
499
  - test/test_contentprocessor_maruku.rb
497
500
  - test/test_contentprocessor_rdiscount.rb