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
@@ -0,0 +1,32 @@
1
+ ---
2
+ title: Webgen::ContentProcessor::Sass
3
+ ---
4
+ ## Description
5
+
6
+ This processor converts the content, which is assumed to be in the Sass meta language, to valid CSS
7
+ using the Haml library. For detailed information about Sass have a look at the [Haml Homepage][1]!
8
+ The short name of the processor is `sass`!
9
+
10
+ > This extension is only available if you have installed the [haml][1] library. The preferred way to
11
+ > do this is via Rubygems:
12
+ >
13
+ > gem install haml
14
+ {.exclamation}
15
+
16
+
17
+ ## Example
18
+
19
+ Here is a short sample of a text in the Sass meta language:
20
+
21
+ #main
22
+ :width 90%
23
+ p
24
+ :border-style solid
25
+ :border-color #00f
26
+ a
27
+ :font-weight bold
28
+ a:hover
29
+ :text-decoration underline
30
+
31
+
32
+ [1]: http://haml.hamptoncatlin.com/
@@ -1,61 +1,73 @@
1
1
  ---
2
2
  title: Webgen::ContentProcessor::Tags
3
3
  ---
4
+ ## Description
4
5
 
5
- > TODO: This needs to be redone!
6
- {.exclamation}
6
+ This processor provides an easy method for adding dynamic content to web pages. It uses so called
7
+ webgen tags to replace special markup constructs with dynamic content. This system allows webgen to
8
+ generate menus and breadcrumb trails, include files and much more. webgen already comes with many
9
+ tags that handle simple things, like including a file, to advanced things, like generating a
10
+ menu. The short name of the processor is `tags`!
7
11
 
8
- ### webgen Tags
12
+ Each webgen tag is defined using a unique name and handled by a tag class. A tag can have zero or
13
+ more parameters some of which are mandatory. Tag parameters map directly to configuration options,
14
+ so you can temporarily (for the rendering of the tag) override some configuration options. Since
15
+ normally only the special configuration options for the tag itself are used, a shorter form can be
16
+ used for them: just remove the tag class name part (without the `Webgen::` prefix) from the
17
+ configuration option. For example, the relocatable tag handled by Webgen::Tag::Relocatable specifies
18
+ the configuration option `tag.relocatable.path` and the short name for it (when used as parameter
19
+ for the relocatable tag, not when used for other tags) is therefore just `path`. The supported
20
+ parameters (and if they are mandatory) are listed for each tag on its documentation page. The
21
+ default mandatory parameter can be specified in a special way, see the following section. When spe
9
22
 
10
- TODO: remove this whole section since it depends on the processing pipeline??? or add a special
11
- section explaining the processing pipeline. ev. move this to the docu for the tags processor. or
12
- still better move this to its own reference section since this is a special webgen construct
23
+ When content is parsed and a webgen tag is encountered, the registered class for this tag is
24
+ called. If no class for a tag exists there are two possibilities: if a default tag class exists,
25
+ then this default class is called. Otherwise an error is raised.
13
26
 
14
- Tags are used to generate content. During processing of a file in WebPage Format so called 'tags'
15
- are replaced with dynamic content. For example, the menu you can see to the left was generated by a
16
- tag. This makes it easier to add or remove menu items. If the menu was not generated, you would have
17
- to change every file which uses the menu.
27
+ For information on how to create such a tag classes have a look at the API documentation of the
28
+ class Webgen::Tag::Base.
18
29
 
19
- #### Usage
20
30
 
21
- Tags are defined by a special markup code. A tag has the following structure:
31
+ ## Syntax for webgen Tags {#syntax}
22
32
 
23
- \{tagname: {parameters}}
33
+ webgen tags are defined using a special markup construct which consists of the tag name, a parameter
34
+ part and a body part.
24
35
 
