gettalong-webgen 0.5.7.20090227 → 0.5.8.20090507

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. data/Rakefile +37 -36
  2. data/data/webgen/resources.yaml +2 -2
  3. data/data/webgen/webgui/app.rb +11 -0
  4. data/data/webgen/webgui/controller/main.rb +30 -26
  5. data/data/webgen/webgui/{view/page.xhtml → layout/default.xhtml} +8 -8
  6. data/data/webgen/webgui/start.rb +9 -0
  7. data/data/webgen/webgui/view/create_website.xhtml +6 -14
  8. data/data/webgen/webgui/view/manage_website.xhtml +2 -2
  9. data/data/webgen/website_bundles/default/README +6 -0
  10. data/data/webgen/website_bundles/default/src/index.page +15 -0
  11. data/data/webgen/{website_styles → website_bundles/style}/1024px/README +0 -0
  12. data/data/webgen/{website_styles → website_bundles/style}/1024px/src/default.css +0 -0
  13. data/data/webgen/{website_styles → website_bundles/style}/1024px/src/default.template +0 -0
  14. data/data/webgen/{website_styles → website_bundles/style}/1024px/src/images/background.gif +0 -0
  15. data/data/webgen/{website_styles → website_bundles/style}/andreas00/README +0 -0
  16. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/default.css +0 -0
  17. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/default.template +0 -0
  18. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/bg.gif +0 -0
  19. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/front.jpg +0 -0
  20. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/menubg.gif +0 -0
  21. data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/menubg2.gif +0 -0
  22. data/data/webgen/{website_styles → website_bundles/style}/andreas01/README +0 -0
  23. data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/default.css +0 -0
  24. data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/default.template +0 -0
  25. data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/images/bg.gif +0 -0
  26. data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/images/front.jpg +0 -0
  27. data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/print.css +0 -0
  28. data/data/webgen/{website_styles → website_bundles/style}/andreas03/README +0 -0
  29. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/default.css +0 -0
  30. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/default.template +0 -0
  31. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/bodybg.png +0 -0
  32. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/contbg.png +0 -0
  33. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/footerbg.png +0 -0
  34. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/gradient1.png +0 -0
  35. data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/gradient2.png +0 -0
  36. data/data/webgen/{website_styles → website_bundles/style}/andreas04/README +0 -0
  37. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/default.css +0 -0
  38. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/default.template +0 -0
  39. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/blinkarrow.gif +0 -0
  40. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/bodybg.png +0 -0
  41. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/contentbg.png +0 -0
  42. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/entrybg.png +0 -0
  43. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/flash.gif +0 -0
  44. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/flash2.gif +0 -0
  45. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/globe.gif +0 -0
  46. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/globebottom.gif +0 -0
  47. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/linkarrow.gif +0 -0
  48. data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/menuhover.png +0 -0
  49. data/data/webgen/{website_styles → website_bundles/style}/andreas05/README +0 -0
  50. data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/default.css +0 -0
  51. data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/default.template +0 -0
  52. data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/images/bodybg.gif +0 -0
  53. data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/images/front.png +0 -0
  54. data/data/webgen/{website_styles → website_bundles/style}/andreas06/README +0 -0
  55. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/default.css +6 -4
  56. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/default.template +2 -2
  57. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/bodybg.gif +0 -0
  58. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/boxbg.gif +0 -0
  59. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/greypx.gif +0 -0
  60. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/header.jpg +0 -0
  61. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/innerbg.gif +0 -0
  62. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/leaves.jpg +0 -0
  63. data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/tabs.gif +0 -0
  64. data/data/webgen/{website_styles → website_bundles/style}/andreas07/README +0 -0
  65. data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/browserfix.css +0 -0
  66. data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/default.css +0 -0
  67. data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/default.template +0 -0
  68. data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/images/bodybg.gif +0 -0
  69. data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/images/sidebarbg.gif +0 -0
  70. data/data/webgen/{website_styles → website_bundles/style}/andreas08/README +0 -0
  71. data/data/webgen/{website_styles → website_bundles/style}/andreas08/src/default.css +0 -0
  72. data/data/webgen/{website_styles → website_bundles/style}/andreas08/src/default.template +0 -0
  73. data/data/webgen/{website_styles → website_bundles/style}/andreas09/README +0 -0
  74. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/default.css +0 -0
  75. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/default.template +0 -0
  76. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-black.jpg +0 -0
  77. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-green.jpg +0 -0
  78. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-orange.jpg +0 -0
  79. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-purple.jpg +0 -0
  80. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-red.jpg +0 -0
  81. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg.jpg +0 -0
  82. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/footerbg.jpg +0 -0
  83. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-black.jpg +0 -0
  84. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-green.jpg +0 -0
  85. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-orange.jpg +0 -0
  86. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-purple.jpg +0 -0
  87. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-red.jpg +0 -0
  88. data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover.jpg +0 -0
  89. data/data/webgen/{website_styles → website_bundles/style}/simple/README +0 -0
  90. data/data/webgen/{website_styles → website_bundles/style}/simple/src/default.css +0 -0
  91. data/data/webgen/{website_styles → website_bundles/style}/simple/src/default.template +0 -0
  92. data/data/webgen/website_skeleton/README +1 -1
  93. data/data/webgen/website_skeleton/config.yaml +5 -4
  94. data/doc/contentprocessor/blocks.page +43 -10
  95. data/doc/contentprocessor/builder.page +1 -1
  96. data/doc/contentprocessor/erb.page +12 -11
  97. data/doc/contentprocessor/redcloth.page +3 -1
  98. data/doc/extensions.page +3 -3
  99. data/doc/faq.page +13 -10
  100. data/doc/getting_started.page +12 -15
  101. data/doc/index.page +7 -1
  102. data/doc/manual.page +78 -27
  103. data/doc/reference_configuration.page +166 -3
  104. data/doc/reference_website_styles.page +28 -0
  105. data/doc/source/filesystem.page +39 -0
  106. data/doc/source/tararchive.page +40 -0
  107. data/doc/tag/tikz.page +2 -1
  108. data/doc/webgen_page_format.page +13 -12
  109. data/doc/website_styles.metainfo +8 -0
  110. data/lib/webgen/blackboard.rb +2 -2
  111. data/lib/webgen/cache.rb +4 -4
  112. data/lib/webgen/cli.rb +29 -16
  113. data/lib/webgen/cli/apply_command.rb +66 -0
  114. data/lib/webgen/cli/create_command.rb +22 -16
  115. data/lib/webgen/cli/utils.rb +23 -0
  116. data/lib/webgen/cli/webgui_command.rb +31 -16
  117. data/lib/webgen/configuration.rb +8 -6
  118. data/lib/webgen/contentprocessor.rb +4 -5
  119. data/lib/webgen/contentprocessor/blocks.rb +2 -0
  120. data/lib/webgen/contentprocessor/builder.rb +6 -3
  121. data/lib/webgen/contentprocessor/erb.rb +6 -3
  122. data/lib/webgen/contentprocessor/erubis.rb +7 -6
  123. data/lib/webgen/contentprocessor/haml.rb +6 -3
  124. data/lib/webgen/contentprocessor/rdoc.rb +0 -1
  125. data/lib/webgen/contentprocessor/redcloth.rb +3 -1
  126. data/lib/webgen/context.rb +73 -0
  127. data/lib/webgen/context/nodes.rb +36 -0
  128. data/lib/webgen/coreext.rb +3 -2
  129. data/lib/webgen/default_config.rb +3 -1
  130. data/lib/webgen/deprecated.rb +53 -0
  131. data/lib/webgen/node.rb +24 -19
  132. data/lib/webgen/output.rb +50 -7
  133. data/lib/webgen/page.rb +45 -36
  134. data/lib/webgen/path.rb +1 -1
  135. data/lib/webgen/source.rb +32 -4
  136. data/lib/webgen/source/resource.rb +3 -3
  137. data/lib/webgen/source/stacked.rb +1 -1
  138. data/lib/webgen/source/tararchive.rb +73 -0
  139. data/lib/webgen/sourcehandler.rb +4 -4
  140. data/lib/webgen/sourcehandler/base.rb +36 -24
  141. data/lib/webgen/sourcehandler/copy.rb +1 -1
  142. data/lib/webgen/sourcehandler/feed.rb +2 -2
  143. data/lib/webgen/sourcehandler/fragment.rb +1 -1
  144. data/lib/webgen/sourcehandler/metainfo.rb +15 -6
  145. data/lib/webgen/sourcehandler/page.rb +9 -5
  146. data/lib/webgen/sourcehandler/virtual.rb +44 -7
  147. data/lib/webgen/tag/base.rb +19 -13
  148. data/lib/webgen/tag/link.rb +1 -0
  149. data/lib/webgen/version.rb +1 -1
  150. data/lib/webgen/webgentask.rb +15 -13
  151. data/lib/webgen/website.rb +42 -11
  152. data/lib/webgen/websiteaccess.rb +1 -1
  153. data/lib/webgen/websitemanager.rb +61 -66
  154. data/man/man1/webgen.1 +4 -0
  155. data/misc/default.css +13 -0
  156. data/misc/default.template +1 -1
  157. data/misc/htmldoc.metainfo +2 -1
  158. data/misc/style.page +33 -0
  159. data/test/test_cli.rb +1 -7
  160. data/test/test_common_sitemap.rb +2 -2
  161. data/test/test_contentprocessor_blocks.rb +14 -1
  162. data/test/test_contentprocessor_builder.rb +3 -1
  163. data/test/test_contentprocessor_erb.rb +3 -2
  164. data/test/test_contentprocessor_erubis.rb +3 -3
  165. data/test/test_contentprocessor_fragments.rb +3 -3
  166. data/test/test_contentprocessor_haml.rb +3 -2
  167. data/test/test_contentprocessor_maruku.rb +3 -3
  168. data/test/test_contentprocessor_rdiscount.rb +1 -1
  169. data/test/test_contentprocessor_rdoc.rb +1 -1
  170. data/test/test_contentprocessor_redcloth.rb +9 -2
  171. data/test/test_contentprocessor_sass.rb +1 -1
  172. data/test/test_contentprocessor_tags.rb +1 -1
  173. data/test/{test_contentprocessor_context.rb → test_context.rb} +9 -7
  174. data/test/test_node.rb +27 -21
  175. data/test/test_page.rb +4 -4
  176. data/test/test_source_tararchive.rb +65 -0
  177. data/test/test_sourcehandler_fragment.rb +1 -1
  178. data/test/test_sourcehandler_memory.rb +6 -6
  179. data/test/test_sourcehandler_metainfo.rb +34 -13
  180. data/test/test_sourcehandler_page.rb +8 -0
  181. data/test/test_sourcehandler_virtual.rb +51 -12
  182. data/test/test_tag_breadcrumbtrail.rb +4 -4
  183. data/test/test_tag_coderay.rb +1 -1
  184. data/test/test_tag_date.rb +1 -1
  185. data/test/test_tag_executecommand.rb +1 -1
  186. data/test/test_tag_includefile.rb +3 -3
  187. data/test/test_tag_langbar.rb +6 -6
  188. data/test/test_tag_link.rb +8 -2
  189. data/test/test_tag_menu.rb +9 -9
  190. data/test/test_tag_metainfo.rb +1 -1
  191. data/test/test_tag_relocatable.rb +1 -1
  192. data/test/test_tag_sitemap.rb +1 -1
  193. data/test/test_tag_tikz.rb +2 -2
  194. data/test/test_website.rb +17 -0
  195. data/test/test_websitemanager.rb +16 -21
  196. metadata +181 -171
  197. data/data/webgen/website_templates/default/README +0 -6
  198. data/data/webgen/website_templates/default/src/index.page +0 -8
  199. data/data/webgen/website_templates/project/README +0 -5
  200. data/data/webgen/website_templates/project/src/about.page +0 -12
  201. data/data/webgen/website_templates/project/src/download.page +0 -15
  202. data/data/webgen/website_templates/project/src/features.page +0 -8
  203. data/data/webgen/website_templates/project/src/index.page +0 -9
  204. data/data/webgen/website_templates/project/src/screenshots.page +0 -18
  205. data/lib/webgen/contentprocessor/context.rb +0 -89
