From monnand.deng at gmail.com Fri May 4 02:18:45 2012 From: monnand.deng at gmail.com (monnand) Date: Thu, 03 May 2012 22:18:45 -0400 Subject: [webgen-users] conditional TOC Message-ID: <4FA33C85.4040100@gmail.com> Hi all, I am constructing a website using webgen. By changing default.template, I could finally insert a TOC in the side bar with {menu: {used_nodes: fragments}}. Now, I want to do something more complex: Given any page, webgen should decide how to generate the table of content using the following algorithm: - If the number of h1 headings is greater than 1, i.e. > 1. Then use all h1 headings as TOC - Else find the number of headings in lower level, until there is a level of headings in which there are more than 1 headings, use headings in that level in TOC. - Else do not generate TOC. More precisely, given the following page content: # Title ## Section 1 ## Section 2 The TOC should contain: * Section 1 * Section 2 (and its corresponding links) If the page is: # Section 1 # Section 1 The TOC should be: * Section 1 * Section 2 If the page is: # There is only one title foo bar blah blah... Then there is not TOC. If there any way to do it by changing the template? I didn't find any document about how to write templates (something like how to write condition stmt, loop stmt and how to find available variables etc.) I would be appreciate if anyone could point me a link or a solution. Regards, -Monnand From t_leitner at gmx.at Mon May 21 17:34:57 2012 From: t_leitner at gmx.at (Thomas Leitner) Date: Mon, 21 May 2012 19:34:57 +0200 Subject: [webgen-users] Next webgen version Message-ID: <20120521193457.3e84b60b@noweto> Hey everybody, I have just pushed the latest webgen code to the ['next' branch on github][1]. This code will become the next major version of webgen. Porting of the features of the 0.5.x series is mostly done. After this is done the documentation will be updated to reflect the new version. This will probably happen in the coming months. I have pushed this branch to github now because most features are implemented and generating a site is possible again. If you have developed an extension for webgen, you may want to have a look at the code (or the rdoc of it) to see what changed. One major change is how dependencies are tracked (see ItemTracker) and how nodes can be created dynamically (see PathHandler#create_secondary_nodes). The extension system has also been revamped to make it easier to create extensions. If you have any questions, feel free to ask! Best regards, Thomas [1]: https://github.com/gettalong/webgen/tree/next From monnand.deng at gmail.com Tue May 22 02:06:19 2012 From: monnand.deng at gmail.com (monnand) Date: Mon, 21 May 2012 22:06:19 -0400 Subject: [webgen-users] conditional TOC In-Reply-To: <4FA33C85.4040100@gmail.com> References: <4FA33C85.4040100@gmail.com> Message-ID: <4FBAF49B.2020204@gmail.com> Anyone? Thought? Sorry for disturbing you all. But is there any comment on my question? -Monnand monnand wrote, On 05/03/2012 10:18 PM: > Hi all, > > I am constructing a website using webgen. By changing default.template, > I could finally insert a TOC in the side bar with {menu: {used_nodes: > fragments}}. Now, I want to do something more complex: > > Given any page, webgen should decide how to generate the table of > content using the following algorithm: > > - If the number of h1 headings is greater than 1, i.e.> 1. Then use all > h1 headings as TOC > - Else find the number of headings in lower level, until there is a > level of headings in which there are more than 1 headings, use headings > in that level in TOC. > - Else do not generate TOC. > > More precisely, given the following page content: > > # Title > > ## Section 1 > ## Section 2 > > The TOC should contain: > * Section 1 > * Section 2 > (and its corresponding links) > > If the page is: > # Section 1 > # Section 1 > > The TOC should be: > * Section 1 > * Section 2 > > If the page is: > # There is only one title > > foo bar blah blah... > > Then there is not TOC. > > If there any way to do it by changing the template? I didn't find any > document about how to write templates (something like how to write > condition stmt, loop stmt and how to find available variables etc.) I > would be appreciate if anyone could point me a link or a solution. > > Regards, > -Monnand From t_leitner at gmx.at Tue May 22 06:01:51 2012 From: t_leitner at gmx.at (Thomas Leitner) Date: Tue, 22 May 2012 08:01:51 +0200 Subject: [webgen-users] conditional TOC In-Reply-To: <4FA33C85.4040100@gmail.com> References: <4FA33C85.4040100@gmail.com> Message-ID: <20120522080151.70f964cf@noweto> Hi, On 2012-05-03 22:18 -0400 monnand wrote: > Hi all, > > I am constructing a website using webgen. By changing > default.template, I could finally insert a TOC in the side bar with > {menu: {used_nodes: fragments}}. Now, I want to do something more > complex: > > Given any page, webgen should decide how to generate the table of > content using the following algorithm: > > - If the number of h1 headings is greater than 1, i.e. > 1. Then use > all h1 headings as TOC > - Else find the number of headings in lower level, until there is a > level of headings in which there are more than 1 headings, use > headings in that level in TOC. > - Else do not generate TOC. There is no such algorithm built into webgen right now. You would have to code this yourself. However, note that fragments are only created for headers that have an ID set. So you could do this with the {menu: {used_nodes: fragments}} tag if you just set the IDs only on those headers that you want to have in the menu. > If there any way to do it by changing the template? I didn't find any > document about how to write templates (something like how to write > condition stmt, loop stmt and how to find available variables etc.) I > would be appreciate if anyone could point me a link or a solution. Have a look at http://webgen.rubyforge.org/documentation/contentprocessor/erb.html This is the default content processor used in template files for adding Ruby code statements. Best regards, Thomas From monnand.deng at gmail.com Tue May 22 23:54:22 2012 From: monnand.deng at gmail.com (monnand) Date: Tue, 22 May 2012 19:54:22 -0400 Subject: [webgen-users] conditional TOC In-Reply-To: <20120522080151.70f964cf@noweto> References: <4FA33C85.4040100@gmail.com> <20120522080151.70f964cf@noweto> Message-ID: <4FBC272E.2020407@gmail.com> Hi Thomas, Thanks for your answer! Thomas Leitner wrote, On 05/22/2012 02:01 AM: > Hi, > > On 2012-05-03 22:18 -0400 monnand wrote: >> Hi all, >> >> I am constructing a website using webgen. By changing >> default.template, I could finally insert a TOC in the side bar with >> {menu: {used_nodes: fragments}}. Now, I want to do something more >> complex: >> >> Given any page, webgen should decide how to generate the table of >> content using the following algorithm: >> >> - If the number of h1 headings is greater than 1, i.e.> 1. Then use >> all h1 headings as TOC >> - Else find the number of headings in lower level, until there is a >> level of headings in which there are more than 1 headings, use >> headings in that level in TOC. >> - Else do not generate TOC. > > There is no such algorithm built into webgen right now. You would have > to code this yourself. However, note that fragments are only created > for headers that have an ID set. > > So you could do this with the {menu: {used_nodes: fragments}} tag if > you just set the IDs only on those headers that you want to have in > the menu. Thanks! That's all I need. In fact, I have already got a solution by reading webgen's class document. My previous problem was unable to find the right variable available in template to manipulate the titles. Now I use context.node.children to test if there are more than one children under context.node. I don't know if this is a right/idiomatic way to do. But it works fine. > >> If there any way to do it by changing the template? I didn't find any >> document about how to write templates (something like how to write >> condition stmt, loop stmt and how to find available variables etc.) I >> would be appreciate if anyone could point me a link or a solution. > > Have a look at > http://webgen.rubyforge.org/documentation/contentprocessor/erb.html > This is the default content processor used in template files for adding > Ruby code statements. I see. That's where I found the solution. Thank you very much! -Monnand > > Best regards, > Thomas > From t_leitner at gmx.at Wed May 30 10:22:35 2012 From: t_leitner at gmx.at (Thomas Leitner) Date: Wed, 30 May 2012 12:22:35 +0200 Subject: [webgen-users] [next] Updated tags, content processors, sass integration ; twitter and IRC info Message-ID: <20120530122235.4843e770@noweto> Hey everybody, I have just pushed the latest changes to the ['next' branch on github][1]. This code will become the next major version of webgen. I will regularly post status updates to this mailing list (one post in one or two weeks) and to my Twitter account @_gettalong (more often). I will also be more often in the IRC chat #webgen on freenode as of now if you like to discuss webgen! Among the recent changes are: * Tag tikz, langbar and breadcrumb_trail are now up-to-date * A small modification of the Webgen Page Format (allows trailing dashes) * Path handler copy has a better integration with the content processor because an extension mapping can now be specified for each content processor (e.g. 'haml' => 'html'). * Better Sass/Scss integration (@import works now in the context of the node tree, ie. importing works correctly!) If you have any questions, feel free to ask! Best regards, Thomas [1]: https://github.com/gettalong/webgen/tree/next