25
- Every time a tag is found in a file, the registered plugin for the tag is called. The plugin returns
26
- a string which is put into the output file instead of the tag. The output a tag plugin can produce
27
- ranges from something simple to something complex. For example, the Tag/Meta plugin copies any
28
- additional meta information specified in the file verbatim into the correct place in the output
29
- file. And in contrast, the Tag/Menu plugin generates a whole menu tree.
36
+ A tag can be specified in one of the following ways:
30
37
 
31
- If you want to use the markup code used for tags, you need to escape the tag with a backslash, like
32
- this:
38
+ * The simplest form of a webgen tag just consists of the tag name itself. This form can only be used
39
+ if the tag does not have any mandatory parameters.
33
40
 
34
- \\\{tagname: {parameters}}
41
+ \{tagname:}
35
42
 
36
- #### Parameters
43
+ * If a plugin has only one mandatory parameter, there is a short-cut syntax for specifying its
44
+ value.
37
45
 
38
- A tag can have zero or more parameters some of which are mandatory. You can see the supported
39
- parameters (and if they are mandatory) for each tag on the tag's plugin page. The default mandatory
40
- parameter can be specified in a special way, see the examples below. The format used for parsing the
41
- parameters is YAML.
46
+ \{tagname: value}
42
47
 
43
- Here some examples with tags and parameters:
48
+ * If a plugin has more than one mandatory parameter or if some default parameter values should be
49
+ overwritten, one needs to use the following general form.
44
50
 