@@ -1,6 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  require 'webgen/cli'
4
+ require 'facets/kernel/silence'
4
5
 
5
6
  module Webgen::CLI
6
7
 
@@ -14,35 +15,49 @@ module Webgen::CLI
14
15
 
15
16
  # Render the website.
16
17
  def execute(args)
17
- # some fixes for ramaze-2008.06
18
- # - fix for Windows bug when win32console is not installed
18
+ # some fixes for ramaze-2009.04
19
+ # - fix for Windows when win32console is not installed
19
20
  # - fix for message displayed on shutdown
21
+ # - fix for warning message
20
22
  $:.unshift File.join(Webgen.data_dir, 'webgui', 'overrides')
21
23
  require 'win32console'
22
24
  $:.shift
23
- require 'ramaze'
24
- Ramaze::Log.loggers = []
25
+ silence_warnings do
26
+ begin
27
+ require 'ramaze/snippets/object/__dir__'
28
+ Object.__send__(:include, Ramaze::CoreExtensions::Object)
29
+ require 'ramaze'
30
+ rescue LoadError
31
+ puts "The Ramaze web framework which is needed for the webgui was not found."
32
+ puts "You can install it via 'gem install ramaze --version 2009.04'"
33
+ return
34
+ end
35
+ end
25
36
  def Ramaze.shutdown; # :nodoc:
