[webgen-users] Port webgen-0.x menu to 1.0

70 views
Skip to first unread message

Mikhail Yakshin

unread,
Oct 8, 2013, 3:50:43 AM10/8/13
to webgen...@rubyforge.org
Hi again,

I'm still struggling with porting some stuff to 1.0 and I'm really
confused. I wish documentation had more ready-made porting recipes
(i.e. "if your code was [...] then you should replace it with [...]").

I had a site with a structure that looks like that:

sect1.html
sect2.html
sect3/index.html
sect3/subsect1.html
sect3/subsect2.html
sect4/index.html
sect4/subsect1.html
sect4/subsect2.html
sect4/subsect3/index.html
sect4/subsect3/subsubsect1.html

Previously, I've used the following, very simple macro for ready-made
menu that was pretty good:

{menu: {max_levels: 2}}

Basically, it did the simple and intuitive thing. For sect1 and sect2
it showed only top-level menus, including links to indexes from
directories sect3 and sect4:

* sect1
* sect2
* sect3/index
* sect4/index

For any path in sect3 it showed top level sections + inner contents of sect3:

* sect1
* sect2
* sect3/index
** sect3/subsect1
** sect3/subsect2
* sect4/index

For any path in sect4 it showed top level sections + inner contents of
sect4, but only up to second level, including indexes to third level:

* sect1
* sect2
* sect3/index
* sect4/index
** sect4/subsect1
** sect4/subsect2
** sect4/subsect3/index

That's all I need. I've already tried:

{menu: {options: {mi: {in_menu: true}, sort: true, absolute_levels:
[1, 2], lang: node}}}

{menu: {options: {mi: {in_menu: true}, sort: true, levels: [1, 2], lang: node}}}

{menu: {options: {mi: {in_menu: true}, sort: true, absolute_levels:
[1, 2], and: {levels: [1, -1]}, lang: node}}}

{menu: {options: {mi: {in_menu: true}, sort: true, siblings: [0, -1]}}}

None of these behave as "{menu: {max_levels: 2}}" did previously, as
I've detailed above. What is the correct way to add a menu like I had
in 0.x?

--
WBR, Mikhail Yakshin
_______________________________________________
webgen-users mailing list
webgen...@rubyforge.org
http://rubyforge.org/mailman/listinfo/webgen-users

Thomas Leitner

unread,
Oct 10, 2013, 3:47:41 PM10/10/13
to webgen...@rubyforge.org
Hi,

On 2013-10-08 11:50 +0400 Mikhail Yakshin wrote:
> sect1.html
> sect2.html
> sect3/index.html
> sect3/subsect1.html
> sect3/subsect2.html
> sect4/index.html
> sect4/subsect1.html
> sect4/subsect2.html
> sect4/subsect3/index.html
> sect4/subsect3/subsubsect1.html

Okay, I'm using the above structure for the examples below.

> Previously, I've used the following, very simple macro for ready-made
> menu that was pretty good:
>
> {menu: {max_levels: 2}}

I know that constructing a menu with the new menu tag is more complex.
However, it also allows for more flexibility.

> {menu: {options: {mi: {in_menu: true}, sort: true, siblings: [0,
> -1]}}}

This is nearly the one you want. Just also use "absolute_levels:
[0,2]". This last part makes sure that only menu items of up to level 2
are displayed (equivalent to the "max_levels: 2" option before).

What you also need to do is to make sure that all items that should
appear in the menu have the "in_menu: true" meta information set.

Ie. something like the following in a meta information file:

~~~
--- alcn
[/**/*.html, /sect3/, /sect4/, /sect4/*/]:
in_menu: true

/**/index.*.html:
in_menu: false
~~~

The first entry makes sure that all our .html files and some of the
directories are in the menu. And the second one makes sure that the
index files themselves do not show up.

-- Thomas

Mikhail Yakshin

unread,
Oct 15, 2013, 11:39:34 AM10/15/13
to webgen...@rubyforge.org
Dear Thomas,

Thanks for your answer.

>> sect1.html
>> sect2.html
>> sect3/index.html
>> sect3/subsect1.html
>> sect3/subsect2.html
>> sect4/index.html
>> sect4/subsect1.html
>> sect4/subsect2.html
>> sect4/subsect3/index.html
>> sect4/subsect3/subsubsect1.html
>
> Okay, I'm using the above structure for the examples below.
>
>> Previously, I've used the following, very simple macro for ready-made
>> menu that was pretty good:
>>
>> {menu: {max_levels: 2}}
>
> I know that constructing a menu with the new menu tag is more complex.
> However, it also allows for more flexibility.
>
>> {menu: {options: {mi: {in_menu: true}, sort: true, siblings: [0,
>> -1]}}}
>
> This is nearly the one you want. Just also use "absolute_levels:
> [0,2]". This last part makes sure that only menu items of up to level 2
> are displayed (equivalent to the "max_levels: 2" option before).

If I understand you correctly, you've suggested

{menu: {options: {mi: {in_menu: true}, sort: true, siblings: [0, -1],
absolute_levels: [0, 2], lang: node}}}

However, it doesn't work as "max_levels: 2" menu:

* When viewing sect1 or sect2, I don't see sect3/index and sect4/index at all
* When viewing anything in sect3, I see sect1 + sect2 + sect3, but I
don't see anything from sect4
* When viewing anything in sect4, I don't see sect3/index and I don't
see sect4/subsect3/index, as it was with max_levels: 2

> What you also need to do is to make sure that all items that should
> appear in the menu have the "in_menu: true" meta information set.
>
> Ie. something like the following in a meta information file:
>
> ~~~
> --- alcn
> [/**/*.html, /sect3/, /sect4/, /sect4/*/]:
> in_menu: true
>
> /**/index.*.html:
> in_menu: false
> ~~~
>
> The first entry makes sure that all our .html files and some of the
> directories are in the menu. And the second one makes sure that the
> index files themselves do not show up.

I've also tried using in_menu inside the page files. Looks the same to me.

I'm attaching an simple test case. If you want, I can also make a
simple programmatic checker if it does everything I've described (as
it was in previous versions) or not.

--
WBR, Mikhail Yakshin
webgen-menu-experiment.tar.bz2

Thomas Leitner

unread,
Oct 26, 2013, 3:56:25 AM10/26/13
to webgen...@rubyforge.org
Dear Mikhail,

sorry for my late answer!

On 2013-10-15 19:39 +0400 Mikhail Yakshin wrote:
> If I understand you correctly, you've suggested
>
> {menu: {options: {mi: {in_menu: true}, sort: true, siblings: [0, -1],
> absolute_levels: [0, 2], lang: node}}}

the difference to my suggestion is that you also used the 'lang'
option. However, directories are always unlocalized and therefore can't
appear in the menu as stated above. If you use "lang: [node, null]"
then you also allow nodes without a language in the menu tree and it
will work (I have tested it by using the sample website you provided
and just changed this one thing).

Best regards,
Reply all
Reply to author
Forward
0 new messages