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
@@ -41,30 +41,33 @@ module Webgen
41
41
  # It is assumed that you have already used the 'webgen' command to create the website directory
42
42
  # for the site.
43
43
  #
44
- # === Basics
44
+ # == Basics
45
45
  #
46
46
  # require 'webgen/webgentask'
47
47
  #
48
48
  # Webgen::WebgenTask.new
49
49
  #
50
- # === Attributes
50
+ # == Attributes
51
51
  #
52
52
  # The attributes available in the new block are:
53
53
  #
54
- # * directory - the root directory of the webgen site
55
- # (default Dir.pwd)
56
- # * config - the config block for setting additional configuration options
57
- # * clobber_outdir - remove webgens output directory on clobber
58
- # (default false)
54
+ # [directory]
55
+ # the root directory of the webgen site (default <tt>Dir.pwd</tt>)
56
+ # [config]
57
+ # the config block for setting additional configuration options
58
+ # [clobber_outdir]
59
+ # remove webgens output directory on clobber (default +false+)
59
60
  #
60
- # === Tasks Provided
61
+ # == Tasks Provided
61
62
  #
62
63
  # The tasks provided are :
63
64
  #
64
- # * webgen - render the webgen website
65
- # * clobber_webgen - remove all the files created during generation
65
+ # [webgen]
66
+ # render the webgen website
67
+ # [clobber_webgen]
68
+ # remove all the files created during generation
66
69
  #
67
- # === Integrate webgen in other project
70
+ # == Integrate webgen in other project
68
71
  #
69
72
  # To integrate webgen tasks in another project you can use rake namespaces. For example assuming
70
73
  # webgen's site directory is +webgen+ under the main project directory use the following code
@@ -96,8 +99,7 @@ module Webgen
96
99
  # The directory of the webgen website. This would be the directory of your <tt>config.yaml</tt>
97
100
  # file. Or the parent directory of the <tt>src/</tt> directory for webgen.
98
101
  #
99
- # The default for this is assumed to be
100
- # Dir.pwd
102
+ # The default for this is assumed to be <tt>Dir.pwd</tt>
101
103
  attr_accessor :directory
102
104
 
103
105
  # The configuration block that is invoked when the Webgen::Website object is initialized. This
@@ -1,5 +1,11 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
+ ##
4
+ # Welcome to the API documentation of wegen!
5
+ #
6
+ # Have a look at the base <a href=Webgen.html>webgen module</a> which provides a good starting point!
7
+
8
+
3
9
  # Standard lib requires
4
10
  require 'logger'
5
11
  require 'set'
@@ -18,16 +24,21 @@ require 'webgen/tree'
18
24
 
19
25
  # Files for autoloading
20
26
  require 'webgen/common'
27
+ require 'webgen/context'
21
28
  require 'webgen/source'
22
29
  require 'webgen/output'
23
30
  require 'webgen/sourcehandler'
24
31
  require 'webgen/contentprocessor'
32
+ require 'webgen/tag'
25
33
 
26
34
  # Load other needed files
27
35
  require 'webgen/path'
28
36
  require 'webgen/node'
29
37
  require 'webgen/page'
30
38
 
39
+ # Load deprecated classes/methods/...
40
+ require 'webgen/deprecated'
41
+
31
42
 
32
43
  # The Webgen namespace houses all classes/modules used by webgen.
33
44
  #
@@ -37,7 +48,7 @@ require 'webgen/page'
37
48
  # files. Despite this fact, the implementation also provides adequate support for using webgen as a
38
49
  # library and *full* *support* for extending it.
39
50
  #
40
- # = Extending webgen
51
+ # == Extending webgen
41
52
  #
42
53
  # webgen can be extended very easily. Any file called <tt>init.rb</tt> put into the <tt>ext/</tt>
43
54
  # directory of the website or into one of its sub-directories is automatically loaded on
@@ -72,7 +83,7 @@ require 'webgen/page'
72
83
  # an easy way for users to include dynamic content such as automatically
73
84
  # generated menus.
74
85
  #
75
- # = Blackboard services
86
+ # == Blackboard services
76
87
  #
77
88
  # The Blackboard class provides an easy communication facility between objects. It implements the