26
37
  end
27
38
 
28
- acquire Webgen.data_dir/:webgui/:controller/'*'
29
- Ramaze::Global.setup do |g|
30
- g.root = Webgen.data_dir/:webgui
31
- g.public_root = Webgen.data_dir/:webgui/:public
32
- g.view_root = Webgen.data_dir/:webgui/:view
33
- g.adapter = :webrick
34
- g.port = 7000
39
+ require File.join(Webgen.data_dir, 'webgui', 'app.rb')
40
+ Ramaze::Log.loggers = []
41
+ Ramaze.options[:middleware_compiler]::COMPILED[:dev].middlewares.delete_if do |app, args, block|
42
+ app == Rack::CommonLogger
35
43
  end
36
44
 
37
45
  puts 'Starting webgui on http://localhost:7000, press Control-C to stop'
46
+
38
47
  Thread.new do
39
- sleep 2
40
- puts 'Launching web browser'
41
- require 'launchy'
42
- Launchy.open('http://localhost:7000')
48
+ begin
49
+ require 'launchy'
50
+ sleep 1
51
+ puts 'Launching web browser'
52
+ Launchy.open('http://localhost:7000')
53
+ rescue LoadError
54
+ puts "Can't open browser because the launchy library was not found."
55
+ puts "You can install it via 'gem install launchy'"
56
+ puts "Please open a browser window and enter 'http://localhost:7000' into the address bar!"
57
+ end
43
58
  end
