webgen 0.5.0 → 0.5.1

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 (80) hide show
  1. data/Rakefile +32 -2
  2. data/VERSION +1 -1
  3. data/doc/contentprocessor.template +10 -0
  4. data/doc/contentprocessor/blocks.page +67 -0
  5. data/doc/contentprocessor/builder.page +80 -0
  6. data/doc/contentprocessor/erb.page +51 -33
  7. data/doc/contentprocessor/haml.page +47 -0
  8. data/doc/contentprocessor/maruku.page +41 -0
  9. data/doc/contentprocessor/rdoc.page +36 -0
  10. data/doc/contentprocessor/redcloth.page +40 -0
  11. data/doc/contentprocessor/sass.page +32 -0
  12. data/doc/contentprocessor/tags.page +56 -44
  13. data/doc/extensions.metainfo +29 -0
  14. data/doc/extensions.page +15 -4
  15. data/doc/extensions.template +17 -0
  16. data/doc/reference_configuration.page +242 -5
  17. data/doc/reference_metainfo.page +9 -0
  18. data/doc/sourcehandler.template +21 -0
  19. data/doc/sourcehandler/copy.page +20 -0
  20. data/doc/sourcehandler/directory.page +27 -0
  21. data/doc/sourcehandler/metainfo.page +38 -115
  22. data/doc/sourcehandler/page.page +9 -27
  23. data/doc/sourcehandler/template.page +45 -0
  24. data/doc/sourcehandler/virtual.page +49 -0
  25. data/doc/tag.template +26 -0
  26. data/doc/tag/breadcrumbtrail.page +32 -0
  27. data/doc/tag/coderay.page +49 -0
  28. data/doc/tag/date.page +31 -0
  29. data/doc/tag/executecommand.page +26 -0
  30. data/doc/tag/includefile.page +32 -0
  31. data/doc/tag/langbar.page +22 -0
  32. data/doc/tag/menu.page +90 -0
  33. data/doc/tag/metainfo.page +29 -0
  34. data/doc/tag/relocatable.page +38 -0
  35. data/doc/webgen_page_format.page +2 -2
  36. data/lib/webgen/cli/utils.rb +1 -1
  37. data/lib/webgen/contentprocessor.rb +5 -0
  38. data/lib/webgen/contentprocessor/builder.rb +26 -0
  39. data/lib/webgen/contentprocessor/context.rb +4 -0
  40. data/lib/webgen/contentprocessor/erb.rb +24 -0
  41. data/lib/webgen/contentprocessor/haml.rb +25 -0
  42. data/lib/webgen/contentprocessor/maruku.rb +1 -1
  43. data/lib/webgen/contentprocessor/rdoc.rb +17 -0
  44. data/lib/webgen/contentprocessor/sass.rb +18 -0
  45. data/lib/webgen/default_config.rb +41 -10
  46. data/lib/webgen/node.rb +3 -2
  47. data/lib/webgen/path.rb +8 -1
  48. data/lib/webgen/sourcehandler.rb +15 -10
  49. data/lib/webgen/sourcehandler/page.rb +9 -1
  50. data/lib/webgen/tag.rb +6 -0
  51. data/lib/webgen/tag/breadcrumbtrail.rb +39 -0
  52. data/lib/webgen/tag/coderay.rb +32 -0
  53. data/lib/webgen/tag/date.rb +18 -0
  54. data/lib/webgen/tag/executecommand.rb +26 -0
  55. data/lib/webgen/tag/includefile.rb +42 -0
  56. data/lib/webgen/tag/langbar.rb +24 -0
  57. data/lib/webgen/tag/metainfo.rb +1 -1
  58. data/lib/webgen/version.rb +1 -1
  59. data/lib/webgen/webgentask.rb +5 -10
  60. data/misc/default.css +19 -0
  61. data/misc/default.template +3 -1
  62. data/misc/htmldoc.metainfo +3 -0
  63. data/misc/htmldoc.virtual +1 -1
  64. data/test/test_contentprocessor_builder.rb +19 -0
  65. data/test/test_contentprocessor_erb.rb +20 -0
  66. data/test/test_contentprocessor_haml.rb +20 -0
  67. data/test/test_contentprocessor_rdoc.rb +16 -0
  68. data/test/test_contentprocessor_sass.rb +20 -0
  69. data/test/test_node.rb +6 -2
  70. data/test/test_path.rb +5 -0
  71. data/test/test_sourcehandler_page.rb +8 -0
  72. data/test/test_tag_breadcrumbtrail.rb +78 -0
  73. data/test/test_tag_coderay.rb +30 -0
  74. data/test/test_tag_date.rb +16 -0
  75. data/test/test_tag_executecommand.rb +40 -0
  76. data/test/test_tag_includefile.rb +48 -0
  77. data/test/test_tag_langbar.rb +53 -0
  78. data/test/test_tag_menu.rb +1 -1
  79. data/test/test_webgentask.rb +21 -0
  80. metadata +81 -2
