webgen 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. data/ChangeLog +280 -0
  2. data/Rakefile +3 -1
  3. data/TODO +29 -12
  4. data/VERSION +1 -1
  5. data/doc/extension.config +11 -6
  6. data/doc/src/about.page +21 -0
  7. data/doc/src/default.css +17 -0
  8. data/doc/src/default.template +3 -5
  9. data/doc/src/design.gallery +1 -1
  10. data/doc/src/designs/curdesign.png +0 -0
  11. data/doc/src/designs/nostyle.png +0 -0
  12. data/doc/src/designs/old.png +0 -0
  13. data/doc/src/documentation/contenthandler/html.page +11 -0
  14. data/doc/src/documentation/contenthandler/index.page +7 -0
  15. data/doc/src/documentation/contenthandler/markdown.page +11 -0
  16. data/doc/src/documentation/contenthandler/rdoc.page +11 -0
  17. data/doc/src/documentation/contenthandler/textile.page +11 -0
  18. data/doc/src/documentation/extloader.page +1 -1
  19. data/doc/src/documentation/filehandler/backing.page +1 -1
  20. data/doc/src/documentation/filehandler/galleryhandler.page +79 -0
  21. data/doc/src/documentation/filehandler/{page.page → pagehandler.page} +2 -7
  22. data/doc/src/documentation/gallerylayouter/defaultlayouter.page +12 -0
  23. data/doc/src/documentation/gallerylayouter/index.page +14 -0
  24. data/doc/src/documentation/htmlvalidator/index.page +6 -0
  25. data/doc/src/documentation/htmlvalidator/xmllint.page +14 -0
  26. data/doc/src/documentation/index.page +33 -6
  27. data/doc/src/documentation/tags/index.page +2 -2
  28. data/doc/src/documentation/tags/{lang.de.page → langbar.de.page} +0 -0
  29. data/doc/src/documentation/tags/{lang.page → langbar.page} +6 -6
  30. data/doc/src/documentation/tags/menu.page +1 -1
  31. data/doc/src/documentation/tags/sitemap.page +18 -0
  32. data/doc/src/download.page +2 -0
  33. data/doc/src/features.page +4 -4
  34. data/doc/src/index.page +18 -20
  35. data/doc/src/meta.info +5 -5
  36. data/install.rb +1 -1
  37. data/lib/webgen/configuration.rb +35 -12
  38. data/lib/webgen/node.rb +9 -3
  39. data/lib/webgen/plugins/contenthandler/defaultcontenthandler.rb +39 -0
  40. data/lib/webgen/plugins/{filehandler/pagehandler → contenthandler}/html.rb +4 -7
  41. data/lib/webgen/plugins/{filehandler/pagehandler → contenthandler}/markdown.rb +4 -7
  42. data/lib/webgen/plugins/{filehandler/pagehandler → contenthandler}/rdoc.rb +5 -5
  43. data/lib/webgen/plugins/{filehandler/pagehandler → contenthandler}/textile.rb +4 -7
  44. data/lib/webgen/plugins/filehandler/backing.rb +4 -4
  45. data/lib/webgen/plugins/filehandler/directory.rb +25 -3
  46. data/lib/webgen/plugins/filehandler/filecopy.rb +4 -2
  47. data/lib/webgen/plugins/filehandler/filehandler.rb +5 -8
  48. data/lib/webgen/plugins/filehandler/{pagehandler/page.rb → page.rb} +48 -32
  49. data/lib/webgen/plugins/filehandler/picturegallery.rb +70 -51
  50. data/lib/webgen/plugins/gallerylayouter/defaultgallerylayouter.rb +152 -0
  51. data/lib/webgen/plugins/htmlvalidator/defaulthtmlvalidator.rb +37 -0
  52. data/lib/webgen/plugins/htmlvalidator/xmllint.rb +70 -0
  53. data/lib/webgen/plugins/tags/{lang.rb → langbar.rb} +3 -3
  54. data/lib/webgen/plugins/tags/menu.rb +9 -13
  55. data/lib/webgen/plugins/tags/relocatable.rb +2 -2
  56. data/lib/webgen/plugins/tags/sitemap.rb +73 -0
  57. data/lib/webgen/plugins/tags/tags.rb +9 -9
  58. data/lib/webgen/plugins/treewalker.rb +2 -2
  59. data/testsite/src/{images/bghack.png → bghack.png} +0 -0
  60. metadata +33 -20
  61. data/doc/src/designs/default.png +0 -0
  62. data/doc/src/documentation/filehandler/picturegallery.page +0 -25
  63. data/testsite/src/images/o.png +0 -0
  64. data/testsite/src/images/smagacor.png +0 -0
  65. data/testsite/src/images/tictactoe.png +0 -0
  66. data/testsite/src/images/x.png +0 -0
  67. data/testsite/src/test.gallery +0 -5