44
59
 
45
- Ramaze.start
60
+ Ramaze.start(:adapter => :webrick, :port => 7000, :file => File.join(Webgen.data_dir, 'webgui', 'app.rb'))
46
61
  puts 'webgui finished'
47
62
  end
48
63
 
@@ -10,9 +10,11 @@ module Webgen
10
10
  #
11
11
  # config.my.new.config 'value', :doc => 'some', :meta => 'info'
12
12
  #
13
- # and later accessed or set using the accessor methods #[] and #[]= or a configuration
14
- # helper. These helpers are defined in the Helpers module and provide easier access to complex
15
- # configuration options.
13
+ # and later accessed or set using the accessor methods #[] and #[]= or a configuration helper.
14
+ # These helpers are defined in the Helpers module and provide easier access to complex
15
+ # configuration options. Also see the {webgen
16
+ # manual}[http://webgen.rubyforge.org/documentation/manual.html#website-configfile] for
17
+ # information about the configuration helpers.
16
18
  class Configuration
17
19
 
18
20
  # Helper class for providing an easy method to define configuration options.
@@ -55,9 +57,9 @@ module Webgen
55
57
  # The special key <tt>:action</tt> should be used for specifying how the configuration option
56
58
  # should be set:
57
59
  #
58
- # replace:: Replace the configuration option with the new values.
59
- # modify:: Replace old values with new values and add missing ones (useful for hashes and
60
- # normally the default value)
60
+ # [replace] Replace the configuration option with the new values.
61
+ # [modify] Replace old values with new values and add missing ones (useful for hashes and
62
+ # normally the default value)
61
63
  module Helpers