78
89
  # Observer pattern on the one side and allows the definition of services on the other side. One
@@ -93,7 +104,7 @@ require 'webgen/page'
93
104
  # <tt>:create_sitemap</tt>:: Common::Sitemap#create_sitemap
94
105
  # <tt>:create_directories</tt>:: SourceHandler::Directory#create_directories
95
106
  # <tt>:create_nodes</tt>:: SourceHandler::Main#create_nodes
96
- # <tt>:source_paths</tt>:: SourceHandler::Main#source_paths
107
+ # <tt>:source_paths</tt>:: SourceHandler::Main#find_all_source_paths
97
108
  #
98
109
  # Following is the list of all messages that can be listened to:
99
110
  #
@@ -119,7 +130,7 @@ require 'webgen/page'
119
130
  # <tt>:before_node_deleted</tt>::
120
131
  # See Tree#delete_node
121
132
  #
122
- # = Other places to look at
133
+ # == Other places to look at
123
134
  #
124
135
  # Here is a list of modules/classes that are primarily used throughout webgen or provide useful
125
136
  # methods for developing extensions:
@@ -141,6 +152,25 @@ module Webgen
141
152
 
142
153
 
143
154
  # Represents a webgen website and is used to render it.
155
+ #
156
+ # Normally, webgen is used from the command line via the +webgen+ command or from Rakefiles via
157
+ # Webgen::WebgenTask. However, you can also easily use webgen as a library and this class provides
158
+ # the interface for this usage!
159
+ #
160
+ # Since a webgen website is, basically, just a directory, the only parameter needed for creating a
161
+ # new Website object is the website directory. After that you can work with the website:
162
+ #
163
+ # * If you want to render the website, you just need to call Website#render which initializes the
164
+ # website and does all the rendering. When the method call returns, everything has been rendered.
165
+ #
166
+ # * If you want to remove the generated output, you just need to invoke Website#clean and it will
167
+ # be done.
168
+ #
169
+ # * Finally, if you want to retrieve data from the website, you first have to call Website#init to
170
+ # initialize the website. After that you can use the various accessors to retrieve the needed
171
+ # data. *Note*: This is generally only useful if the website has been rendered because otherwise
172
+ # there is no data to retrieve.
173
+ #
144
174
  class Website
145
175
 
146
176
  # Raised when the configuration file of the website is invalid.
@@ -169,16 +199,17 @@ module Webgen
169
199
  # The website directory.
170
200
  attr_reader :directory
171
201
 
172
- # Create a new webgen website for the website in the directory +dir+. You can provide a
173
- # block (has to take the configuration object as parameter) for adjusting the configuration
174
- # values during the initialization.
175
- def initialize(dir, logger=Webgen::Logger.new($stdout, false), &block)
202
+ # Create a new webgen website for the website in the directory +dir+. If +dir+ is +nil+, the
203
+ # environment variable +WEBGEN_WEBSITE+ or, if it is not set either, the current working
204
+ # directory is used. You can provide a block (has to take the configuration object as parameter)
205
+ # for adjusting the configuration values during the initialization.
206
+ def initialize(dir = nil, logger=Webgen::Logger.new($stdout, false), &block)
176
207
  @blackboard = nil
177
208
  @cache = nil
178
209
  @config = nil
179
210
  @logger = logger
180
211
  @config_block = block
181
- @directory = dir
212
+ @directory = (dir.nil? ? (ENV['WEBGEN_WEBSITE'].to_s.empty? ? Dir.pwd : ENV['WEBGEN_WEBSITE']) : dir)
182
213
  end
183
214
 
184
215
  # Define a service +service_name+ provided by the instance of +klass+. The parameter +method+
@@ -254,11 +285,11 @@ module Webgen
254
285
  # The provided block is executed within a proper environment sothat any object can access the
255
286
  # Website object.
256
287
  def execute_in_env
257
- set_back = Thread.current[:webgen_website].nil?
288
+ set_back = Thread.current[:webgen_website]
258
289
  Thread.current[:webgen_website] = self
259
290
  yield
260
291
  ensure
261
- Thread.current[:webgen_website] = nil if set_back
292
+ Thread.current[:webgen_website] = set_back
262
293
  end
