thewoolleyman-webgen 0.5.8.20090419

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 (309) hide show
  1. data/AUTHORS +8 -0
  2. data/COPYING +10 -0
  3. data/GPL +340 -0
  4. data/Rakefile +334 -0
  5. data/THANKS +18 -0
  6. data/bin/webgen +12 -0
  7. data/data/webgen/resources.yaml +3 -0
  8. data/data/webgen/webgui/controller/main.rb +135 -0
  9. data/data/webgen/webgui/overrides/win32console.rb +0 -0
  10. data/data/webgen/webgui/public/css/jquery.autocomplete.css +50 -0
  11. data/data/webgen/webgui/public/css/ramaze_error.css +90 -0
  12. data/data/webgen/webgui/public/css/style.css +55 -0
  13. data/data/webgen/webgui/public/img/headerbg.jpg +0 -0
  14. data/data/webgen/webgui/public/img/webgen_logo.png +0 -0
  15. data/data/webgen/webgui/public/js/jquery.autocomplete.js +15 -0
  16. data/data/webgen/webgui/public/js/jquery.js +32 -0
  17. data/data/webgen/webgui/view/create_website.xhtml +22 -0
  18. data/data/webgen/webgui/view/error.xhtml +64 -0
  19. data/data/webgen/webgui/view/index.xhtml +22 -0
  20. data/data/webgen/webgui/view/manage_website.xhtml +18 -0
  21. data/data/webgen/webgui/view/page.xhtml +40 -0
  22. data/data/webgen/website_skeleton/README +10 -0
  23. data/data/webgen/website_skeleton/Rakefile +40 -0
  24. data/data/webgen/website_skeleton/config.yaml +17 -0
  25. data/data/webgen/website_skeleton/ext/init.rb +10 -0
  26. data/data/webgen/website_styles/1024px/README +13 -0
  27. data/data/webgen/website_styles/1024px/src/default.css +188 -0
  28. data/data/webgen/website_styles/1024px/src/default.template +60 -0
  29. data/data/webgen/website_styles/1024px/src/images/background.gif +0 -0
  30. data/data/webgen/website_styles/andreas00/README +13 -0
  31. data/data/webgen/website_styles/andreas00/src/default.css +290 -0
  32. data/data/webgen/website_styles/andreas00/src/default.template +60 -0
  33. data/data/webgen/website_styles/andreas00/src/images/bg.gif +0 -0
  34. data/data/webgen/website_styles/andreas00/src/images/front.jpg +0 -0
  35. data/data/webgen/website_styles/andreas00/src/images/menubg.gif +0 -0
  36. data/data/webgen/website_styles/andreas00/src/images/menubg2.gif +0 -0
  37. data/data/webgen/website_styles/andreas01/README +14 -0
  38. data/data/webgen/website_styles/andreas01/src/default.css +310 -0
  39. data/data/webgen/website_styles/andreas01/src/default.template +62 -0
  40. data/data/webgen/website_styles/andreas01/src/images/bg.gif +0 -0
  41. data/data/webgen/website_styles/andreas01/src/images/front.jpg +0 -0
  42. data/data/webgen/website_styles/andreas01/src/print.css +35 -0
  43. data/data/webgen/website_styles/andreas03/README +14 -0
  44. data/data/webgen/website_styles/andreas03/src/default.css +223 -0
  45. data/data/webgen/website_styles/andreas03/src/default.template +58 -0
  46. data/data/webgen/website_styles/andreas03/src/images/bodybg.png +0 -0
  47. data/data/webgen/website_styles/andreas03/src/images/contbg.png +0 -0
  48. data/data/webgen/website_styles/andreas03/src/images/footerbg.png +0 -0
  49. data/data/webgen/website_styles/andreas03/src/images/gradient1.png +0 -0
  50. data/data/webgen/website_styles/andreas03/src/images/gradient2.png +0 -0
  51. data/data/webgen/website_styles/andreas04/README +15 -0
  52. data/data/webgen/website_styles/andreas04/src/default.css +290 -0
  53. data/data/webgen/website_styles/andreas04/src/default.template +81 -0
  54. data/data/webgen/website_styles/andreas04/src/images/blinkarrow.gif +0 -0
  55. data/data/webgen/website_styles/andreas04/src/images/bodybg.png +0 -0
  56. data/data/webgen/website_styles/andreas04/src/images/contentbg.png +0 -0
  57. data/data/webgen/website_styles/andreas04/src/images/entrybg.png +0 -0
  58. data/data/webgen/website_styles/andreas04/src/images/flash.gif +0 -0
  59. data/data/webgen/website_styles/andreas04/src/images/flash2.gif +0 -0
  60. data/data/webgen/website_styles/andreas04/src/images/globe.gif +0 -0
  61. data/data/webgen/website_styles/andreas04/src/images/globebottom.gif +0 -0
  62. data/data/webgen/website_styles/andreas04/src/images/linkarrow.gif +0 -0
  63. data/data/webgen/website_styles/andreas04/src/images/menuhover.png +0 -0
  64. data/data/webgen/website_styles/andreas05/README +14 -0
  65. data/data/webgen/website_styles/andreas05/src/default.css +33 -0
  66. data/data/webgen/website_styles/andreas05/src/default.template +40 -0
  67. data/data/webgen/website_styles/andreas05/src/images/bodybg.gif +0 -0
  68. data/data/webgen/website_styles/andreas05/src/images/front.png +0 -0
  69. data/data/webgen/website_styles/andreas06/README +14 -0
  70. data/data/webgen/website_styles/andreas06/src/default.css +354 -0
  71. data/data/webgen/website_styles/andreas06/src/default.template +70 -0
  72. data/data/webgen/website_styles/andreas06/src/images/bodybg.gif +0 -0
  73. data/data/webgen/website_styles/andreas06/src/images/boxbg.gif +0 -0
  74. data/data/webgen/website_styles/andreas06/src/images/greypx.gif +0 -0
  75. data/data/webgen/website_styles/andreas06/src/images/header.jpg +0 -0
  76. data/data/webgen/website_styles/andreas06/src/images/innerbg.gif +0 -0
  77. data/data/webgen/website_styles/andreas06/src/images/leaves.jpg +0 -0
  78. data/data/webgen/website_styles/andreas06/src/images/tabs.gif +0 -0
  79. data/data/webgen/website_styles/andreas07/README +15 -0
  80. data/data/webgen/website_styles/andreas07/src/browserfix.css +7 -0
  81. data/data/webgen/website_styles/andreas07/src/default.css +92 -0
  82. data/data/webgen/website_styles/andreas07/src/default.template +42 -0
  83. data/data/webgen/website_styles/andreas07/src/images/bodybg.gif +0 -0
  84. data/data/webgen/website_styles/andreas07/src/images/sidebarbg.gif +0 -0
  85. data/data/webgen/website_styles/andreas08/README +14 -0
  86. data/data/webgen/website_styles/andreas08/src/default.css +224 -0
  87. data/data/webgen/website_styles/andreas08/src/default.template +51 -0
  88. data/data/webgen/website_styles/andreas09/README +14 -0
  89. data/data/webgen/website_styles/andreas09/src/default.css +308 -0
  90. data/data/webgen/website_styles/andreas09/src/default.template +68 -0
  91. data/data/webgen/website_styles/andreas09/src/images/bodybg-black.jpg +0 -0
  92. data/data/webgen/website_styles/andreas09/src/images/bodybg-green.jpg +0 -0
  93. data/data/webgen/website_styles/andreas09/src/images/bodybg-orange.jpg +0 -0
  94. data/data/webgen/website_styles/andreas09/src/images/bodybg-purple.jpg +0 -0
  95. data/data/webgen/website_styles/andreas09/src/images/bodybg-red.jpg +0 -0
  96. data/data/webgen/website_styles/andreas09/src/images/bodybg.jpg +0 -0
  97. data/data/webgen/website_styles/andreas09/src/images/footerbg.jpg +0 -0
  98. data/data/webgen/website_styles/andreas09/src/images/menuhover-black.jpg +0 -0
  99. data/data/webgen/website_styles/andreas09/src/images/menuhover-green.jpg +0 -0
  100. data/data/webgen/website_styles/andreas09/src/images/menuhover-orange.jpg +0 -0
  101. data/data/webgen/website_styles/andreas09/src/images/menuhover-purple.jpg +0 -0
  102. data/data/webgen/website_styles/andreas09/src/images/menuhover-red.jpg +0 -0
  103. data/data/webgen/website_styles/andreas09/src/images/menuhover.jpg +0 -0
  104. data/data/webgen/website_styles/simple/README +6 -0
  105. data/data/webgen/website_styles/simple/src/default.css +84 -0
  106. data/data/webgen/website_styles/simple/src/default.template +36 -0
  107. data/data/webgen/website_templates/default/README +6 -0
  108. data/data/webgen/website_templates/default/src/index.page +8 -0
  109. data/data/webgen/website_templates/project/README +5 -0
  110. data/data/webgen/website_templates/project/src/about.page +12 -0
  111. data/data/webgen/website_templates/project/src/download.page +15 -0
  112. data/data/webgen/website_templates/project/src/features.page +8 -0
  113. data/data/webgen/website_templates/project/src/index.page +9 -0
  114. data/data/webgen/website_templates/project/src/screenshots.page +18 -0
  115. data/doc/contentprocessor.template +11 -0
  116. data/doc/contentprocessor/blocks.page +129 -0
  117. data/doc/contentprocessor/builder.page +80 -0
  118. data/doc/contentprocessor/erb.page +59 -0
  119. data/doc/contentprocessor/erubis.page +46 -0
  120. data/doc/contentprocessor/fragments.page +25 -0
  121. data/doc/contentprocessor/haml.page +47 -0
  122. data/doc/contentprocessor/maruku.page +41 -0
  123. data/doc/contentprocessor/rdiscount.page +37 -0
  124. data/doc/contentprocessor/rdoc.page +36 -0
  125. data/doc/contentprocessor/redcloth.page +39 -0
  126. data/doc/contentprocessor/sass.page +31 -0
  127. data/doc/contentprocessor/tags.page +73 -0
  128. data/doc/extensions.metainfo +29 -0
  129. data/doc/extensions.page +16 -0
  130. data/doc/extensions.template +17 -0
  131. data/doc/faq.page +219 -0
  132. data/doc/getting_started.page +135 -0
  133. data/doc/index.page +65 -0
  134. data/doc/manual.page +589 -0
  135. data/doc/reference_configuration.page +959 -0
  136. data/doc/reference_metainfo.page +222 -0
  137. data/doc/source/filesystem.page +39 -0
  138. data/doc/source/tararchive.page +40 -0
  139. data/doc/sourcehandler.template +21 -0
  140. data/doc/sourcehandler/copy.page +19 -0
  141. data/doc/sourcehandler/directory.page +27 -0
  142. data/doc/sourcehandler/feed.page +105 -0
  143. data/doc/sourcehandler/metainfo.page +41 -0
  144. data/doc/sourcehandler/page.page +14 -0
  145. data/doc/sourcehandler/sitemap.page +46 -0
  146. data/doc/sourcehandler/template.page +45 -0
  147. data/doc/sourcehandler/virtual.page +49 -0
  148. data/doc/tag.template +25 -0
  149. data/doc/tag/breadcrumbtrail.page +40 -0
  150. data/doc/tag/coderay.page +49 -0
  151. data/doc/tag/date.page +31 -0
  152. data/doc/tag/executecommand.page +26 -0
  153. data/doc/tag/includefile.page +32 -0
  154. data/doc/tag/langbar.page +44 -0
  155. data/doc/tag/link.page +44 -0
  156. data/doc/tag/menu.page +106 -0
  157. data/doc/tag/metainfo.page +29 -0
  158. data/doc/tag/relocatable.page +38 -0
  159. data/doc/tag/sitemap.page +31 -0
  160. data/doc/tag/tikz.page +158 -0
  161. data/doc/upgrading.page +139 -0
  162. data/doc/webgen_page_format.page +129 -0
  163. data/lib/webgen/blackboard.rb +78 -0
  164. data/lib/webgen/cache.rb +87 -0
  165. data/lib/webgen/cli.rb +124 -0
  166. data/lib/webgen/cli/apply_command.rb +64 -0
  167. data/lib/webgen/cli/create_command.rb +66 -0
  168. data/lib/webgen/cli/run_command.rb +22 -0
  169. data/lib/webgen/cli/utils.rb +88 -0
  170. data/lib/webgen/cli/webgui_command.rb +72 -0
  171. data/lib/webgen/common.rb +21 -0
  172. data/lib/webgen/common/sitemap.rb +83 -0
  173. data/lib/webgen/configuration.rb +153 -0
  174. data/lib/webgen/contentprocessor.rb +99 -0
  175. data/lib/webgen/contentprocessor/blocks.rb +60 -0
  176. data/lib/webgen/contentprocessor/builder.rb +30 -0
  177. data/lib/webgen/contentprocessor/context.rb +89 -0
  178. data/lib/webgen/contentprocessor/erb.rb +28 -0
  179. data/lib/webgen/contentprocessor/erubis.rb +40 -0
  180. data/lib/webgen/contentprocessor/fragments.rb +25 -0
  181. data/lib/webgen/contentprocessor/haml.rb +30 -0
  182. data/lib/webgen/contentprocessor/maruku.rb +20 -0
  183. data/lib/webgen/contentprocessor/rdiscount.rb +17 -0
  184. data/lib/webgen/contentprocessor/rdoc.rb +19 -0
  185. data/lib/webgen/contentprocessor/redcloth.rb +17 -0
  186. data/lib/webgen/contentprocessor/sass.rb +20 -0
  187. data/lib/webgen/contentprocessor/tags.rb +136 -0
  188. data/lib/webgen/coreext.rb +13 -0
  189. data/lib/webgen/default_config.rb +215 -0
  190. data/lib/webgen/languages.rb +589 -0
  191. data/lib/webgen/loggable.rb +25 -0
  192. data/lib/webgen/logger.rb +97 -0
  193. data/lib/webgen/node.rb +391 -0
  194. data/lib/webgen/output.rb +82 -0
  195. data/lib/webgen/output/filesystem.rb +69 -0
  196. data/lib/webgen/page.rb +153 -0
  197. data/lib/webgen/path.rb +194 -0
  198. data/lib/webgen/source.rb +54 -0
  199. data/lib/webgen/source/filesystem.rb +61 -0
  200. data/lib/webgen/source/resource.rb +44 -0
  201. data/lib/webgen/source/stacked.rb +55 -0
  202. data/lib/webgen/source/tararchive.rb +73 -0
  203. data/lib/webgen/sourcehandler.rb +226 -0
  204. data/lib/webgen/sourcehandler/base.rb +248 -0
  205. data/lib/webgen/sourcehandler/copy.rb +43 -0
  206. data/lib/webgen/sourcehandler/directory.rb +36 -0
  207. data/lib/webgen/sourcehandler/feed.rb +117 -0
  208. data/lib/webgen/sourcehandler/fragment.rb +68 -0
  209. data/lib/webgen/sourcehandler/memory.rb +43 -0
  210. data/lib/webgen/sourcehandler/metainfo.rb +128 -0
  211. data/lib/webgen/sourcehandler/page.rb +59 -0
  212. data/lib/webgen/sourcehandler/sitemap.rb +60 -0
  213. data/lib/webgen/sourcehandler/template.rb +66 -0
  214. data/lib/webgen/sourcehandler/virtual.rb +110 -0
  215. data/lib/webgen/tag.rb +27 -0
  216. data/lib/webgen/tag/base.rb +170 -0
  217. data/lib/webgen/tag/breadcrumbtrail.rb +70 -0
  218. data/lib/webgen/tag/coderay.rb +31 -0
  219. data/lib/webgen/tag/date.rb +18 -0
  220. data/lib/webgen/tag/executecommand.rb +30 -0
  221. data/lib/webgen/tag/includefile.rb +42 -0
  222. data/lib/webgen/tag/langbar.rb +52 -0
  223. data/lib/webgen/tag/link.rb +26 -0
  224. data/lib/webgen/tag/menu.rb +207 -0
  225. data/lib/webgen/tag/metainfo.rb +25 -0
  226. data/lib/webgen/tag/relocatable.rb +54 -0
  227. data/lib/webgen/tag/sitemap.rb +41 -0
  228. data/lib/webgen/tag/tikz.rb +119 -0
  229. data/lib/webgen/tree.rb +90 -0
  230. data/lib/webgen/version.rb +8 -0
  231. data/lib/webgen/webgentask.rb +152 -0
  232. data/lib/webgen/website.rb +342 -0
  233. data/lib/webgen/websiteaccess.rb +31 -0
  234. data/lib/webgen/websitemanager.rb +127 -0
  235. data/man/man1/webgen.1 +73 -0
  236. data/misc/default.css +384 -0
  237. data/misc/default.template +75 -0
  238. data/misc/htmldoc.metainfo +25 -0
  239. data/misc/htmldoc.virtual +5 -0
  240. data/misc/images/arrow.gif +0 -0
  241. data/misc/images/error.png +0 -0
  242. data/misc/images/headerbg.jpg +0 -0
  243. data/misc/images/important.png +0 -0
  244. data/misc/images/information.png +0 -0
  245. data/misc/images/quote.gif +0 -0
  246. data/misc/images/warning.png +0 -0
  247. data/setup.rb +1585 -0
  248. data/test/helper.rb +45 -0
  249. data/test/test_blackboard.rb +60 -0
  250. data/test/test_cache.rb +59 -0
  251. data/test/test_cli.rb +21 -0
  252. data/test/test_common.rb +18 -0
  253. data/test/test_common_sitemap.rb +58 -0
  254. data/test/test_configuration.rb +68 -0
  255. data/test/test_contentprocessor.rb +33 -0
  256. data/test/test_contentprocessor_blocks.rb +68 -0
  257. data/test/test_contentprocessor_builder.rb +23 -0
  258. data/test/test_contentprocessor_context.rb +40 -0
  259. data/test/test_contentprocessor_erb.rb +23 -0
  260. data/test/test_contentprocessor_erubis.rb +49 -0
  261. data/test/test_contentprocessor_fragments.rb +42 -0
  262. data/test/test_contentprocessor_haml.rb +23 -0
  263. data/test/test_contentprocessor_maruku.rb +29 -0
  264. data/test/test_contentprocessor_rdiscount.rb +17 -0
  265. data/test/test_contentprocessor_rdoc.rb +18 -0
  266. data/test/test_contentprocessor_redcloth.rb +15 -0
  267. data/test/test_contentprocessor_sass.rb +22 -0
  268. data/test/test_contentprocessor_tags.rb +99 -0
  269. data/test/test_languages.rb +67 -0
  270. data/test/test_loggable.rb +32 -0
  271. data/test/test_logger.rb +94 -0
  272. data/test/test_node.rb +367 -0
  273. data/test/test_output_filesystem.rb +60 -0
  274. data/test/test_page.rb +214 -0
  275. data/test/test_path.rb +165 -0
  276. data/test/test_source_filesystem.rb +76 -0
  277. data/test/test_source_resource.rb +28 -0
  278. data/test/test_source_stacked.rb +36 -0
  279. data/test/test_source_tararchive.rb +65 -0
  280. data/test/test_sourcehandler_base.rb +123 -0
  281. data/test/test_sourcehandler_copy.rb +47 -0
  282. data/test/test_sourcehandler_directory.rb +42 -0
  283. data/test/test_sourcehandler_feed.rb +77 -0
  284. data/test/test_sourcehandler_fragment.rb +69 -0
  285. data/test/test_sourcehandler_memory.rb +44 -0
  286. data/test/test_sourcehandler_metainfo.rb +118 -0
  287. data/test/test_sourcehandler_page.rb +65 -0
  288. data/test/test_sourcehandler_sitemap.rb +49 -0
  289. data/test/test_sourcehandler_template.rb +65 -0
  290. data/test/test_sourcehandler_virtual.rb +87 -0
  291. data/test/test_tag_base.rb +85 -0
  292. data/test/test_tag_breadcrumbtrail.rb +91 -0
  293. data/test/test_tag_coderay.rb +32 -0
  294. data/test/test_tag_date.rb +18 -0
  295. data/test/test_tag_executecommand.rb +41 -0
  296. data/test/test_tag_includefile.rb +50 -0
  297. data/test/test_tag_langbar.rb +72 -0
  298. data/test/test_tag_link.rb +69 -0
  299. data/test/test_tag_menu.rb +207 -0
  300. data/test/test_tag_metainfo.rb +19 -0
  301. data/test/test_tag_relocatable.rb +59 -0
  302. data/test/test_tag_sitemap.rb +47 -0
  303. data/test/test_tag_tikz.rb +69 -0
  304. data/test/test_tree.rb +70 -0
  305. data/test/test_webgentask.rb +23 -0
  306. data/test/test_website.rb +98 -0
  307. data/test/test_websiteaccess.rb +25 -0
  308. data/test/test_websitemanager.rb +70 -0
  309. metadata +613 -0