62
64
 
63
65
  # Set the default meta information for source handlers.
@@ -4,12 +4,12 @@ module Webgen
4
4
 
5
5
  # Namespace for all content processors.
6
6
  #
7
- # = Implementing a content processor
7
+ # == Implementing a content processor
8
8
  #
9
9
  # Content processors are used to process the content of files, normally of files in Webgen Page
10
10
  # Format. A content processor only needs to respond to one method called +call+ and must not take
11
11
  # any parameters in the +initialize+ method. This method is invoked with a
12
- # Webgen::ContentProcessor::Context object that provides the whole context (especially the content
12
+ # Webgen::Context object that provides the whole context (especially the content
13
13
  # and the node chain) and the method needs to return this object. During processing a content
14
14
  # processor normally changes the content of the context but it does not need to.
15
15
  #
@@ -21,7 +21,7 @@ module Webgen
21
21
  # be a short name without special characters or spaces and the value is the class name, not as
22
22
  # constant but as a string.
23
23
  #
24
- # = Sample Content Processor
24
+ # == Sample Content Processor
25
25
  #
26
26
  # The following sample content processor checks for a meta information +replace_key+ and replaces
27
27
  # strings of the form <tt>replace_key:path/to/node</tt> with a link to the specified node if it is
@@ -55,7 +55,6 @@ module Webgen
55
55
  #
56
56
  module ContentProcessor
57
57
 
58
- autoload :Context, 'webgen/contentprocessor/context'
59
58
  autoload :Tags, 'webgen/contentprocessor/tags'
60
59
  autoload :Blocks, 'webgen/contentprocessor/blocks'
61
60
  autoload :Maruku, 'webgen/contentprocessor/maruku'
@@ -80,7 +79,7 @@ module Webgen
80
79
  klass.nil? ? nil : WebsiteAccess.website.cache.instance(klass)
81
80
  end
82
81
 
83
- # Helper class for accessing content processors in a Webgen::ContentProcessor::Context object.
82
+ # Helper class for accessing content processors in a Webgen::Context object.
84
83
  class AccessHash
85
84
 
86
85
  # Check if a content processor called +name+ exists.
@@ -33,6 +33,8 @@ module Webgen::ContentProcessor
33
33
 
34
34
  if attr['node'] == 'first'
35
35
  used_chain.shift while used_chain.length > 0 && !used_chain.first.node_info[:page].blocks.has_key?(attr['name'])
36
+ elsif attr['node'] == 'current'
37
+ used_chain = context[:chain].dup
36
38
  end
37
39
  block_node = used_chain.first
38
40
 
@@ -6,14 +6,17 @@ module Webgen::ContentProcessor
6
6
  # library.
7
7
  class Builder
8
8
 
9
+ include Deprecated
10
+
9
11
  # Process the content of +context+ which needs to be valid Ruby code. The special variable +xml+
10
12
  # should be used to construct the XML content.
11
13
  def call(context)
12
14
  require 'builder'
13
15
 
14
- node = context.content_node
15
- ref_node = context.ref_node
16
- dest_node = context.dest_node
16
+ website = deprecate('website', 'context.website', context.website)
17
+ node = deprecate('node', 'context.node', context.content_node)
18
+ ref_node = deprecate('ref_node', 'context.ref_node', context.ref_node)
19
+ dest_node = deprecate('dest_node', 'context.dest_node', context.dest_node)
17
20
 