@@ -1,22 +1,22 @@
1
- index.html:
1
+ index.page:
2
2
  en:
3
3
  menuOrder: 1
4
4
 
5
- download.html:
5
+ download.page:
6
6
  en:
7
7
  menuOrder: 3
8
8
 
9
- features.html:
9
+ features.page:
10
10
  en:
11
11
  menuOrder: 5
12
12
 
13
- api.html:
13
+ api.page:
14
14
  en:
15
15
  dest: rdoc/index.html
16
16
  title: API Reference
17
17
  menuOrder: 7
18
18
  inMenu: true
19
19
 
20
- documentation/index.html:
20
+ documentation/index.page:
21
21
  en:
22
22
  menuOrder: 9
data/install.rb CHANGED
@@ -3,7 +3,7 @@ require 'rpa/install'
3
3
 
4
4
  class Install_webgen < RPA::Install::FullInstaller
5
5
  name 'webgen'
6
- version '0.3.0-1'
6
+ version '0.3.1-1'
7
7
  classification Application
8
8
  build do
9
9
  installdocs %w[COPYING ChangeLog TODO]
@@ -1,7 +1,7 @@
1
1
  #
2
2
  #--
3
3
  #
4
- # $Id: configuration.rb 203 2005-02-21 18:42:04Z thomas $
4
+ # $Id: configuration.rb 217 2005-03-11 15:15:54Z thomas $
5
5
  #
6
6
  # webgen: template based static website generator
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -37,10 +37,13 @@ class Dependency < Hash
37
37
  end
38
38
  end
39
39
 
40
+ class OpenStruct
41
+ public :table #:nodoc:#
42
+ end
40
43
 
41
44
  module Webgen
42
45
 
43
- VERSION = [0, 3, 0]
46
+ VERSION = [0, 3, 1]
44
47
  SUMMARY = "Webgen is a templated based static website generator."
45
48
  DESCRIPTION = "Webgen is a web page generator implemented in Ruby. " \
46
49
  "It is used to generate static web pages from templates and page " \
@@ -53,12 +56,12 @@ module Webgen
53
56
  @@config = {}
54
57
 
55
58
  def self.inherited( klass )
56
- (@@config[klass.name] = OpenStruct.new).klass = klass
57
- @@config[klass.name].plugin = klass.name.split( /::/ ).last
59
+ (@@config[klass] = OpenStruct.new).klass = klass
60
+ @@config[klass].plugin = klass.name.split( /::/ ).last
58
61
  end
59
62
 
60
63
  ['extension', 'summary', 'description'].each do |name|
61
- self.module_eval "def self.#{name}( obj ); @@config[self.name].#{name} = obj; end"
64
+ self.module_eval "def self.#{name}( obj ); @@config[self].#{name} = obj; end"
62
65
  end
63
66
 
64
67
  # Return plugin data
@@ -69,7 +72,7 @@ module Webgen
69
72
  # Add a dependency to the plugin. Dependencies are instantiated before the plugin gets
70
73
  # instantiated.
71
74
  def self.depends_on( *dep )
72
- dep.each {|d| (@@config[self.name].dependencies ||= []) << d}
75
+ dep.each {|d| (@@config[self].dependencies ||= []) << d}
73
76
  end
74
77
 
75
78
  # Shortcut for getting the plugin with the name +name+.
@@ -88,7 +91,7 @@ module Webgen
88
91
  def self.add_param( name, default, description )
89
92
  self.logger.debug { "Adding parameter '#{name}' for plugin class '#{self.name}'" }
90
93
  data = OpenStruct.new( :name => name, :value => default, :default => default, :description => description )
91
- (@@config[self.name].params ||= {})[name] = data
94
+ (@@config[self].params ||= {})[name] = data
92
95
  end
93
96
 
94
97
  # Set parameter +name+ for +plugin+ to +value+.
@@ -96,7 +99,7 @@ module Webgen
96
99
  found = catch( :found ) do
97
100
  item = @@config.find {|k,v| v.plugin == plugin }[1]
98
101
  item.klass.ancestor_classes.each do |k|
