webgen 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
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
data/Rakefile CHANGED
@@ -145,6 +145,9 @@ EOF
145
145
  s.add_development_dependency('rcov', '>= 0.8.0')
146
146
  s.add_development_dependency('dcov', '>= 0.2.2')
147
147
  s.add_development_dependency('rubyforge', '>= 1.0.0')
148
+ s.add_development_dependency('RedCloth', '>= 3.0.0')
149
+ s.add_development_dependency('haml', '>= 2.0.1')
150
+ s.add_development_dependency('builder', '>= 2.1.0')
148
151
 
149
152
  s.require_path = 'lib'
150
153
 
@@ -173,7 +176,7 @@ EOF
173
176
 
174
177
  desc "Upload webgen documentation to Rubyforge homepage"
175
178
  task :publish_doc => [:doc] do
176
- sh "rsync -avc htmldoc/ gettalong@rubyforge.org:/var/www/gforge-projects/webgen/documentation/#{(Webgen::VERSION.split('.')[0..-2] + ['x']).join('.')}"
179
+ sh "rsync -avc --delete htmldoc/ gettalong@rubyforge.org:/var/www/gforge-projects/webgen/documentation/#{(Webgen::VERSION.split('.')[0..-2] + ['x']).join('.')}"
177
180
  end
178
181
 
179
182
  desc 'Release webgen version ' + Webgen::VERSION
@@ -228,7 +231,7 @@ EOF
228
231
 
229
232
  desc "Upload the webgen website to Rubyforge"
230
233
  task :publish_website => [:website] do
231
- sh "rsync -avc --exclude 'documentation/0.5.x' --exclude 'documentation/0.4.x' --exclude 'wiki' website/out/ gettalong@rubyforge.org:/var/www/gforge-projects/webgen/"
234
+ sh "rsync -avc --exclude 'documentation/0.5.x' --exclude 'documentation/0.4.x' --exclude 'wiki' --exclude 'robots.txt' website/out/ gettalong@rubyforge.org:/var/www/gforge-projects/webgen/"
232
235
  end
233
236
 
234
237
 
@@ -255,6 +258,33 @@ EOF
255
258
  end
256
259
  end
257
260
 
