gettalong-webgen 0.5.6.20081020 → 0.5.7.20090227
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +3 -0
- data/THANKS +1 -0
- data/bin/webgen +2 -0
- data/data/webgen/webgui/controller/main.rb +2 -0
- data/data/webgen/website_skeleton/ext/init.rb +4 -0
- data/doc/contentprocessor/blocks.page +44 -14
- data/doc/contentprocessor/builder.page +1 -1
- data/doc/contentprocessor/erb.page +1 -1
- data/doc/contentprocessor/erubis.page +1 -1
- data/doc/contentprocessor/fragments.page +1 -1
- data/doc/contentprocessor/haml.page +1 -1
- data/doc/contentprocessor/rdiscount.page +1 -1
- data/doc/contentprocessor/rdoc.page +1 -1
- data/doc/contentprocessor/redcloth.page +1 -1
- data/doc/contentprocessor/sass.page +1 -1
- data/doc/faq.page +7 -2
- data/doc/manual.page +6 -5
- data/doc/reference_metainfo.page +1 -1
- data/doc/sourcehandler/feed.page +9 -1
- data/doc/sourcehandler/sitemap.page +1 -1
- data/doc/tag/coderay.page +1 -1
- data/doc/tag/langbar.page +15 -0
- data/doc/tag/menu.page +1 -1
- data/doc/tag/relocatable.page +2 -2
- data/lib/webgen/blackboard.rb +9 -4
- data/lib/webgen/cache.rb +2 -0
- data/lib/webgen/cli.rb +6 -1
- data/lib/webgen/cli/create_command.rb +2 -0
- data/lib/webgen/cli/run_command.rb +2 -0
- data/lib/webgen/cli/utils.rb +2 -0
- data/lib/webgen/cli/webgui_command.rb +2 -0
- data/lib/webgen/common.rb +12 -1
- data/lib/webgen/common/sitemap.rb +12 -4
- data/lib/webgen/configuration.rb +2 -0
- data/lib/webgen/contentprocessor.rb +2 -0
- data/lib/webgen/contentprocessor/blocks.rb +22 -8
- data/lib/webgen/contentprocessor/builder.rb +2 -0
- data/lib/webgen/contentprocessor/context.rb +2 -0
- data/lib/webgen/contentprocessor/erb.rb +2 -0
- data/lib/webgen/contentprocessor/erubis.rb +2 -0
- data/lib/webgen/contentprocessor/fragments.rb +2 -0
- data/lib/webgen/contentprocessor/haml.rb +2 -0
- data/lib/webgen/contentprocessor/maruku.rb +2 -0
- data/lib/webgen/contentprocessor/rdiscount.rb +2 -0
- data/lib/webgen/contentprocessor/rdoc.rb +2 -0
- data/lib/webgen/contentprocessor/redcloth.rb +2 -0
- data/lib/webgen/contentprocessor/sass.rb +2 -0
- data/lib/webgen/contentprocessor/tags.rb +2 -0
- data/lib/webgen/coreext.rb +2 -0
- data/lib/webgen/default_config.rb +4 -1
- data/lib/webgen/languages.rb +2 -0
- data/lib/webgen/loggable.rb +2 -0
- data/lib/webgen/logger.rb +2 -0
- data/lib/webgen/node.rb +22 -8
- data/lib/webgen/output.rb +3 -1
- data/lib/webgen/output/filesystem.rb +2 -0
- data/lib/webgen/page.rb +2 -0
- data/lib/webgen/path.rb +3 -1
- data/lib/webgen/source.rb +2 -0
- data/lib/webgen/source/filesystem.rb +5 -2
- data/lib/webgen/source/resource.rb +2 -0
- data/lib/webgen/source/stacked.rb +2 -0
- data/lib/webgen/sourcehandler.rb +8 -0
- data/lib/webgen/sourcehandler/base.rb +2 -0
- data/lib/webgen/sourcehandler/copy.rb +2 -0
- data/lib/webgen/sourcehandler/directory.rb +2 -0
- data/lib/webgen/sourcehandler/feed.rb +3 -1
- data/lib/webgen/sourcehandler/fragment.rb +2 -0
- data/lib/webgen/sourcehandler/memory.rb +2 -0
- data/lib/webgen/sourcehandler/metainfo.rb +3 -1
- data/lib/webgen/sourcehandler/page.rb +2 -0
- data/lib/webgen/sourcehandler/sitemap.rb +2 -0
- data/lib/webgen/sourcehandler/template.rb +2 -0
- data/lib/webgen/sourcehandler/virtual.rb +3 -1
- data/lib/webgen/tag.rb +2 -0
- data/lib/webgen/tag/base.rb +2 -0
- data/lib/webgen/tag/breadcrumbtrail.rb +2 -0
- data/lib/webgen/tag/coderay.rb +2 -0
- data/lib/webgen/tag/date.rb +2 -0
- data/lib/webgen/tag/executecommand.rb +2 -0
- data/lib/webgen/tag/includefile.rb +2 -0
- data/lib/webgen/tag/langbar.rb +4 -1
- data/lib/webgen/tag/link.rb +2 -0
- data/lib/webgen/tag/menu.rb +2 -0
- data/lib/webgen/tag/metainfo.rb +2 -0
- data/lib/webgen/tag/relocatable.rb +2 -0
- data/lib/webgen/tag/sitemap.rb +2 -0
- data/lib/webgen/tag/tikz.rb +3 -1
- data/lib/webgen/tree.rb +5 -0
- data/lib/webgen/version.rb +3 -1
- data/lib/webgen/webgentask.rb +2 -0
- data/lib/webgen/website.rb +104 -3
- data/lib/webgen/websiteaccess.rb +2 -0
- data/lib/webgen/websitemanager.rb +2 -0
- data/man/man1/webgen.1 +6 -0
- data/misc/default.css +36 -12
- data/misc/default.template +1 -1
- data/misc/images/error.png +0 -0
- data/misc/images/important.png +0 -0
- data/misc/images/information.png +0 -0
- data/misc/images/warning.png +0 -0
- data/test/helper.rb +4 -0
- data/test/test_blackboard.rb +2 -0
- data/test/test_cache.rb +2 -0
- data/test/test_cli.rb +7 -0
- data/test/test_common.rb +18 -0
- data/test/test_common_sitemap.rb +7 -5
- data/test/test_configuration.rb +2 -0
- data/test/test_contentprocessor.rb +2 -0
- data/test/test_contentprocessor_blocks.rb +22 -1
- data/test/test_contentprocessor_builder.rb +2 -0
- data/test/test_contentprocessor_context.rb +2 -0
- data/test/test_contentprocessor_erb.rb +2 -0
- data/test/test_contentprocessor_erubis.rb +2 -0
- data/test/test_contentprocessor_fragments.rb +2 -0
- data/test/test_contentprocessor_haml.rb +2 -0
- data/test/test_contentprocessor_maruku.rb +2 -0
- data/test/test_contentprocessor_rdiscount.rb +2 -0
- data/test/test_contentprocessor_rdoc.rb +2 -0
- data/test/test_contentprocessor_redcloth.rb +2 -0
- data/test/test_contentprocessor_sass.rb +2 -0
- data/test/test_contentprocessor_tags.rb +2 -0
- data/test/test_languages.rb +2 -0
- data/test/test_loggable.rb +2 -0
- data/test/test_logger.rb +2 -0
- data/test/test_node.rb +2 -0
- data/test/test_output_filesystem.rb +2 -0
- data/test/test_page.rb +2 -0
- data/test/test_path.rb +2 -0
- data/test/test_source_filesystem.rb +17 -0
- data/test/test_source_resource.rb +2 -0
- data/test/test_source_stacked.rb +2 -0
- data/test/test_sourcehandler_base.rb +2 -0
- data/test/test_sourcehandler_copy.rb +2 -0
- data/test/test_sourcehandler_directory.rb +2 -0
- data/test/test_sourcehandler_feed.rb +2 -0
- data/test/test_sourcehandler_fragment.rb +2 -0
- data/test/test_sourcehandler_memory.rb +2 -0
- data/test/test_sourcehandler_metainfo.rb +2 -0
- data/test/test_sourcehandler_page.rb +2 -0
- data/test/test_sourcehandler_sitemap.rb +2 -0
- data/test/test_sourcehandler_template.rb +2 -0
- data/test/test_sourcehandler_virtual.rb +2 -0
- data/test/test_tag_base.rb +4 -0
- data/test/test_tag_breadcrumbtrail.rb +2 -0
- data/test/test_tag_coderay.rb +2 -0
- data/test/test_tag_date.rb +2 -0
- data/test/test_tag_executecommand.rb +2 -0
- data/test/test_tag_includefile.rb +2 -0
- data/test/test_tag_langbar.rb +13 -6
- data/test/test_tag_link.rb +2 -0
- data/test/test_tag_menu.rb +2 -0
- data/test/test_tag_metainfo.rb +2 -0
- data/test/test_tag_relocatable.rb +2 -0
- data/test/test_tag_sitemap.rb +4 -1
- data/test/test_tag_tikz.rb +4 -1
- data/test/test_tree.rb +2 -0
- data/test/test_webgentask.rb +2 -0
- data/test/test_website.rb +6 -4
- data/test/test_websiteaccess.rb +2 -0
- data/test/test_websitemanager.rb +2 -0
- metadata +8 -5
- data/misc/images/error.gif +0 -0
- data/misc/images/exclamation.gif +0 -0
- data/misc/images/information.gif +0 -0
data/lib/webgen/sourcehandler.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
require 'webgen/loggable'
|
2
4
|
require 'benchmark'
|
3
5
|
|
@@ -50,12 +52,18 @@ module Webgen
|
|
50
52
|
end
|
51
53
|
puts "...done in " + ('%2.4f' % time.real) + ' seconds'
|
52
54
|
|
55
|
+
if !tree.root
|
56
|
+
puts 'No source files found - maybe not a webgen website?'
|
57
|
+
return nil
|
58
|
+
end
|
59
|
+
|
53
60
|
puts "Writing changed nodes..."
|
54
61
|
time = Benchmark.measure do
|
55
62
|
write_tree(tree)
|
56
63
|
end
|
57
64
|
puts "...done in " + ('%2.4f' % time.real) + ' seconds'
|
58
65
|
end while tree.node_access[:alcn].any? {|name,node| node.flagged(:created) || node.flagged(:reinit)}
|
66
|
+
:success
|
59
67
|
end
|
60
68
|
|
61
69
|
#######
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
module Webgen::SourceHandler
|
2
4
|
|
3
5
|
# Source handler for creating atom and/or rss feeds.
|
@@ -53,7 +55,7 @@ module Webgen::SourceHandler
|
|
53
55
|
# Helper method for returning the entries for the feed node +node+.
|
54
56
|
def feed_entries(node)
|
55
57
|
nr_items = (node['number_of_entries'].to_i == 0 ? 10 : node['number_of_entries'].to_i)
|
56
|
-
patterns = [node['entries']].flatten.map {|pat|
|
58
|
+
patterns = [node['entries']].flatten.map {|pat| Webgen::Common.absolute_path(pat, node.parent.absolute_lcn)}
|
57
59
|
|
58
60
|
node.tree.node_access[:alcn].values.
|
59
61
|
select {|node| patterns.any? {|pat| node =~ pat} && node.node_info[:page]}.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
require 'pathname'
|
2
4
|
require 'yaml'
|
3
5
|
|
@@ -27,7 +29,7 @@ module Webgen::SourceHandler
|
|
27
29
|
[[:mi_paths, 'paths'], [:mi_alcn, 'alcn']].each do |mi_key, block_name|
|
28
30
|
node.node_info[mi_key] = {}
|
29
31
|
YAML::load(page.blocks[block_name].content).each do |key, value|
|
30
|
-
key =
|
32
|
+
key = Webgen::Common.absolute_path(key, parent.absolute_lcn)
|
31
33
|
node.node_info[mi_key][key] = value
|
32
34
|
end if page.blocks.has_key?(block_name)
|
33
35
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
require 'uri'
|
2
4
|
require 'yaml'
|
3
5
|
|
@@ -17,7 +19,7 @@ module Webgen::SourceHandler
|
|
17
19
|
page = page_from_path(path)
|
18
20
|
nodes = []
|
19
21
|
YAML::load(page.blocks['content'].content).each do |key, meta_info|
|
20
|
-
key = (key =~
|
22
|
+
key = Webgen::Common.absolute_path(key, parent.absolute_lcn) + (key =~ /\/$/ ? '/' : '')
|
21
23
|
temp_parent = create_directories(parent.tree.root, File.dirname(key), path)
|
22
24
|
|
23
25
|
meta_info ||= {}
|
data/lib/webgen/tag.rb
CHANGED
data/lib/webgen/tag/base.rb
CHANGED
data/lib/webgen/tag/coderay.rb
CHANGED
data/lib/webgen/tag/date.rb
CHANGED
data/lib/webgen/tag/langbar.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
module Webgen::Tag
|
2
4
|
|
3
5
|
# Generates a list with all the languages of the page.
|
@@ -19,7 +21,8 @@ module Webgen::Tag
|
|
19
21
|
sort {|a, b| a.lang <=> b.lang}.
|
20
22
|
collect {|n| context.dest_node.link_to(n, :link_text => (param('tag.langbar.lang_names')[n.lang] || n.lang), :lang => n.lang)}.
|
21
23
|
join(param('tag.langbar.separator'))
|
22
|
-
|
24
|
+
|
25
|
+
[(param('tag.langbar.show_single_lang') || lang_nodes.length > 1 ? result : ""), param('tag.langbar.process_output')]
|
23
26
|
end
|
24
27
|
|
25
28
|
#######
|
data/lib/webgen/tag/link.rb
CHANGED
data/lib/webgen/tag/menu.rb
CHANGED
data/lib/webgen/tag/metainfo.rb
CHANGED
data/lib/webgen/tag/sitemap.rb
CHANGED
data/lib/webgen/tag/tikz.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
require 'erb'
|
2
4
|
require 'tempfile'
|
3
5
|
require 'fileutils'
|
@@ -30,7 +32,7 @@ EOF
|
|
30
32
|
# Create a graphic from the commands in the body of the tag.
|
31
33
|
def call(tag, body, context)
|
32
34
|
path = param('tag.tikz.path')
|
33
|
-
path =
|
35
|
+
path = Webgen::Common.absolute_path(path, context.ref_node.parent.absolute_lcn)
|
34
36
|
|
35
37
|
mem_handler = website.cache.instance('Webgen::SourceHandler::Memory')
|
36
38
|
src_path = context.ref_node.node_info[:src]
|
data/lib/webgen/tree.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
require 'webgen/websiteaccess'
|
2
4
|
require 'webgen/node'
|
3
5
|
|
@@ -65,6 +67,9 @@ module Webgen
|
|
65
67
|
end
|
66
68
|
|
67
69
|
# Delete the node identified by +node_or_alcn+ and all of its children from the tree.
|
70
|
+
#
|
71
|
+
# The message <tt>:before_node_deleted</tt> is sent with the to-be-deleted node before this node
|
72
|
+
# is actually deleted from the tree.
|
68
73
|
def delete_node(node_or_alcn)
|
69
74
|
n = node_or_alcn.kind_of?(Node) ? node_or_alcn : @node_access[:alcn][node_or_alcn]
|
70
75
|
return if n.nil? || n == @dummy_root
|
data/lib/webgen/version.rb
CHANGED
data/lib/webgen/webgentask.rb
CHANGED
data/lib/webgen/website.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
# Standard lib requires
|
2
4
|
require 'logger'
|
3
5
|
require 'set'
|
@@ -28,6 +30,102 @@ require 'webgen/page'
|
|
28
30
|
|
29
31
|
|
30
32
|
# The Webgen namespace houses all classes/modules used by webgen.
|
33
|
+
#
|
34
|
+
# = webgen
|
35
|
+
#
|
36
|
+
# webgen is a command line application for generating a web site from templates and content
|
37
|
+
# files. Despite this fact, the implementation also provides adequate support for using webgen as a
|
38
|
+
# library and *full* *support* for extending it.
|
39
|
+
#
|
40
|
+
# = Extending webgen
|
41
|
+
#
|
42
|
+
# webgen can be extended very easily. Any file called <tt>init.rb</tt> put into the <tt>ext/</tt>
|
43
|
+
# directory of the website or into one of its sub-directories is automatically loaded on
|
44
|
+
# Website#init.
|
45
|
+
#
|
46
|
+
# You can extend webgen in several ways. However, no magic or special knowledge is needed since
|
47
|
+
# webgen relies on the power of Ruby itself. So, for example, an extension is just a normal Ruby
|
48
|
+
# class. Most extension types provide a Base module for mixing into an extension which provides
|
49
|
+
# default implementations for needed methods.
|
50
|
+
#
|
51
|
+
# Following are links to detailed descriptions on how to develop specific types of extensions:
|
52
|
+
#
|
53
|
+
# [Webgen::Source] Information on how to implement a class that provides source paths for
|
54
|
+
# webgen. For example, one could implement a source class that uses a database as
|
55
|
+
# backend.
|
56
|
+
#
|
57
|
+
# [Webgen::Output] Information on how to implement a class that writes content to an output
|
58
|
+
# location. The default output class just writes to the file system. One could, for
|
59
|
+
# example, implement an output class that writes the generated files to multiple
|
60
|
+
# locations or to a remote server.
|
61
|
+
#
|
62
|
+
# [Webgen::ContentProcessor] Information on how to develop an extension that processes the
|
63
|
+
# content. For example, markup-to-HTML converters are implemented as
|
64
|
+
# content processors in webgen.
|
65
|
+
#
|
66
|
+
# [Webgen::SourceHandler::Base] Information on how to implement a class that handles objects of type
|
67
|
+
# source Path and creates Node instances. For example,
|
68
|
+
# Webgen::SourceHandler::Page handles the conversion of <tt>.page</tt>
|
69
|
+
# files to <tt>.html</tt> files.
|
70
|
+
#
|
71
|
+
# [Webgen::Tag::Base] Information on how to implement a webgen tag. webgen tags are used to provide
|
72
|
+
# an easy way for users to include dynamic content such as automatically
|
73
|
+
# generated menus.
|
74
|
+
#
|
75
|
+
# = Blackboard services
|
76
|
+
#
|
77
|
+
# The Blackboard class provides an easy communication facility between objects. It implements the
|
78
|
+
# Observer pattern on the one side and allows the definition of services on the other side. One
|
79
|
+
# advantage of a service over the direct use of an object instance method is that the caller does
|
80
|
+
# not need to how to find the object that provides the service. It justs uses the Website#blackboard
|
81
|
+
# instance. An other advantage is that one can easily exchange the place where the service was
|
82
|
+
# defined without breaking extensions that rely on it.
|
83
|
+
#
|
84
|
+
# Following is a list of all services available in the stock webgen distribution by the name and the
|
85
|
+
# method that implements it (which is useful for looking up the parameters of service).
|
86
|
+
#
|
87
|
+
# <tt>:create_fragment_nodes</tt>:: SourceHandler::Fragment#create_fragment_nodes
|
88
|
+
# <tt>:templates_for_node</tt>:: SourceHandler::Template#templates_for_node
|
89
|
+
# <tt>:parse_html_headers</tt>:: SourceHandler::Fragment#parse_html_headers
|
90
|
+
# <tt>:output_instance</tt>:: Output.instance
|
91
|
+
# <tt>:content_processor_names</tt>:: ContentProcessor.list
|
92
|
+
# <tt>:content_processor</tt>:: ContentProcessor.for_name
|
93
|
+
# <tt>:create_sitemap</tt>:: Common::Sitemap#create_sitemap
|
94
|
+
# <tt>:create_directories</tt>:: SourceHandler::Directory#create_directories
|
95
|
+
# <tt>:create_nodes</tt>:: SourceHandler::Main#create_nodes
|
96
|
+
# <tt>:source_paths</tt>:: SourceHandler::Main#source_paths
|
97
|
+
#
|
98
|
+
# Following is the list of all messages that can be listened to:
|
99
|
+
#
|
100
|
+
# <tt>:node_flagged</tt>::
|
101
|
+
# See Node#flag
|
102
|
+
#
|
103
|
+
# <tt>:node_unflagged</tt>::
|
104
|
+
# See Node#unflag
|
105
|
+
#
|
106
|
+
# <tt>:node_changed?</tt>::
|
107
|
+
# See Node#changed?
|
108
|
+
# <tt>:node_meta_info_changed?</tt>::
|
109
|
+
# See Node#meta_info_changed?
|
110
|
+
#
|
111
|
+
# <tt>:before_node_created</tt>::
|
112
|
+
# Sent by the <tt>:create_nodes</tt> service before a node is created (handled by a source handler)
|
113
|
+
# with the +parent+ and the +path+ as arguments.
|
114
|
+
#
|
115
|
+
# <tt>:after_node_created</tt>::
|
116
|
+
# Sent by the <tt>:create_nodes</tt> service after a node has been created with the created node
|
117
|
+
# as argument.
|
118
|
+
#
|
119
|
+
# <tt>:before_node_deleted</tt>::
|
120
|
+
# See Tree#delete_node
|
121
|
+
#
|
122
|
+
# = Other places to look at
|
123
|
+
#
|
124
|
+
# Here is a list of modules/classes that are primarily used throughout webgen or provide useful
|
125
|
+
# methods for developing extensions:
|
126
|
+
#
|
127
|
+
# Common, Tree, Node, Path, Cache, Page
|
128
|
+
|
31
129
|
module Webgen
|
32
130
|
|
33
131
|
# Returns the data directory for webgen.
|
@@ -108,15 +206,17 @@ module Webgen
|
|
108
206
|
self
|
109
207
|
end
|
110
208
|
|
111
|
-
# Render the website (after calling #init if the website is not already initialized)
|
209
|
+
# Render the website (after calling #init if the website is not already initialized) and return
|
210
|
+
# a status code not equal to +nil+ if rendering was successful.
|
112
211
|
def render
|
212
|
+
result = nil
|
113
213
|
execute_in_env do
|
114
214
|
init unless @config
|
115
215
|
|
116
216
|
puts "Starting webgen..."
|
117
217
|
shm = SourceHandler::Main.new
|
118
|
-
shm.render(@tree)
|
119
|
-
save_tree_and_cache
|
218
|
+
result = shm.render(@tree)
|
219
|
+
save_tree_and_cache if result
|
120
220
|
puts "Finished"
|
121
221
|
|
122
222
|
if @logger && @logger.log_output.length > 0
|
@@ -124,6 +224,7 @@ module Webgen
|
|
124
224
|
puts @logger.log_output
|
125
225
|
end
|
126
226
|
end
|
227
|
+
result
|
127
228
|
end
|
128
229
|
|
129
230
|
# Clean the website directory from all generated output files (including the cache file). If
|
data/lib/webgen/websiteaccess.rb
CHANGED