263
294
 
264
295
  #######
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Webgen
4
4
 
5
- # Mixed into modules/classes that need access to the current website object.
5
+ # Should be mixed into modules/classes that need access to the current website object.
6
6
  module WebsiteAccess
7
7
 
8
8
  # The methods of this module are available on classes that include WebsiteAccess.
@@ -6,107 +6,102 @@ require 'webgen/website'
6
6
 
7
7
  module Webgen
8
8
 
9
- # This class is used for managing webgen websites. It provides access to website templates and
10
- # styles defined as resources and makes it easy to apply them to a webgen website.
9
+ # This class is used for managing webgen websites. It provides access to website bundles defined
10
+ # as resources and makes it easy to apply them to a webgen website.
11
11
  #
12
- # = General information
12
+ # == General information
13
13
  #
14
14
  # Currently, the following actions are supported:
15
15
  #
16
- # * creating a website based on a website template (#create_website)
17
- # * applying a template to an existing website (#apply_template)
18
- # * applying a style to an existing website (#apply_style)
16
+ # * creating a website based on a website bundle (#create_website)
17
+ # * applying a bundle to an existing website (#apply_bundle)
19
18
  #
20
- # A website template defines some initial pages which should be filled with real data. For
21
- # example, the @project@ template defines several pages which are useful for software projects
22
- # including a features and about page.
19
+ # Bundles are partial webgen websites that contain certain functionality. For example, most of the
20
+ # bundles shipped with webgen are style bundles that define the basic page layout or how image
21
+ # galleries should look like. So style bundles are basically used to change the appearance of
22
+ # parts (or the whole) website. This makes them a powerful tool as this plugin makes it easy to
23
+ # change to another style bundle later!
23
24
  #
24
- # A style defines, for example, the basic page layout (in the case of website styles) or how image
25
- # galleries should look like (in the case of gallery styles). So styles are basically used to
26
- # change the appearance of parts (or the whole) website. This makes them a powerful tool as this
27
- # plugin makes it easy to change a style later!
25
+ # However, not all bundles have to be style bundles. For example, you could as easily create a
26
+ # bundle for a plugin or for a complete website (e.g. a blog template).
28
27
  #
29
- # = website template and style resource naming convention
28
+ # == website bundle resource naming convention
30
29
  #
31
- # Styles and website templates are defined using resources. Each such resource has to be a
32
- # directory containing an optional README file in YAML format in which key-value pairs provide
33
- # additional information about the style or website template. All other files/directories in the
34
- # directory are copied to the root of the destination webgen website when the style or website
35
- # template is used.
30
+ # The shipped bundles are defined using resources. Each such resource has to be a directory
31
+ # containing an optional README file in YAML format in which key-value pairs provide additional
32
+ # information about the bundle (e.g. copyright information, description, ...). All other
33
+ # files/directories in the directory are copied to the root of the destination webgen website when
34
+ # the bundle is used.
36
35
  #
37
- # This class uses a special naming convention to recognize website templates and styles:
36
+ # This class uses a special naming convention to recognize website bundles:
38
37
  #
39
- # * A resource named <tt>webgen-website-template-TEMPLATE_NAME</tt> is considered to be a website
40
- # template called TEMPLATE_NAME and can be later accessed using this name.
38
+ # * A resource named <tt>webgen-website-bundle-CATEGORY-NAME</tt> is considered to be a bundle in
39
+ # the category CATEGORY called NAME (where CATEGORY is optional). There are no fixed categories,
40
+ # one can use anything here! The shipped style bundles are located in the 'style' category. You
41
+ # need to use the the full name, i.e. CATEGORY-NAME, for accessing a bundle later.
41
42
  #
42
- # * A resource named <tt>webgen-website-style-CATEGORY-STYLE_NAME</tt> is considered to be a style
43
- # in the category CATEGORY called STYLE_NAME. There are no fixed categories, one can use
44
- # anything here! Again, the style can later be accessed by providing the category and style
45
- # name.
46
- #
47
- # Website template names have to be unique and style names have to be unique in respect to their
48
- # categories!
49
- #
50
- # Note: All styles without a category or which are in the category 'website' are website styles.
43
+ # Website bundle names have to be unique!
51
44
  class WebsiteManager
