Module Webgen
In: lib/webgen/version.rb
lib/webgen/error.rb
lib/webgen/loggable.rb
lib/webgen/cli.rb
lib/webgen/cache.rb
lib/webgen/context.rb
lib/webgen/source/filesystem.rb
lib/webgen/source/tararchive.rb
lib/webgen/output.rb
lib/webgen/tree.rb
lib/webgen/languages.rb
lib/webgen/websitemanager.rb
lib/webgen/contentprocessor.rb
lib/webgen/common.rb
lib/webgen/sourcehandler.rb
lib/webgen/page.rb
lib/webgen/node.rb
lib/webgen/configuration.rb
lib/webgen/websiteaccess.rb
lib/webgen/website.rb
lib/webgen/tag.rb
lib/webgen/source.rb
lib/webgen/blackboard.rb
lib/webgen/path.rb
lib/webgen/context/nodes.rb
lib/webgen/context/tags.rb
lib/webgen/context/render.rb
lib/webgen/webgentask.rb
lib/webgen/logger.rb
Error RenderError CommandNotFoundError LoadError NodeCreationError ::Rake::TaskLib WebgenTask Helpers Configuration Node Context\n[lib/webgen/context.rb\nlib/webgen/context/nodes.rb\nlib/webgen/context/render.rb\nlib/webgen/context/tags.rb] Tree FileSystem Sitemap Copy Feed Virtual Sitemap Directory Page Fragment Template Metainfo Memory Coderay Sitemap IncludeFile BreadcrumbTrail Langbar TikZ Menu Tags Fragments Resource Website Tidy Head Kramdown Less Xmllint Blocks Comparable Language Path StandardError CmdParse::CommandParser CommandParser CmdParse::Command RunCommand WebguiCommand CreateCommand ApplyCommand WebsiteAccess Main Loggable OutputPathHelpers ExecuteCommand Link Date Relocatable Metainfo ::Kramdown::Converter::Html KramdownHtmlConverter Cache Blackboard WebsiteManager Logger Page ProxyNode Utils Scss RDoc Sass Erb RDiscount Erubis Haml Maruku Builder RedCloth AccessHash TarArchive Stacked FileSystem lib/webgen/cache.rb lib/webgen/error.rb lib/webgen/languages.rb lib/webgen/context/render.rb lib/webgen/website.rb lib/webgen/blackboard.rb lib/webgen/tree.rb lib/webgen/websitemanager.rb lib/webgen/logger.rb lib/webgen/configuration.rb lib/webgen/path.rb lib/webgen/webgentask.rb lib/webgen/page.rb lib/webgen/node.rb ClassMethods WebsiteAccess lib/webgen/cli/run_command.rb lib/webgen/cli/utils.rb lib/webgen/cli/apply_command.rb lib/webgen/cli/webgui_command.rb lib/webgen/cli.rb lib/webgen/cli/create_command.rb Color CLI LanguageManager lib/webgen/output/filesystem.rb Output lib/webgen/common/sitemap.rb Common lib/webgen/sourcehandler/memory.rb lib/webgen/sourcehandler/metainfo.rb lib/webgen/sourcehandler/copy.rb lib/webgen/sourcehandler/directory.rb lib/webgen/sourcehandler.rb lib/webgen/sourcehandler/page.rb lib/webgen/sourcehandler/template.rb lib/webgen/sourcehandler/fragment.rb lib/webgen/sourcehandler/sitemap.rb lib/webgen/sourcehandler/virtual.rb lib/webgen/sourcehandler/feed.rb OutputPathHelpers Base SourceHandler lib/webgen/tag/coderay.rb lib/webgen/tag/relocatable.rb lib/webgen/tag/menu.rb lib/webgen/tag/langbar.rb lib/webgen/tag/executecommand.rb lib/webgen/tag/breadcrumbtrail.rb lib/webgen/tag/metainfo.rb lib/webgen/tag/includefile.rb lib/webgen/tag/link.rb lib/webgen/tag/date.rb lib/webgen/tag/tikz.rb lib/webgen/tag/sitemap.rb Base Tag lib/webgen/contentprocessor/less.rb lib/webgen/contentprocessor/scss.rb lib/webgen/contentprocessor/blocks.rb lib/webgen/contentprocessor/rdoc.rb lib/webgen/contentprocessor/sass.rb lib/webgen/contentprocessor/erb.rb lib/webgen/contentprocessor/rdiscount.rb lib/webgen/contentprocessor/tags.rb lib/webgen/contentprocessor/erubis.rb lib/webgen/contentprocessor/kramdown/html.rb lib/webgen/contentprocessor/haml.rb lib/webgen/contentprocessor/maruku.rb lib/webgen/contentprocessor/xmllint.rb lib/webgen/contentprocessor/kramdown.rb lib/webgen/contentprocessor/head.rb lib/webgen/contentprocessor/builder.rb lib/webgen/contentprocessor/tidy.rb lib/webgen/contentprocessor/redcloth.rb lib/webgen/contentprocessor/fragments.rb lib/webgen/contentprocessor.rb ContentProcessor lib/webgen/source/tararchive.rb lib/webgen/source/stacked.rb lib/webgen/source/resource.rb lib/webgen/source/filesystem.rb Source Loggable Webgen dot/m_82_0.png