18
21
  xml = ::Builder::XmlMarkup.new(:indent => 2)
19
22
  eval(context.content, binding, context.ref_node.absolute_lcn)
@@ -5,13 +5,16 @@ module Webgen::ContentProcessor
5
5
  # Processes embedded Ruby statements.
6
6
  class Erb
7
7
 
8
+ include Deprecated
9
+
8
10
  # Process the Ruby statements embedded in the content of +context+.
9
11
  def call(context)
10
12
  require 'erb'
11
13
 
12
- node = context.content_node
13
- ref_node = context.ref_node
14
- dest_node = context.dest_node
14
+ website = deprecate('website', 'context.website', context.website)
15
+ node = deprecate('node', 'context.node', context.content_node)
16
+ ref_node = deprecate('ref_node', 'context.ref_node', context.ref_node)
17
+ dest_node = deprecate('dest_node', 'context.dest_node', context.dest_node)
15
18
 
16
19
  erb = ERB.new(context.content)
17
20
  erb.filename = context.ref_node.absolute_lcn
@@ -5,7 +5,7 @@ module Webgen::ContentProcessor
5
5
  # Processes embedded Ruby statements with the +erubis+ library.
6
6
  class Erubis
7
7
 
8
- include Webgen::WebsiteAccess
8
+ include Deprecated
9
9
 
10
10
  # Process the Ruby statements embedded in the content of +context+.
11
11
  def call(context)
@@ -13,17 +13,18 @@ module Webgen::ContentProcessor
13
13
  # including Erubis because of problem with resolving Erubis::XmlHelper et al
14
14
  self.class.class_eval "include ::Erubis"
15
15
 
16
- node = context.content_node
17
- ref_node = context.ref_node
18
- dest_node = context.dest_node
16
+ website = deprecate('website', 'context.website', context.website)
17
+ node = deprecate('node', 'context.node', context.content_node)
18
+ ref_node = deprecate('ref_node', 'context.ref_node', context.ref_node)
19
+ dest_node = deprecate('dest_node', 'context.dest_node', context.dest_node)
19
20
 
20
- options = website.config['contentprocessor.erubis.options']
21
+ options = context.website.config['contentprocessor.erubis.options']
21
22
  if context[:block]
22
23
  use_pi = context[:block].options['erubis_use_pi']
23
24
  context[:block].options.select {|k,v| k =~ /^erubis_/}.
24
25
  each {|k,v| options[k.sub(/^erubis_/, '').to_sym] = v }
25
26
  end
26
- erubis = if (!use_pi.nil? && use_pi) || (use_pi.nil? && website.config['contentprocessor.erubis.use_pi'])
27
+ erubis = if (!use_pi.nil? && use_pi) || (use_pi.nil? && context.website.config['contentprocessor.erubis.use_pi'])
27
28
  ::Erubis::PI::Eruby.new(context.content, options)
28
29
  else
29
30
  ::Erubis::Eruby.new(context.content, options)
@@ -5,15 +5,18 @@ module Webgen::ContentProcessor
5
5
  # Processes content in Haml markup using the +haml+ library.
6
6
  class Haml
7
7
 
8
+ include Deprecated
9
+
8
10
  # Convert the content in +haml+ markup to HTML.
9
11
  def call(context)
10
12
  require 'haml'
11
13
 
12
14
  locals = {
13
15
  :context => context,
14
- :node => context.content_node,
15
- :ref_node => context.ref_node,
16
- :dest_node => context.dest_node,
16
+ :website => deprecate('website', 'context.website', context.website),
17
+ :node => deprecate('node', 'context.node', context.content_node),
18
+ :ref_node => deprecate('ref_node', 'context.ref_node', context.ref_node),
19
+ :dest_node => deprecate('dest_node', 'context.dest_node', context.dest_node)
17
20
  }
