webgen 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/ChangeLog +154 -0
  2. data/Rakefile +1 -1
  3. data/TODO +7 -4
  4. data/VERSION +1 -1
  5. data/doc/plugin/extension.rb +9 -1
  6. data/doc/src/about.page +2 -2
  7. data/doc/src/default.css +2 -2
  8. data/doc/src/default.template +4 -2
  9. data/doc/src/documentation/cli.page +1 -1
  10. data/doc/src/documentation/gettingstarted.page +4 -4
  11. data/doc/src/documentation/index.page +5 -5
  12. data/doc/src/documentation/meta_info_reference.page +21 -0
  13. data/doc/src/documentation/plugins/filehandler/directory.page +12 -0
  14. data/doc/src/documentation/plugins/filehandler/index.page +21 -5
  15. data/doc/src/documentation/plugins/filehandler/pagehandler.page +31 -3
  16. data/doc/src/documentation/plugins/index.page +2 -2
  17. data/doc/src/documentation/plugins/tags/index.page +7 -2
  18. data/doc/src/documentation/plugins/tags/multilang.fr.page +1 -1
  19. data/doc/src/download.page +1 -1
  20. data/doc/src/features.page +3 -2
  21. data/doc/src/generated_by_webgen.png +0 -0
  22. data/doc/src/index.page +18 -5
  23. data/doc/src/meta.info +8 -5
  24. data/install.rb +1 -1
  25. data/lib/{util → webgen}/composite.rb +1 -1
  26. data/lib/webgen/configuration.rb +2 -2
  27. data/lib/{util → webgen}/listener.rb +1 -1
  28. data/lib/webgen/node.rb +10 -10
  29. data/lib/webgen/plugin.rb +19 -12
  30. data/lib/webgen/plugins/filehandler/backing.rb +7 -4
  31. data/lib/webgen/plugins/filehandler/directory.rb +10 -9
  32. data/lib/webgen/plugins/filehandler/filecopy.rb +5 -6
  33. data/lib/webgen/plugins/filehandler/filehandler.rb +104 -89
  34. data/lib/webgen/plugins/filehandler/page.rb +45 -16
  35. data/lib/webgen/plugins/filehandler/picturegallery.rb +4 -3
  36. data/lib/webgen/plugins/filehandler/template.rb +4 -2
  37. data/lib/webgen/plugins/tags/langbar.rb +2 -2
  38. data/lib/webgen/plugins/tags/menu.rb +48 -35
  39. data/lib/webgen/plugins/tags/relocatable.rb +18 -6
  40. data/lib/webgen/plugins/tags/sitemap.rb +10 -9
  41. data/lib/webgen/plugins/tags/wikilink.rb +3 -1
  42. data/testsite/src/projects/00.index.de.page +1 -1
  43. data/testsite/src/projects/subproj/index.page +1 -1
  44. metadata +7 -5
@@ -73,8 +73,36 @@ named @sidebar@ and formatted using @markdown@.
73
73
 
74
74
  h2. Content format
75
75
 
76
- The content of page description can be written in different formats. Have a look at the sub menu
77
- entries to get an overview of the existing formats.
76
+ h3. Embedded Ruby (ERB)
77
+
78
+ Before the content is converted to HTML with a specific content handler, ERB is run over the
79
+ content. This allows one to add dynamic content to the web pages without using tags. Following is an
80
+ example of a page file which uses ERB:
81
+
82
+ <notextile>
83
+ <pre>
84
+ \---
85
+ title: Test page with ERB
86
+ \---
87
+ This page has the following meta info items:
88
+ &lt;% node.metainfo.each do |key, value| %&gt;
89
+ * &lt;%=key %&gt;: &lt;%=value %&gt;
90
+ &lt;% end %&gt;
91
+ </pre>
92
+ </notextile>
93
+
94
+ This would output all meta information for the current page. As one can see in the example, the node
95
+ for the current page can be accessed by using @node@. The parameter @useERB@ specifies if ERB should
96
+ be used. To provide more control, one can enable or disable ERB for a page file by setting the meta
97
+ information @useERB@ to @true@ or @false@.
98
+
99
+ The template will always be processed with ERB!
100
+
101
+ h3. Format
102
+
103
+ The content of page description can be written in different formats. Have a look at the
104
+ <a href="{relocatable: ../contenthandler}">Content Handlers</a> to get an overview of the existing
105
+ formats.
78
106
 