@@ -0,0 +1,129 @@
1
+ ---
2
+ title: Webgen Page Format
3
+ ---
4
+ ## Webgen Page Format
5
+
6
+ The Webgen Page Format is a custom format designed primarily for page and template files. It
7
+ consists of an optional meta information block and one or more blocks of data; it is very simple and
8
+ easy to use.
9
+
10
+ ## Structure
11
+
12
+ A file using the Webgen Page Format consists of one or more blocks which are the smallest units
13
+ recognized. Blocks are separated from each other through a line containing three dashes. This is
14
+ illustrated in the following examples which are all valid files in WebPage Format:
15
+
16
+ Example 1:
17
+
18
+ Here is a block!
19
+
20
+ Example 2:
21
+
22
+ This is one block of the file
23
+ ---
24
+ This is another block.
25
+
26
+ Example 3:
27
+
28
+ Block 1
29
+ --- name:block2
30
+ Block 2
31
+ --- name:block3
32
+ Block 3...
33
+
34
+ If you want to use three dashes in a block but you don't want to end the block, you have to escape
35
+ them with a backslash character, like this:
36
+
37
+ Block 1
38
+ \---
39
+ still Block 1
40
+ --- name:block2
41
+ Block 2
42
+
43
+ All of the above examples show one kind of block, the content block. However, there may also be
44
+ another type of block: the meta information block. Following is a short description of both kinds,
45
+ starting with the meta information block.
46
+
47
+
48
+ ### Meta Information Block
49
+
50
+ Each file in Webgen Page Format can have zero or one meta information blocks. This block is
51
+ specified at the beginning of the file. To tell the parser that the first block is the meta
52
+ information block and not a content block, you have to start the file with three dashes:
53
+
54
+ ---
55
+ title: The title set by Meta info
56
+ ---
57
+ This is the content of the file
58
+
59
+ The above defines a meta information block and a content block. The meta information block has to be
60
+ in YAML format and should contain key-value pairs of meta information. [YAML](http://www.yaml.org)
61
+ is a simple markup language designed for ease of use and although you define structured data with
62
+ it, it feels like just writing a plain text document.
63
+
64
+
65
+ ### Content Blocks
66
+
67
+ A content block is used to provide content in a specific format. Each file in Webgen Page Format
68
+ needs to have at least one content block which may be empty. However, it can have as many content
69
+ blocks as necessary. This functionality can be used, for example, to provide the main content of an
70
+ HTML page in one block and sidebar content in another one.
71
+
72
+ Each content block needs to have a unique name and additional options can also be set. The name
73
+ uniquely identifies a content block and is used to access it. The only option used by webgen is the
74
+ `pipeline` option which specifies the processing pipeline for the block. The processing pipeline is
75
+ used for rendering the block by using the specified content processors in the specified order. There
76
+ are many different content processors available - have a look at the [extensions page]({relocatable:
77
+ extensions.html}) for an overview.
78
+
79
+ webgen extensions that use files in Webgen Page Format may specify defaults for the name and the
80
+ options of a block but these defaults can be overwritten. You can use one of two ways to do this:
81
+
82
+ * you either specify the name and additional options of the block on the starting line with the
83
+ three dashes
84
+
85
+ * or you use the special meta information `block` to define the names and options of one or all
86
+ blocks.
87
+
88
+ The following example uses the first technique to override the name and/or the `pipeline` option:
89
+
90
+ 1. content block of the file
91
+ --- name:sidebar pipeline:maruku,tags
92
+ 2. content block of the file
93
+ --- name:other
94
+ 3. content block of the file
95
+
96
+ The first block has no identifieres set (there is no line with three dashes and the identifieres).
97
+ Therefore the default value for the name is used: `content`. The second block is named `sidebar` and
98
+ uses the processing pipeline `maruku,tags`. As you can see, the name of a block as well as
99
+ additional options are specified by stating the key (e.g. `name` or `pipeline`) followed by a colon
100
+ and the value. Multiple options are separated via one or more spaces. The value of a block option is
101
+ parsed with YAML. For example, when specifying `use_something:true` the value `true` is
102
+ automatically converted from the string `true` to the boolean `true`.
103
+
104
+ > Only the first block gets the default name of `content`. The second and following blocks have
105
+ > numbered names like `block2`, `block3` and so on.
106
+ {.information}
107
+
108
+ You can also set the name and additional options of the content blocks by using the special `blocks`
109
+ meta information. It is a hash using the index of a block (or the special value `default`) as key
110
+ and the options as values. The above example can therefore also be written like this:
111
+
112
+ ---
113
+ blocks: \{2: {name: sidebar, pipeline: maruku,tags}, 3: {name: other}}
114
+ ---
115
+ 1. content block of the file
116
+ ---
117
+ 2. content block of the file
118
+ ---
119
+ 3. content block of the file
120
+
121
+ When selecting a value for the name of a block or an option, the following precedence is used (from
122
+ low to high):
123
+
124
+ * global defaults set via the `default` key of the meta information `blocks`
125
+ * block defaults set via the meta information `blocks`
126
+ * the `--- line` options
127
+
128
+ As stated above, the "option" `name` is special insofar that when it is not set, an automatic name
129
+ gets generated.
@@ -0,0 +1,78 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module Webgen
4
+
5
+ # A blackboard object provides two features for inter-object communication:
6
+ #
7
+ # * *services*: An object can add a service to the blackboard which can be called by any other
8
+ # object by just specifing the service name. Therefore it is easy to change the underlying
9
+ # implementation of the service and there are no hard dependencies on specific class or method
10
+ # names.
11
+ #
12
+ # * *listeners*: Objects may register themselves for specific messsage names and get notified when
13
+ # such a message gets dispatched.
14
+ #
15
+ # For a list of all available services and messages have a look at the main Webgen documentation
16
+ # page.
17
+ class Blackboard
18
+
19
+ # Create a new Blackboard object.
20
+ def initialize
21
+ @listener = {}
22
+ @services = {}
23
+ end
24
+
25
+ # Add the +callable_object+ or the given block as listener for the messages +msg_names+ (one
26
+ # message name or an array of message names).
27
+ def add_listener(msg_names = nil, callable_object = nil, &block)
28
+ callable_object = callable_object || block
29
+ if !callable_object.nil?
30
+ raise ArgumentError, "The listener needs to respond to 'call'" unless callable_object.respond_to?(:call)
31
+ [msg_names].flatten.compact.each {|name| (@listener[name] ||= []) << callable_object}
32
+ else
33
+ raise ArgumentError, "You have to provide a callback object or a block"
34
+ end
35
+ end
36
+
37
+ # Remove the given object from the dispatcher queues of the message names specified in
38
+ # +msg_names+.
39
+ def del_listener(msg_names, callable_object)
40
+ [msg_names].flatten.each {|name| @listener[name].delete(callable_object) if @listener[name]}
41
+ end
42
+
43
+ # Dispatch the message +msg_name+ to all listeners for this message, passing the given
44
+ # arguments.
45
+ def dispatch_msg(msg_name, *args)
46
+ return unless @listener[msg_name]
47
+ @listener[msg_name].each {|obj| obj.call(*args)}
48
+ end
49
+
50
+ # Add a service named +service_name+ provided by the +callable_object+ or a block to the
51
+ # blackboard.
52
+ def add_service(service_name, callable_object = nil, &block)
53
+ callable_object = callable_object || block
54
+ if @services.has_key?(service_name)
55
+ raise "The service name '#{service_name}' is already taken"
56
+ else
57
+ raise ArgumentError, "An object providing a service needs to respond to 'call'" unless callable_object.respond_to?(:call)
58
+ @services[service_name] = callable_object
59
+ end
60
+ end
61
+
62
+ # Delete the service +service_name+.
63
+ def del_service(service_name)
64
+ @services.delete(service_name)
65
+ end
66
+
67
+ # Invoke the service called +service_name+ with the given arguments.
68
+ def invoke(service_name, *args, &block)
69
+ if @services.has_key?(service_name)
70
+ @services[service_name].call(*args, &block)
71
+ else
72
+ raise ArgumentError, "No such service named '#{service_name}' available"
73
+ end
74
+ end
75
+
76
+ end
77
+
78
+ end
@@ -0,0 +1,87 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'set'
4
+ require 'facets/kernel/constant'
5
+
6
+ module Webgen
7
+
8
+ # A cache object provides access to various caches to speed up rendering of a website:
9
+ #
10
+ # [permanent] The permanent cache should be used for data that should be available between webgen
11
+ # runs.
12
+ #
13
+ # [volatile] The volatile cache is used for data that can easily be regenerated but might be
14
+ # expensive to do so. This cache is not stored between webgen runs.
15
+ #
16
+ # [standard] The standard cache saves data between webgen runs and returns the cached data (not
17
+ # the newly set data) if it is available. This is useful, for example, to store file
18
+ # modifcation times and check if a file has been changed between runs.
19
+ #
20
+ # The standard cache should be accessed through the <tt>[]</tt> method which returns the correct
21
+ # value and the <tt>[]=</tt> method should be used for setting the new value. However, if you
22
+ # really need to access a particular value of the old or new standard cache, you can use the
23
+ # accessors +old_data+ and +new_data+.
24
+ class Cache
25
+
26
+ # The permanent cache hash.
27
+ attr_reader :permanent
28
+
29
+ # The volatile cache hash.
30
+ attr_reader :volatile
31
+
32
+ # The cache data stored in the previous webgen run.
33
+ attr_reader :old_data
34
+
35
+ # The cache data stored in the current webgen run.
36
+ attr_reader :new_data
37
+
38
+ # Create a new cache object.
39
+ def initialize()
40
+ @old_data = {}
41
+ @new_data = {}
42
+ @volatile = {}
43
+ @permanent = {:classes => []}
44
+ end
45
+
46
+ # Return the cached data (or, if it is not available, the new data) identified by +key+ from the
47
+ # standard cache.
48
+ def [](key)
49
+ if @old_data.has_key?(key)
50
+ @old_data[key]
51
+ else
52
+ @new_data[key]
53
+ end
54
+ end
55
+
56
+ # Store +value+ identified by +key+ in the standard cache.
57
+ def []=(key, value)
58
+ @new_data[key] = value
59
+ end
60
+
61
+ # Restore the caches from +data+ and recreate all cached instances (see #instance).
62
+ def restore(data)
63
+ @old_data, @permanent = *data
64
+ @permanent[:classes].each {|klass| instance(klass)}
65
+ end
66
+
67
+ # Return all caches that should be available between webgen runs.
68
+ def dump
69
+ [@old_data.merge(@new_data), @permanent]
70
+ end
71
+
72
+ # Reset the volatile cache.
73
+ def reset_volatile_cache
74
+ @volatile = {:classes => @volatile[:classes]}
75
+ end
76
+
77
+ # Return the unique instance of the class +name+. This method should be used when it is
78
+ # essential that webgen uses only one object of a class or when an object should automatically
79
+ # be recreated upon cache restoration (see #restore).
80
+ def instance(name)
81
+ @permanent[:classes] << name unless @permanent[:classes].include?(name)
82
+ (@volatile[:classes] ||= {})[name] ||= constant(name).new
83
+ end
84
+
85
+ end
86
+
87
+ end
data/lib/webgen/cli.rb ADDED
@@ -0,0 +1,124 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'cmdparse'
4
+ require 'webgen/website'
5
+ require 'webgen/version'
6
+
7
+ module Webgen
8
+
9
+ # Namespace for all classes that act as CLI commands.
10
+ #
11
+ # == Implementing a CLI command
12
+ #
13
+ # Each CLI command class needs to be put into this module and has to end with +Command+, otherwise
14
+ # it is not used. A CLI command is an extension that can be invoked from the webgen command and
15
+ # thus needs to be derived from CmdParse::Command. For detailed information on this class and the
16
+ # whole cmdparse package have a look at http://cmdparse.rubyforge.org!
17
+ #
18
+ # == Sample CLI command
19
+ #
20
+ # Here is a sample CLI command extension:
21
+ #
22
+ # require 'webgen/cli'
23
+ #
24
+ # class Webgen::CLI::SampleCommand < CmdParse::Command
25
+ #
26
+ # def initialize
27
+ # super('sample', false)
28
+ # self.short_desc = "This sample command just outputs its parameters"
29
+ # self.description = Utils.format("Uses the global verbosity level and outputs additional " +
30
+ # "information when the level is set to verbose!")
31
+ # @username = nil
32
+ # self.options = CmdParse::OptionParserWrapper.new do |opts|
33
+ # opts.separator "Options:"
34
+ # opts.on('-u', '--user USER', String,
35
+ # 'Specify an additional user name to output') {|@username|}
36
+ # end
37
+ # end
38
+ #
39
+ # def execute(args)
40
+ # if args.length == 0
41
+ # raise OptionParser::MissingArgument.new('ARG1 [ARG2 ...]')
42
+ # else
43
+ # puts "Command line arguments:"
44
+ # args.each {|arg| puts arg}
45
+ # if commandparser.verbosity == :verbose
46
+ # puts "Yeah, some additional information is always cool!"
47
+ # end
48
+ # puts "The entered username: #{@username}" if @username
49
+ # end
50
+ # end
51
+ #
52
+ # end
53
+ #
54
+ # Note the use of Utils.format in the initialize method so that the long text gets wrapped
55
+ # correctly! The Utils class provides some other useful methods, too!
56
+ #
57
+ # For information about which attributes are available on the webgen command parser instance have
58
+ # a look at Webgen::CLI::CommandParser!
59
+ module CLI
60
+
61
+ autoload :RunCommand, 'webgen/cli/run_command'
62
+ autoload :CreateCommand, 'webgen/cli/create_command'
63
+ autoload :WebguiCommand, 'webgen/cli/webgui_command'
64
+ autoload :ApplyCommand, 'webgen/cli/apply_command'
65
+
66
+ autoload :Utils, 'webgen/cli/utils'
67
+
68
+
69
+ # This is the command parser class used for handling the webgen command line interface. After
70
+ # creating an instance, the inherited #parse method can be used for parsing the command line
71
+ # arguments and executing the requested command.
72
+ class CommandParser < CmdParse::CommandParser
73
+
74
+ # The website directory. Default: the current working directory.
75
+ attr_reader :directory
76
+
77
+ # The verbosity level. Default: <tt>:normal</tt>
78
+ attr_reader :verbosity
79
+
80
+ # The log level. Default: <tt>Logger::WARN</tt>
81
+ attr_reader :log_level
82
+
83
+ # Create a new CommandParser class. The default webgen website (if not specified via the
84
+ # <tt>-d</tt> option) is taken from the environment variable +WEBGEN_WEBSITE+ or, if it is not
85
+ # set or empty, the current working directory.
86
+ def initialize # :nodoc:
87
+ super(true)
88
+ @directory = (ENV['WEBGEN_WEBSITE'].to_s.empty? ? Dir.pwd : ENV['WEBGEN_WEBSITE'])
89
+ @verbosity = :normal
90
+ @log_level = ::Logger::WARN
91
+ @log_filter = nil
92
+
93
+ self.program_name = "webgen"
94
+ self.program_version = Webgen::VERSION
95
+ self.options = CmdParse::OptionParserWrapper.new do |opts|
96
+ opts.separator "Global options:"
97
+ opts.on("--directory DIR", "-d", String, "The website directory (default: the current directory)") {|p| @directory = p}
98
+ opts.on("--verbose", "-v", "Print more output") { @verbosity = :verbose }
99
+ opts.on("--quiet", "-q", "No output") { @verbosity = :quiet }
100
+ opts.on("--log-level LEVEL", "-l", Integer, "The logging level (0..debug, 3..error)") {|p| @log_level = p}
101
+ opts.on("--log-filter", "-f", Regexp, 'Filter for logging events') {|p| @log_filter = p}
102
+ end
103
+ self.add_command(CmdParse::HelpCommand.new)
104
+ self.add_command(CmdParse::VersionCommand.new)
105
+ Webgen::CLI.constants.select {|c| c =~ /.+Command$/ }.each do |c|
106
+ self.add_command(Webgen::CLI.const_get(c).new, (c.to_s == 'RunCommand' ? true : false))
107
+ end
108
+ end
109
+
110
+ # Utility method for sub-commands to create the correct Webgen::Website object.
111
+ def create_website
112
+ website = Webgen::Website.new(@directory) do |config|
113
+ config['logger.mask'] = @log_filter
114
+ end
115
+ website.logger.level = @log_level
116
+ website.logger.verbosity = @verbosity
117
+ website
118
+ end
119
+
120
+ end
121
+
122
+ end
123
+
124
+ end
@@ -0,0 +1,64 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'webgen/cli'
4
+ require 'webgen/websitemanager'
5
+
6
+ module Webgen::CLI
7
+
8
+ # The CLI command for applying a style to a webgen website.
9
+ class ApplyCommand < CmdParse::Command
10
+
11
+ def initialize #:nodoc:
12
+ super('apply', false)
13
+ @force = false
14
+
15
+ self.short_desc = 'Apply a website style to an existing webgen website'
16
+ self.options = CmdParse::OptionParserWrapper.new do |opts|
17
+ opts.separator "Options:"
18
+ opts.on('-f', '--[no-]force', 'Specifies whether files should be overwritten (default: no)') do |val|
19
+ @force = val
20
+ end
21
+ opts.separator ""
22
+ opts.separator "Arguments:"
23
+ opts.separator opts.summary_indent + "STYLE: the style the should be applied to the website"
24
+ end
25
+ end
26
+
27
+ def usage # :nodoc:
28
+ "Usage: #{commandparser.program_name} [global options] apply [options] STYLE"
29
+ end
30
+
31
+ def show_help # :nodoc:
32
+ super
33
+ wm = Webgen::WebsiteManager.new(commandparser.directory)
34
+
35
+ puts
36
+ puts "Available styles:"
37
+ puts Utils.headline('Styles')
38
+ wm.styles.sort.each {|name, entry| Utils.hash_output(name, entry.instance_eval { @table }) }
39
+ end
40
+
41
+ # Apply the style specified in <tt>args[0]</tt> to the webgen website.
42
+ def execute(args)
43
+ wm = Webgen::WebsiteManager.new(commandparser.directory)
44
+ if !File.directory?(commandparser.directory)
45
+ puts "You need to specify a valid webgen website directory!"
46
+ elsif args.length == 0
47
+ raise OptionParser::MissingArgument.new('STYLE')
48
+ elsif !wm.styles.has_key?(args[0])
49
+ raise OptionParser::InvalidArgument.new("#{args[0]} is not a valid style")
50
+ else
51
+ puts "The following files in the website directory will be created or overwritten:"
52
+ puts wm.styles[args[0]].paths.to_a.sort.join("\n")
53
+ continue = @force
54
+ if !continue
55
+ print "Procede? (yes/no): "
56
+ continue = ($stdin.readline =~ /y(es)?/)
57
+ end
58
+ wm.apply_style(args[0]) if continue
59
+ end
60
+ end
61
+
62
+ end
63
+
64
+ end