The Webgen namespace houses all classes/modules used by webgen.
webgen is a command line application for generating a web site from templates and content files. Despite this fact, the implementation also provides adequate support for using webgen as a library and full support for extending it.
webgen can be extended very easily. Any file called init.rb put into the ext/ directory of the website or into one of its sub-directories is automatically loaded on Website#init.
You can extend webgen in several ways. However, no magic or special knowledge is needed since webgen relies on the power of Ruby itself. So, for example, an extension is just a normal Ruby class. Most extension types provide a Base module for mixing into an extension which provides default implementations for needed methods.
Following are links to detailed descriptions on how to develop specific types of extensions:
Here are some detail on the internals of webgen that will help you while developing for webgen:
The Blackboard class provides an easy communication facility between objects. It implements the Observer pattern on the one side and allows the definition of services on the other side. One advantage of a service over the direct use of an object instance method is that the caller does not need to how to find the object that provides the service. It justs uses the Website#blackboard instance. An other advantage is that one can easily exchange the place where the service was defined without breaking extensions that rely on it.
Following is a list of all services available in the stock webgen distribution by the name and the method that implements it (which is useful for looking up the parameters of service).
:create_fragment_nodes: | SourceHandler::Fragment#create_fragment_nodes |
:templates_for_node: | SourceHandler::Template#templates_for_node |
:parse_html_headers: | SourceHandler::Fragment#parse_html_headers |
:output_instance: | Output.instance |
:content_processor_names: | ContentProcessor.list |
:content_processor: | ContentProcessor.for_name |
:create_sitemap: | Common::Sitemap#create_sitemap |
:create_directories: | SourceHandler::Directory#create_directories |
:create_nodes: | SourceHandler::Main#create_nodes |
:create_nodes_from_paths: | SourceHandler::Main#create_nodes_from_paths |
:source_paths: | SourceHandler::Main#find_all_source_paths |
Following is the list of all messages that can be listened to:
:node_flagged: | See Node#flag |
:node_unflagged: | See Node#unflag |
:node_changed?: | See Node#changed? |
:node_meta_info_changed?: | See Node#meta_info_changed? |
:before_node_created: | Sent by the :create_nodes service before a node is created (handled by a source handler) with the parent and the path as arguments. |
:after_node_created: | Sent by the :create_nodes service after a node has been created with the created node as argument. |
:before_node_deleted: | See Tree#delete_node |
Here is a list of modules/classes that are primarily used throughout webgen or provide useful methods for developing extensions:
VERSION | = | '0.5.12' | The version of webgen. |
Returns the data directory for webgen.
# File lib/webgen/website.rb, line 169 169: def self.data_dir 170: unless defined?(@@data_dir) 171: require 'rbconfig' 172: @@data_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'data', 'webgen')) 173: @@data_dir = File.expand_path(File.join(Config::CONFIG["datadir"], "webgen")) if !File.exists?(@@data_dir) 174: raise "Could not find webgen data directory! This is a bug, report it please!" unless File.directory?(@@data_dir) 175: end 176: @@data_dir 177: end