79
107
  h2. Default settings
80
108
 
@@ -85,7 +113,7 @@ The following defaults are used:
85
113
 
86
114
  * Content format
87
115
 
88
- If there is only content in a page description file, its formatting defaults to the parameter
116
+ If there is only one content in a page description file, its formatting defaults to the parameter
89
117
  value @defaultContentFormat@.
90
118
 
91
119
  * Title, ordering and language
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Plugins
3
- menuOrder: 30
3
+ orderInfo: 30
4
4
  directoryName: Plugins
5
5
  ---
6
6
  h2. About
@@ -10,7 +10,7 @@ to get more information!
10
10
 
11
11
  h2. Plugins
12
12
 
13
- Webgen is written with extensibility in mind; therefore most of its features are implemented with
13
+ webgen is written with extensibility in mind; therefore most of its features are implemented with
14
14
  plugins, only the core functions are not plugins.
15
15
 
16
16
  Writing your own plugins is not difficult, too! If you need a specific functionality, implement a
@@ -8,14 +8,14 @@ are substituted. For example, the menu you see to left was generated. This makes
8
8
  remove menu items. If the menu was not generated, you would have to change every file which uses the
9
9
  menu.
10
10
 
11
- Webgen comes bundled with some default tag plugins. All currently available tags are exercised in
11
+ webgen comes bundled with some default tag plugins. All currently available tags are exercised in
12
12
  this online demo. Choose a tag from the menu to get a detailed description of the tag.
13
13
 
14
14
  h2. Usage
15
15
 
16
16
  Tags are defined by a special markup code. A tag has the following structure:
17
17
 
18
- <pre class="webgen-file">\{tagname: {parameters}}</pre>
18
+ <pre>\{tagname: {parameters}}</pre>
19
19
 
20
20
  Every time a tag is found in a source file, the registered plugin for the tag is called. The plugin
21
21
  returns a string which is put into the output file instead of the tag. The output a tag plugin can
@@ -24,6 +24,11 @@ Meta Tag</a> plugin copies any additional info specified in the source file verb
24
24
  into the correct place in the output file. And in contrast, the <a href="{relocatable: menu.html}">
25
25
  Menu Tag</a> plugin generates a whole menu tree.
26
26
 
27
+ If you want to use the markup code used for tags, you need to escape the tag, like this:
28
+
29
+ <pre>\\\{tagname: {parameters}}</pre>
30
+
31
+
27
32
  h2. Tag Parameters
28
33
 
29
34
  A tag can have zero or more parameters some of which are mandatory. You can see the supported
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  title: Francais
3
3
  ---
4
- Parle vouz francais?
4
+ Ceci est la version française de cette page.
@@ -12,7 +12,7 @@ Download: "http://rubyforge.org/frs/?group_id=296":http://rubyforge.org/frs/?gro
12
12
 
13
13
  h2. Dependencies
14
14
 
15
- * "cmdparse":http://cmdparse.rubyforge.org version 1.0.1 or higher
15
+ * "cmdparse":http://cmdparse.rubyforge.org version 1.0.2 or higher
16
16
  * "RedCloth":http://redcloth.rubyforge.org version 2.0.10 or higher if you want Textile support
17
17
  * "BlueCloth":http://www.deveiate.org version 1.0.0 or higher if you want Markdown support
18
18
  * "RMagick":http://rmagick.rubyforge.org/ version 1.7.1 or higher if you want automatic thumbnail
@@ -5,10 +5,11 @@ inMenu: true
5
5
  h2. Feature list
6
6
 
7
7
  * Easily extendable through plugins
8
+ * Easy to install and use
8
9
  * Uses templates for separating layout from content