261
+ EXCLUDED_FOR_TESTS=FileList.new(['lib/webgen/cli{*,**/*}', 'lib/webgen/version.rb',
262
+ 'lib/webgen/output.rb', 'lib/webgen/source.rb',
263
+ 'lib/webgen/tag.rb', 'lib/webgen/default_config.rb',
264
+ ])
265
+
266
+ EXCLUDED_FOR_DOCU=FileList.new(['lib/webgen/cli{*,**/*}', 'lib/webgen/contentprocessor/context.rb',
267
+ 'lib/webgen/*/base.rb', 'lib/webgen/sourcehandler/fragment.rb',
268
+ ])
269
+
270
+ desc "Checks for missing test/docu"
271
+ task :check_missing do
272
+ puts 'Files for which no test exists:'
273
+ Dir['lib/webgen/**/*'].each do |path|
274
+ next if File.directory?(path) || EXCLUDED_FOR_TESTS.include?(path)
275
+ test_path = 'test/test_' + path.gsub(/lib\/webgen\//, "").tr('/', '_')
276
+ puts ' '*4 + path unless File.exists?(test_path)
277
+ end
278
+
279
+ puts
280
+ puts 'Files for which no docu exists:'
281
+ Dir['lib/webgen/*/*'].each do |path|
282
+ next if EXCLUDED_FOR_DOCU.include?(path)
283
+ docu_path = 'doc/' + path.gsub(/lib\/webgen\//, "").gsub(/\.rb$/, '.page')
284
+ puts ' '*4 + path unless File.exists?(docu_path)
285
+ end
286
+ end
287
+
258
288
  end
259
289
 
260
290
  task :clobber => ['dev:clobber']
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -0,0 +1,10 @@
1
+ ---
2
+ template: extensions.template
3
+ --- name:summary pipeline:erb,tags,maruku,blocks
4
+
5
+ The short name of the content processor (used, for example, in the `pipeline` option of a block in a
6
+ file in [Webgen Page Format]({relocatable: webgen_page_format.html}) is `<%=
7
+ context.website.config['contentprocessor.map'].invert[context.content_node['title']] %>`.
8
+
9
+ --- name:content
10
+ <webgen:block name='content' />
@@ -0,0 +1,67 @@
1
+ ---
2
+ title: Webgen::ContentProcessor::Blocks
3
+ ---
4
+ ## Description
5
+
6
+ This processor replaces a special xml tag with rendered blocks. It is used, for example, in
7
+ templates to define the place where the actual page content should be. The short name of the
8
+ processor is `blocks`!
9
+
10
+ The general syntax is as follows:
11
+
12
+ <webgen:block name='BLOCK_NAME' chain='(L)CN;(L)CN;...' />
13
+
14
+ So it is basically an XML tag with two attributes, `name` and `chain`. The `name` attribute
15
+ specifies the name of the block that should be rendered in place of the block tag. The next node in
16
+ the used node chain needs to have a block that is named so, otherwise an error is thrown (if there
17
+ is only one node left in the node chain that node is used). The block is rendered according to its
18
+ render pipeline and then inserted.
19
+
20
+ The optional attribute `chain` specifies the node chain that should be used for rendering the
21
+ block. Its value needs to be a list of (localized) canonical names of nodes separated by semicolons
22
+ that should be used as node chain. If this attribute is not specified the default node chain is
23
+ used.
24
+
25
+ This is more easily explained with examples. Assume we have a `default.template` file, a
26
+ `page.template` file and a `my.page` file with the following contents:
27
+
28
+ The `default.template` file:
29
+
30
+ --- name:content, pipeline:blocks
31
+ before default
32
+ <webgen:block name='content' />
33
+ after default 1
34
+ <webgen:block name='content' chain='page.template;my.page' />
35
+ after default 2
36
+
37
+ The `page.template` file:
38
+
39
+ --- name:content, pipeline:blocks
40
+ before page 1
41
+ <webgen:block name='content' />
42
+ after page 1
43
+
44
+ And the `my.page` file:
45
+
46
+ --- name:content
47
+ The content of the page file.
48
+
49
+ When `my.page` gets rendered to `my.html`, the node chain looks like this by default:
50
+
51
+ default.template ---> my.page
52
+
53
+ The first webgen block tag just inserts the rendered block named `content` of `my.page`. The second
54
+ block tag uses a custom node chain. Therefore the block named `content` of `page.template` gets
55
+ rendered using the node chain:
56
+
57
+ page.template ---> my.page
58
+
59
+ and then inserted. Summing up the above, the rendered file `my.html` will then look like this:
60
+
61
+ before default 1
62
+ The content of the page file.
63
+ after default 1
64
+ before page 1
65
+ The content of the page file.
66
+ after page 1
67
+ after default 2
@@ -0,0 +1,80 @@
1
+ ---
2
+ title: Webgen::ContentProcessor::Builder
3
+ ---
4
+ ## Description
5
+
6
+ This content processor can be used to programatically create XHTML/XML documents
7
+ ([Reference][1]). The top builder object is provided through the `xml` object. There are also other
8
+ objects provided by webgen available - have a look at the [erb documentation]({relocatable:
9
+ erb.html}). The short name of the processor is `builder`!
10
+
11
+ > This extension is only available if you have installed the [builder][1] library. The preferred way
12
+ > to do this is via Rubygems:
13
+ >
14
+ > gem install builder
15
+ {.exclamation}
16
+
17
+
18
+ ## Examples
19
+
20
+ Here is a short sample of content that is valid Ruby and uses the special `xml` object:
21
+
22
+ xml.h1("This a h1 header", :id => 'myid')
23
+
24
+ xml.p do |p|
25
+ p.text! "You can just write "
26
+ p.b "your"
27
+ p.text! "paragraphs here and"
28
+ p.a("link", :href => "http://someurl.com")
29
+ p.text! "them below. This is also a"
30
+ p.i "nice"
31
+ p.text! "format!"
32
+ end
33
+
34
+ xml.blockquote(:class => 'information') do |bq|
35
+ bq.text! "Citations are easy too."
36
+ bq.text! "Really. And you can assign them attributes."
37
+ end
38
+
39
+ xml.ul do |ul|
40
+ ul.li "Lists"
41
+ ul.li "aren't"
42
+ ul.li "difficult"
43
+ ul.li "either."
44
+ end
45
+
46
+
47
+ Following is a complete example which shows how to use this extension in a page file which generates
48
+ a custom XML document (the `content` block has to be valid Ruby!):
49
+
50
+ ---
51
+ output_path_style: [:parent, :cnbase, ['.', :lang], '.xml']
52
+ title: Person Object
53
+ template: ~
54
+ --- pipeline:builder
55
+ xml.persons(:path => node.absolute_lcn) do |p|
56
+ p.person do |b|
57
+ b.firstname('Thomas')
58
+ b.lastname('Leitner')
59
+ end
60
+ p.person do |b|
61
+ b.firstname('Other first')
62
+ b.lastname('Other last')
63
+ end
64
+ end
65
+
66
+ The above will produce the following output:
67
+
68
+ <persons path="/test.xml">
69
+ <person>
70
+ <firstname>Thomas</firstname>
71
+ <lastname>Leitner</lastname>
72
+ </person>
73
+ <person>
74
+ <firstname>Other first</firstname>
75
+ <lastname>Other last</lastname>
76
+ </person>
77
+ </persons>
78
+
79
+
80
+ [1]: http://builder.rubyforge.org "Homepage of builder library"
@@ -1,38 +1,56 @@
1
1
  ---
2
2
  title: Webgen::ContentProcessor::Erb
3
3
  ---
4
+ ## Description
4
5
 
5
- > TODO: This needs to be redone
6
- {.exclamation}
6
+ This processer uses ERB (embedded Ruby) to process content. For detailed information about ERB have
7
+ a look at its documentation by executing `ri ERB` or the [ruby documentation
8
+ site](http://www.ruby-doc.org/)! The short name of the processor is `erb`!
9
+
10
+ You can use the following special objects in your ERB code:
11
+
12
+ * `context`: This object provides the whole rendering context, the following objects are just for
13
+ backwards compatibility.
14
+
15
+ * `ref_node` (or `context.ref_node`): The reference node which is the source of the ERB code that is
16
+ executed. Should be used, for example, for resolving paths.
17
+
18
+ * `node` (or `context.content_node`): The node that gets currently rendered. Should be used for
19
+ retrieving meta information.
20
+
21
+ * `dest_node` (or `context.dest_node`): The node in which the result gets inserted. Should be used
22
+ for calculating relative paths.
23
+
24
+ Here is a small usage example. The following put in a page file
7
25
 
8
- #### Evaluating ERB Tags
9
-
10
- TODO: ev move this to the ContentProcessor/Erb documentation???
11
-
12
- The evaluation of ERB (embedded ruby) tags is optional and only done if the meta information
13
- `useERB` is set to `true`. The use of ERB allows to add dynamic content without using webgen tags.
14
- Following is an example of a file which uses ERB:
15
-
16
- <notextile>
17
- <pre>
18
- \---
19
- title: Test page with ERB
20
- useERB: true
21
- \---
22
- This page has the following meta info items:
23
- &lt;% node.meta_info.each do |key, value| %&gt;
24
- * &lt;%=key %&gt;: &lt;%=value %&gt;
25
- &lt;% end %&gt;
26
- </pre>
27
- </notextile>
28
-
29
- This would output all meta information for the file. There are some objects available which you can
30
- use in your ERB code:
31
-
32
- * `node`: the node for the current file (normally a page file)
33
- * `ref_node`: the reference node, i.e. the node in which the content will be embedded (normally a
34
- template file)
35
-
36
- *Caveat*: you may need to ensure that the ERB start and end tags are not processed by the content
37
- converter. For example, with Textile you may need to surround the ERB code with &lt;textile&gt;
38
- tags!
26
+ Counting 5 items dynamically:
27
+ <%% for i in 1..5 %>
28
+ * item <%%= i %>
29
+ <%% end %>
30
+
31
+ Outputting all meta information:
32
+ <%% node.meta_info.each do |k,v| %>
33
+ * <%%= k %> = <%%= v %>
34
+ <%% end %>
35
+
36
+ ... will give the result:
37
+
38
+ Counting 5 items dynamically:
39
+ <% for i in 1..5 %>
40
+ * item <%= i %>
41
+ <% end %>
42
+
43
+ Outputting all meta information:
44
+ <% node.meta_info.each do |k,v| %>
45
+ * <%= k %> = <%= v %>
46
+ <% end %>
47
+
48
+ The second line shows the first form of the ERB tags which executes Ruby code but does not output
49
+ anything: it just starts a `for` loop. On the third line the second form of ERB tags is used to
50
+ output the result of the Ruby code (note the equation sign!). And the fourth line completes the
51
+ `for` loop by adding the needed `end` keyword.
52
+
53
+ > You may need to ensure that the ERB start and end tags are not processed by the content
54
+ > processor. For example, when using the RedCloth content processor, you may need to surround the
55
+ > ERB code with `<textile>` tags!
56
+ {.exclamation}
@@ -0,0 +1,47 @@
1
+ ---
2
+ title: Webgen::ContentProcessor::Haml
3
+ ---
4
+ ## Description
5
+
6
+ This processor converts the content, which is assumed to be in the Haml markup language, to valid
7
+ XHTML by using the Haml library. For detailed information about Haml have a look at the [Haml
8
+ Homepage][1]! The short name of the processor is `haml`!
9
+
10
+ You can use some special objects provided by webgen in your Haml markup. These are the same objects
11
+ that are available to the `erb` processor, have a look at its [documentation page]({relocatable:
12
+ erb.html}).
13
+
14
+ > This extension is only available if you have installed the [haml][1] library. The preferred way to
15
+ > do this is via Rubygems:
16
+ >
17
+ > gem install haml
18
+ {.exclamation}
19
+
20
+
21
+ ## Example
22
+
23
+ Here is a short sample of a text in Haml markup:
24
+
25
+ %h1#myid This a h1 header
26
+
27
+ %p
28
+ You can just write
29
+ %b your
30
+ paragraphs here and
31
+ %a{:href => 'http://someurl.com'} link
32
+ them below. This is a
33
+ %strong nice
34
+ format!
35
+
36
+ %blockquote.information
37
+ Citations are easy too.
38
+ Really. And you can assign them attributes.
39
+
40
+ %ul
41
+ %li Lists
42
+ %li aren't
43
+ %li difficult
44
+ %li either.
45
+
46
+
47
+ [1]: http://haml.hamptoncatlin.com/
@@ -0,0 +1,41 @@
1
+ ---
2
+ title: Webgen::ContentProcessor::Maruku
3
+ ---
4
+ ## Description
5
+
6
+ This processor converts the content, which is assumed to be in Markdown markup, to HTML by using the
7
+ Maruku library. Maruku is a Markdown processor which supports a superset of Markdown, including
8
+ support for assigning ids and classes to every element, support for Markdown inside HTML elements
9
+ and footnotes. The short name of the processor is `maruku`!
10
+
11
+ For detailed information about Maruku have a look at the [Maruku Homepage][1]. There you will find
12
+ information about the general Markdown syntax as well as information about the extras added by
13
+ Maruku.
14
+
15
+ > Maruku is the default markup content processor for webgen as its markup syntax is easy to learn
16
+ > and nice to look at. Give it a try!
17
+ {.info}
18
+
19
+ Example
20
+ -------
21
+
22
+ Here is a short sample of a text in Markdown+Extras markup:
23
+
24
+ # This a h1 header {#myid}
25
+
26
+ You can just write *your* paragraphs here and
27
+ [link][1] them below. This is **nice** format!
28
+
29
+ > Citations are easy too.
30
+ > Really. And you can assign them attributes.
31
+ {.information}
32
+
33
+ * Lists
34
+ * aren't
35
+ * difficult
36
+ * either.
37
+
38
+ [1]: http://someurl.com
39
+
40
+
41
+ [1]: http://maruku.rubyforge.org/
@@ -0,0 +1,36 @@
1
+ ---
2
+ title: Webgen::ContentProcessor::RDoc
3
+ ---
4
+ ## Description
5
+
6
+ This content processors converts content written in RDoc markup (the default documentation format
7
+ for Ruby source files, [reference][1]) to HTML. The short name of the processor is `rdoc`!
8
+
9
+ > This extension needs the [new RDoc implementation][2] and is not compatible with the
10
+ > implementation included in the Ruby distribution. The preferred way to install the new
11
+ > implementation is via Rubygems:
12
+ >
13
+ > gem install rdoc
14
+ {.exclamation}
15
+
16
+ [1]: http://rdoc.rubyforge.org/rdoc/ "RDoc Reference"
17
+ [2]: http://rubyforge.org/projects/rdoc/ "New RDoc implementation"
18
+
19
+ ## Example
20
+
21
+ Here is a short sample of a text in RDoc markup:
22
+
23
+ = This a h1 header
24
+
25
+ You can just write *your* paragraphs here and <a href="http://someurl.com">link</a> them below.
26
+ This is also a _nice_ format!
27
+
28
+ <blockquote class='information>
29
+ Citations are easy too.
30
+ Really. And you can assign them attributes.
31
+ </blockquote>
32
+
33
+ * Lists
34
+ * aren't
35
+ * difficult
36
+ * either.
@@ -0,0 +1,40 @@
1
+ ---
2
+ title: Webgen::ContentProcessor::RedCloth
3
+ ---
4
+ ## Description
5
+
6
+ This processor converts the content, which is assumed to be in Textile markup, to HTML by using the
7
+ RedCloth library. For detailed information about Textile have a look at the [Textile Reference][1]!
8
+ The short name of the processor is `redcloth`!
9
+
10
+ > This extension is only available if you have installed the [redcloth][2] library. The preferred
11
+ > way to do this is via Rubygems:
12
+ >
13
+ > gem install RedCloth
14
+ {.exclamation}
15
+
16
+
17
+ Example
18
+ -------
19
+
20
+ Here is a short sample of a text in Textile markup:
21
+
22
+ h1(#myid). This a h1 header
23
+
24
+ You can just write *your* paragraphs here and
25
+ "link":http://someurl.com them below. This is also a
26
+ **nice** format!
27
+
28
+ <blockquote class='information>
29
+ Citations are easy too.
30
+ Really. And you can assign them attributes.
31
+ </blockquote>
32
+
33
+ * Lists
34
+ * aren't
35
+ * difficult
36
+ * either.
37
+
38
+
39
+ [1]: http://hobix.com/textile/
40
+ [2]: http://whytheluckystiff.net/ruby/redcloth/