18
21
  context.content = ::Haml::Engine.new(context.content, :filename => context.ref_node.absolute_lcn).
19
22
  render(Object.new, locals)
@@ -9,7 +9,6 @@ module Webgen::ContentProcessor
9
9
  # Convert the content in RDoc markup to HTML.
10
10
  def call(context)
11
11
  require 'rdoc/markup/to_html'
12
-
13
12
  context.content = ::RDoc::Markup::ToHtml.new.convert(context.content)
14
13
  context
15
14
  end
@@ -8,7 +8,9 @@ module Webgen::ContentProcessor
8
8
  # Convert the content in +context+ to HTML.
9
9
  def call(context)
10
10
  require 'redcloth'
11
- context.content = ::RedCloth.new(context.content).to_html
11
+ doc = ::RedCloth.new(context.content)
12
+ doc.hard_breaks = context.website.config['contentprocessor.redcloth.hard_breaks']
13
+ context.content = doc.to_html
12
14
  context
13
15
  end
14
16
 
@@ -0,0 +1,73 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'webgen/context/nodes'
3
+
4
+ module Webgen
5
+
6
+ # This class represents the context object that is passed, for example, to the +call+ method of a
7
+ # content processor.
8
+ #
9
+ # The needed context variables are stored in the +options+ hash. You can set any options you like,
10
+ # however, there are three noteworthy options:
11
+ #
12
+ # [<tt>:content</tt>]
13
+ # The content string that should be processed.
14
+ #
15
+ # [<tt>:processors</tt>]
16
+ # Normally an AccessHash object providing access to all available content processors.
17
+ #
18
+ # [<tt>:chain</tt>]
19
+ # The chain of nodes that is processed. There are some utiltity methods for getting
20
+ # special nodes of the chain (see #ref_node, #content_node and #dest_node).
21
+ class Context
22
+
23
+ include Webgen::WebsiteAccess
24
+ public :website
25
+
26
+ # Processing options
27
+ attr_accessor :options
28
+
29
+ # Create a new Context object. You can use the +options+ hash to set needed options.
30
+ #
31
+ # The following options are set by default and can be overridden via the +options+ hash:
32
+ #
33
+ # [<tt>:content</tt>]
34
+ # Is set to an empty string.
35
+ #
36
+ # [<tt>:processors</tt>]
37
+ # Is set to a new AccessHash.
38
+ def initialize(options = {})
39
+ @options = {
40
+ :content => '',
41
+ :processors => Webgen::ContentProcessor::AccessHash.new
42
+ }.merge(options)
43
+ end
44
+
45
+ # Create a copy of the current object. You can use the +options+ parameter to override options
46
+ # of the current Context object in the newly created Context object.
47
+ def clone(options = {})
48
+ self.class.new(@options.merge(options))
49
+ end
50
+
51
+ # Return the value of the option +name+.
52
+ def [](name)
53
+ @options[name]
54
+ end
55
+
56
+ # Set the option +name+ to the given +value.
57
+ def []=(name, value)
58
+ @options[name] = value
59
+ end
60
+
61
+ # Return the <tt>:content</tt> option.
62
+ def content
63
+ @options[:content]
64
+ end
65
+
66
+ # Set the <tt>:content</tt> option to the given +value+.
67
+ def content=(value)
68
+ @options[:content] = value
69
+ end
70
+
71
+ end
72
+
73
+ end
@@ -0,0 +1,36 @@
1
+ module Webgen
2
+
3
+ class Context
4
+
5
+ # Return the node which represents the file into which everything gets rendered. This is normally
6
+ # the same node as <tt>#content_node</tt> but can differ in special cases. For example, when
7
+ # rendering the content of node called <tt>my.page</tt> into the output of the node
8
+ # <tt>this.page</tt>, <tt>this.page</tt> would be the +dest_node+ and <tt>my.page</tt> would be
9
+ # the +content_node+.
10
+ #
11
+ # The +dest_node+ is not included in the chain but can be set via the option <tt>:dest_node</tt>!
12
+ #
13
+ # The returned node should be used as source node for calculating relative paths to other nodes.
14
+ def dest_node
15
+ @options[:dest_node] || self.content_node
16
+ end
17
+
18
+ # Return the reference node, ie. the node which provided the original content for this context
19
+ # object.
20
+ #
21
+ # The returned node should be used, for example, for resolving relative paths.
22
+ def ref_node
23
+ @options[:chain] && @options[:chain].first
24
+ end
25
+
26
+ # Return the node that is ultimately rendered.
27
+ #
28
+ # This node should be used, for example, for retrieving meta information.
29
+ def content_node
30
+ @options[:chain] && @options[:chain].last
31
+ end
32
+ alias :node :content_node
33
+
34
+ end
35
+
36
+ end
@@ -1,12 +1,13 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- # :nodoc:
3
+ # :stopdoc:
4
4
  class Array