52
45
 
53
- # A hash with the available website templates (mapping name to infos).
54
- attr_reader :templates
55
-
56
- # A hash with the available website styles (mapping name to infos).
57
- attr_reader :styles
46
+ # A hash with the available website bundles (mapping name to infos).
47
+ attr_reader :bundles
58
48
 
59
49
  # The used Website object.
60
50
  attr_reader :website
61
51
 
62
- # Create a new WebsiteManager for the website +dir+.
52
+ # Create a new WebsiteManager.
53
+ #
54
+ # If +dir+ is a String, then the website manager is created for the website in the directory
55
+ # +dir+.
56
+ #
57
+ # If +dir+ is a Website object, the website manager is created for the website represented by
58
+ # +dir+. If the website object is initialized if it isn't already.
63
59
  def initialize(dir)
64
- @website = Webgen::Website.new(dir)
65
- @website.init
66
- @styles = {}
67
- @templates = {}
60
+ if dir.kind_of?(Webgen::Website)
61
+ @website = dir
62
+ @website.init if @website.config.nil?
63
+ else
64
+ @website = Webgen::Website.new(dir)
65
+ @website.init
66
+ end
67
+ @bundles = {}
68
68
 
69
69
  @website.execute_in_env do
70
- [['webgen-website-style-', @styles], ['webgen-website-template-', @templates]].each do |prefix, var|
71
- @website.config['resources'].select {|name, data| name =~ /^#{prefix}/}.each do |name, data|
72
- paths = Webgen::Source::Resource.new(name).paths
73
- readme = paths.select {|path| path == '/README' }.first
74
- paths.delete(readme) if readme
75
- infos = OpenStruct.new(readme.nil? ? {} : YAML::load(readme.io.data))
76
- infos.paths = paths
77
- var[name.sub(prefix, '')] = infos
78
- end
70
+ prefix = "webgen-website-bundle-"
71
+ @website.config['resources'].select {|name, data| name =~ /^#{prefix}/}.each do |name, data|
72
+ add_source(Webgen::Source::Resource.new(name), name.sub(prefix, ''))
79
73
  end
80
74
  end
81
75
  end
82
76
 
83
- # Create the basic website skeleton (without any template or style applied).
77
+ # Treat the +source+ as a website bundle and make it available to the WebsiteManager under
78
+ # +name+.
79
+ def add_source(source, name)
80
+ paths = source.paths.dup
81
+ readme = paths.select {|path| path == '/README' }.first
82
+ paths.delete(readme) if readme
83
+ infos = OpenStruct.new(readme.nil? ? {} : YAML::load(readme.io.data))
84
+ infos.paths = paths
85
+ @bundles[name] = infos
86
+ end
87
+
88
+ # Create the basic website skeleton (without any bundle applied).
84
89
  def create_website
85
90
  raise "Directory <#{@website.directory}> does already exist!" if File.exists?(@website.directory)
86
91
  @website.execute_in_env { write_paths(Webgen::Source::Resource.new('webgen-website-skeleton').paths) }
87
92
  end
88
93
 
89
- # Apply the given +template+ to the website by copying the template files.
90
- def apply_template(name)
91
- write_paths_to_website(@templates[name], 'template')
92
- end
93
-
94
- # Apply the given website style +name+ to the website by copying the styles files.
95
- def apply_style(name)
96
- write_paths_to_website(@styles[name], 'style')
94
+ # Apply the given +bundle+ to the website by copying the files.
95
+ def apply_bundle(bundle)
96
+ raise ArgumentError.new("Invalid bundle name") if !@bundles.has_key?(bundle)
97
+ raise "Directory <#{@website.directory}> does not exist!" unless File.exists?(@website.directory)
98
+ write_paths(@bundles[bundle].paths)
97
99
  end
98
100
 
99
101
  #######
100
102
  private
101
103
  #######
102
104
 
103
- # Do some sanity checks and write the +paths+ from +infos+ to the website directory.
104
- def write_paths_to_website(infos, infos_type)
105
- raise ArgumentError.new("Invalid #{infos_type} name") if infos.nil?
106
- raise "Directory <#{@website.directory}> does not exist!" unless File.exists?(@website.directory)
107
- write_paths(infos.paths)
108
- end
109
-
110
105
  # Write the paths to the website directory.
111
106
  def write_paths(paths)
112
107
  paths.each do |path|
data/man/man1/webgen.1 CHANGED
@@ -36,6 +36,10 @@ Show generic help.
36
36
  Show the version of the program and exit.
37
37
  .SH COMMANDS
38
38
  .TP
39
+ \fBapply\fR
40
+ Applies a website bundle to an existing website. The \fIbundle\fR argument may either be the name of
41
+ a bundle shipped with webgen or an URL to a (gzipped) tar archive bundle.
42
+ .TP
39
43
  \fBcreate\fR
40
44
  Creates the basic directories and files for webgen. This includes the source and
41
45
  output directories as well as an empty extensions directory. Also, a basic template plus a CSS and
data/misc/default.css CHANGED
@@ -382,3 +382,16 @@ blockquote.blog-entry-details {
382
382
  .blog-entry-date, .blog-entry-author {
383
383
  font-weight: bold;
384
384
  }
385
+
386
+
387
+ /* website style preview classes */
388
+ div.website-styles {
389
+ margin: 0px 10px;
390
+ }
391
+
392
+ div.website-styles object {
393
+ border: 1px solid black;
394
+ width: 100%;
395
+ height: 300px;
396
+ overflow: hidden;
397
+ }
@@ -28,7 +28,7 @@
28
28
 
29
29
  <div id="sidebar" >
30
30
 
31
- <% if !node.children.empty? %>
31
+ <% if !context.node.children.empty? %>
32
32
  <h1>Contents</h1>
33
33
  <% end %>
34
34
 
@@ -22,4 +22,5 @@ extensions.*.html:
22
22
  in_menu: true
23
23
  sort_info: 50
24
24
 
25
-
25
+ images/:
26
+ index_path: ~
data/misc/style.page ADDED
@@ -0,0 +1,33 @@
1
+ ---
2
+ title: Style Example
3
+ ---
4
+ ## General Information
5
+
6
+ This sample website showcases the website style *<%= context.content_node.parent.cn %>*. Most
7
+ website styles include dynamic parts by default, for example, automatically generated menus and
8
+ breadcrumb trails. All such dynamic parts are active in this showcase like they would be on a normal
9
+ website.
10
+
11
+ ## How to use this style
12
+
13
+ This website style can be used when creating a new website by using the following command:
14
+
15
+ webgen create -b default -b <%= context.content_node.parent.cn %> SITE_DIR
16
+
17
+ Or it can be applied later on to an already existing website by using the following command:
18
+
19
+ webgen apply <%= context.content_node.parent.cn %>
20
+
21
+ ## Style Information
22
+
23
+ <dl>
24
+ <%
25
+ require 'webgen/websitemanager'
26
+ infos = Webgen::WebsiteManager.new(context.website).bundles[context.content_node.parent.cn]
27
+ infos.instance_eval {@table}.sort {|(ak,av), (bk,bv)| ak.to_s <=> bk.to_s}.each do |name, value|
28
+ next if name.to_s == 'paths'
29
+ %>
30
+ <dt><%= name.to_s.capitalize %></dt>
31
+ <dd><%= ::ERB::Util::h(value) %></dd>
32
+ <% end %>
33
+ </dl>
data/test/test_cli.rb CHANGED
@@ -7,15 +7,9 @@ class TestCLICommandParser < Test::Unit::TestCase
7
7
 
8
8
  def test_initialize
9
9
  cli = Webgen::CLI::CommandParser.new
10
- assert_equal('render', cli.main_command.default_command)
11
10
  assert_equal(:normal, cli.verbosity)
12
11
  assert_equal(Logger::WARN, cli.log_level)
13
- assert_equal(Dir.pwd, cli.directory)
12
+ assert_equal(nil, cli.directory)
14
13
  end
15
14
 
16
- def test_website_from_env
17
- ENV['WEBGEN_WEBSITE'] = '/webgen/test/site'
18
- cli = Webgen::CLI::CommandParser.new
19
- assert_equal('/webgen/test/site', cli.directory)
20
- end
21
15
  end