@@ -0,0 +1,31 @@
1
+ ---
2
+ title: Webgen::Tag::Date
3
+ used_options:
4
+ - tag.date.format
5
+ ---
6
+ ## Description
7
+
8
+ The date tag is used to display the current time in a specific format (the format of Ruby's inbuilt
9
+ method [Time#strftime][1]). Have a look a the examples below to see some possible outputs.
10
+
11
+ [1]: http://www.ruby-doc.org/core/classes/Time.html
12
+
13
+ ## Examples
14
+
15
+ <table class="examples">
16
+ <tr>
17
+ <th>Usage</th><th>Output</th>
18
+ </tr>
19
+ <tr>
20
+ <td>\{date:}</td>
21
+ <td>{date:}</td>
22
+ </tr>
23
+ <tr>
24
+ <td>\{date: {format: '%A, %Y-%m-%d'}}</td>
25
+ <td>{date: {format: '%A, %Y-%m-%d'}}</td>
26
+ </tr>
27
+ <tr>
28
+ <td>\{date: {format: %x - %X}}</td>
29
+ <td>{date: {format: %x - %X}}</td>
30
+ </tr>
31
+ </table>
@@ -0,0 +1,26 @@
1
+ ---
2
+ title: Webgen::Tag::ExecuteCommand
3
+ used_options:
4
+ - tag.executecommand.command
5
+ - tag.executecommand.process_output
6
+ - tag.executecommand.escape_html
7
+ ---
8
+ ## Description
9
+
10
+ The execute command tag is used to include the output from a shell command.
11
+
12
+ ## Examples
13
+
14
+ <table class="examples">
15
+ <tr>
16
+ <th>Usage</th><th>Output</th>
17
+ </tr>
18
+ <tr>
19
+ <td>\{execute_cmd: uname -p}</td>
20
+ <td><pre>{execute_cmd: uname -p}</pre></td>
21
+ </tr>
22
+ <tr>
23
+ <td>\{execute_cmd: {command: 'ruby -v'}}</td>
24
+ <td><pre>{execute_cmd: {command: 'ruby -v'}}</pre></td>
25
+ </tr>
26
+ </table>
@@ -0,0 +1,32 @@
1
+ ---
2
+ title: Webgen::Tag::IncludeFile
3
+ used_options:
4
+ - tag.includefile.filename
5
+ - tag.includefile.process_output
6
+ - tag.includefile.escape_html
7
+ ---
8
+ ## Description
9
+
10
+ The include file tag is used to include the content of a file. The filename needs to be specified
11
+ relative to the website directory or an absolute filename.
12
+
13
+ > By surrounding the include file tag with a syntax highlighting tag it is possible to highlight the
14
+ > contents of a file.
15
+ {.information}
16
+
17
+
18
+ ## Examples
19
+
20
+ <table class="examples">
21
+ <tr>
22
+ <th>Usage</th><th>Output</th>
23
+ </tr>
24
+ <tr>
25
+ <td>\{include_file: {filename: AUTHORS, process_output: false}}</td>
26
+ <% if File.exists?(File.join(context.website.directory, 'AUTHORS')) %>
27
+ <td><pre>{include_file: {filename: AUTHORS, process_output: false}}</pre></td>
28
+ <% else %>
29
+ <td><pre>{include_file: {filename: ../AUTHORS, process_output: false}}</pre></td>
30
+ <% end %>
31
+ </tr>
32
+ </table>
@@ -0,0 +1,22 @@
1
+ ---
2
+ title: Webgen::Tag::Langbar
3
+ used_options:
4
+ - tag.langbar.separator
5
+ - tag.langbar.show_own_lang
6
+ - tag.langbar.show_single_lang
7
+ ---
8
+ ## Description
9
+
10
+ This tag is used to display a list of links to translations of the page.
11
+
12
+ ## Examples
13
+
14
+ <table class="examples">
15
+ <tr>
16
+ <th>Usage</th><th>Output</th>
17
+ </tr>
18
+ <tr>
19
+ <td>\{langbar:}</td>
20
+ <td>{langbar:}</td>
21
+ </tr>
22
+ </table>
@@ -0,0 +1,90 @@
1
+ ---
2
+ title: Webgen::Tag::Menu
3
+ used_options:
4
+ - tag.menu.used_nodes
5
+ - tag.menu.start_level
6
+ - tag.menu.min_levels
7
+ - tag.menu.max_levels
8
+ - tag.menu.show_current_subtree_only
9
+ ---
10
+ ## Description
11
+
12
+ The menu tag builds a seemingly simple menu using HTML lists. However, it is very flexible due to
13
+ its many options that let you decide every detail of the menu.
14
+
15
+ > The menu is constructed using HTML lists with `ul` and `li` tags. However, the menu normally
16
+ > looks better if no discs are shown for the menu items (using the CSS directive `list-style-type:
17
+ > none`).
18
+ {.information}
19
+
20
+ It uses the meta information `in_menu` and `sort_info` to determine which nodes should be in the
21
+ menu and how they should be ordered. A separate menu tree is then created from all nodes for each
22
+ language.
23
+
24
+ By setting the option `tag.menu.used_nodes` to `fragments`, the menu tag can also be used for
25
+ generating an in-page content menu of all the header sections.
26
+
27
+ > When using the option value `files` for `tag.menu.used_nodes`, all nodes which are only in the
28
+ > menu because they have fragment nodes beneath them are not included in the menu.
29
+ {.exclamation}
30
+
31
+ The rendered menu consists of `ul` and `li` tags and the links to the menu entries as well as a
32
+ surrounding `div` tag. The `li` tags have special CSS classes set for styling. These CSS class names
33
+ are as follows:
34
+
35
+ * `webgen-menu-submenu`: Set if the menu item contains sub menu items.
36
+ * `webgen-menu-submenu-inhierarchy`: Set if the menu item contains sub menu items and it is in the
37
+ sub tree of the rendered node.
38
+ * `webgen-menu-item-selected`: Set if the menu item corresponds to the rendered node.
39
+
40
+
41
+ ## "Static" Menus
42
+
43
+ It is also possible to define a "static" menu or to augment the dynamic menu with static entries by
44
+ using virtual files. They can be used to structure the menu the way you like it. This way it is also
45
+ possible to add one page under two different headings:
46
+
47
+ features.en.html:
48
+ in_menu: true
49
+ title: Features
50
+ url: index.en.html#features
51
+
52
+ newdir:
53
+ sort_info: 2
54
+
55
+ newdir/new.en.html:
56
+ sort_info: 1
57
+ in_menu: true
58
+ url: ../features.en.html
59
+
60
+ There is no need to specify `in_menu` for `newdir` since a page under the directory is in the
61
+ menu. Also be aware that you need to set the language explicitly if a file should only appear in the
62
+ menu for a specific language. Otherwise it appears in every menu. The `url` specifies the file that
63
+ should be shown when clicked on the generated link.
64
+
65
+ A completely "static" menu can be generated by only using virtual directories and files and not
66
+ setting `in_menu` for any other node.
67
+
68
+ ## Examples
69
+
70
+ <table class="examples">
71
+ <tr>
72
+ <th>Usage</th><th>Output</th>
73
+ </tr>
74
+ <tr>
75
+ <td>\{menu: }</td>
76
+ <td>{menu:}</td>
77
+ </tr>
78
+ <tr>
79
+ <td>\{menu: {used_nodes: all}}</td>
80
+ <td>{menu: {used_nodes: all}}</td>
81
+ </tr>
82
+ <tr>
83
+ <td>\{menu: {used_nodes: files}}</td>
84
+ <td>{menu: {used_nodes: files}}</td>
85
+ </tr>
86
+ <tr>
87
+ <td>\{menu: {used_nodes: fragments}}</td>
88
+ <td>{menu: {used_nodes: fragments}}</td>
89
+ </tr>
90
+ </table>
@@ -0,0 +1,29 @@
1
+ ---
2
+ title: Webgen::Tag::Metainfo
3
+ ---
4
+ ## Description
5
+
6
+ The meta tag is used to copy meta information verbatim. It is used as fallback when no other tag
7
+ class for a specific tag name could not be found. For example, if you define a meta information with
8
+ the key `revision`, you can put the tag `\{revision:}` into a block of a page file and the value
9
+ gets substituted automatically.
10
+
11
+ An every day usage example for the meta tag would be including the title of a page in the
12
+ `head`-section of a HTML template or specifying the language of the HTML file by using the
13
+ `\{lang:}` tag.
14
+
15
+ ## Examples
16
+
17
+ <table class="examples">
18
+ <tr>
19
+ <th>Usage</th><th>Output</th>
20
+ </tr>
21
+ <tr>
22
+ <td>\{title: }</td>
23
+ <td>{title:}</td>
24
+ </tr>
25
+ <tr>
26
+ <td>\{lang: }</td>
27
+ <td>{lang:}</td>
28
+ </tr>
29
+ </table>
@@ -0,0 +1,38 @@
1
+ ---
2
+ title: Webgen::Tag::Relocatable
3
+ used_options:
4
+ - tag.relocatable.path
5
+ ---
6
+ ## Description
7
+
8
+ This tag ensures that the relative path to the specified path is always correct.
9
+
10
+ When the tag is used, it changes the directory part of the supplied path name to a relative path to
11
+ the destination and is most often used in template files. A relocatable tag looks like this:
12
+ `\{relocatable: default.css}`. If this was put into a template and the template was used by a file
13
+ in a subdirectory, then the `relocatable` tag would put `../default.css` into the output file; thus
14
+ ensuring that the relative path to file is valid.
15
+
16
+ > You can only use the `relocatable` tag with paths that are handled by webgen. If you want to
17
+ > handle paths that are not normally handled by webgen, create a virtual path for them.
18
+ {.exclamation}
19
+
20
+ If the specified path is an absolute URL (like `http://webgen.rubyforge.org`), it will just return
21
+ it. And if you specify an URL fragment, this fragment has to exist. If you don't want to resolve a
22
+ fragment, just don't specify it in the tag but afterwards!
23
+
24
+ ## Examples
25
+
26
+ <table class="examples">
27
+ <tr>
28
+ <th>Usage</th><th>Output</th>
29
+ </tr>
30
+ <tr>
31
+ <td>\{relocatable: /default.css}</td>
32
+ <td>{relocatable: /default.css}</td>
33
+ </tr>
34
+ <tr>
35
+ <td>\{relocatable: ../}</td>
36
+ <td>{relocatable: ../}</td>
37
+ </tr>
38
+ </table>
@@ -72,8 +72,8 @@ be set.
72
72
  The name uniquely identifies a content block and is used to access it. The only option used by
73
73
  webgen is the `pipeline` option which specifies the processing pipeline for the block. The
74
74
  processing pipeline is used for rendering the block by using the specified content processors in the
75
- specified order. There are several different content processors available - have a look at the
76
- [content processor listing]({relocatable: contentprocessor/}) for an overview.
75
+ specified order. There are many different content processors available - have a look at the
76
+ [extensions page]({relocatable: extensions.html}) for an overview.
77
77
 
78
78
  There are also defaults for the name and the options of a block but they can be overwritten. You can
79
79
  use one of two ways to do this:
@@ -10,7 +10,7 @@ module Webgen::CLI
10
10
  class Utils
11
11
 
12
12
  USE_ANSI_COLORS = !Config::CONFIG['arch'].include?('mswin32')
13
- DEFAULT_WIDTH = %x{stty size}.split.collect {|n| n.to_i }.last rescue 72
13
+ DEFAULT_WIDTH = ((size = %x{stty size 2>/dev/null}).length > 0 ? x.split.last.to_i : 72) rescue 72
14
14
 
15
15
  # Used for dynamically formatting the text (setting color, bold face, ...).
16
16
  def self.method_missing(id, text = nil)
@@ -58,6 +58,11 @@ module Webgen
58
58
  autoload :Blocks, 'webgen/contentprocessor/blocks'
59
59
  autoload :Maruku, 'webgen/contentprocessor/maruku'
60
60
  autoload :RedCloth, 'webgen/contentprocessor/redcloth'
61
+ autoload :Erb, 'webgen/contentprocessor/erb'
62
+ autoload :Haml, 'webgen/contentprocessor/haml'
63
+ autoload :Sass, 'webgen/contentprocessor/sass'
64
+ autoload :RDoc, 'webgen/contentprocessor/rdoc'
65
+ autoload :Builder, 'webgen/contentprocessor/builder'
61
66
 
62
67
  # Return the list of all available content processors.
63
68
  def self.list
@@ -0,0 +1,26 @@
1
+ module Webgen::ContentProcessor
2
+
3
+ # Processes content that is valid Ruby to build an XML tree. This is done by using the +builder+
4
+ # library.
5
+ class Builder
6
+
7
+ # Process the content of +context+ which needs to be valid Ruby code. The special variable +xml+
8
+ # should be used to construct the XML content.
9
+ def call(context)
10
+ require 'builder'
11
+
12
+ node = context.content_node
13
+ ref_node = context.ref_node
14
+ dest_node = context.dest_node
15
+
16
+ xml = ::Builder::XmlMarkup.new(:indent => 2)
17
+ eval(context.content, binding, context.ref_node.absolute_lcn)
18
+ context.content = xml.target!
19
+ context
20
+ rescue Exception => e
21
+ raise RuntimeError, "Error using Builder to generate XML: #{e.message}", e.backtrace
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -1,4 +1,5 @@
1
1
  require 'webgen/contentprocessor'
2
+ require 'webgen/websiteaccess'
2
3
 
3
4
  module Webgen::ContentProcessor
4
5
 
@@ -13,6 +14,9 @@ module Webgen::ContentProcessor
13
14
  # special nodes of the chain (see #ref_node, #content_node).
14
15
  class Context
15
16
 
17
+ include Webgen::WebsiteAccess
18
+ public :website
19
+
16
20
  # Processing options
17
21
  attr_accessor :options
18
22
 
@@ -0,0 +1,24 @@
1
+ module Webgen::ContentProcessor
2
+
3
+ # Processes embedded Ruby statements.
4
+ class Erb
5
+
6
+ # Process the Ruby statements embedded in the content of +context+.
7
+ def call(context)
8
+ require 'erb'
9
+
10
+ node = context.content_node
11
+ ref_node = context.ref_node
12
+ dest_node = context.dest_node
13
+
14
+ erb = ERB.new(context.content)
15
+ erb.filename = context.ref_node.absolute_lcn
16
+ context.content = erb.result(binding)
17
+ context
18
+ rescue Exception => e
19
+ raise RuntimeError, "Erb processing failed: #{e.message}", e.backtrace
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,25 @@
1
+ module Webgen::ContentProcessor
2
+
3
+ # Processes content in Haml markup using the +haml+ library.
4
+ class Haml
5
+
6
+ # Convert the content in +haml+ markup to HTML.
7
+ def call(context)
8
+ require 'haml'
9
+
10
+ locals = {
11
+ :context => context,
12
+ :node => context.content_node,
13
+ :ref_node => context.ref_node,
14
+ :dest_node => context.dest_node,
15
+ }
16
+ context.content = ::Haml::Engine.new(context.content, :filename => context.ref_node.absolute_lcn).
17
+ render(Object.new, locals)
18
+ context
19
+ rescue Exception => e
20
+ raise RuntimeError, "Error converting Haml markup to HTML: #{e.message}", e.backtrace
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -10,7 +10,7 @@ module Webgen::ContentProcessor
10
10
  context.content = ::Maruku.new(context.content, :on_error => :raise).to_html
11
11
  context
12
12
  rescue Exception => e
13
- raise "Maruku to HTML conversion failed: #{e.message}"
13
+ raise RuntimeError, "Maruku to HTML conversion failed: #{e.message}", e.backtrace
14
14
  end
15
15
 
16
16
  end
@@ -0,0 +1,17 @@
1
+ module Webgen::ContentProcessor
2
+
3
+ # Converts content in RDoc markup (the native Ruby documentation format) to HTML. Needs the newer
4
+ # RDoc implementation provided as +rdoc+ gem!
5
+ class RDoc
6
+
7
+ # Convert the content in RDoc markup to HTML.
8
+ def call(context)
9
+ require 'rdoc/markup/to_html'
10
+
11
+ context.content = ::RDoc::Markup::ToHtml.new.convert(context.content)
12
+ context
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,18 @@
1
+ module Webgen::ContentProcessor
2
+
3
+ # Processes content in Sass markup (used for writing CSS files) using the +haml+ library.
4
+ class Sass
5
+
6
+ # Convert the content in +sass+ markup to CSS.
7
+ def call(context)
8
+ require 'sass'
9
+
10
+ context.content = ::Sass::Engine.new(context.content, :filename => context.ref_node.absolute_lcn).render
11
+ context
12
+ rescue Exception => e
13
+ raise RuntimeError, "Error converting Sass markup to CSS: #{e.message}", e.backtrace
14
+ end
15
+
16
+ end
17
+
18
+ end