Matthias Kirschner
2008-Oct-04 14:03 UTC
[webgen-users] Rename language code + link to source
Hi all, I am using webgen 0.4.7 and I have two question. 1. would like to do the following: have index.de.html, index.en.html, index.fr.html, index.it.html, ... But {langbar: } should not display [de | en | fr | it | ...] but [Deutsch | English | Fran?ais | Italiano | ...] 2. I would like to have a link to the original file from src/ in the footer. Background: Someone can just click on the file, translate it and sent it via e-mail to me so I can upload it. (http://www.fsfeurope.org is using that system, too.) Any tipps how to accomplish those two things? Or would it be possible to include something like that in webgen 5.X? Thanks, Matthias
Am Sat, 4 Oct 2008 16:03:10 +0200 schrieb Matthias Kirschner <mk at fsfe.org>:> Hi all, > > I am using webgen 0.4.7 and I have two question. > > 1. would like to do the following: have index.de.html, index.en.html, > index.fr.html, index.it.html, ... > > But {langbar: } should not display > [de | en | fr | it | ...] but > [Deutsch | English | Fran?ais | Italiano | ...]This is not possible (even in the 0.5.5 version). You could rewrite the plugin if you want to do that.> 2. I would like to have a link to the original file from src/ in the > footer. Background: Someone can just click on the file, translate it > and sent it via e-mail to me so I can upload it. > (http://www.fsfeurope.org is using that system, too.)This is possible in 0.4.x (very easy with 0.5.x). However, the easy way of using the File/CopyHandler to just copy the page files won''t work due to the used node resolution code of File/PageHandler. The following plugin can be put in the plugin/ directory of your website and will correctly copy each source file to an output file with the extension src: # BEGIN CODE class SourceHandler < FileHandlers::DefaultHandler infos( :name => ''File/SourceHandler'', :author => Webgen::AUTHOR, :summary => "Copies the source files to the output dir" ) register_extension ''page'' def create_node( path, parent, meta_info ) name = File.basename(path, ''.*'') + ".src" node = parent.find {|c| c =~ name } if node.nil? node = Node.new( parent, name ) node[''title''] = name node.meta_info.update( meta_info ) node.node_info[:src] = path node.node_info[:processor] = self else log(:warn) { "Can''t create node <#{node.full_path}> as it already exists (node handled by #{node.node_info[:processor].class.plugin_name})!" } end node end # Copy the file to the destination directory if it has been modified. def write_node( node ) if @plugin_manager[''Core/FileHandler''].file_modified?( node.node_info[:src], node.full_path ) FileUtils.cp( node.node_info[:src], node.full_path ) end end end #END CODE Then you can use the following snippet in your default.template to include a link to the source file: <a href="{relocatable: <%= node.absolute_path.sub(/html$/, ''src'') %>}">Source</a> The important thing is that you use an other extension instead of ''page''!> Any tipps how to accomplish those two things? Or would it be possible > to include something like that in webgen 5.X?I have put the customizable langbar texts onto my todo list for webgen 0.5.x. -- Thomas
Matthias Kirschner
2008-Oct-06 15:29 UTC
[webgen-users] Rename language code + link to source
* Thomas Leitner <t_leitner at gmx.at> [2008-10-05 08:53:55 +0200]:> This is possible in 0.4.x (very easy with 0.5.x). However, the easy > way of using the File/CopyHandler to just copy the page files won''t > work due to the used node resolution code of File/PageHandler.[...] Thank you very much for the solution!!! I will try it.> > Any tipps how to accomplish those two things? Or would it be possible > > to include something like that in webgen 5.X? > > I have put the customizable langbar texts onto my todo list for webgen > 0.5.x.And thank you for putting it on your todo list. Best wishes, Matthias