webgen 0.3.4 → 0.3.5
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.
- data/ChangeLog +201 -0
- data/Rakefile +3 -2
- data/TODO +31 -4
- data/VERSION +1 -1
- data/data/webgen/example/config.yaml +2 -0
- data/data/webgen/example/src/default.css +84 -0
- data/data/webgen/example/src/default.template +32 -0
- data/data/webgen/example/src/index.page +8 -0
- data/{doc/src → data/webgen/images}/generated_by_webgen.png +0 -0
- data/data/webgen/images/valid-css.gif +0 -0
- data/data/webgen/images/valid-xhtml11.png +0 -0
- data/data/webgen/images/webgen_logo.png +0 -0
- data/doc/config.yaml +2 -0
- data/doc/plugin/extension.rb +8 -4
- data/doc/plugin/resources.rb +30 -0
- data/doc/src/default.css +251 -149
- data/doc/src/default.template +8 -8
- data/doc/src/documentation/gettingstarted.page +1 -1
- data/doc/src/documentation/index.page +6 -2
- data/doc/src/documentation/plugins/filehandler/backing.page +22 -9
- data/doc/src/documentation/plugins/filehandler/galleryhandler.page +1 -1
- data/doc/src/documentation/plugins/filehandler/index.page +9 -4
- data/doc/src/documentation/plugins/filehandler/pagehandler.page +33 -10
- data/doc/src/documentation/plugins/index.page +9 -1
- data/doc/src/documentation/plugins/menustyles/horizontal-dropdown.page +42 -0
- data/doc/src/documentation/plugins/menustyles/horizontal.page +21 -0
- data/doc/src/documentation/plugins/menustyles/index.page +12 -0
- data/doc/src/documentation/plugins/menustyles/partial.page +27 -0
- data/doc/src/documentation/plugins/menustyles/vertical-dropdown.page +23 -0
- data/doc/src/documentation/plugins/menustyles/vertical.page +32 -0
- data/doc/src/documentation/plugins/resourcemanager.page +30 -0
- data/doc/src/documentation/plugins/tags/index.page +2 -2
- data/doc/src/documentation/plugins/tags/langbar.page +4 -4
- data/doc/src/documentation/plugins/tags/menu.page +6 -17
- data/doc/src/documentation/plugins/tags/navbar.page +2 -1
- data/doc/src/documentation/plugins/tags/resource.page +22 -0
- data/doc/src/download.page +1 -1
- data/doc/src/features.page +32 -9
- data/doc/src/index.page +24 -10
- data/doc/src/meta.info +16 -6
- data/install.rb +1 -1
- data/lib/webgen/configuration.rb +24 -2
- data/lib/webgen/node.rb +29 -5
- data/lib/webgen/plugin.rb +1 -5
- data/lib/webgen/plugins/contenthandler/textile.rb +3 -3
- data/lib/webgen/plugins/filehandler/backing.rb +5 -4
- data/lib/webgen/plugins/filehandler/directory.rb +3 -3
- data/lib/webgen/plugins/filehandler/filehandler.rb +8 -4
- data/lib/webgen/plugins/filehandler/page.rb +33 -18
- data/lib/webgen/plugins/filehandler/picturegallery.rb +10 -8
- data/lib/webgen/plugins/menustyles/defaultmenustyle.rb +73 -0
- data/lib/webgen/plugins/menustyles/horizontal.rb +93 -0
- data/lib/webgen/plugins/menustyles/horizontal_dropdown.rb +113 -0
- data/lib/webgen/plugins/menustyles/partial.rb +95 -0
- data/lib/webgen/plugins/menustyles/vertical.rb +107 -0
- data/lib/webgen/plugins/menustyles/vertical_dropdown.rb +107 -0
- data/lib/webgen/plugins/resourcemanager.rb +264 -0
- data/lib/webgen/plugins/tags/langbar.rb +9 -5
- data/lib/webgen/plugins/tags/menu.rb +4 -66
- data/lib/webgen/plugins/treewalker.rb +7 -6
- data/lib/webgen/webgen.rb +72 -161
- metadata +37 -6
- data/doc/src/logo.png +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
#--
|
3
3
|
#
|
4
|
-
# $Id: page.rb
|
4
|
+
# $Id: page.rb 301 2005-06-14 10:25:49Z thomas $
|
5
5
|
#
|
6
6
|
# webgen: template based static website generator
|
7
7
|
# Copyright (C) 2004 Thomas Leitner
|
@@ -43,7 +43,7 @@ module FileHandlers
|
|
43
43
|
add_param 'outputNameStyle', [:name, ['.', :lang], '.html'], 'Defines how the output name should be built. The correct name will be used for ' \
|
44
44
|
'the :name part and the file language will be used for the :lang part. If <defaultLangInFilename> is true, the :lang part or the subarray in which '\
|
45
45
|
'the :lang part was defined, will be omitted.'
|
46
|
-
add_param 'validator',
|
46
|
+
add_param 'validator', nil, 'The validator for checking HTML files on their validness. Set to "" or nil to prevent checking.'
|
47
47
|
add_param 'useERB', true, 'Specifies if the content blocks of the page file should be processed with ERB before they are formatted.'
|
48
48
|
|
49
49
|
used_meta_info 'title', 'orderInfo', 'lang', 'blocks', 'useERB'
|
@@ -56,26 +56,39 @@ module FileHandlers
|
|
56
56
|
create_node_internally( parse_data( data, srcName ), analyse_file_name( File.basename( srcName ) ), parent )
|
57
57
|
end
|
58
58
|
|
59
|
-
def
|
60
|
-
|
59
|
+
def render_node( node, with_template = true, block_name = 'content' )
|
60
|
+
unless node['int:content-formatted']
|
61
|
+
useERB = node['useERB'] || ( node['useERB'].nil? && get_param( 'useERB' ) )
|
62
|
+
node['blocks'].each do |blockdata|
|
63
|
+
begin
|
64
|
+
content = ( useERB ? ERB.new( blockdata['data'] ).result( binding ) : blockdata['data'] )
|
65
|
+
rescue Exception => e
|
66
|
+
logger.error { "ERB threw an error while processing an ERB template (<#{node.recursive_value('src')}>, block #{blockdata['name']}): #{e.message}" }
|
67
|
+
content = blockdata['data']
|
68
|
+
end
|
69
|
+
node[blockdata['name']] = Webgen::Plugin['DefaultContentHandler'].get_format( blockdata['format'] ).format_content( content )
|
70
|
+
end
|
71
|
+
node['int:content-formatted'] = true
|
72
|
+
end
|
61
73
|
|
62
|
-
|
63
|
-
|
74
|
+
if with_template
|
75
|
+
templateNode = Webgen::Plugin['TemplateFileHandler'].get_template_for_node( node )
|
64
76
|
begin
|
65
|
-
|
77
|
+
outstring = ERB.new( templateNode['content'] ).result( binding )
|
66
78
|
rescue Exception => e
|
67
|
-
logger.error { "ERB threw an error while processing an ERB template (<#{
|
68
|
-
|
79
|
+
logger.error { "ERB threw an error while processing an ERB template (<#{templateNode.recursive_value('src')}>: #{e.message}" }
|
80
|
+
outstring = templateNode['content'].dup
|
69
81
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
outstring = ERB.new( templateNode['content'] ).result( binding )
|
74
|
-
rescue Exception => e
|
75
|
-
logger.error { "ERB threw an error while processing an ERB template (<#{templateNode.recursive_value('src')}>: #{e.message}" }
|
76
|
-
outstring = templateNode['content'].dup
|
82
|
+
else
|
83
|
+
templateNode = node
|
84
|
+
outstring = node[block_name].to_s.dup
|
77
85
|
end
|
78
|
-
|
86
|
+
|
87
|
+
Webgen::Plugin['Tags'].substitute_tags( outstring, node, templateNode )
|
88
|
+
end
|
89
|
+
|
90
|
+
def write_node( node )
|
91
|
+
outstring = render_node( node )
|
79
92
|
|
80
93
|
File.open( node.recursive_value( 'dest' ), File::CREAT|File::TRUNC|File::RDWR ) do |file|
|
81
94
|
file.write( outstring )
|
@@ -125,7 +138,8 @@ module FileHandlers
|
|
125
138
|
def create_node_internally( data, analysed, parent )
|
126
139
|
lang = data['lang'] || analysed.lang
|
127
140
|
|
128
|
-
pagename =
|
141
|
+
pagename = analysed.name + '.page'
|
142
|
+
localizedPagename = analysed.name + '.' + lang + '.page'
|
129
143
|
|
130
144
|
if node = parent.find {|node| node['int:pagename'] == pagename && node['lang'] == lang }
|
131
145
|
logger.warn do
|
@@ -141,6 +155,7 @@ module FileHandlers
|
|
141
155
|
node['src'] = analysed.srcName
|
142
156
|
node['dest'] = create_output_name( analysed, node['outputNameStyle'] || get_param( 'outputNameStyle' ) )
|
143
157
|
node['int:pagename'] = pagename
|
158
|
+
node['int:local-pagename'] = localizedPagename
|
144
159
|
node['processor'] = self
|
145
160
|
end
|
146
161
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
#--
|
3
3
|
#
|
4
|
-
# $Id: picturegallery.rb
|
4
|
+
# $Id: picturegallery.rb 303 2005-06-24 13:44:14Z thomas $
|
5
5
|
#
|
6
6
|
# webgen: template based static website generator
|
7
7
|
# Copyright (C) 2004 Thomas Leitner
|
@@ -154,6 +154,7 @@ module FileHandlers
|
|
154
154
|
imageData['imageFilename'] = image
|
155
155
|
imageData['srcName'] = File.basename( image ).tr( ' .', '_' ) + '.html'
|
156
156
|
imageData['thumbnail'] ||= get_thumbnail( imageData, parent )
|
157
|
+
imageData['thumbnailSize'] ||= @filedata['thumbnailSize']
|
157
158
|
|
158
159
|
imageList << imageData
|
159
160
|
end
|
@@ -175,7 +176,7 @@ module FileHandlers
|
|
175
176
|
remove_method :get_thumbnail
|
176
177
|
def get_thumbnail( imageData, parent )
|
177
178
|
p_node = Webgen::Plugin['DirHandler'].recursive_create_path( File.dirname( imageData['imageFilename'] ), parent )
|
178
|
-
node = Webgen::Plugin['ThumbnailWriter'].create_node( File.join( @path, imageData['imageFilename'] ), p_node )
|
179
|
+
node = Webgen::Plugin['ThumbnailWriter'].create_node( File.join( @path, imageData['imageFilename'] ), p_node, imageData['thumbnailSize'] )
|
179
180
|
p_node.add_child( node )
|
180
181
|
|
181
182
|
File.dirname( imageData['imageFilename'] ) + '/' + node['dest']
|
@@ -188,19 +189,20 @@ module FileHandlers
|
|
188
189
|
summary "Writes out thumbnails with RMagick"
|
189
190
|
add_param "thumbnailSize", "100x100", "The size of the thumbnails"
|
190
191
|
|
191
|
-
def create_node( file, parent )
|
192
|
+
def create_node( file, parent, thumbnailSize = nil )
|
192
193
|
node = Node.new( parent )
|
193
194
|
node['title'] = node['src'] = node['dest'] = 'tn_' + File.basename( file )
|
194
|
-
node['
|
195
|
+
node['int:thumbnailFile'] = file
|
196
|
+
node['int:thumbnailSize'] = thumbnailSize
|
195
197
|
node['processor'] = self
|
196
198
|
node
|
197
199
|
end
|
198
200
|
|
199
201
|
def write_node( node )
|
200
|
-
if Webgen::Plugin['FileHandler'].file_modified?( node['
|
201
|
-
self.logger.info {"Creating thumbnail <#{node.recursive_value('dest')}> from <#{node['
|
202
|
-
image = Magick::ImageList.new( node['
|
203
|
-
image.change_geometry( get_param( 'thumbnailSize' ) ) {|c,r,i| i.resize!( c, r )}
|
202
|
+
if Webgen::Plugin['FileHandler'].file_modified?( node['int:thumbnailFile'], node.recursive_value( 'dest' ) )
|
203
|
+
self.logger.info {"Creating thumbnail <#{node.recursive_value('dest')}> from <#{node['int:thumbnailFile']}>"}
|
204
|
+
image = Magick::ImageList.new( node['int:thumbnailFile'] )
|
205
|
+
image.change_geometry( node['int:thumbnailSize'] || get_param( 'thumbnailSize' ) ) {|c,r,i| i.resize!( c, r )}
|
204
206
|
image.write( node.recursive_value( 'dest' ) )
|
205
207
|
end
|
206
208
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
#
|
4
|
+
# $Id: defaultmenustyle.rb 293 2005-06-11 08:37:51Z 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 MenuStyles
|
25
|
+
|
26
|
+
class DefaultMenuStyle < Webgen::Plugin
|
27
|
+
|
28
|
+
summary "Base class for all menu styles"
|
29
|
+
|
30
|
+
define_handler 'menu_style'
|
31
|
+
|
32
|
+
add_param 'divClass', '', 'Additional CSS class for the div-tag surrounding the menu'
|
33
|
+
add_param 'submenuClass', 'webgen-menu-submenu', 'Specifies the class of a submenu.'
|
34
|
+
add_param 'submenuInHierarchyClass', 'webgen-menu-submenu-inhierarchy', 'Specifies the class of the submenus which are ' \
|
35
|
+
'in the hierarchy of the selected menu item.'
|
36
|
+
add_param 'selectedMenuitemClass', 'webgen-menu-item-selected', 'Specifies the class of the selected menu item.'
|
37
|
+
|
38
|
+
def build_menu( srcNode, menuTree, options )
|
39
|
+
@options = options
|
40
|
+
internal_build_menu( srcNode, menuTree )
|
41
|
+
end
|
42
|
+
|
43
|
+
def internal_build_menu( srcNode, menuTree )
|
44
|
+
""
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_param( name )
|
48
|
+
( !@options.nil? && @options.kind_of?( Hash ) && @options.has_key?( name ) ? @options[name] : super )
|
49
|
+
end
|
50
|
+
|
51
|
+
#########
|
52
|
+
protected
|
53
|
+
#########
|
54
|
+
|
55
|
+
def menu_item_details( srcNode, node )
|
56
|
+
langNode = node['processor'].get_node_for_lang( node, srcNode['lang'] )
|
57
|
+
isDir = node['int:directory?']
|
58
|
+
|
59
|
+
styles = []
|
60
|
+
styles << get_param( 'submenuClass' ) if isDir
|
61
|
+
styles << get_param( 'submenuInHierarchyClass' ) if isDir && srcNode.in_subtree?( node )
|
62
|
+
styles << get_param( 'selectedMenuitemClass' ) if langNode.recursive_value( 'dest' ) == srcNode.recursive_value( 'dest' )
|
63
|
+
|
64
|
+
style = "class=\"#{styles.join(' ')}\"" if styles.length > 0
|
65
|
+
link = node['processor'].get_html_link( node, srcNode )
|
66
|
+
|
67
|
+
self.logger.debug { [style, link] }
|
68
|
+
return style, link
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
#
|
4
|
+
# $Id: horizontal.rb 293 2005-06-11 08:37:51Z 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
|
+
require 'webgen/plugins/menustyles/defaultmenustyle'
|
24
|
+
|
25
|
+
module MenuStyles
|
26
|
+
|
27
|
+
class HorizontalMenuStyle < MenuStyles::DefaultMenuStyle
|
28
|
+
|
29
|
+
summary "Builds a horizontal menu"
|
30
|
+
|
31
|
+
register_menu_style 'horizontal'
|
32
|
+
|
33
|
+
CSS = "
|
34
|
+
/* START Webgen horizontal menu style */
|
35
|
+
.webgen-menu-horiz {
|
36
|
+
text-align: center;
|
37
|
+
}
|
38
|
+
|
39
|
+
.webgen-menu-horiz ul {
|
40
|
+
display: block;
|
41
|
+
margin: 0px;
|
42
|
+
padding-bottom: 3px;
|
43
|
+
margin-bottom: 3px;
|
44
|
+
}
|
45
|
+
|
46
|
+
.webgen-menu-horiz li {
|
47
|
+
display: inline;
|
48
|
+
padding: 0px 5px;
|
49
|
+
}
|
50
|
+
|
51
|
+
.webgen-menu-horiz .webgen-menu-submenu-inhierarchy {
|
52
|
+
font-weight: bold;
|
53
|
+
}
|
54
|
+
|
55
|
+
.webgen-menu-horiz .webgen-menu-item-selected {
|
56
|
+
font-weight: bold;
|
57
|
+
}
|
58
|
+
/* STOP Webgen horizontal menu style */
|
59
|
+
"
|
60
|
+
|
61
|
+
def internal_build_menu( srcNode, menuTree )
|
62
|
+
unless defined?( @css_added )
|
63
|
+
Webgen::Plugin['ResourceManager'].append_data( 'webgen-css', CSS )
|
64
|
+
@css_added = true
|
65
|
+
end
|
66
|
+
"<div class=\"webgen-menu-horiz #{get_param('divClass')}\">#{submenu( srcNode, menuTree, 1 )}</div>"
|
67
|
+
end
|
68
|
+
|
69
|
+
#######
|
70
|
+
private
|
71
|
+
#######
|
72
|
+
|
73
|
+
def submenu( srcNode, node, level )
|
74
|
+
if node.nil? || node['node'].level > srcNode.level || !srcNode.in_subtree?( node['node'] )
|
75
|
+
return ''
|
76
|
+
end
|
77
|
+
|
78
|
+
submenu = ''
|
79
|
+
out = "<ul>"
|
80
|
+
node.each do |child|
|
81
|
+
submenu << (child['node']['int:directory?'] ? submenu( srcNode, child, level + 1 ) : '')
|
82
|
+
style, link = menu_item_details( srcNode, child['node'] )
|
83
|
+
out << "<li #{style}>#{link}</li>"
|
84
|
+
end
|
85
|
+
out << "</ul>"
|
86
|
+
out << submenu
|
87
|
+
|
88
|
+
return out
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
#
|
4
|
+
# $Id: horizontal_dropdown.rb 300 2005-06-14 10:04:17Z 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
|
+
require 'webgen/plugins/menustyles/defaultmenustyle'
|
24
|
+
|
25
|
+
module MenuStyles
|
26
|
+
|
27
|
+
class HorizontalDropdownMenuStyle < MenuStyles::DefaultMenuStyle
|
28
|
+
|
29
|
+
summary "Builds a horizontal menu with CSS drop down submenus"
|
30
|
+
|
31
|
+
register_menu_style 'horizontal-dropdown'
|
32
|
+
|
33
|
+
CSS = "
|
34
|
+
/* START Webgen horizontal dropdown menu style */
|
35
|
+
.webgen-menu-horiz-dd ul {
|
36
|
+
list-style-type: none;
|
37
|
+
margin: 0;
|
38
|
+
padding: 0;
|
39
|
+
float: left;
|
40
|
+
}
|
41
|
+
|
42
|
+
.webgen-menu-horiz-dd ul ul {
|
43
|
+
width: 15em;
|
44
|
+
border: 1px solid black;
|
45
|
+
position: absolute;
|
46
|
+
z-index: 500;
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
.webgen-menu-horiz-dd a {
|
51
|
+
display: block;
|
52
|
+
margin: 0px;
|
53
|
+
padding: 3px 3px;
|
54
|
+
background-color: white;
|
55
|
+
}
|
56
|
+
|
57
|
+
.webgen-menu-horiz-dd li {
|
58
|
+
position: relative;
|
59
|
+
}
|
60
|
+
|
61
|
+
.webgen-menu-horiz-dd ul ul ul {
|
62
|
+
position: absolute;
|
63
|
+
top: 0;
|
64
|
+
left: 100%;
|
65
|
+
}
|
66
|
+
|
67
|
+
.webgen-menu-horiz-dd ul ul {
|
68
|
+
display: none;
|
69
|
+
}
|
70
|
+
|
71
|
+
.webgen-menu-horiz-dd ul li:hover > ul > ul {
|
72
|
+
display: none;
|
73
|
+
}
|
74
|
+
|
75
|
+
.webgen-menu-horiz-dd ul li:hover > ul {
|
76
|
+
display: block;
|
77
|
+
}
|
78
|
+
/* STOP Webgen horizontal dropdown menu style */
|
79
|
+
"
|
80
|
+
|
81
|
+
def internal_build_menu( srcNode, menuTree )
|
82
|
+
unless defined?( @css_added )
|
83
|
+
Webgen::Plugin['ResourceManager'].append_data( 'webgen-css', CSS )
|
84
|
+
@css_added = true
|
85
|
+
end
|
86
|
+
"<div class=\"webgen-menu-horiz-dd #{get_param('divClass')}\">#{submenu( srcNode, menuTree, 1 )}</div>"
|
87
|
+
end
|
88
|
+
|
89
|
+
#######
|
90
|
+
private
|
91
|
+
#######
|
92
|
+
|
93
|
+
def submenu( srcNode, node, level )
|
94
|
+
out = ''
|
95
|
+
out = "<ul>" if level > 1
|
96
|
+
node.each do |child|
|
97
|
+
menu = child['node']['int:directory?'] ? submenu( srcNode, child, level + 1 ) : ''
|
98
|
+
style, link = menu_item_details( srcNode, child['node'] )
|
99
|
+
|
100
|
+
out << "<ul>" if level == 1
|
101
|
+
out << "<li #{style}>#{link}"
|
102
|
+
out << menu
|
103
|
+
out << "</li>"
|
104
|
+
out << "</ul>" if level == 1
|
105
|
+
end
|
106
|
+
out << "</ul>" if level > 1
|
107
|
+
|
108
|
+
return out
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
#
|
4
|
+
# $Id: partial.rb 293 2005-06-11 08:37:51Z 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
|
+
require 'webgen/plugins/menustyles/defaultmenustyle'
|
24
|
+
|
25
|
+
module MenuStyles
|
26
|
+
|
27
|
+
class PartialMenuStyle < MenuStyles::DefaultMenuStyle
|
28
|
+
|
29
|
+
summary "Builds a partial menu"
|
30
|
+
description "Creates a menu that only shows the menu levels under the current page"
|
31
|
+
|
32
|
+
register_menu_style 'partial'
|
33
|
+
|
34
|
+
add_param 'subtreeLevel', 1, \
|
35
|
+
'Specifies how many levels should be shown. The number specifies ' \
|
36
|
+
'the maximum depth the menu will have.'
|
37
|
+
add_param 'dropdown', false, 'Specifies if the menu should be a drop-down menu'
|
38
|
+
|
39
|
+
CSS = "
|
40
|
+
/* START Webgen partial menu style */
|
41
|
+
.webgen-menu-partial-dropdown > ul {
|
42
|
+
display: none;
|
43
|
+
}
|
44
|
+
|
45
|
+
.webgen-menu-partial-dropdown:hover > ul {
|
46
|
+
display: block;
|
47
|
+
}
|
48
|
+
/* STOP Webgen partial menu style */
|
49
|
+
"
|
50
|
+
|
51
|
+
def internal_build_menu( srcNode, menuTree )
|
52
|
+
unless defined?( @css_added )
|
53
|
+
Webgen::Plugin['ResourceManager'].append_data( 'webgen-css', CSS )
|
54
|
+
@css_added = true
|
55
|
+
end
|
56
|
+
styles = ['webgen-menu-partial',
|
57
|
+
(get_param( 'dropdown' ) ? 'webgen-menu-partial-dropdown' : ''),
|
58
|
+
get_param( 'divClass' )]
|
59
|
+
|
60
|
+
"<div class=\"#{styles.join(' ')}\">#{submenu( srcNode, menuTree, 1 )}</div>"
|
61
|
+
end
|
62
|
+
|
63
|
+
#######
|
64
|
+
private
|
65
|
+
#######
|
66
|
+
|
67
|
+
def submenu( srcNode, node, level )
|
68
|
+
if node.nil? || level - srcNode.level >= get_param( 'subtreeLevel' ) || \
|
69
|
+
(level >= srcNode.level && !node['node'].in_subtree?( srcNode ))
|
70
|
+
return ''
|
71
|
+
end
|
72
|
+
|
73
|
+
out = ''
|
74
|
+
if get_param( 'dropdown' ) && level == srcNode.level
|
75
|
+
style, link = menu_item_details( srcNode, node['node'] )
|
76
|
+
out << "#{link}"
|
77
|
+
end
|
78
|
+
|
79
|
+
out << "<ul>" if level >= srcNode.level
|
80
|
+
node.each do |child|
|
81
|
+
menu = child['node']['int:directory?'] ? submenu( srcNode, child, level + 1 ) : ''
|
82
|
+
style, link = menu_item_details( srcNode, child['node'] )
|
83
|
+
|
84
|
+
out << "<li #{style}>#{link}" if level >= srcNode.level
|
85
|
+
out << menu
|
86
|
+
out << "</li>" if level >= srcNode.level
|
87
|
+
end
|
88
|
+
out << "</ul>" if level >= srcNode.level
|
89
|
+
|
90
|
+
return out
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|