99
- item = @@config[k.name]
102
+ item = @@config[k]
100
103
  if !item.nil? && !item.params.nil? && item.params.has_key?( name )
101
104
  item.params[name].value = value
102
105
  logger.debug { "Setting parameter '#{name}' for plugin '#{plugin}' to #{value.inspect}" }
@@ -110,7 +113,7 @@ module Webgen
110
113
  # Return parameter +name+.
111
114
  def []( name )
112
115
  self.class.ancestor_classes.each do |klass|
113
- data = @@config[klass.name]
116
+ data = @@config[klass]
114
117
  return data.params[name].value unless data.params.nil? || data.params[name].nil?
115
118
  end
116
119
  logger.error { "Referencing invalid configuration value '#{name}' in class #{self.class.name}" }
@@ -119,17 +122,37 @@ module Webgen
119
122
 
120
123
  # Set parameter +name+.
121
124
  def []=( name, value )
122
- self.class.set_param( @@config[self.class.name].plugin, name, value )
125
+ self.class.set_param( @@config[self.class].plugin, name, value )
123
126
  end
124
127
  alias get_param []
125
128
 
126
129
  # Checks if the plugin has a parameter +name+.
127
130
  def has_param?( name )
128
131
  self.class.ancestor_classes.any? do |klass|
129
- !@@config[klass.name].params.nil? && @@config[klass.name].params.has_key?( name )
132
+ !@@config[klass].params.nil? && @@config[klass].params.has_key?( name )
130
133
  end
131
134
  end
132
135
 