5
5
 
6
- def to_hash # :nodoc:
6
+ def to_hash
7
7
  h = {}
8
8
  self.each {|k,v| h[k] = v}
9
9
  h
10
10
  end
11
11
 
12
12
  end
13
+ # :startdoc:
@@ -156,9 +156,11 @@ config.contentprocessor.tags.map({
156
156
  :default => 'Webgen::Tag::Metainfo'
157
157
  }, :doc => 'Tag processor name to class map')
158
158
 
159
- config.contentprocessor.erubis.use_pi(false, :doc => 'Specify whether processing instructions should be used')
159
+ config.contentprocessor.erubis.use_pi(false, :doc => 'Specifies whether processing instructions should be used')
160
160
  config.contentprocessor.erubis.options({}, :doc => 'A hash of additional options')
161
161
 
162
+ config.contentprocessor.redcloth.hard_breaks(false, :doc => 'Specifies whether new lines are turned into hard breaks')
163
+
162
164
  config.tag.relocatable.path(nil, :doc => 'The path which should be made relocatable', :mandatory => 'default')
163
165
 
164
166
  config.tag.menu.start_level(1, :doc => 'The level at which the menu starts.')
@@ -0,0 +1,53 @@
1
+ module Webgen
2
+
3
+ class Node
4
+
5
+ def flagged(key)
6
+ warn("Deprecation warning: this method will be removed in one of the next releases - use Node#flagged? instead!")
7
+ flagged?(key)
8
+ end
9
+
10
+ end
11
+
12
+ def self.const_missing(const)
13
+ if const.to_s == 'Block'
14
+ warn("Deprecation warning: Webgen::Block name will be removed in one of the next releases - use Webgen::Page::Block instead!")
15
+ Webgen::Page::Block
16
+ elsif const.to_s == "WebgenPageFormatError"
17
+ warn("Deprecation warning: Webgen::WebgenPageFormatError name will be removed in one of the next releases - use Webgen::Page::FormatError instead!")
18
+ Webgen::Page::FormatError
19
+ else
20
+ super
21
+ end
22
+ end
23
+
24
+ module ContentProcessor
25
+
26
+ def self.const_missing(const)
27
+ if const.to_s == 'Context'
28
+ warn("Deprecation warning: Webgen::ContentProcessor::Context is now named Webgen::Context! This alias will be removed in one of the next releases.")
29
+ Webgen::Context
30
+ else
31
+ super
32
+ end
33
+ end
34
+
35
+ module Deprecated
36
+
37
+ def deprecate(old, new, obj)
38
+ klass = Class.new
39
+ klass.instance_methods.select {|m| m.to_s !~ /^(__|instance_eval|object_id)/}.each {|m| klass.__send__(:undef_method, m)}
40
+ result = klass.new
41
+ result.instance_eval { @old, @new, @obj = old, new, obj }
42
+ def result.method_missing(sym, *args, &block)
43
+ Kernel::warn("Deprecation warning (~ #{caller.first}): The alias '#{@old}' will be removed in one of the next releases - use '#{@new}' instead!")
44
+ @obj.send(sym, *args, &block)
45
+ end
46
+ result
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+
53
+ end