webgen 0.3.0

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 (105) hide show
  1. data/COPYING +340 -0
  2. data/ChangeLog +2172 -0
  3. data/README +16 -0
  4. data/Rakefile +283 -0
  5. data/TODO +133 -0
  6. data/VERSION +1 -0
  7. data/bin/webgen +5 -0
  8. data/doc/extension.config +55 -0
  9. data/doc/src/default.css +129 -0
  10. data/doc/src/default.template +45 -0
  11. data/doc/src/design.gallery +18 -0
  12. data/doc/src/designs/default.png +0 -0
  13. data/doc/src/designs/nostyle.png +0 -0
  14. data/doc/src/designs/old.png +0 -0
  15. data/doc/src/documentation/extloader.page +20 -0
  16. data/doc/src/documentation/filehandler/backing.page +16 -0
  17. data/doc/src/documentation/filehandler/copy.page +12 -0
  18. data/doc/src/documentation/filehandler/directory.page +15 -0
  19. data/doc/src/documentation/filehandler/index.page +13 -0
  20. data/doc/src/documentation/filehandler/page.page +122 -0
  21. data/doc/src/documentation/filehandler/picturegallery.page +25 -0
  22. data/doc/src/documentation/filehandler/template.page +21 -0
  23. data/doc/src/documentation/index.page +47 -0
  24. data/doc/src/documentation/tags/date.page +19 -0
  25. data/doc/src/documentation/tags/executecommand.page +19 -0
  26. data/doc/src/documentation/tags/includefile.page +15 -0
  27. data/doc/src/documentation/tags/index.page +39 -0
  28. data/doc/src/documentation/tags/lang.de.page +6 -0
  29. data/doc/src/documentation/tags/lang.page +27 -0
  30. data/doc/src/documentation/tags/menu.de.page +11 -0
  31. data/doc/src/documentation/tags/menu.page +30 -0
  32. data/doc/src/documentation/tags/meta.page +20 -0
  33. data/doc/src/documentation/tags/multilang.de.page +4 -0
  34. data/doc/src/documentation/tags/multilang.fr.page +4 -0
  35. data/doc/src/documentation/tags/multilang.page +4 -0
  36. data/doc/src/documentation/tags/navbar.page +19 -0
  37. data/doc/src/documentation/tags/relocatable.page +16 -0
  38. data/doc/src/documentation/tags/wikilink.page +18 -0
  39. data/doc/src/download.page +42 -0
  40. data/doc/src/features.page +14 -0
  41. data/doc/src/index.page +48 -0
  42. data/doc/src/logo.png +0 -0
  43. data/doc/src/meta.info +22 -0
  44. data/install.rb +19 -0
  45. data/lib/util/composite.rb +101 -0
  46. data/lib/util/listener.rb +105 -0
  47. data/lib/webgen/configuration.rb +216 -0
  48. data/lib/webgen/logging.rb +73 -0
  49. data/lib/webgen/node.rb +147 -0
  50. data/lib/webgen/plugins/extloader.rb +88 -0
  51. data/lib/webgen/plugins/filehandler/backing.rb +200 -0
  52. data/lib/webgen/plugins/filehandler/directory.rb +96 -0
  53. data/lib/webgen/plugins/filehandler/filecopy.rb +59 -0
  54. data/lib/webgen/plugins/filehandler/filehandler.rb +209 -0
  55. data/lib/webgen/plugins/filehandler/pagehandler/html.rb +43 -0
  56. data/lib/webgen/plugins/filehandler/pagehandler/markdown.rb +53 -0
  57. data/lib/webgen/plugins/filehandler/pagehandler/page.rb +205 -0
  58. data/lib/webgen/plugins/filehandler/pagehandler/rdoc.rb +50 -0
  59. data/lib/webgen/plugins/filehandler/pagehandler/textile.rb +52 -0
  60. data/lib/webgen/plugins/filehandler/picturegallery.rb +194 -0
  61. data/lib/webgen/plugins/filehandler/template.rb +98 -0
  62. data/lib/webgen/plugins/tags/date.rb +46 -0
  63. data/lib/webgen/plugins/tags/executecommand.rb +53 -0
  64. data/lib/webgen/plugins/tags/includefile.rb +60 -0
  65. data/lib/webgen/plugins/tags/lang.rb +50 -0
  66. data/lib/webgen/plugins/tags/menu.rb +198 -0
  67. data/lib/webgen/plugins/tags/meta.rb +54 -0
  68. data/lib/webgen/plugins/tags/navbar.rb +62 -0
  69. data/lib/webgen/plugins/tags/relocatable.rb +58 -0
  70. data/lib/webgen/plugins/tags/tags.rb +247 -0
  71. data/lib/webgen/plugins/tags/wikilink.rb +58 -0
  72. data/lib/webgen/plugins/treewalker.rb +81 -0
  73. data/lib/webgen/webgen.rb +155 -0
  74. data/setup.rb +1331 -0
  75. data/testsite/config.yaml +7 -0
  76. data/testsite/src/bluecloth.page +102 -0
  77. data/testsite/src/default.css +146 -0
  78. data/testsite/src/default.template +33 -0
  79. data/testsite/src/home.en.page +22 -0
  80. data/testsite/src/home.page +22 -0
  81. data/testsite/src/images/bghack.png +0 -0
  82. data/testsite/src/images/o.png +0 -0
  83. data/testsite/src/images/smagacor.png +0 -0
  84. data/testsite/src/images/tictactoe.png +0 -0
  85. data/testsite/src/images/x.png +0 -0
  86. data/testsite/src/index.page +21 -0
  87. data/testsite/src/meta.info +15 -0
  88. data/testsite/src/news.page +20 -0
  89. data/testsite/src/news_are_so-cool.de.page +19 -0
  90. data/testsite/src/noindex/noindex.page +20 -0
  91. data/testsite/src/pictures/index.page +20 -0
  92. data/testsite/src/projects.de.page +11 -0
  93. data/testsite/src/projects.es.page +11 -0
  94. data/testsite/src/projects.page +17 -0
  95. data/testsite/src/projects/00.index.de.page +10 -0
  96. data/testsite/src/projects/01.project2.page +20 -0
  97. data/testsite/src/projects/02.project1.page +20 -0
  98. data/testsite/src/projects/05.project3.page +22 -0
  99. data/testsite/src/projects/index.page +20 -0
  100. data/testsite/src/projects/subproj/index.page +22 -0
  101. data/testsite/src/projects/subproj/project3.page +21 -0
  102. data/testsite/src/rdoc.page +12 -0
  103. data/testsite/src/redcloth.page +106 -0
  104. data/testsite/src/test.gallery +5 -0
  105. metadata +155 -0