45
- <table class="examples">
46
- <tr>
47
- <th>Usage</th><th>Output</th>
48
- </tr>
49
- <tr>
50
- <td>`\{tagname: }`</td>
51
- <td>No parameters specified</td>
52
- </tr>
53
- <tr>
54
- <td>`\{tagname: test.html}`</td>
55
- <td>The default mandatory parameter is set to `test.html`. This form can only be used if there is only one mandatory parameter</td>
56
- </tr>
57
- <tr>
58
- <td>`\{tagname: {param1: value1, param2: value2}}`</td>
59
- <td>Two parameters (param1 and param2) specified</td>
60
- </tr>
61
- </table>
51
+ \{tagname: {option: value, other_option: other_value}}
52
+
53
+ > The parameters defined using this syntax are actually specified using a hash in YAML
54
+ > markup. So you can use any valid YAML construct in the YAML hash definition.
55
+ {.information}
56
+
57
+ * Additionally, you can use a body part with any of the above forms. To specify that the tag has a
58
+ body part, just use two colons instead of one after the tag name and don't forget the closing
59
+ tag.
60
+
61
+ \{tagname::}Here comes the body{tagname}
62
+
63
+ Although you can always specify a body part, only some tags actually use it - the documentation
64
+ for each tag states if the body part is used or not.
65
+
66
+ Sometimes you need to specify something which looks like a webgen tag but should not be processed
67
+ like one. In such cases, you need to escape the tag with a backslash, like this:
68
+
69
+ \\\{tagname: {key:value}}
70
+
71
+ Another solution to this is to specify a general prefix for all webgen tags using the configuration
72
+ option `contentprocessor.tags.prefix`. Let's imagine that you set the prefix to `webgen:`; then this
73
+ content processor will only process webgen tags of the form `\{webgen:tagname: {key: value}}`.
@@ -0,0 +1,29 @@
1
+ contentprocessor/:
2
+ index_path: ~
3
+
4
+ contentprocessor/*:
5
+ template: ../contentprocessor.template
6
+
7
+ sourcehandler/:
8
+ index_path: ~
9
+
10
+ sourcehandler/*:
11
+ template: ../sourcehandler.template
12
+
13
+ tag/:
14
+ index_path: ~
15
+
16
+ tag/*:
17
+ template: ../tag.template
18
+
19
+ source/:
20
+ index_path: ~
21
+
22
+ source/*:
23
+ template: ../extensions.template
24
+
25
+ output/:
26
+ index_path: ~
27
+
28
+ output/*:
29
+ template: ../extensions.template
@@ -2,10 +2,21 @@
2
2
  title: Extensions
3
3
  in_menu: true
4
4
  ---
5
+ # webgen Extensions
5
6
 
6
- > TODO: This needs to be filled with real docu.
7
- {.exclamation}
7
+ webgen comes with many extensions that allow for rapid creation of static websites. The variety of
8
+ the extensions allows you to use your tools of choice, for example, your preferred markup
9
+ language. And if your choice is not available, you can write the extension for it yourself or make a
10
+ feature request!
8
11
 
9
- # webgen Extensions
12
+ Here is a list of all extensions:
10
13
 
11
- webgen comes with many extensions. Below is a list of all extensions:
14
+ <%
15
+ pattern = /#{File.join(node.parent.absolute_lcn, '/')}(contentprocessor|output|source|sourcehandler|tag|)\//
16
+ context.content_node.tree.node_access[:alcn].select {|alcn, n| alcn =~ pattern}.sort.each do |alcn, n|
17
+ next if n.is_fragment?
18
+ %>
19
+ * <%= dest_node.link_to(n) %>
20
+ <%
21
+ end
22
+ %>
@@ -0,0 +1,17 @@
1
+ --- pipeline:erb,tags,maruku,blocks
2
+ [Back]({relocatable: extensions.html}) to the extension listing.
3
+ {.backlink}
4
+
5
+ # {title:}
6
+
7
+ <% if (context[:chain][1] || context[:chain][0]).node_info[:page].blocks.has_key?('summary') %>
8
+ ## Summary
9
+
10
+ <webgen:block name='summary' />
11
+
12
+ <% end %>
13
+
14
+ <webgen:block name='content' />
15
+
16
+ [Back]({relocatable: extensions.html}) to the extension listing.
17
+ {.backlink}
@@ -234,16 +234,237 @@ These options are not normally set in the configuration file but given directly
234
234
  respective tag classes. Therefore, all examples in this section show the use of these options in
235
235
  files in Webgen Page Format.
236
236
 
237
- * ### `tag.relocatable.path`
237
+ * ### `tag.breadcrumbtrail.separator`
238
238
 
239
- The default mandatory configuration option for Tag::Relocatable that specifies the path that
240
- should be made relocatable.
239
+ Specifies the string that should be used as separator between indivdual parts of the breadcrumb
240
+ trail.
241
241
 
242
- * Syntax: `PATH` where `PATH` is a (localized) canonical name.
242
+ * Syntax: `SEPARATOR` where `SEPARATOR` is a string (special HTML characters need to be properly
243
+ escaped)
243
244
 
244
245
  * Examples:
245
246
 
246
- <a href="\{relocatable: ../features.html}">Some Path</a>
247
+ Breadcrumb trail with different separator: \{breadcrumb_trail: {separator: ' --- '}}
248
+
249
+
250
+ * ### `tag.breadcrumbtrail.omit_last`
251
+
252
+ Specifies that the last part of the breadcrumb trail should be omitted. If
253
+ `tag.breadcrumbtrail.omit_index_path` is also set to `true` and the last part is an index path,
254
+ only the index path is omitted (and not the parent of the index node too)!
255
+
256
+ * Syntax: `BOOLEAN` where `BOOLEAN` is either `true` or `false`.
257
+
258
+ * Examples:
259
+
260
+ Breadcrumb trail with last part omitted: \{breadcrumb_trail: {omit_last: true}}
261
+
262
+
263
+ * ### `tag.breadcrumbtrail.omit_index_path`
264
+
265
+ Specifies that the last part of the breadcrumb trail should be omitted if it is an index path.
266
+
267
+ * Syntax: `BOOLEAN` where `BOOLEAN` is either `true` or `false`.
268
+
269
+ * Examples:
270
+
271
+ Breadcrumb trail with index path omitted: \{breadcrumb_trail: {omit_index_path: true}}
272
+
273
+
274
+ * ### `tag.coderay.lang`
275
+
276
+ Specifies the language that should be used for syntax highlighting.
277
+
278
+ * Syntax: `LANG` where `LANG` is one of <%= (require 'coderay'; CodeRay::Scanners.list.map {|n| '`' + n + '`'}.join(', ')) %>.
279
+
280
+ * Examples:
281
+
282
+ highlighting some ruby code \{coderay:: ruby}puts 5 + 5{coderay}
283
+
284
+
285
+ * ### `tag.coderay.process_body`
286
+
287
+ Specifies whether the body of the tag should be processed by the tags content processor first.
288
+
289
+ * Syntax: `BOOLEAN` where `BOOLEAN` is either `true` or `false`.
290
+
291
+ * Examples:
292
+
293
+ wrapping in a span: \{coderay:: {lang: ruby, process_body: false}}puts 5 + 5{coderay}
294
+
295
+
296
+ * ### `tag.coderay.wrap`
297
+
298
+ Specifies in which HTML element the highlighted code should be wrapped.
299
+
300
+ * Syntax: `WRAP` where `WRAP` is either `div` or `span`
301
+
302
+ * Examples:
303
+
304
+ wrapping in a span: \{coderay:: {lang: ruby, wrap: span}}puts 5 + 5{coderay}
305
+
306
+
307
+ * ### `tag.coderay.line_numbers`
308
+
309
+ Specifies whether line numbers should be shown.
310
+
311
+ * Syntax: `BOOLEAN` where `BOOLEAN` is either `true` or `false`.
312
+
313
+ * Examples:
314
+
315
+ not showing line numbers: \{coderay:: {lang: ruby, line_numbers: false}}puts 5 + 5{coderay}
316
+
317
+
318
+ * ### `tag.coderay.line_number_start`
319
+
320
+ Specifies the line number that should be used for the first line.
321
+
322
+ * Syntax: `NUMBER` where `NUMBER` is an integer value.
323
+
324
+ * Examples:
325
+
326
+ starting with line 4: \{coderay:: {lang: ruby, line_number_start: 4}}puts 5 + 5{coderay}
327
+
328
+
329
+ * ### `tag.coderay.bold_every`
330
+
331
+ Specifies the interval at which the line numbers should appear bold.
332
+
333
+ * Syntax: `NUMBER` where `NUMBER` is an integer value.
334
+
335
+ * Examples:
336
+
337
+ every other line bold: \{coderay:: {lang: ruby, bold_every: 2}}puts 5 + 5{coderay}
338
+
339
+
340
+ * ### `tag.coderay.tab_width`
341
+
342
+ Specifies the number of spaces that should be used to replace tabulator characters.
343
+
344
+ * Syntax: `NUMBER` where `NUMBER` is an integer value.
345
+
346
+ * Examples:
347
+
348
+ tabulator == 4 spaces: \{coderay:: {lang: ruby, tab_width: 4}}puts 5 + 5{coderay}
349
+
350
+
351
+ * ### `tag.date.format`
352
+
353
+ Specifies the format that should be used for formatting the current date. The format string
354
+ needs to be in a format supported by Ruby's method
355
+ [Time#strftime](http://www.ruby-doc.org/core/classes/Time.html).
356
+
357
+ * Syntax: `FORMAT` where `FORMAT` is a string.
358
+
359
+ * Examples:
360
+
361
+ very short date format: \{date: {format: '%Y-%m-%d'}}
362
+
363
+
364
+ * ### `tag.executecommand.command`
365
+
366
+ Specifies the command that should be executed. This option is the default mandatory option for
367
+ Webgen::Tag::ExecuteCommand.
368
+
369
+ * Syntax: `COMMAND` where `COMMAND` is the to-be-executed command.
370
+
371
+ * Examples:
372
+
373
+ executing a simple command \{exeucte_cmd: echo hallo}
374
+
375
+
376
+ * ### `tag.executecommand.process_output`
377
+
378
+ Specifies whether the output of the executed command should be further processed by the tags
379
+ content processor.
380
+
381
+ * Syntax: `BOOLEAN` where `BOOLEAN` is either `true` or `false`.
382
+
383
+ * Examples:
384
+
385
+ executing command without further processing \{execute_cmd: {command: 'echo hallo', process_output: false}}
386
+
387
+
388
+ * ### `tag.executecommand.escape_html`
389
+
390
+ Specifies whether special HTML characters in the output of the executed command should be escaped.
391
+
392
+ * Syntax: `BOOLEAN` where `BOOLEAN` is either `true` or `false`.
393
+
394
+ * Examples:
395
+
396
+ executing command, output not escaped \{execute_cmd: {command: 'echo hallo', escape_html: false}}
397
+
398
+
399
+ * ### `tag.includefile.filename`
400
+
401
+ Specifies the name of the file that should be included. The filename needs to be relative to the
402
+ website directory or an absolute path. This option is the default mandatory option for
403
+ Webgen::Tag::IncludeFile.
404
+
405
+ * Syntax: `FILENAME` where `FILENAME` is the name of a file
406
+
407
+ * Examples:
408
+
409
+ including a file \{include_file: my_file.txt}
410
+
411
+
412
+ * ### `tag.includefile.process_output`
413
+
414
+ Specifies whether the content of the file should be further processed by the tags content
415
+ processor.
416
+
417
+ * Syntax: `BOOLEAN` where `BOOLEAN` is either `true` or `false`.
418
+
419
+ * Examples:
420
+
421
+ including a file without further processing \{include_file: {filename: my_file.txt, process_output: false}}
422
+
423
+
424
+ * ### `tag.includefile.escape_html`
425
+
426
+ Specifies whether special HTML characters in the content of the file should be escaped.
427
+
428
+ * Syntax: `BOOLEAN` where `BOOLEAN` is either `true` or `false`.
429
+
430
+ * Examples:
431
+
432
+ including a file without escaping \{include_file: {filename: my_file.txt, escape_html: false}}
433
+
434
+
435
+ * ### `tag.langbar.separator`
436
+
437
+ Specifies the string that should be used as separator between the individual language parts.
438
+
439
+ * Syntax: `SEPARATOR` where `SEPARATOR` is a string (special HTML characters need to be properly
440
+ escaped)
441
+
442
+ * Examples:
443
+
444
+ Langbar with another separator: \{langbar: {separator: ' --- '}}
445
+
446
+
447
+ * ### `tag.langbar.show_own_lang`
448
+
449
+ Specifies whether the link to the language of the current page should be displayed.
450
+
451
+ * Syntax: `BOOLEAN` where `BOOLEAN` is either `true` or `false`.
452
+
453
+ * Examples:
454
+
455
+ Langbar with current page's lang not shown: \{langbar: {show_own_lang: false}}
456
+
457
+
458
+ * ### `tag.langbar.show_single_lang`
459
+
460
+ Specifies whether the list should be displayed even if there are no translations of the page
461
+ (i.e. when there is only one page).
462
+
463
+ * Syntax: `BOOLEAN` where `BOOLEAN` is either `true` or `false`.
464
+
465
+ * Examples:
466
+
467
+ Langbar with single language not shown: \{langbar: {show_single_lang: false}}
247
468
 
248
469
 
249
470
  * ### `tag.menu.used_nodes`
@@ -308,6 +529,22 @@ files in Webgen Page Format.
308
529
 
309
530
  Showing all subtrees: \{menu: {show_current_subtree_only: false}}
310
531
 
532
+
533
+ * ### `tag.relocatable.path`
534
+
535
+ The default mandatory configuration option for Tag::Relocatable that specifies the path that
536
+ should be made relocatable. This option is the default mandatory option for
537
+ Webgen::Tag::Relocatable.
538
+
539
+ * Syntax: `PATH` where `PATH` is a (localized) canonical name.
540
+
541
+ * Examples:
542
+
543
+ <a href="\{relocatable: ../features.html}">Some Path</a>
544
+
545
+
546
+
547
+
311
548
  ---
312
549
 
313
550
  ## Miscelleanous Configuration Options