9
10
  * Supports several different content formats (Textile, Markdown, RDOC, plain HTML), new ones are easy to add
10
- * Uses 'tags' to add generated, ie. dynamic, content to the web pages
11
- * Standard distribution provides often used tags
11
+ * Uses 'tags' to add generated, ie. dynamic, content to the web pages -- standard distribution provides often used tags
12
12
  * Supports 'virtual files' via meta information backing files
13
+ * Automatically checks generated files if they are standard conform
13
14
  * Easy to configure if one needs to (no need if you are happy with the default values)
14
15
  * Relatively fast: processes ~1000 files in ~25 seconds on an {execute: uname -p}
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: HomePage
3
3
  inMenu: true
4
- directoryName: Webgen
4
+ directoryName: webgen
5
5
  ---
6
6
  h2. Welcome
7
7
 
@@ -18,7 +18,20 @@ list":http://rubyforge.org/mail/?group_id=296 available if you have any question
18
18
 
19
19
  h2. News
20
20
 
21
- *Webgen 0.3.3 released!!!*
21
+ <b>12.05.2005 - webgen 0.3.4 released!!!</b>
22
+
23
+ Major changes:
24
+
25
+ * FileHandler now uses path patterns and/or extensions for determining which files to process !
26
+ * ERB (embedded ruby) can now be used in templates and page files (see <a href="{relocatable: documentation/plugins/filehandler/pagehandler.html}">PageHandler</a>)!
27
+ * Relocatable tag now accepts complex URIs (URIs with query and fragment part, absolute URIs)
28
+ * Changed meta info name *menuOrder* to *orderInfo* (e.g. used for specifying order information for menus) -- you have to adapt your page and backing files!!!
29
+ * New parameters: <a href="{relocatable: documentation/plugins/filehandler/pagehandler.html}">PageHandler:useERB</a>
30
+ * Changed parameters: <a href="{relocatable: documentation/plugins/filehandler}">FileHandler:ignorePaths</a>, <a href="{relocatable: documentation/plugins/filehandler/copy.html}">FileCopyHandler:paths</a>
31
+ * New page describing meta information items used by plugins
32
+ * Fixed bugs
33
+
34
+ <b>21.04.2005 - webgen 0.3.3 released!!!</b>
22
35
 
23
36
  Major changes:
24
37
 
@@ -32,12 +45,12 @@ Major changes:
32
45
  * Fixed bugs
33
46
 
34
47
 
35
- <b>Webgen 0.3.2 released!!!</b>
48
+ <b>17.03.2005 - webgen 0.3.2 released!!!</b>
36
49
 
37
50
  Bug fix release for bug #1637 and other bugs
38
51
 
39
52
 
40
- *Webgen 0.3.1 released!!!*
53
+ <b>16.03.2005 - webgen 0.3.1 released!!!</b>
41
54
 
42
55
  Major changes:
43
56
 
@@ -51,7 +64,7 @@ Major changes:
51
64
  * Fixed bugs
52
65
 
53
66
 
54
- *Webgen 0.3.0 released!!!*
67
+ <b>21.02.2005 - webgen 0.3.0 released!!!</b>
55
68
 
56
69
  Major changes:
57
70
 
@@ -1,17 +1,20 @@
1
1
  index.html:
2
- menuOrder: 1
2
+ orderInfo: 1
3
3
 
4
4
  download.html:
5
- menuOrder: 3
5
+ orderInfo: 3
6
6
 
7
7
  features.html:
8
- menuOrder: 5
8
+ orderInfo: 5
9
9
 
10
10
  api.html:
11
11
  dest: rdoc/index.html
12
12
  title: API Reference
13
- menuOrder: 7
13
+ orderInfo: 7
14
14
  inMenu: true
15
15
 
16
16
  documentation/index.html:
17
- menuOrder: 9
17
+ orderInfo: 9
18
+
19
+ designs:
20
+ indexFile: ~
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.3-1'
6
+ version '0.3.4-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: composite.rb 203 2005-02-21 18:42:04Z thomas $
4
+ # $Id: composite.rb 271 2005-05-09 08:50:47Z thomas $
5
5
  #
