gettalong-webgen 0.5.4.20080929

Sign up to get free protection for your applications and to get access to all the features.
Files changed (290) hide show
  1. data/AUTHORS +5 -0
  2. data/COPYING +10 -0
  3. data/GPL +340 -0
  4. data/Rakefile +324 -0
  5. data/THANKS +17 -0
  6. data/bin/webgen +10 -0
  7. data/data/webgen/resources.yaml +3 -0
  8. data/data/webgen/webgui/controller/main.rb +129 -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 +6 -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 +61 -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 +66 -0
  117. data/doc/contentprocessor/builder.page +80 -0
  118. data/doc/contentprocessor/erb.page +56 -0
  119. data/doc/contentprocessor/erubis.page +46 -0
  120. data/doc/contentprocessor/haml.page +47 -0
  121. data/doc/contentprocessor/maruku.page +41 -0
  122. data/doc/contentprocessor/rdiscount.page +37 -0
  123. data/doc/contentprocessor/rdoc.page +36 -0
  124. data/doc/contentprocessor/redcloth.page +39 -0
  125. data/doc/contentprocessor/sass.page +31 -0
  126. data/doc/contentprocessor/tags.page +73 -0
  127. data/doc/extensions.metainfo +29 -0
  128. data/doc/extensions.page +16 -0
  129. data/doc/extensions.template +17 -0
  130. data/doc/faq.page +214 -0
  131. data/doc/getting_started.page +134 -0
  132. data/doc/index.page +65 -0
  133. data/doc/manual.page +532 -0
  134. data/doc/reference_configuration.page +646 -0
  135. data/doc/reference_metainfo.page +213 -0
  136. data/doc/sourcehandler.template +21 -0
  137. data/doc/sourcehandler/copy.page +19 -0
  138. data/doc/sourcehandler/directory.page +27 -0
  139. data/doc/sourcehandler/feed.page +82 -0
  140. data/doc/sourcehandler/metainfo.page +41 -0
  141. data/doc/sourcehandler/page.page +30 -0
  142. data/doc/sourcehandler/sitemap.page +46 -0
  143. data/doc/sourcehandler/template.page +45 -0
  144. data/doc/sourcehandler/virtual.page +49 -0
  145. data/doc/tag.template +25 -0
  146. data/doc/tag/breadcrumbtrail.page +40 -0
  147. data/doc/tag/coderay.page +49 -0
  148. data/doc/tag/date.page +31 -0
  149. data/doc/tag/executecommand.page +26 -0
  150. data/doc/tag/includefile.page +32 -0
  151. data/doc/tag/langbar.page +22 -0
  152. data/doc/tag/menu.page +92 -0
  153. data/doc/tag/metainfo.page +29 -0
  154. data/doc/tag/relocatable.page +38 -0
  155. data/doc/tag/sitemap.page +31 -0
  156. data/doc/upgrading.page +139 -0
  157. data/doc/webgen_page_format.page +128 -0
  158. data/lib/webgen/blackboard.rb +73 -0
  159. data/lib/webgen/cache.rb +85 -0
  160. data/lib/webgen/cli.rb +118 -0
  161. data/lib/webgen/cli/create_command.rb +64 -0
  162. data/lib/webgen/cli/run_command.rb +20 -0
  163. data/lib/webgen/cli/utils.rb +86 -0
  164. data/lib/webgen/cli/webgui_command.rb +49 -0
  165. data/lib/webgen/common.rb +10 -0
  166. data/lib/webgen/common/sitemap.rb +76 -0
  167. data/lib/webgen/configuration.rb +147 -0
  168. data/lib/webgen/contentprocessor.rb +96 -0
  169. data/lib/webgen/contentprocessor/blocks.rb +46 -0
  170. data/lib/webgen/contentprocessor/builder.rb +26 -0
  171. data/lib/webgen/contentprocessor/context.rb +90 -0
  172. data/lib/webgen/contentprocessor/erb.rb +24 -0
  173. data/lib/webgen/contentprocessor/erubis.rb +40 -0
  174. data/lib/webgen/contentprocessor/haml.rb +25 -0
  175. data/lib/webgen/contentprocessor/maruku.rb +18 -0
  176. data/lib/webgen/contentprocessor/rdiscount.rb +15 -0
  177. data/lib/webgen/contentprocessor/rdoc.rb +17 -0
  178. data/lib/webgen/contentprocessor/redcloth.rb +15 -0
  179. data/lib/webgen/contentprocessor/sass.rb +18 -0
  180. data/lib/webgen/contentprocessor/tags.rb +134 -0
  181. data/lib/webgen/coreext.rb +10 -0
  182. data/lib/webgen/default_config.rb +198 -0
  183. data/lib/webgen/languages.rb +578 -0
  184. data/lib/webgen/loggable.rb +23 -0
  185. data/lib/webgen/logger.rb +78 -0
  186. data/lib/webgen/node.rb +347 -0
  187. data/lib/webgen/output.rb +37 -0
  188. data/lib/webgen/output/filesystem.rb +67 -0
  189. data/lib/webgen/page.rb +133 -0
  190. data/lib/webgen/path.rb +182 -0
  191. data/lib/webgen/source.rb +24 -0
  192. data/lib/webgen/source/filesystem.rb +58 -0
  193. data/lib/webgen/source/resource.rb +42 -0
  194. data/lib/webgen/source/stacked.rb +53 -0
  195. data/lib/webgen/sourcehandler.rb +202 -0
  196. data/lib/webgen/sourcehandler/base.rb +211 -0
  197. data/lib/webgen/sourcehandler/copy.rb +41 -0
  198. data/lib/webgen/sourcehandler/directory.rb +31 -0
  199. data/lib/webgen/sourcehandler/feed.rb +121 -0
  200. data/lib/webgen/sourcehandler/fragment.rb +71 -0
  201. data/lib/webgen/sourcehandler/metainfo.rb +117 -0
  202. data/lib/webgen/sourcehandler/page.rb +77 -0
  203. data/lib/webgen/sourcehandler/sitemap.rb +60 -0
  204. data/lib/webgen/sourcehandler/template.rb +68 -0
  205. data/lib/webgen/sourcehandler/virtual.rb +75 -0
  206. data/lib/webgen/tag.rb +23 -0
  207. data/lib/webgen/tag/base.rb +162 -0
  208. data/lib/webgen/tag/breadcrumbtrail.rb +71 -0
  209. data/lib/webgen/tag/coderay.rb +32 -0
  210. data/lib/webgen/tag/date.rb +18 -0
  211. data/lib/webgen/tag/executecommand.rb +29 -0
  212. data/lib/webgen/tag/includefile.rb +42 -0
  213. data/lib/webgen/tag/langbar.rb +52 -0
  214. data/lib/webgen/tag/menu.rb +186 -0
  215. data/lib/webgen/tag/metainfo.rb +25 -0
  216. data/lib/webgen/tag/relocatable.rb +53 -0
  217. data/lib/webgen/tag/sitemap.rb +42 -0
  218. data/lib/webgen/tree.rb +80 -0
  219. data/lib/webgen/version.rb +6 -0
  220. data/lib/webgen/webgentask.rb +148 -0
  221. data/lib/webgen/website.rb +214 -0
  222. data/lib/webgen/websiteaccess.rb +29 -0
  223. data/lib/webgen/websitemanager.rb +125 -0
  224. data/man/man1/webgen.1 +67 -0
  225. data/misc/default.css +360 -0
  226. data/misc/default.template +75 -0
  227. data/misc/htmldoc.metainfo +25 -0
  228. data/misc/htmldoc.virtual +5 -0
  229. data/misc/images/arrow.gif +0 -0
  230. data/misc/images/error.gif +0 -0
  231. data/misc/images/exclamation.gif +0 -0
  232. data/misc/images/headerbg.jpg +0 -0
  233. data/misc/images/information.gif +0 -0
  234. data/misc/images/quote.gif +0 -0
  235. data/setup.rb +1585 -0
  236. data/test/helper.rb +41 -0
  237. data/test/test_blackboard.rb +58 -0
  238. data/test/test_cache.rb +57 -0
  239. data/test/test_common_sitemap.rb +56 -0
  240. data/test/test_configuration.rb +66 -0
  241. data/test/test_contentprocessor.rb +31 -0
  242. data/test/test_contentprocessor_blocks.rb +34 -0
  243. data/test/test_contentprocessor_builder.rb +19 -0
  244. data/test/test_contentprocessor_context.rb +38 -0
  245. data/test/test_contentprocessor_erb.rb +20 -0
  246. data/test/test_contentprocessor_erubis.rb +47 -0
  247. data/test/test_contentprocessor_haml.rb +20 -0
  248. data/test/test_contentprocessor_maruku.rb +27 -0
  249. data/test/test_contentprocessor_rdiscount.rb +15 -0
  250. data/test/test_contentprocessor_rdoc.rb +16 -0
  251. data/test/test_contentprocessor_redcloth.rb +12 -0
  252. data/test/test_contentprocessor_sass.rb +20 -0
  253. data/test/test_contentprocessor_tags.rb +97 -0
  254. data/test/test_languages.rb +53 -0
  255. data/test/test_loggable.rb +30 -0
  256. data/test/test_logger.rb +73 -0
  257. data/test/test_node.rb +339 -0
  258. data/test/test_output_filesystem.rb +58 -0
  259. data/test/test_page.rb +203 -0
  260. data/test/test_path.rb +131 -0
  261. data/test/test_source_filesystem.rb +59 -0
  262. data/test/test_source_resource.rb +26 -0
  263. data/test/test_source_stacked.rb +34 -0
  264. data/test/test_sourcehandler_base.rb +92 -0
  265. data/test/test_sourcehandler_copy.rb +45 -0
  266. data/test/test_sourcehandler_directory.rb +25 -0
  267. data/test/test_sourcehandler_feed.rb +74 -0
  268. data/test/test_sourcehandler_fragment.rb +67 -0
  269. data/test/test_sourcehandler_metainfo.rb +93 -0
  270. data/test/test_sourcehandler_page.rb +70 -0
  271. data/test/test_sourcehandler_sitemap.rb +47 -0
  272. data/test/test_sourcehandler_template.rb +63 -0
  273. data/test/test_sourcehandler_virtual.rb +56 -0
  274. data/test/test_tag_base.rb +82 -0
  275. data/test/test_tag_breadcrumbtrail.rb +89 -0
  276. data/test/test_tag_coderay.rb +30 -0
  277. data/test/test_tag_date.rb +16 -0
  278. data/test/test_tag_executecommand.rb +39 -0
  279. data/test/test_tag_includefile.rb +48 -0
  280. data/test/test_tag_langbar.rb +60 -0
  281. data/test/test_tag_menu.rb +195 -0
  282. data/test/test_tag_metainfo.rb +17 -0
  283. data/test/test_tag_relocatable.rb +57 -0
  284. data/test/test_tag_sitemap.rb +44 -0
  285. data/test/test_tree.rb +69 -0
  286. data/test/test_webgentask.rb +21 -0
  287. data/test/test_website.rb +96 -0
  288. data/test/test_websiteaccess.rb +23 -0
  289. data/test/test_websitemanager.rb +68 -0
  290. metadata +575 -0