136
+ # Defines a new *handler class. The methods creates two methods based on the parameter +name+:
137
+ # - klass.register_[name]
138
+ # - object.get_[name]
139
+ def self.define_handler( name )
140
+ s = "def self.register_#{name}( param )
141
+ self.logger.info { \"Registering class \#{self.name} for handling '\#{param}'\" }
142
+ (Webgen::Plugin.config[#{self.name}].#{name}s ||= {})[param] = self
143
+ Webgen::Plugin.config[self].registered_#{name} = param
144
+ end\n"
145
+ s += "def get_#{name}( param )
146
+ if Webgen::Plugin.config[#{self.name}].#{name}s.has_key?( param )
147
+ Webgen::Plugin.config[Webgen::Plugin.config[#{self.name}].#{name}s[param]].obj
148
+ else
149
+ self.logger.error { \"Invalid #{name} specified: \#{param}! Using #{self.name}!\" }
150
+ Webgen::Plugin.config[#{self.name}].obj
151
+ end
152
+ end"
153
+ module_eval s
154
+ end
155
+
133
156
  #######
134
157
  private
135
158
  #######
@@ -209,7 +232,7 @@ module Webgen
209
232
  end
210
233
 
211
234
  # Initialize single configuration instance
212
- Plugin.config[Configuration.name].obj = Configuration.new
235
+ Plugin.config[Configuration].obj = Configuration.new
213
236
 
214
237
  end
215
238
 
@@ -1,7 +1,7 @@
1
1
  #
2
2
  #--
3
3
  #
4
- # $Id: node.rb 203 2005-02-21 18:42:04Z thomas $
4
+ # $Id: node.rb 220 2005-03-12 15:41:05Z thomas $
5
5
  #
6
6
  # webgen: template based static website generator
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -114,6 +114,13 @@ class Node
114
114
  /^#{node.recursive_value( 'dest' )}/ =~ recursive_value( 'dest' )
115
115
  end
116
116
 
117
+ # Returns the parent directory for this node. This function ignores virtual directories.
118
+ def parent_dir
119
+ node = self.parent
120
+ node = node.parent while !node.nil? && node['virtual']
121
+ node
122
+ end
123
+
117
124
  # Returns the root node for +node+.
118
125
  def self.root( node )
119
126
  node = node.parent until node.parent.nil?
@@ -129,8 +136,7 @@ class Node
129
136
  node = Node.root( self )
130
137
  destString = destString[1..-1]
131
138
  else
132
- node = self.parent || self
133
- node = node.parent while !node.nil? && node['virtual']
139
+ node = self.parent_dir || self
134
140
  end
135
141
 
136
142
  destString.split( '/' ).each do |element|
@@ -0,0 +1,39 @@
1
+ #
2
+ #--
3
+ #
4
+ # $Id: defaultcontenthandler.rb 214 2005-02-27 13:40:27Z thomas $
5
+ #
6
+ # webgen: template based static website generator
7
+ # Copyright (C) 2004 Thomas Leitner
8
+ #
9
+ # This program is free software; you can redistribute it and/or modify it under the terms of the GNU
10
+ # General Public License as published by the Free Software Foundation; either version 2 of the
11
+ # License, or (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
14
+ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ # General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along with this program; if not,
18
+ # write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ #
20
+ #++
21
+ #
22
+
23
+
24
+ module ContentHandlers
25
+
26
+ class DefaultContentHandler < Webgen::Plugin
27
+
28
+ summary "Base class for all content handlers"
29
+
30
+ define_handler 'format'
31
+
32
+ # Format the given +content+. Should be overridden in subclass!
33
+ def format_content( content )
34
+ content
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -1,7 +1,7 @@
1
1
  #
2
2
  #--
3
3
  #
4
- # $Id: html.rb 203 2005-02-21 18:42:04Z thomas $
4
+ # $Id: html.rb 212 2005-02-27 12:02:27Z thomas $
5
5
  #
6
6
  # webgen: template based static website generator
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -20,19 +20,16 @@
20
20
  #++
21
21
  #
22
22
 
23
- require 'webgen/plugins/filehandler/pagehandler/page'
23
+ require 'webgen/plugins/contenthandler/defaultcontenthandler'
24
24
 
25
25
  module ContentHandlers
26
26
 
27
27
  # Handles HTML content. Assumes that the content is already valid HTML.
28
- class HTMLHandler < ContentHandler
28
+ class HTMLContentHandler < DefaultContentHandler
29
29
 
30
30
  summary "Handles HTML formatted content"
31
- depends_on "PageHandler"
32
31
 
33
- def initialize
34
- register_format( 'html' )
35
- end
32
+ register_format( 'html' )
36
33
 
37
34
  def format_content( txt )
38
35
  txt
@@ -1,7 +1,7 @@
1
1
  #
2
2
  #--
3
3
  #
4
- # $Id: markdown.rb 203 2005-02-21 18:42:04Z thomas $
4
+ # $Id: markdown.rb 212 2005-02-27 12:02:27Z thomas $
5
5
  #
6
6
  # webgen: template based static website generator
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -23,19 +23,16 @@
23
23
 
24
24
  begin
25
25
  require 'bluecloth'
26
- require 'webgen/plugins/filehandler/pagehandler/page'
26
+ require 'webgen/plugins/contenthandler/defaultcontenthandler'
27
27
 
28
28
  module ContentHandlers
29
29
 
30
30
  # Handles text formatted in Markdown format using BlueCloth.
31
- class MarkdownHandler < ContentHandler
31
+ class MarkdownContentHandler < DefaultContentHandler
32
32
 
33
33
  summary "Handles content formatted in Markdown format using BlueCloth"
34
- depends_on "PageHandler"
35
34
 
36
- def initialize
37
- register_format( 'markdown' )
38
- end
35
+ register_format( 'markdown' )
39
36
 
40
37
  def format_content( txt )
41
38
  BlueCloth.new( txt ).to_html
@@ -1,7 +1,7 @@
1
1
  #
2
2
  #--
3
3
  #
4
- # $Id: rdoc.rb 203 2005-02-21 18:42:04Z thomas $
4
+ # $Id: rdoc.rb 212 2005-02-27 12:02:27Z thomas $
5
5
  #
6
6
  # webgen: template based static website generator
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -22,18 +22,18 @@
22
22
 
23
23
  require 'rdoc/markup/simple_markup'
24
24
  require 'rdoc/markup/simple_markup/to_html'
25
- require 'webgen/plugins/filehandler/pagehandler/page'
25
+ require 'webgen/plugins/contenthandler/defaultcontenthandler'
26
26
 
27
27
  module ContentHandlers
28
28
 
29
29
  # Handles text in RDoc format.
30
- class RDocHandler < ContentHandler
30
+ class RDocContentHandler < DefaultContentHandler
31
31
 
32
32
  summary "Handles content in RDOC format"
33
- depends_on "PageHandler"
33
+
34
+ register_format( 'rdoc' )
34
35
 
35
36
  def initialize
36
- register_format( 'rdoc' )
37
37
  @processor = SM::SimpleMarkup.new
38
38
  @formatter = SM::ToHtml.new
39
39
  end
@@ -1,7 +1,7 @@
1
1
  #
2
2
  #--
3
3
  #
4
- # $Id: textile.rb 203 2005-02-21 18:42:04Z thomas $
4
+ # $Id: textile.rb 212 2005-02-27 12:02:27Z thomas $
5
5
  #
6
6
  # webgen: template based static website generator
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -22,19 +22,16 @@
22
22
 
23
23
  begin
24
24
  require 'redcloth'
25
- require 'webgen/plugins/filehandler/pagehandler/page'
25
+ require 'webgen/plugins/contenthandler/defaultcontenthandler'
26
26
 
27
27
  module ContentHandlers
28
28
 
29
29
  # Handles content in Textile format using RedCloth.
30
- class TextileHandler < ContentHandler
30
+ class TextileContentHandler < DefaultContentHandler
31
31
 
32
32
  summary "Handles content in Textile format using RedCloth"
33
- depends_on "PageHandler"
34
33
 
35
- def initialize
36
- register_format( 'textile' )
37
- end
34
+ register_format( 'textile' )
38
35
 
39
36
  def format_content( txt )
40
37
  RedCloth.new( txt ).to_html
@@ -1,7 +1,7 @@
1
1
  #
2
2
  #--
3
3
  #
4
- # $Id: backing.rb 203 2005-02-21 18:42:04Z thomas $
4
+ # $Id: backing.rb 214 2005-02-27 13:40:27Z thomas $
5
5
  #
6
6
  # webgen: template based static website generator
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -22,7 +22,7 @@
22
22
 
23
23
  require 'webgen/plugins/filehandler/filehandler'
24
24
  require 'webgen/plugins/filehandler/directory'
25
- require 'webgen/plugins/filehandler/pagehandler/page'
25
+ require 'webgen/plugins/filehandler/page'
26
26
 
27
27
  module FileHandlers
28
28
 
@@ -98,7 +98,7 @@ module FileHandlers
98
98
  end
99
99
 
100
100
  def process_backing_file( dirNode )
101
- backingFiles = dirNode.find_all {|child| /\.#{Webgen::Plugin.config[self.class.name].extension}$/ =~ child['src'] }
101
+ backingFiles = dirNode.find_all {|child| /\.#{Webgen::Plugin.config[self.class].extension}$/ =~ child['src'] }
102
102
 
103
103
  backingFiles.each do |backingFile|
104
104
  backingFile['content'].each do |filename, data|
@@ -158,7 +158,7 @@ module FileHandlers
158
158
  when '..'
159
159
  node = node.parent
160
160
  else
161
- node = node.find do |child| /^#{element}\/?$/ =~ child['src'] end
161
+ node = node.find {|child| /^#{element}\/?$/ =~ child['src'] }
162
162
  end
163
163
  if node.nil?
164
164
  node = FileHandlers::DirHandler::DirNode.new( parent, element )
@@ -1,7 +1,7 @@
1
1
  #
2
2
  #--
3
3
  #
4
- # $Id: directory.rb 203 2005-02-21 18:42:04Z thomas $
4
+ # $Id: directory.rb 224 2005-03-16 15:26:33Z thomas $
5
5
  #
6
6
  # webgen: template based static website generator
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -58,13 +58,16 @@ module FileHandlers
58
58
 
59
59
  summary "Handles directories"
60
60
  extension :dir
61
- add_param 'indexFile', 'index.html', 'The default file name for the directory index file.'
61
+ add_param 'indexFile', 'index.page', 'The default file name for the directory index file.'
62
62
  depends_on 'FileHandler'
63
63
 
64
64
 
65
65
  # Return a new DirNode.
66
66
  def create_node( path, parent )
67
- DirNode.new( parent, File.basename( path ) )
67
+ unless parent && node = parent.find {|child| /^#{File.basename( path )}\/$/ =~ child['src'] }
68
+ node = DirNode.new( parent, File.basename( path ) )
69
+ end
70
+ node
68
71
  end
69
72
 
70
73
  # Create the directory (and all its parent directories if necessary).
@@ -91,6 +94,25 @@ module FileHandlers
91
94
  super( lang_node, refNode, title )
92
95
  end
93
96
 
97
+ # Recursively create a given path
98
+ def recursive_create_path( path, parent )
99
+ p = parent
100
+ node = nil
101
+ path.split( File::SEPARATOR ).each do |pathname|
102
+ case pathname
103
+ when '.' then
104
+ # do nothing
105
+ when '..' then
106
+ p = p.parent
107
+ else
108
+ node = create_node( pathname, p )
109
+ p.add_child( node ) unless p.nil? || node.nil?
110
+ p = node
111
+ end
112
+ end
113
+ node
114
+ end
115
+
94
116
  end
95
117
 
96
118
  end