6
6
  # webgen: template based static website generator
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -1,7 +1,7 @@
1
1
  #
2
2
  #--
3
3
  #
4
- # $Id: configuration.rb 259 2005-04-21 10:37:47Z thomas $
4
+ # $Id: configuration.rb 268 2005-05-02 15:28:31Z thomas $
5
5
  #
6
6
  # webgen: template based static website generator
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -37,7 +37,7 @@ end
37
37
 
38
38
  module Webgen
39
39
 
40
- VERSION = [0, 3, 3]
40
+ VERSION = [0, 3, 4]
41
41
  SUMMARY = "Webgen is a templated based static website generator."
42
42
  DESCRIPTION = "Webgen is a web page generator implemented in Ruby. " \
43
43
  "It is used to generate static web pages from templates and page " \
@@ -1,7 +1,7 @@
1
1
  #
2
2
  #--
3
3
  #
4
- # $Id: listener.rb 203 2005-02-21 18:42:04Z thomas $
4
+ # $Id: listener.rb 271 2005-05-09 08:50:47Z thomas $
5
5
  #
6
6
  # webgen: template based static website generator
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -1,7 +1,7 @@
1
1
  #
2
2
  #--
3
3
  #
4
- # $Id: node.rb 258 2005-04-21 10:35:28Z thomas $
4
+ # $Id: node.rb 272 2005-05-09 08:53:04Z thomas $
5
5
  #
6
6
  # webgen: template based static website generator
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -20,7 +20,7 @@
20
20
  #++
21
21
  #
22
22
 
23
- require 'util/composite'
23
+ require 'webgen/composite'
24
24
 
25
25
  class Node
26
26
 
@@ -82,8 +82,8 @@ class Node
82
82
 
83
83
 
84
84
  # Return the node identified by +destString+ relative to the current node.
85
- def node_for_string( destString )
86
- node = get_node_for_string( destString )
85
+ def node_for_string( destString, metainfo='dest' )
86
+ node = get_node_for_string( destString, metainfo )
87
87
  if node.nil?
88
88
  self.logger.warn { "Could not get destination node '#{destString}' for <#{recursive_value( 'src' )}>" }
89
89
  end
@@ -91,8 +91,8 @@ class Node
91
91
  end
92
92
 
93
93
  # Check if there is a node for +destString+.
94
- def node_for_string?( destString )
95
- get_node_for_string( destString ) != nil
94
+ def node_for_string?( destString, metainfo='dest' )
95
+ get_node_for_string( destString, metainfo )
96
96
  end
97
97
 
98
98
  # Return the level of the node. The level specifies how deep the node is in the hierarchy.
@@ -130,7 +130,7 @@ class Node
130
130
  private
131
131
  #######
132
132
 
133
- def get_node_for_string( destString )
133
+ def get_node_for_string( destString, metainfo='dest' )
134
134
  if /^\// =~ destString
135
135
  node = Node.root( self )
136
136
  destString = destString[1..-1]
@@ -145,7 +145,7 @@ class Node
145
145
  break if node.nil?
146
146
  case element
147
147
  when '..' then node = node.parent