data/lib/webgen/cli.rb ADDED
@@ -0,0 +1,118 @@
1
+ require 'cmdparse'
2
+ require 'webgen/website'
3
+ require 'webgen/version'
4
+
5
+ module Webgen
6
+
7
+ # Namespace for all classes that act as CLI commands.
8
+ #
9
+ # = Implementing a CLI command
10
+ #
11
+ # Each CLI command class needs to be put into this module and has to end with +Command+, otherwise
12
+ # it is not used. A CLI command is an extension that can be invoked from the webgen command and
13
+ # thus needs to be derived from CmdParse::Command. For detailed information on this class and the
14
+ # whole cmdparse package have a look at http://cmdparse.rubyforge.org!
15
+ #
16
+ # = Sample CLI command
17
+ #
18
+ # Here is a sample CLI command extension:
19
+ #
20
+ # require 'webgen/cli'
21
+ #
22
+ # class Webgen::CLI::SampleCommand < CmdParse::Command
23
+ #
24
+ # def initialize
25
+ # super('sample', false)
26
+ # self.short_desc = "This sample command just outputs its parameters"
27
+ # self.description = Utils.format("Uses the global verbosity level and outputs additional " +
28
+ # "information when the level is set to verbose!")
29
+ # @username = nil
30
+ # self.options = CmdParse::OptionParserWrapper.new do |opts|
31
+ # opts.separator "Options:"
32
+ # opts.on('-u', '--user USER', String,
33
+ # 'Specify an additional user name to output') {|@username|}
34
+ # end
35
+ # end
36
+ #
37
+ # def execute(args)
38
+ # if args.length == 0
39
+ # raise OptionParser::MissingArgument.new('ARG1 [ARG2 ...]')
40
+ # else
41
+ # puts "Command line arguments:"
42
+ # args.each {|arg| puts arg}
43
+ # if commandparser.verbosity == :verbose
44
+ # puts "Yeah, some additional information is always cool!"
45
+ # end
46
+ # puts "The entered username: #{@username}" if @username
47
+ # end
48
+ # end
49
+ #
50
+ # end
51
+ #
52
+ # Note the use of Utils.format in the initialize method so that the long text gets wrapped
53
+ # correctly! The Utils class provides some other useful methods, too!
54
+ #
55
+ # For information about which attributes are available on the webgen command parser instance have
56
+ # a look at Webgen::CLI::CommandParser!
57
+ module CLI
58
+
59
+ autoload :RunCommand, 'webgen/cli/run_command'
60
+ autoload :CreateCommand, 'webgen/cli/create_command'
61
+ autoload :WebguiCommand, 'webgen/cli/webgui_command'
62
+
63
+ autoload :Utils, 'webgen/cli/utils'
64
+
65
+
66
+ # This is the command parser class used for handling the webgen command line interface. After
67
+ # creating an instance, the inherited #parse method can be used for parsing the command line
68
+ # arguments and executing the requested command.
69
+ class CommandParser < CmdParse::CommandParser
70
+
71
+ # The website directory. Default: the current working directory.
72
+ attr_reader :directory
73
+
74
+ # The verbosity level. Default: <tt>:normal</tt>
75
+ attr_reader :verbosity
76
+
77
+ # The log level. Default: <tt>Logger::WARN</tt>
78
+ attr_reader :log_level
79
+
80
+ def initialize # :nodoc:
81
+ super(true)
82
+ @directory = Dir.pwd
83
+ @verbosity = :normal
84
+ @log_level = ::Logger::WARN
85
+ @log_filter = nil
86
+
87
+ self.program_name = "webgen"
88
+ self.program_version = Webgen::VERSION
89
+ self.options = CmdParse::OptionParserWrapper.new do |opts|
90
+ opts.separator "Global options:"
91
+ opts.on("--directory DIR", "-d", String, "The website directory (default: the current directory)") {|@directory|}
92
+ opts.on("--verbose", "-v", "Print more output") { @verbosity = :verbose }
93
+ opts.on("--quiet", "-q", "No output") { @verbosity = :quiet }
94
+ opts.on("--log-level LEVEL", "-l", Integer, "The logging level (0..debug, 3..error)") {|@log_level|}
95
+ opts.on("--log-filter", "-f", Regexp, 'Filter for logging events') {|@log_filter|}
96
+ end
97
+ self.add_command(CmdParse::HelpCommand.new)
98
+ self.add_command(CmdParse::VersionCommand.new)
99
+ Webgen::CLI.constants.select {|c| c =~ /.+Command$/ }.each do |c|
100
+ self.add_command(Webgen::CLI.const_get(c).new, (c == 'RunCommand' ? true : false))
101
+ end
102
+ end
103
+
104
+ # Utility method for sub-commands to create the correct Webgen::Website object.
105
+ def create_website
106
+ website = Webgen::Website.new(@directory) do |config|
107
+ config['logger.mask'] = @log_filter
108
+ end
109
+ website.logger.level = @log_level
110
+ website.logger.verbosity = @verbosity
111
+ website
112
+ end
113
+
114
+ end
115
+
116
+ end
117
+
118
+ end
@@ -0,0 +1,64 @@
1
+ require 'webgen/cli'
2
+ require 'webgen/websitemanager'
3
+
4
+ module Webgen::CLI
5
+
6
+ # The CLI command for creating a webgen website.
7
+ class CreateCommand < CmdParse::Command
8
+
9
+ def initialize #:nodoc:
10
+ super('create', false)
11
+ self.description = Utils.format("If the verbosity level is set to verbose, the created files are listed.")
12
+ @template = 'default'
13
+ @style = 'andreas07'
14
+
15
+ self.short_desc = 'Create a basic webgen website with selectable template/style'
16
+ self.options = CmdParse::OptionParserWrapper.new do |opts|
17
+ opts.separator "Options:"
18
+ opts.on('-t', '--template TEMPLATE', String, 'A website template or "none" (default: default)') do |val|
19
+ @template = (val == 'none' ? nil : val)
20
+ end
21
+ opts.on('-s', '--style STYLE', String, 'A website style or "none" (default: andreas07)') do |val|
22
+ @style = (val == 'none' ? nil : val)
23
+ end
24
+ opts.separator ""
25
+ opts.separator "Arguments:"
26
+ opts.separator opts.summary_indent + "DIR: the directory in which the website should be created"
27
+ end
28
+ end
29
+
30
+ def usage # :nodoc:
31
+ "Usage: #{commandparser.program_name} [global options] create [options] DIR"
32
+ end
33
+
34
+ def show_help # :nodoc:
35
+ super
36
+ wm = Webgen::WebsiteManager.new(commandparser.directory)
37
+
38
+ puts
39
+ puts "Available templates and styles:"
40
+ puts Utils.headline('Templates')
41
+ wm.templates.sort.each {|name, entry| Utils.hash_output(name, entry.instance_eval { @table }) }
42
+ puts Utils.headline('Styles')
43
+ wm.styles.select {|k,v| k =~ /^website-|[^-]+/ }.sort.each {|name, entry| Utils.hash_output(name, entry.instance_eval { @table }) }
44
+ end
45
+
46
+ # Create a webgen website in the directory <tt>args[0]</tt>.
47
+ def execute(args)
48
+ if args.length == 0
49
+ raise OptionParser::MissingArgument.new('DIR')
50
+ else
51
+ wm = Webgen::WebsiteManager.new(args[0])
52
+ paths = wm.create_website
53
+ paths += wm.apply_template(@template) if @template
54
+ paths += wm.apply_style(@style) if @style
55
+ if commandparser.verbosity == :verbose
56
+ puts "The following files were created in the directory #{args[0]}:"
57
+ puts paths.sort.collect {|f| "- " + f }.join("\n")
58
+ end
59
+ end
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,20 @@
1
+ require 'webgen/cli'
2
+
3
+ module Webgen::CLI
4
+
5
+ # The CLI command for rendering a webgen website.
6
+ class RunCommand < CmdParse::Command
7
+
8
+ def initialize # :nodoc:
9
+ super('render', false)
10
+ self.short_desc = 'Render the webgen website'
11
+ end
12
+
13
+ # Render the website.
14
+ def execute(args)
15
+ commandparser.create_website.render
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,86 @@
1
+ require 'facets/ansicode'
2
+ require 'rbconfig'
3
+
4
+ ANSICode.define_ansicolor_method(:lred, '1;31')
5
+ ANSICode.define_ansicolor_method(:lblue, '1;34')
6
+
7
+ module Webgen::CLI
8
+
9
+ # Provides methods for other CLI classes for formatting text in a consistent manner.
10
+ class Utils
11
+
12
+ USE_ANSI_COLORS = !Config::CONFIG['arch'].include?('mswin32')
13
+ DEFAULT_WIDTH = if Config::CONFIG['arch'].include?('mswin32')
14
+ 72
15
+ else
16
+ ((size = %x{stty size 2>/dev/null}).length > 0 ? size.split.last.to_i : 72) rescue 72
17
+ end
18
+
19
+ # Used for dynamically formatting the text (setting color, bold face, ...).
20
+ def self.method_missing(id, text = nil)
21
+ if USE_ANSI_COLORS && ANSICode.respond_to?(id)
22
+ ANSICode.send(id, text.to_s)
23
+ else
24
+ text.to_s
25
+ end
26
+ end
27
+
28
+ # Return an array of lines which represents the text in +content+ formatted sothat no line is
29
+ # longer than +width+ characters. The +indent+ parameter specifies the amount of spaces
30
+ # prepended to each line. If +first_line_indented+ is +true+, then the first line is indented.
31
+ def self.format(content, indent = 0, first_line_indented = false, width = DEFAULT_WIDTH)
32
+ content = (content || '').dup
33
+ length = width - indent
34
+
35
+ paragraphs = content.split(/\n\n/)
36
+ if (0..1) === paragraphs.length
37
+ pattern = /^(.{0,#{length}})[ \n]/m
38
+ lines = []
39
+ while content.length > length
40
+ if content =~ pattern
41
+ str = $1
42
+ len = $&.length
43
+ else
44
+ str = content[0, length]
45
+ len = length
46
+ end
47
+ lines << (lines.empty? && !first_line_indented ? '' : ' '*indent) + str.gsub(/\n/, ' ')
48
+ content.slice!(0, len)
49
+ end
50
+ lines << (lines.empty? && !first_line_indented ? '' : ' '*indent) + content.gsub(/\n/, ' ') unless content.strip.empty?
51
+ lines
52
+ else
53
+ ((format(paragraphs.shift, indent, first_line_indented, width) << '') +
54
+ paragraphs.collect {|p| format(p, indent, true, width) << '' }).flatten[0..-2]
55
+ end
56
+ end
57
+
58
+ # Return a headline with the given +text+ and amount of +indent+.
59
+ def self.headline(text, indent = 2)
60
+ ' '*indent + "#{bold(text)}"
61
+ end
62
+
63
+ # Return a section header with the given +text+ formatted in the given +color+ and indented
64
+ # according to +indent+. The whole text is also left justified to the column specified with
65
+ # +ljustlength+.
66
+ def self.section(text, ljustlength = 0, indent = 4, color = :green)
67
+ ' '*indent + "#{send(color, text)}".ljust(ljustlength - indent + send(color).length)
68
+ end
69
+
70
+ # Creates a listing of the key-value pairs of +hash+ under a section called +name+.
71
+ def self.hash_output(name, hash)
72
+ ljust = 20
73
+ puts section('Name', ljust) + "#{lred(name)}"
74
+
75
+ hash.sort_by {|k,v| k.to_s }.each do |name, value|
76
+ next unless value.respond_to?(:to_str)
77
+ desc = format(value.to_str, ljust)
78
+ puts section(name.to_s.capitalize, ljust) + desc.shift
79
+ desc.each {|line| puts line}
80
+ end
81
+ puts
82
+ end
83
+
84
+ end
85
+
86
+ end
@@ -0,0 +1,49 @@
1
+ require 'webgen/cli'
2
+
3
+ module Webgen::CLI
4
+
5
+ # The CLI command for starting the webgen webgui.
6
+ class WebguiCommand < CmdParse::Command
7
+
8
+ def initialize # :nodoc:
9
+ super('webgui', false)
10
+ self.short_desc = 'Starts the webgen webgui'
11
+ end
12
+
13
+ # Render the website.
14
+ def execute(args)
15
+ # some fixes for ramaze-2008.06
16
+ # - fix for Windows bug when win32console is not installed
17
+ # - fix for message displayed on shutdown
18
+ $:.unshift File.join(Webgen.data_dir, 'webgui', 'overrides')
19
+ require 'win32console'
20
+ $:.shift
21
+ require 'ramaze'
22
+ Ramaze::Log.loggers = []
23
+ def Ramaze.shutdown; # :nodoc:
24
+ end
25
+
26
+ acquire Webgen.data_dir/:webgui/:controller/'*'
27
+ Ramaze::Global.setup do |g|
28
+ g.root = Webgen.data_dir/:webgui
29
+ g.public_root = Webgen.data_dir/:webgui/:public
30
+ g.view_root = Webgen.data_dir/:webgui/:view
31
+ g.adapter = :webrick
32
+ g.port = 7000
33
+ end
34
+
35
+ puts 'Starting webgui on http://localhost:7000, press Control-C to stop'
36
+ Thread.new do
37
+ sleep 2
38
+ puts 'Launching web browser'
39
+ require 'launchy'
40
+ Launchy.open('http://localhost:7000')
41
+ end
42
+
43
+ Ramaze.start
44
+ puts 'webgui finished'
45
+ end
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,10 @@
1
+ module Webgen
2
+
3
+ # Namespace for classes that provide common functionality.
4
+ module Common
5
+
6
+ autoload :Sitemap, 'webgen/common/sitemap'
7
+
8
+ end
9
+
10
+ end
@@ -0,0 +1,76 @@
1
+ require 'webgen/tag/menu'
2
+ require 'webgen/websiteaccess'
3
+
4
+ module Webgen::Common
5
+
6
+ # This class provides functionality for creating sitemaps and checking if a sitemap has changed.
7
+ class Sitemap
8
+
9
+ include Webgen::WebsiteAccess
10
+
11
+ def initialize #:nodoc:
12
+ website.blackboard.add_listener(:node_changed?, method(:node_changed?))
13
+ end
14
+
15
+ # Return the sitemap tree as Webgen::Tag::Menu::MenuNode created for the +node+ in the language
16
+ # +lang+ using the provided +options+ which can be any configuration option starting with
17
+ # <tt>common.sitemap</tt>.
18
+ def create_sitemap(node, lang, options)
19
+ @options = options
20
+ tree = recursive_create(nil, node.tree.root, lang).sort!
21
+ @options = nil
22
+ (node.node_info[:common_sitemap] ||= {})[[options.to_a.sort, lang]] = tree.to_lcn_list
23
+ tree
24
+ end
25
+
26
+ #######
27
+ private
28
+ #######
29
+
30
+ # Recursively create the sitemap.
31
+ def recursive_create(parent, node, lang, in_sitemap = true)
32
+ mnode = Webgen::Tag::Menu::MenuNode.new(parent, node)
33
+ node.children.map do |n|
34
+ sub_in_sitemap = ((option('common.sitemap.used_kinds').empty? || option('common.sitemap.used_kinds').include?(n['kind'])) &&
35
+ (option('common.sitemap.any_lang') || n.lang.nil? || n.lang == lang) &&
36
+ (!option('common.sitemap.honor_in_menu') || n['in_menu']) &&
37
+ (parent.nil? || node.routing_node(lang) != n))
38
+ [(!n.children.empty? || sub_in_sitemap ? n : nil), sub_in_sitemap]
39
+ end.each do |n, sub_in_sitemap|
40
+ next if n.nil?
41
+ sub_node = recursive_create(mnode, n, lang, sub_in_sitemap)
42
+ mnode.children << sub_node unless sub_node.nil?
43
+ end
44
+ (mnode.children.empty? && !in_sitemap ? nil : mnode)
45
+ end
46
+
47
+ # Retrieve the configuration option value for +name+. The value is taken from the current
48
+ # configuration options hash if +name+ is specified there or from the website configuration
49
+ # otherwise.
50
+ def option(name)
51
+ (@options && @options.has_key?(name) ? @options[name] : website.config[name])
52
+ end
53
+
54
+ # Check if the sitemaps for +node+ have changed.
55
+ def node_changed?(node)
56
+ return if !node.node_info[:common_sitemap]
57
+
58
+ node.node_info[:common_sitemap].each do |(options, lang), cached_tree|
59
+ @options = options.to_hash
60
+ tree = recursive_create(nil, node.tree.root, lang).sort!.to_lcn_list
61
+ @options = nil
62
+
63
+ if (tree != cached_tree) ||
64
+ (tree.flatten.any? do |alcn|
65
+ (n = node.tree[alcn]) && (r = n.routing_node(lang)) && r.meta_info_changed?
66
+ end)
67
+ node.dirty = true
68
+ break
69
+ end
70
+ end
71
+ end
72
+
73
+
74
+ end
75
+
76
+ end
@@ -0,0 +1,147 @@
1
+ module Webgen
2
+
3
+ # Stores the configuration for a webgen website.
4
+ #
5
+ # Configuration options should be created like this:
6
+ #
7
+ # config.my.new.config 'value', :doc => 'some', :meta => 'info'
8
+ #
9
+ # and later accessed or set using the accessor methods #[] and #[]= or a configuration
10
+ # helper. These helpers are defined in the Helpers module and provide easier access to complex
11
+ # configuration options.
12
+ class Configuration
13
+
14
+ # Helper class for providing an easy method to define configuration options.
15
+ class MethodChain
16
+
17
+ def initialize(config) #:nodoc:
18
+ @config = config
19
+ @name = ''
20
+ end
21
+
22
+ def method_missing(id, *args) #:nodoc:
23
+ @name += (@name.empty? ? '' : '.') + id.id2name.sub(/(!|=)$/,'')
24
+ if args.length > 0
25
+ value = args.shift
26
+ @config.data[@name] = value unless @config.data.has_key?(@name) # value is set only the first time
27
+ @config.meta_info[@name] ||= {}
28
+ @config.meta_info[@name].update(*args) if args.length > 0
29
+ nil
30
+ else
31
+ self
32
+ end
33
+ end
34
+
35
+ end
36
+
37
+ # This module provides methods for setting more complex configuration options. It is mixed into
38
+ # Webgen::Configuration so that its methods can be used. Detailed information on the use of the
39
+ # methods can be found in the "User Manual" in the "Configuration File" section.
40
+ #
41
+ # All public methods defined in this module are available for direct use in the
42
+ # configuration file, e.g. the method named +default_meta_info+ can be used like this:
43
+ #
44
+ # default_meta_info:
45
+ # Webgen::SourceHandler::Page:
46
+ # in_menu : true
47
+ # :action : replace
48
+ #
49
+ # All methods have to take exactly one argument, a Hash.
50
+ #
51
+ # The special key <tt>:action</tt> should be used for specifying how the configuration option
52
+ # should be set:
53
+ #
54
+ # replace:: Replace the configuration option with the new values.
55
+ # modify:: Replace old values with new values and add missing ones (useful for hashes and
56
+ # normally the default value)
57
+ module Helpers
58
+
59
+ # Set the default meta information for source handlers.
60
+ def default_meta_info(args)
61
+ args.each do |sh_name, mi|
62
+ raise ArgumentError, 'Invalid argument for configuration helper default_meta_info' unless mi.kind_of?(Hash)
63
+ action = mi.delete(:action) || 'modify'
64
+ mi_hash = (self['sourcehandler.default_meta_info'][complete_source_handler_name(sh_name)] ||= {})
65
+ case action
66
+ when 'replace' then mi_hash.replace(mi)
67
+ else mi_hash.update(mi)
68
+ end
69
+ end
70
+ end
71
+
72
+
73
+ # Set the path patterns used by source handlers.
74
+ def patterns(args)
75
+ args.each do |sh_name, data|
76
+ pattern_arr = (self['sourcehandler.patterns'][complete_source_handler_name(sh_name)] ||= [])
77
+ case data
78
+ when Array then pattern_arr.replace(data)
79
+ when Hash
80
+ (data['del'] || []).each {|pat| pattern_arr.delete(pat)}
81
+ (data['add'] || []).each {|pat| pattern_arr << pat}
82
+ else
83
+ raise ArgumentError, 'Invalid argument for configuration helper patterns'
84
+ end
85
+ end
86
+ end
87
+
88
+
89
+ # Set the default processing pipeline for a source handler.
90
+ def default_processing_pipeline(args)
91
+ args.each do |sh_name, pipeline|
92
+ raise ArgumentError, 'Invalid argument for configuration helper pipeline' unless pipeline.kind_of?(String)
93
+ mi_hash = (self['sourcehandler.default_meta_info'][complete_source_handler_name(sh_name)] ||= {})
94
+ ((mi_hash['blocks'] ||= {})['default'] ||= {})['pipeline'] = pipeline
95
+ end
96
+ end
97
+
98
+
99
+ # Complete +sh_name+ by checking if a source handler called
100
+ # <tt>Webgen::SourceHandler::SH_NAME</tt> exists.
101
+ def complete_source_handler_name(sh_name)
102
+ (Webgen::SourceHandler.constants.include?(sh_name) ? 'Webgen::SourceHandler::' + sh_name : sh_name)
103
+ end
104
+ private :complete_source_handler_name
105
+
106
+ end
107
+
108
+
109
+ include Helpers
110
+
111
+ # The hash which stores the meta info for the configuration options.
112
+ attr_reader :meta_info
113
+
114
+ # The configuration options hash.
115
+ attr_reader :data
116
+
117
+ # Create a new Configuration object.
118
+ def initialize
119
+ @data = {}
120
+ @meta_info = {}
121
+ end
122
+
123
+ # Return the configuration option +name+.
124
+ def [](name)
125
+ if @data.has_key?(name)
126
+ @data[name]
127
+ else
128
+ raise ArgumentError, "No such configuration option: #{name}"
129
+ end
130
+ end
131
+
132
+ # Set the configuration option +name+ to the provided +value+.
133
+ def []=(name, value)
134
+ if @data.has_key?(name)
135
+ @data[name] = value
136
+ else
137
+ raise ArgumentError, "No such configuration option: #{name}"
138
+ end
139
+ end
140
+
141
+ def method_missing(id, *args) #:nodoc:
142
+ MethodChain.new(self).method_missing(id, *args)
143
+ end
144
+
145
+ end
146
+
147
+ end