@@ -0,0 +1,60 @@
1
+ #
2
+ #--
3
+ #
4
+ # $Id: includefile.rb 203 2005-02-21 18:42:04Z 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 'cgi'
24
+ require 'webgen/plugins/tags/tags'
25
+
26
+ module Tags
27
+
28
+ # Includes a file verbatim. All HTML special characters are escaped.
29
+ class IncludeFileTag < DefaultTag
30
+
31
+ summary "Includes a file verbatim"
32
+ depends_on 'Tags'
33
+ add_param 'filename', nil, 'The name of the file which should be included'
34
+ add_param 'processOutput', true, 'The file content will be processed if true'
35
+ add_param 'escapeHTML', true, 'Special HTML characters in the file content will be escaped if true'
36
+ set_mandatory 'filename', true
37
+
38
+ def initialize
39
+ super
40
+ register_tag( 'includeFile' )
41
+ end
42
+
43
+ def process_tag( tag, node, refNode )
44
+ @processOutput = get_param( 'processOutput' )
45
+ content = ''
46
+ begin
47
+ filename = refNode.parent.recursive_value( 'src' ) + get_param( 'filename' )
48
+ self.logger.debug { "File location: <#{filename}>" }
49
+ content = File.read( filename )
50
+ rescue
51
+ self.logger.error { "Given file <#{filename}> does not exist (tag specified in <#{refNode.recursive_value( 'src' )}>" }
52
+ end
53
+ content = CGI::escapeHTML( content ) if get_param( 'escapeHTML' )
54
+
55
+ content
56
+ end
57
+
58
+ end
59
+
60
+ end
@@ -0,0 +1,50 @@
1
+ #
2
+ #--
3
+ #
4
+ # $Id: lang.rb 203 2005-02-21 18:42:04Z 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/tags/tags'
24
+
25
+ module Tags
26
+
27
+ # Generates a list with all the languages for a page.
28
+ class LanguageTag < DefaultTag
29
+
30
+ summary 'Provides links to translations of the page'
31
+ add_param 'separator', ' | ', 'Separates the languages from each other.'
32
+ add_param 'showSingleLang', true, 'True if the language link should be shown '\
33
+ 'although the page is only available in one language.'
34
+ depends_on 'Tags'
35
+
36
+ def initialize
37
+ super
38
+ register_tag( 'lang' )
39
+ end
40
+
41
+ def process_tag( tag, node, refNode )
42
+ output = node.parent.children.sort do |a, b| a['lang'] <=> b['lang'] end.collect do |n|
43
+ n['processor'].get_html_link( n, n, n['lang'] )
44
+ end.join( get_param( 'separator' ) )
45
+ return ( get_param( 'showSingleLang' ) || node.parent.children.length > 1 ? output : "" )
46
+ end
47
+
48
+ end
49
+
50
+ end
@@ -0,0 +1,198 @@
1
+ #
2
+ #--
3
+ #
4
+ # $Id: menu.rb 203 2005-02-21 18:42:04Z 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/node'
24
+ require 'webgen/plugins/tags/tags'
25
+
26
+ module Tags
27
+
28
+ # Generates a menu. All page files for which the meta information +inMenu+ is set are displayed.
29
+ # If you have one page in several languages, it is sufficient to add this meta information to only
30
+ # one page file.
31
+ #
32
+ # The order in which the menu items are listed can be controlled via the meta information
33
+ # +menuOrder+. By default the menu items are sorted by the file names.
34
+ #
35
+ # Tag parameters:
36
+ # [<b>level</b>]
37
+ # The depth of the menu. A level of one only displays the top level menu files. A level of two
38
+ # also displays the menu files in the direct subdirectories and so on.
39
+ class MenuTag < DefaultTag
40
+
41
+
42
+ # Specialised node class for the menu.
43
+ class MenuNode < Node
44
+
45
+ def initialize( parent, node )
46
+ super( parent )
47
+ self.logger.info { "Creating menu node for <#{node.recursive_value( 'src', false )}>" }
48
+ self['title'] = 'Menu: '+ node['title']
49
+ self['isMenuNode'] = true
50
+ self['virtual'] = true
51
+ self['node'] = node
52
+ end
53
+
54
+
55
+ # Sorts recursively all children of the node depending on their order value.
56
+ def sort!
57
+ self.children.sort! {|a,b| get_order_value( a ) <=> get_order_value( b )}
58
+ self.children.each {|child| child.sort! if child.kind_of?( MenuNode ) && child['node'].kind_of?( FileHandlers::DirHandler::DirNode )}
59
+ end
60
+
61
+
62
+ # Retrieves the order value for the specific node.
63
+ def get_order_value( node )
64
+ # be optimistic and try metainfo field first
65
+ node = node['node'] if node.kind_of?( MenuNode )
66
+ value = node['menuOrder'].to_s.to_i unless node['menuOrder'].nil?
67
+
68
+ # find the first menuOrder entry in the page files
69
+ node = node['indexFile'] if node.kind_of?( FileHandlers::DirHandler::DirNode )
70
+ node = node.find {|child| child['menuOrder'].to_s.to_i != 0} if node.kind_of?( FileHandlers::PageHandler::PageNode )
71
+ value ||= node['menuOrder'].to_s.to_i unless node.nil?
72
+
73
+ # fallback value
74
+ value ||= 0
75
+
76
+ value
77
+ end
78
+
79
+ end
80
+
81
+
82
+ summary 'Builds up a menu'
83
+ depends_on 'Tags'
84
+
85
+ add_param 'menuTag', 'ul', 'The tag used for menus.'
86
+ add_param 'itemTag', 'li', 'The tag used for menu items.'
87
+ add_param 'level', 1, \
88
+ 'Specifies how many levels the menu should have by default, ie. how deep it is. ' \
89
+ 'For example, if level = 3, then three levels are always shown at least.'
90
+ add_param 'subtreeLevel', 3, \
91
+ 'Specifies how many levels should be shown for subtrees. The number specifies ' \
92
+ 'the maximum depth the menu will have.'
93
+ add_param 'showCurrentSubtreeOnly', true, \
94
+ 'True if only the current subtree should be shown in the menu. If set to false, ' \
95
+ 'each subtree will be shown.'
96
+
97
+ def initialize
98
+ super
99
+ register_tag( 'menu' )
100
+ end
101
+
102
+ def process_tag( tag, node, refNode )
103
+ unless defined?( @menuTree )
104
+ @menuTree = create_menu_tree( Node.root( node ), nil )
105
+ unless @menuTree.nil?
106
+ Webgen::Plugin['TreeWalker'].execute( @menuTree, Webgen::Plugin['DebugTreePrinter'] )
107
+ @menuTree.sort!
108
+ Webgen::Plugin['TreeWalker'].execute( @menuTree, Webgen::Plugin['DebugTreePrinter'] )
109
+ end
110
+ end
111
+ build_menu( node, @menuTree, 1 )
112
+ end
113
+
114
+
115
+ #######
116
+ private
117
+ #######
118
+
119
+
120
+ def build_menu( srcNode, node, level )
121
+ if node.nil? \
122
+ || level > get_param( 'subtreeLevel' ) \
123
+ || ( level > get_param( 'level' ) \
124
+ && ( node['node'].level > srcNode.level \
125
+ || ( get_param( 'showCurrentSubtreeOnly' ) && !srcNode.in_subtree?( node['node'] ) )
126
+ )
127
+ )
128
+ return ''
129
+ end
130
+
131
+ out = "<#{get_param( 'menuTag' )}>"
132
+ node.each do |child|
133
+ if child.kind_of?( MenuNode )
134
+ menu = child['node'].kind_of?( FileHandlers::DirHandler::DirNode ) ? build_menu( srcNode, child, level + 1 ) : ''
135
+ before, after = menu_entry( srcNode, child['node'] )
136
+ else
137
+ menu = ''
138
+ before, after = menu_entry( srcNode, child )
139
+ end
140
+
141
+ out << before
142
+ out << menu
143
+ out << after
144
+ end
145
+ out << "</#{get_param( 'menuTag' )}>"
146
+
147
+ return out
148
+ end
149
+
150
+
151
+ def menu_entry( srcNode, node )
152
+ langNode = node['processor'].get_lang_node( node, srcNode['lang'] )
153
+ isDir = node.kind_of?( FileHandlers::DirHandler::DirNode )
154
+
155
+ styles = []
156
+ styles << 'webgen-submenu' if isDir
157
+ styles << 'webgen-menuitem-selected' if langNode.recursive_value( 'dest' ) == srcNode.recursive_value( 'dest' )
158
+
159
+ style = " class=\"#{styles.join(' ')}\"" if styles.length > 0
160
+ link = langNode['processor'].get_html_link( langNode, srcNode, ( isDir ? langNode['directoryName'] || node['directoryName'] : langNode['title'] ) )
161
+
162
+ itemTag = get_param( 'itemTag' )
163
+ if isDir
164
+ before = "<#{itemTag}#{style}>#{link}"
165
+ after = "</#{itemTag}>"
166
+ else
167
+ before = "<#{itemTag}#{style}>#{link}</#{itemTag}>"
168
+ after = ""
169
+ end
170
+
171
+ self.logger.debug { [before, after] }
172
+ return before, after
173
+ end
174
+
175
+
176
+ def create_menu_tree( node, parent )
177
+ menuNode = MenuNode.new( parent, node )
178
+
179
+ node.each do |child|
180
+ menu = create_menu_tree( child, menuNode )
181
+ menuNode.add_child( menu ) unless menu.nil?
182
+ end
183
+
184
+ return menuNode.has_children? ? menuNode : ( put_node_in_menu?( node ) ? node : nil )
185
+ end
186
+
187
+
188
+ def put_node_in_menu?( node )
189
+ inMenu = node['inMenu']
190
+ inMenu ||= node.parent && node.parent.kind_of?( FileHandlers::PageHandler::PageNode ) &&
191
+ node.parent.find do |child| child['inMenu'] end
192
+ inMenu &&= !node['virtual']
193
+ inMenu
194
+ end
195
+
196
+ end
197
+
198
+ end
@@ -0,0 +1,54 @@
1
+ #
2
+ #--
3
+ #
4
+ # $Id: meta.rb 203 2005-02-21 18:42:04Z 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/tags/tags'
24
+
25
+ module Tags
26
+
27
+ # This plugin registers itself as default plugin for tags. It substitutes tags with their
28
+ # respective values from the node meta data.
29
+ #
30
+ # This is very useful if you want to add new meta information to the page description files and
31
+ # simple copy the values to the output file.
32
+ class MetaTag < DefaultTag
33
+
34
+ summary "Replaces all tags without tag plugin with their respective values from the node meta data"
35
+ depends_on 'Tags'
36
+
37
+ def initialize
38
+ super
39
+ register_tag( :default )
40
+ end
41
+
42
+ def process_tag( tag, node, refNode )
43
+ output = ''
44
+ if node[tag]
45
+ output = node[tag]
46
+ else
47
+ self.logger.warn { "No value for tag '#{tag}' in <#{refNode.recursive_value( 'src' )}> found in <#{node.recursive_value( 'src' )}>" }
48
+ end
49
+ return output
50
+ end
51
+
52
+ end
53
+
54
+ end
@@ -0,0 +1,62 @@
1
+ #
2
+ #--
3
+ #
4
+ # $Id: navbar.rb 203 2005-02-21 18:42:04Z 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/tags/tags'
24
+
25
+ module Tags
26
+
27
+ # Generates a navigation bar. A navigation bar consists of all pages in the hierarchy of the
28
+ # current page.
29
+ #
30
+ # For example, assuming we have the following branch
31
+ # /directory1/directory2/currentFile
32
+ # this plugin will generate something like this:
33
+ # root / directory1 / directory2 / currentFile
34
+ # where each listed name is linked to the corresponding file.
35
+ class NavbarTag < DefaultTag
36
+
37
+ summary 'Shows the hierarchy of current page'
38
+ add_param 'separator', ' / ', 'Separates the hierachy entries from each other.'
39
+ depends_on 'Tags'
40
+
41
+ def initialize
42
+ super
43
+ register_tag( 'navbar' )
44
+ end
45
+
46
+ def process_tag( tag, srcNode, refNode )
47
+ out = []
48
+ node = srcNode
49
+
50
+ until node.nil?
51
+ out.push( node['processor'].get_html_link( node, srcNode ) )
52
+ begin node = node.parent end while !node.nil? && node['virtual']
53
+ end
54
+
55
+ out = out.reverse.join( get_param( 'separator' ) )
56
+ self.logger.debug { "Navbar for #{srcNode.recursive_value( 'src' )}: #{out}" }
57
+ out
58
+ end
59
+
60
+ end
61
+
62
+ end
@@ -0,0 +1,58 @@
1
+ #
2
+ #--
3
+ #
4
+ # $Id: relocatable.rb 203 2005-02-21 18:42:04Z 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/tags/tags'
24
+
25
+ module Tags
26
+
27
+ # Changes the path of file. This is very useful for templates. For example, you normally include a
28
+ # stylesheet in a template. If you specify the filename of the stylesheet directly, the reference
29
+ # to the stylesheet in the output file of a page file that is not in the same directory as the template
30
+ # would be invalid.
31
+ #
32
+ # By using the +relocatable+ tag you ensure that the path stays valid.
33
+ #
34
+ # Tag parameter: the name of the file which should be relocated
35
+ class RelocatableTag < DefaultTag
36
+
37
+ summary 'Adds a relative path to the specified name if necessary'
38
+ depends_on 'Tags'
39
+ add_param 'item', nil, 'The item which should be relocatable'
40
+ set_mandatory 'item', true
41
+
42
+ def initialize
43
+ super
44
+ register_tag( 'relocatable' )
45
+ end
46
+
47
+ def process_tag( tag, node, refNode )
48
+ unless get_param( 'item' ).nil?
49
+ destNode = refNode.node_for_string( get_param( 'item' ) )
50
+ return ( destNode.nil? ? '' : node.relpath_to_node( destNode['processor'].get_lang_node( destNode, node['lang'] ) ) )
51
+ else
52
+ return ''
53
+ end
54
+ end
55
+
56
+ end
57
+
58
+ end