148
- else node = node.find {|child| /^#{element}\/?$/ =~ child['dest'] }
148
+ else node = node.find {|child| /^#{element}\/?$/ =~ child[metainfo] }
149
149
  end
150
150
  end
151
151
 
@@ -154,11 +154,11 @@ class Node
154
154
  node = startElement
155
155
  elements.each_with_index do |element, index|
156
156
  break if node.nil?
157
- temp = node.find {|child| /^#{elements[index..-1].join( '/' )}\/?$/ =~ child['dest']}
157
+ temp = node.find {|child| /^#{elements[index..-1].join( '/' )}\/?$/ =~ child[metainfo]}
158
158
  if temp.nil?
159
159
  case element
160
160
  when '..' then node = node.parent
161
- else node = node.find {|child| /^#{element}\/?$/ =~ child['dest'] }
161
+ else node = node.find {|child| /^#{element}\/?$/ =~ child[metainfo] }
162
162
  end
163
163
  else
164
164
  node = temp
@@ -1,7 +1,7 @@
1
1
  #
2
2
  #--
3
3
  #
4
- # $Id: plugin.rb 259 2005-04-21 10:37:47Z thomas $
4
+ # $Id: plugin.rb 275 2005-05-11 17:30:20Z thomas $
5
5
  #
6
6
  # webgen: template based static website generator
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -36,6 +36,19 @@ module Webgen
36
36
  @@config = {}
37
37
  @@configFileData = ( File.exists?( 'config.yaml' ) ? YAML::load( File.new( 'config.yaml' ) ) : {} )
38
38
 
39
+ # Return plugin data
40
+ def self.config
41
+ @@config
42
+ end
43
+
44
+ # Shortcut for getting the plugin with the name +name+.
45
+ def self.[]( name )
46
+ pair = @@config.find {|k,v| v.plugin == name }
47
+ self.logger.warn { "Could not retrieve plugin '#{name}' as such a plugin does not exist!" } if pair.nil?
48
+ pair[1].obj unless pair.nil?
49
+ end
50
+
51
+ # Add subclass to plugin data.
39
52
  def self.inherited( klass )
40
53
  (@@config[klass] = OpenStruct.new).klass = klass
41
54
  @@config[klass].plugin = klass.name.split( /::/ ).last
@@ -45,22 +58,15 @@ module Webgen
45
58
  self.module_eval "def self.#{name}( obj ); @@config[self].#{name} = obj; end"
46
59
  end
47
60
 
48
- # Return plugin data
49
- def self.config
50
- @@config
51
- end
52
-
53
61
  # Add a dependency to the plugin. Dependencies are instantiated before the plugin gets
54
62
  # instantiated.
55
63
  def self.depends_on( *dep )
56
64
  dep.each {|d| (@@config[self].dependencies ||= []) << d}
57
65
  end
58
66
 
59
- # Shortcut for getting the plugin with the name +name+.
60
- def self.[]( name )
61
- pair = @@config.find {|k,v| v.plugin == name }
62
- self.logger.warn { "Could not retrieve plugin '#{name}' as such a plugin does not exist!" } if pair.nil?
63
- pair[1].obj unless pair.nil?
67
+ # Specify which meta information entries are used by the plugin.
68
+ def self.used_meta_info( *names )
69
+ names.each {|n| (@@config[self].used_meta_info ||= []) << n }
64
70
  end
65
71
 
66
72
  # Add a parameter for the current class. Has to be used by subclasses to define their parameters!
@@ -74,8 +80,9 @@ module Webgen
74
80
  def self.add_param( name, default, description, changeHandler = nil )
75
81
  self.logger.debug { "Adding parameter '#{name}' for plugin class '#{self.name}'" }
76
82
  if @@configFileData.kind_of?( Hash ) && @@configFileData.has_key?( @@config[self].plugin ) \
77
- && @@configFileData[@@config[self].plugin].has_key?( name )
83
+ && @@configFileData[@@config[self].plugin].kind_of?( Hash ) && @@configFileData[@@config[self].plugin].has_key?( name )
78
84
  curval = @@configFileData[@@config[self].plugin][name]
85
+ self.logger.debug { "Using configured value for parameter #{@@config[self].plugin} -> #{name}" }
79
86
  else
80
87
  curval = default
81
88
  end
@@ -1,7 +1,7 @@
1
1
  #
2
2
  #--
3
3
  #
4
- # $Id: backing.rb 256 2005-04-14 01:13:57Z thomas $
4
+ # $Id: backing.rb 275 2005-05-11 17:30:20Z thomas $
5
5
  #
6
6
  # webgen: template based static website generator
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -34,12 +34,13 @@ module FileHandlers
34
34
 
35
35
  def initialize
36
36
  super
37
- Webgen::Plugin['FileHandler'].add_msg_listener( :AFTER_DIR_READ, method( :process_backing_file ) )
37
+ Webgen::Plugin['FileHandler'].add_msg_listener( :AFTER_ALL_READ, method( :process_backing_files ) )
38
38
  end
39
39
 
40
40
  def create_node( path, parent )
41
41
  node = Node.new( parent )
42
42
  node['src'] = node['dest'] = node['title'] = File.basename( path )
43
+ node['int:backingFile?'] = true
43
44
  begin
44
45
  node['content'] = YAML::load( File.new( path ) )
45
46
  if !valid_content( node['content'] )
@@ -68,8 +69,8 @@ module FileHandlers
68
69
  && data.all? {|k,v| v.kind_of?( Hash ) }
69
70
  end
70
71
 
71
- def process_backing_file( dirNode )
72
- backingFiles = dirNode.find_all {|child| /\.#{Webgen::Plugin.config[self.class].extension}$/ =~ child['src'] }
72
+ def process_backing_files( dirNode )
73
+ backingFiles = dirNode.find_all {|child| child['int:backingFile?'] }
73
74
 
74
75
  backingFiles.each do |backingFile|
75
76
  backingFile['content'].each do |filename, data|
@@ -82,6 +83,8 @@ module FileHandlers
82
83
  end
83
84
  end
84
85
  end
86
+
87
+ dirNode.each {|child| process_backing_files( child ) if child['directory']}
85
88
  end
86
89
 
87
90
 
@@ -1,7 +1,7 @@
1
1
  #
2
2
  #--
3
3
  #
4
- # $Id: directory.rb 256 2005-04-14 01:13:57Z thomas $
4
+ # $Id: directory.rb 275 2005-05-11 17:30:20Z thomas $
5
5
  #
6
6
  # webgen: template based static website generator
7
7
  # Copyright (C) 2004 Thomas Leitner
@@ -32,13 +32,14 @@ module FileHandlers
32
32
 
33
33
  def initialize( parent, name )
34
34
  super( parent )
35
- self['title'] = self['directoryName'] = name
35
+ self['title'] = name
36
36
  self['src'] = self['dest'] = name + '/'
37
37
  self['processor'] = Webgen::Plugin['DirHandler']
38
+ self['int:directory?'] = true
38
39
  end
39
40
 
40
41
  def []( name )
41
- process_dir_index if super('indexFile').nil? && name == 'indexFile'
42
+ process_dir_index if !self.metainfo.has_key?( 'indexFile' ) && name == 'indexFile'
42
43
  super
43
44
  end
44
45
 
@@ -57,10 +58,10 @@ module FileHandlers
57
58
 
58
59
 
59
60
  summary "Handles directories"
60
- extension :dir
61
+ handle_path '**/'
61
62
  add_param 'indexFile', 'index.html', 'The default file name for the directory index file.'
62
63
  depends_on 'FileHandler'
63
-
64
+ used_meta_info 'indexFile', 'directoryName'
64
65
 
65
66
  # Return a new DirNode.
66
67
  def create_node( path, parent )
@@ -79,9 +80,9 @@ module FileHandlers
79
80
  # Return the page node for the directory +node+ using the specified language +lang+. If an
80
81
  # index file is specified, then the its correct language node is returned, else +node+ is
81
82
  # returned.
82
- def get_page_node_for_lang( node, lang )
83
+ def get_node_for_lang( node, lang )
83
84
  if node['indexFile']
84
- node['indexFile']['processor'].get_page_node_for_lang( node['indexFile'], lang )
85
+ node['indexFile']['processor'].get_node_for_lang( node['indexFile'], lang )
85
86
  else
86
87
  node
87
88
  end
@@ -89,8 +90,8 @@ module FileHandlers
89
90
 
90
91
  # Get the HTML link for the directory +node+.
91
92
  def get_html_link( node, refNode, title = nil )
92
- lang_node = get_page_node_for_lang( node, refNode['lang'] )
93
- title ||= lang_node['directoryName'] || node['directoryName']
93
+ lang_node = get_node_for_lang( node, refNode['lang'] )
94
+ title ||= lang_node['directoryName'] || node['title']
94
95
  super( lang_node, refNode, title )
95
96
  end
96
97