The Webgen namespace houses all classes/modules used by webgen.

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.

Extending webgen

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:

Webgen::Source
Information on how to implement a class that provides source paths for webgen. For example, one could implement a source class that uses a database as backend.
Webgen::Output
Information on how to implement a class that writes content to an output location. The default output class just writes to the file system. One could, for example, implement an output class that writes the generated files to multiple locations or to a remote server.
Webgen::ContentProcessor
Information on how to develop an extension that processes the content. For example, markup-to-HTML converters are implemented as content processors in webgen.
Webgen::SourceHandler::Base
Information on how to implement a class that handles objects of type source Path and creates Node instances. For example, Webgen::SourceHandler::Page handles the conversion of .page files to .html files.
Webgen::Tag::Base
Information on how to implement a webgen tag. webgen tags are used to provide an easy way for users to include dynamic content such as automatically generated menus.

General information

Here are some detail on the internals of webgen that will help you while developing for webgen:

  • webgen uses a not so complex system for determining whether a node needs to be recreated or re-rendered. However, for this to work correctly all extensions have to follow some rules:
    • It is necessary that all node alcns from which the content is used are put into the destination node‘s node_info[:used_nodes] set.
    • It is necessary that all other node alcns that are used for a node in any way, even if they are only referenced or the route to their output path used, have to be put into the node‘s node_info[:used_meta_info_nodes] set.
  • Any node that is created during the rendering phase, ie. via a content processor, a tag or in the content method of a source handler needs to be put into the rendered node‘s node_info[:used_meta_info_nodes] or node_info[:used_nodes] set (see above for details)! This is especially necessary when using resolved nodes since resolved nodes can be created by passive sources!
  • webgen provides various Error classes. However, errors should only be raised if additional runs won‘t correct the problem. For example, if a path cannot be resolved, it is possible that in the next run a node will be created and that the path can be resolved then. This is always the case, for example, with fragment nodes! In such cases an error message should be written out to the log to inform the user that there is a potential problem.

Blackboard services

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

Other places to look at

Here is a list of modules/classes that are primarily used throughout webgen or provide useful methods for developing extensions:

Common, Tree, Node, Path, Cache, Page

Methods

data_dir  

Classes and Modules

Module Webgen::CLI
Module Webgen::Common
Module Webgen::ContentProcessor
Module Webgen::LanguageManager
Module Webgen::Loggable
Module Webgen::Output
Module Webgen::Source
Module Webgen::SourceHandler
Module Webgen::Tag
Module Webgen::WebsiteAccess
Class Webgen::Blackboard
Class Webgen::Cache
Class Webgen::CommandNotFoundError
Class Webgen::Configuration
Class Webgen::Context
Class Webgen::Error
Class Webgen::Language
Class Webgen::LoadError
Class Webgen::Logger
Class Webgen::Node
Class Webgen::NodeCreationError
Class Webgen::Page
Class Webgen::Path
Class Webgen::ProxyNode
Class Webgen::RenderError
Class Webgen::Tree
Class Webgen::WebgenTask
Class Webgen::Website
Class Webgen::WebsiteManager

Constants

VERSION = '0.5.14'   The version of webgen.

Public Class methods

Returns the data directory for webgen.

[Source]

     # 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

[Validate]