[Lift] Re: lift:Menu.group
So, how would I test this function in specs? I would need to create a mock object of S, right? Thanks, Bradford On Mar 29, 8:02 pm, bradford fingerm...@gmail.com wrote: This can probably be improved (and I've done little testing on it), but I've come up with something to satisfy my description above: def group(template: NodeSeq): NodeSeq = { val default = S.attr(default).openOr() val active_attrs = S.prefixedAttrsToMetaData(active) val names = template \\ bind filter(_.prefix == menu) flatMap(_.attributes.get(name)) def bind(xml: NodeSeq, currentPage: String): NodeSeq = { xml.flatMap { node = node match { case s : Elem if (node.prefix == menu node.label == bind) = { node.attributes.get(name) match { case None = bind(node.child, currentPage) case Some(ns) = { SiteMap.findLoc(ns.text) match { case Full(location) = val link: Elem = a href={location.createDefaultLink}{location.linkText.openOr()}/a // location.createDefaultLink.toList.firstOption.getOrElse(a /).asInstanceOf[Elem] if (ns == currentPage) link % anchorAttributes(node.attributes) % active_attrs else link % anchorAttributes(node.attributes) case _ = bind (node.child, currentPage) } } } } case Group(nodes) = Group(bind(nodes, currentPage)) case s : Elem = Elem(node.prefix, node.label, node.attributes,node.scope, bind(node.child, currentPage) : _*) case n = node } } } for (request - S.request.toList; loc - request.location.toList) yield { val currentPage: String = if (names.contains(loc.name)) loc.name else default println(currentPage + currentPage) Group(bind(template, currentPage)) } } private def anchorAttributes(attributes : MetaData) : MetaData = { val amap = Map() ++ attributes.flatMap(attr = attr match { case ua : PrefixedAttribute = ua.pre match { case a = List(ua.key - ua.value.first.toString) case _ = Nil } case _ = Nil }) S.mapToAttrs(amap) } On Mar 28, 11:59 am, bradford fingerm...@gmail.com wrote: Hi Derek, Cool. I will still use your changes, but for this task I will need what I have described above. This will give me the ability to set attributes to the selected item or default to a selected item if there is no match. For example, let's say I have archives, music, and movies. If I am on music, I want to set a selected class or style on it. But if I embed movies into home, there will be no matches so I want it to default to movies. Thanks for your help and work, Bradford On Mar 28, 11:53 am, Derek Chen-Becker dchenbec...@gmail.com wrote: Argh, stupid mistake on not capturing attrs. I'm pushing a fix up to git in about 10 minutes. With this fix, is there still a reason that you need to build your own MyMenu.group snippet? Derek On Fri, Mar 27, 2009 at 7:02 PM, bradford fingerm...@gmail.com wrote: Derek, I saw the changes and noticed that it doesn't capture the a attributes anymore. I just wanted to point it out, because I wasn't sure if that was intended or not. Ok, I finally came up with a design for what I'm looking for: lift:MyMenu.group active:class=selected default=home limenu:bind name=home a:id=home //li limenu:bind name=archives a:id=archives //li limenu:bind name=music a:id=music a:style=margin-left: 10px; //li /lift:MyMenu.group I originally was going to try menu:home / and menu:archives / instead since I could probably just call bind straight up on them, but I couldn't figure out how to extract these sub-elements since they are prefixed. Regards, Bradford On Mar 27, 1:57 am, Derek Chen-Becker dchenbec...@gmail.com wrote: It's in trunk now. Add the donthide attribute to your Menu.item tags and you'll get the same text as you would normally, just not in link form. Derek On Wed, Mar 25, 2009 at 4:31 PM, bradford fingerm...@gmail.com wrote: Derek, that'll work :) Thanks, Bradford
[Lift] Re: lift:Menu.group
This can probably be improved (and I've done little testing on it), but I've come up with something to satisfy my description above: def group(template: NodeSeq): NodeSeq = { val default = S.attr(default).openOr() val active_attrs = S.prefixedAttrsToMetaData(active) val names = template \\ bind filter(_.prefix == menu) flatMap(_.attributes.get(name)) def bind(xml: NodeSeq, currentPage: String): NodeSeq = { xml.flatMap { node = node match { case s : Elem if (node.prefix == menu node.label == bind) = { node.attributes.get(name) match { case None = bind(node.child, currentPage) case Some(ns) = { SiteMap.findLoc(ns.text) match { case Full(location) = val link: Elem = a href={location.createDefaultLink}{location.linkText.openOr()}/a // location.createDefaultLink.toList.firstOption.getOrElse(a / ).asInstanceOf[Elem] if (ns == currentPage) link % anchorAttributes(node.attributes) % active_attrs else link % anchorAttributes(node.attributes) case _ = bind (node.child, currentPage) } } } } case Group(nodes) = Group(bind(nodes, currentPage)) case s : Elem = Elem(node.prefix, node.label, node.attributes,node.scope, bind(node.child, currentPage) : _*) case n = node } } } for (request - S.request.toList; loc - request.location.toList) yield { val currentPage: String = if (names.contains(loc.name)) loc.name else default println(currentPage + currentPage) Group(bind(template, currentPage)) } } private def anchorAttributes(attributes : MetaData) : MetaData = { val amap = Map() ++ attributes.flatMap(attr = attr match { case ua : PrefixedAttribute = ua.pre match { case a = List(ua.key - ua.value.first.toString) case _ = Nil } case _ = Nil }) S.mapToAttrs(amap) } On Mar 28, 11:59 am, bradford fingerm...@gmail.com wrote: Hi Derek, Cool. I will still use your changes, but for this task I will need what I have described above. This will give me the ability to set attributes to the selected item or default to a selected item if there is no match. For example, let's say I have archives, music, and movies. If I am on music, I want to set a selected class or style on it. But if I embed movies into home, there will be no matches so I want it to default to movies. Thanks for your help and work, Bradford On Mar 28, 11:53 am, Derek Chen-Becker dchenbec...@gmail.com wrote: Argh, stupid mistake on not capturing attrs. I'm pushing a fix up to git in about 10 minutes. With this fix, is there still a reason that you need to build your own MyMenu.group snippet? Derek On Fri, Mar 27, 2009 at 7:02 PM, bradford fingerm...@gmail.com wrote: Derek, I saw the changes and noticed that it doesn't capture the a attributes anymore. I just wanted to point it out, because I wasn't sure if that was intended or not. Ok, I finally came up with a design for what I'm looking for: lift:MyMenu.group active:class=selected default=home limenu:bind name=home a:id=home //li limenu:bind name=archives a:id=archives //li limenu:bind name=music a:id=music a:style=margin-left: 10px; //li /lift:MyMenu.group I originally was going to try menu:home / and menu:archives / instead since I could probably just call bind straight up on them, but I couldn't figure out how to extract these sub-elements since they are prefixed. Regards, Bradford On Mar 27, 1:57 am, Derek Chen-Becker dchenbec...@gmail.com wrote: It's in trunk now. Add the donthide attribute to your Menu.item tags and you'll get the same text as you would normally, just not in link form. Derek On Wed, Mar 25, 2009 at 4:31 PM, bradford fingerm...@gmail.com wrote: Derek, that'll work :) Thanks, Bradford On Mar 25, 6:13 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: That seems reasonable to me. That's actually what the Menu.builder does, essentially. I don't think we want to modify the default behavior, but I could make it a donthide attribute instead of always
[Lift] Re: lift:Menu.group
Derek, I saw the changes and noticed that it doesn't capture the a attributes anymore. I just wanted to point it out, because I wasn't sure if that was intended or not. Ok, I finally came up with a design for what I'm looking for: lift:MyMenu.group active:class=selected default=home limenu:bind name=home a:id=home //li limenu:bind name=archives a:id=archives //li limenu:bind name=music a:id=music a:style=margin-left: 10px; //li /lift:MyMenu.group I originally was going to try menu:home / and menu:archives / instead since I could probably just call bind straight up on them, but I couldn't figure out how to extract these sub-elements since they are prefixed. Regards, Bradford On Mar 27, 1:57 am, Derek Chen-Becker dchenbec...@gmail.com wrote: It's in trunk now. Add the donthide attribute to your Menu.item tags and you'll get the same text as you would normally, just not in link form. Derek On Wed, Mar 25, 2009 at 4:31 PM, bradford fingerm...@gmail.com wrote: Derek, that'll work :) Thanks, Bradford On Mar 25, 6:13 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: That seems reasonable to me. That's actually what the Menu.builder does, essentially. I don't think we want to modify the default behavior, but I could make it a donthide attribute instead of always to do what you're saying. Bradford, would that work for you? Derek On Wed, Mar 25, 2009 at 3:54 PM, Charles F. Munat c...@munat.com wrote: Actually, my feeling on item is that if you're on that page, item should return placeholder text (i.e. the same text without the link). For me, at least, that's the most common scenario. Chas. bradford wrote: David, you're right that needing to surround the element text of a with span is a unique case and should be a custom snippet. I've removed the span now and think that Derek's addition of always would be just what I need. Adding group=foo to Menu.builder would suffice as well. Thanks for the tips, Chas. Derek, if you do add always can you please let me know so that I can update my code. Thanks, Bradford On Mar 24, 10:37 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: The general case is that a page won't link to itself, I think, which is why the default isn't to show it when the page matches. Unless anyone has objections I can add an always attribute. As for #1, the Menu.item makes a link using whatever the contents of the Menu.item tag are for the link text: lift:Menu.item name=foospanGo here/span/lift:Menu.item should become a href={foo location}spanGo here/span/a Am I misunderstanding what you're looking for there? As for #2, you should be able to add a class using the prefixed attribute: lift:Menu.builder li_item:class=bar / In this context, li_item is the menu item that matches the current page. With Menu.group, you can specify the binding template: ul lift:Menu.group group=help li class=barmenu:bind //li /lift:Menu.group /ul But there's no provision to do anything special for the current page. Let me know if that's not sufficient or if I'm misunderstanding your requirement. Derek On Tue, Mar 24, 2009 at 3:50 PM, bradford fingerm...@gmail.com wrote: Thanks for the clarification, David, and for your snippet, Derek. I think adding an always attribute to Menu.item would be very beneficial. I still don't understand why that's not its default behavior. It looks like I will not be able to use any of lift's Menu tags at this time, because 1) I need to surround the item text with span and 2) I need a way to add class=active to the li_item. Both are not possible with Menu.item, Menu.group, or Menu.builder. Let me know if I am mistaken. If I am not not, may I put in a feature request for these items. For the time being I will just hard code it as follows (which is not a big deal to me at this time): ul class=menu lia href=/foo1 class=activespanFoo1/span/foo lia href=/foo2spanFoo2/span/foo lia href=/foo3spanFoo3/span/foo /ul Thanks again for the great support :) Bradford On Mar 24, 12:08 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Mar 24, 2009 at 9:02 AM, Charles F. Munat c...@munat.com wrote: David Pollak wrote: What's the best practice: For more information about lift:Menu.item name=foo1 /. For more information about lift:Menu.item name=foo2 /. Or For more information about a href=/foo1foo1/a. For more information about a href=/foo2foo2/a. The latter. This allows you to move the pages around on the filesystem without having to grep through all you source files looking for what needs to be
[Lift] Re: lift:Menu.group
Ok, I'm stuck now. I can't figure out how to mixin the prefixed attributes of menu:bind with the links. Here's what I have so far (mostly copied from BindHelpers.scala: import scala.xml._ object Main { def group(template: NodeSeq): NodeSeq = { val active_attrs = a class=selected /.attributes // S.prefixedAttrsToMetaData(active) val vals = Map(foo1 - a href=foo1Link1/a, foo2 - a href=foo2Link2/a) // from the SiteMap val names = template \\ bind filter(_.prefix == menu) flatMap(_.attributes.get(name)) val item = foo1 // loc.name val default = foo1 // S.attr(default) val currentPage = if (names.contains(item)) item else default def bind(xml: NodeSeq): NodeSeq = { xml.flatMap { node = node match { case s : Elem if (node.prefix == menu node.label == bind) = { node.attributes.get(name) match { case None = bind(node.child) case Some(ns) = { vals.get(ns.text) match { case None = bind (node.child) case Some(nodes) = if (ns == currentPage) nodes % active_attrs else nodes // NEED HELP HERE (how to just get attributes prefixed with a to mixin) } } } } case Group(nodes) = Group(bind(nodes)) case s : Elem = Elem(node.prefix, node.label, node.attributes,node.scope, bind(node.child) : _*) case n = node } } } bind(template) } def main(args: Array[String]) = { val template: NodeSeq = limenu:bind name=foo1 a:id=aid1// lilimenu:bind name=foo2 a:id=aid2//li; println(template) println(group(template)) } } On Mar 27, 9:02 pm, bradford fingerm...@gmail.com wrote: Derek, I saw the changes and noticed that it doesn't capture the a attributes anymore. I just wanted to point it out, because I wasn't sure if that was intended or not. Ok, I finally came up with a design for what I'm looking for: lift:MyMenu.group active:class=selected default=home limenu:bind name=home a:id=home //li limenu:bind name=archives a:id=archives //li limenu:bind name=music a:id=music a:style=margin-left: 10px; //li /lift:MyMenu.group I originally was going to try menu:home / and menu:archives / instead since I could probably just call bind straight up on them, but I couldn't figure out how to extract these sub-elements since they are prefixed. Regards, Bradford On Mar 27, 1:57 am, Derek Chen-Becker dchenbec...@gmail.com wrote: It's in trunk now. Add the donthide attribute to your Menu.item tags and you'll get the same text as you would normally, just not in link form. Derek On Wed, Mar 25, 2009 at 4:31 PM, bradford fingerm...@gmail.com wrote: Derek, that'll work :) Thanks, Bradford On Mar 25, 6:13 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: That seems reasonable to me. That's actually what the Menu.builder does, essentially. I don't think we want to modify the default behavior, but I could make it a donthide attribute instead of always to do what you're saying. Bradford, would that work for you? Derek On Wed, Mar 25, 2009 at 3:54 PM, Charles F. Munat c...@munat.com wrote: Actually, my feeling on item is that if you're on that page, item should return placeholder text (i.e. the same text without the link). For me, at least, that's the most common scenario. Chas. bradford wrote: David, you're right that needing to surround the element text of a with span is a unique case and should be a custom snippet. I've removed the span now and think that Derek's addition of always would be just what I need. Adding group=foo to Menu.builder would suffice as well. Thanks for the tips, Chas. Derek, if you do add always can you please let me know so that I can update my code. Thanks, Bradford On Mar 24, 10:37 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: The general case is that a page won't link to itself, I think, which is why the default isn't to show it when the page matches. Unless anyone has objections I can add an always attribute. As for #1, the Menu.item makes a link using whatever the contents of the Menu.item tag are for the link text: lift:Menu.item name=foospanGo here/span/lift:Menu.item should become a href={foo location}spanGo here/span/a Am I misunderstanding what you're looking for there? As for #2, you should be able
[Lift] Re: lift:Menu.group
Argh, stupid mistake on not capturing attrs. I'm pushing a fix up to git in about 10 minutes. With this fix, is there still a reason that you need to build your own MyMenu.group snippet? Derek On Fri, Mar 27, 2009 at 7:02 PM, bradford fingerm...@gmail.com wrote: Derek, I saw the changes and noticed that it doesn't capture the a attributes anymore. I just wanted to point it out, because I wasn't sure if that was intended or not. Ok, I finally came up with a design for what I'm looking for: lift:MyMenu.group active:class=selected default=home limenu:bind name=home a:id=home //li limenu:bind name=archives a:id=archives //li limenu:bind name=music a:id=music a:style=margin-left: 10px; //li /lift:MyMenu.group I originally was going to try menu:home / and menu:archives / instead since I could probably just call bind straight up on them, but I couldn't figure out how to extract these sub-elements since they are prefixed. Regards, Bradford On Mar 27, 1:57 am, Derek Chen-Becker dchenbec...@gmail.com wrote: It's in trunk now. Add the donthide attribute to your Menu.item tags and you'll get the same text as you would normally, just not in link form. Derek On Wed, Mar 25, 2009 at 4:31 PM, bradford fingerm...@gmail.com wrote: Derek, that'll work :) Thanks, Bradford On Mar 25, 6:13 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: That seems reasonable to me. That's actually what the Menu.builder does, essentially. I don't think we want to modify the default behavior, but I could make it a donthide attribute instead of always to do what you're saying. Bradford, would that work for you? Derek On Wed, Mar 25, 2009 at 3:54 PM, Charles F. Munat c...@munat.com wrote: Actually, my feeling on item is that if you're on that page, item should return placeholder text (i.e. the same text without the link). For me, at least, that's the most common scenario. Chas. bradford wrote: David, you're right that needing to surround the element text of a with span is a unique case and should be a custom snippet. I've removed the span now and think that Derek's addition of always would be just what I need. Adding group=foo to Menu.builder would suffice as well. Thanks for the tips, Chas. Derek, if you do add always can you please let me know so that I can update my code. Thanks, Bradford On Mar 24, 10:37 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: The general case is that a page won't link to itself, I think, which is why the default isn't to show it when the page matches. Unless anyone has objections I can add an always attribute. As for #1, the Menu.item makes a link using whatever the contents of the Menu.item tag are for the link text: lift:Menu.item name=foospanGo here/span/lift:Menu.item should become a href={foo location}spanGo here/span/a Am I misunderstanding what you're looking for there? As for #2, you should be able to add a class using the prefixed attribute: lift:Menu.builder li_item:class=bar / In this context, li_item is the menu item that matches the current page. With Menu.group, you can specify the binding template: ul lift:Menu.group group=help li class=barmenu:bind //li /lift:Menu.group /ul But there's no provision to do anything special for the current page. Let me know if that's not sufficient or if I'm misunderstanding your requirement. Derek On Tue, Mar 24, 2009 at 3:50 PM, bradford fingerm...@gmail.com wrote: Thanks for the clarification, David, and for your snippet, Derek. I think adding an always attribute to Menu.item would be very beneficial. I still don't understand why that's not its default behavior. It looks like I will not be able to use any of lift's Menu tags at this time, because 1) I need to surround the item text with span and 2) I need a way to add class=active to the li_item. Both are not possible with Menu.item, Menu.group, or Menu.builder. Let me know if I am mistaken. If I am not not, may I put in a feature request for these items. For the time being I will just hard code it as follows (which is not a big deal to me at this time): ul class=menu lia href=/foo1 class=activespanFoo1/span/foo lia href=/foo2spanFoo2/span/foo lia href=/foo3spanFoo3/span/foo /ul Thanks again for the great support :) Bradford On Mar 24, 12:08 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Mar 24, 2009 at 9:02 AM, Charles F. Munat c...@munat.com wrote: David Pollak wrote: What's the best practice:
[Lift] Re: lift:Menu.group
Derek, that'll work :) Thanks, Bradford On Mar 25, 6:13 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: That seems reasonable to me. That's actually what the Menu.builder does, essentially. I don't think we want to modify the default behavior, but I could make it a donthide attribute instead of always to do what you're saying. Bradford, would that work for you? Derek On Wed, Mar 25, 2009 at 3:54 PM, Charles F. Munat c...@munat.com wrote: Actually, my feeling on item is that if you're on that page, item should return placeholder text (i.e. the same text without the link). For me, at least, that's the most common scenario. Chas. bradford wrote: David, you're right that needing to surround the element text of a with span is a unique case and should be a custom snippet. I've removed the span now and think that Derek's addition of always would be just what I need. Adding group=foo to Menu.builder would suffice as well. Thanks for the tips, Chas. Derek, if you do add always can you please let me know so that I can update my code. Thanks, Bradford On Mar 24, 10:37 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: The general case is that a page won't link to itself, I think, which is why the default isn't to show it when the page matches. Unless anyone has objections I can add an always attribute. As for #1, the Menu.item makes a link using whatever the contents of the Menu.item tag are for the link text: lift:Menu.item name=foospanGo here/span/lift:Menu.item should become a href={foo location}spanGo here/span/a Am I misunderstanding what you're looking for there? As for #2, you should be able to add a class using the prefixed attribute: lift:Menu.builder li_item:class=bar / In this context, li_item is the menu item that matches the current page. With Menu.group, you can specify the binding template: ul lift:Menu.group group=help li class=barmenu:bind //li /lift:Menu.group /ul But there's no provision to do anything special for the current page. Let me know if that's not sufficient or if I'm misunderstanding your requirement. Derek On Tue, Mar 24, 2009 at 3:50 PM, bradford fingerm...@gmail.com wrote: Thanks for the clarification, David, and for your snippet, Derek. I think adding an always attribute to Menu.item would be very beneficial. I still don't understand why that's not its default behavior. It looks like I will not be able to use any of lift's Menu tags at this time, because 1) I need to surround the item text with span and 2) I need a way to add class=active to the li_item. Both are not possible with Menu.item, Menu.group, or Menu.builder. Let me know if I am mistaken. If I am not not, may I put in a feature request for these items. For the time being I will just hard code it as follows (which is not a big deal to me at this time): ul class=menu lia href=/foo1 class=activespanFoo1/span/foo lia href=/foo2spanFoo2/span/foo lia href=/foo3spanFoo3/span/foo /ul Thanks again for the great support :) Bradford On Mar 24, 12:08 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Mar 24, 2009 at 9:02 AM, Charles F. Munat c...@munat.com wrote: David Pollak wrote: What's the best practice: For more information about lift:Menu.item name=foo1 /. For more information about lift:Menu.item name=foo2 /. Or For more information about a href=/foo1foo1/a. For more information about a href=/foo2foo2/a. The latter. This allows you to move the pages around on the filesystem without having to grep through all you source files looking for what needs to be changed. Am I missing something, or did you mean the former? D'oh! That brain-finger connection is always getting messed up. I meant the former. Thanks for correcting me! Chas. -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: lift:Menu.group
It's in trunk now. Add the donthide attribute to your Menu.item tags and you'll get the same text as you would normally, just not in link form. Derek On Wed, Mar 25, 2009 at 4:31 PM, bradford fingerm...@gmail.com wrote: Derek, that'll work :) Thanks, Bradford On Mar 25, 6:13 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: That seems reasonable to me. That's actually what the Menu.builder does, essentially. I don't think we want to modify the default behavior, but I could make it a donthide attribute instead of always to do what you're saying. Bradford, would that work for you? Derek On Wed, Mar 25, 2009 at 3:54 PM, Charles F. Munat c...@munat.com wrote: Actually, my feeling on item is that if you're on that page, item should return placeholder text (i.e. the same text without the link). For me, at least, that's the most common scenario. Chas. bradford wrote: David, you're right that needing to surround the element text of a with span is a unique case and should be a custom snippet. I've removed the span now and think that Derek's addition of always would be just what I need. Adding group=foo to Menu.builder would suffice as well. Thanks for the tips, Chas. Derek, if you do add always can you please let me know so that I can update my code. Thanks, Bradford On Mar 24, 10:37 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: The general case is that a page won't link to itself, I think, which is why the default isn't to show it when the page matches. Unless anyone has objections I can add an always attribute. As for #1, the Menu.item makes a link using whatever the contents of the Menu.item tag are for the link text: lift:Menu.item name=foospanGo here/span/lift:Menu.item should become a href={foo location}spanGo here/span/a Am I misunderstanding what you're looking for there? As for #2, you should be able to add a class using the prefixed attribute: lift:Menu.builder li_item:class=bar / In this context, li_item is the menu item that matches the current page. With Menu.group, you can specify the binding template: ul lift:Menu.group group=help li class=barmenu:bind //li /lift:Menu.group /ul But there's no provision to do anything special for the current page. Let me know if that's not sufficient or if I'm misunderstanding your requirement. Derek On Tue, Mar 24, 2009 at 3:50 PM, bradford fingerm...@gmail.com wrote: Thanks for the clarification, David, and for your snippet, Derek. I think adding an always attribute to Menu.item would be very beneficial. I still don't understand why that's not its default behavior. It looks like I will not be able to use any of lift's Menu tags at this time, because 1) I need to surround the item text with span and 2) I need a way to add class=active to the li_item. Both are not possible with Menu.item, Menu.group, or Menu.builder. Let me know if I am mistaken. If I am not not, may I put in a feature request for these items. For the time being I will just hard code it as follows (which is not a big deal to me at this time): ul class=menu lia href=/foo1 class=activespanFoo1/span/foo lia href=/foo2spanFoo2/span/foo lia href=/foo3spanFoo3/span/foo /ul Thanks again for the great support :) Bradford On Mar 24, 12:08 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Mar 24, 2009 at 9:02 AM, Charles F. Munat c...@munat.com wrote: David Pollak wrote: What's the best practice: For more information about lift:Menu.item name=foo1 /. For more information about lift:Menu.item name=foo2 /. Or For more information about a href=/foo1foo1/a. For more information about a href=/foo2foo2/a. The latter. This allows you to move the pages around on the filesystem without having to grep through all you source files looking for what needs to be changed. Am I missing something, or did you mean the former? D'oh! That brain-finger connection is always getting messed up. I meant the former. Thanks for correcting me! Chas. -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: lift:Menu.group
David, you're right that needing to surround the element text of a with span is a unique case and should be a custom snippet. I've removed the span now and think that Derek's addition of always would be just what I need. Adding group=foo to Menu.builder would suffice as well. Thanks for the tips, Chas. Derek, if you do add always can you please let me know so that I can update my code. Thanks, Bradford On Mar 24, 10:37 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: The general case is that a page won't link to itself, I think, which is why the default isn't to show it when the page matches. Unless anyone has objections I can add an always attribute. As for #1, the Menu.item makes a link using whatever the contents of the Menu.item tag are for the link text: lift:Menu.item name=foospanGo here/span/lift:Menu.item should become a href={foo location}spanGo here/span/a Am I misunderstanding what you're looking for there? As for #2, you should be able to add a class using the prefixed attribute: lift:Menu.builder li_item:class=bar / In this context, li_item is the menu item that matches the current page. With Menu.group, you can specify the binding template: ul lift:Menu.group group=help li class=barmenu:bind //li /lift:Menu.group /ul But there's no provision to do anything special for the current page. Let me know if that's not sufficient or if I'm misunderstanding your requirement. Derek On Tue, Mar 24, 2009 at 3:50 PM, bradford fingerm...@gmail.com wrote: Thanks for the clarification, David, and for your snippet, Derek. I think adding an always attribute to Menu.item would be very beneficial. I still don't understand why that's not its default behavior. It looks like I will not be able to use any of lift's Menu tags at this time, because 1) I need to surround the item text with span and 2) I need a way to add class=active to the li_item. Both are not possible with Menu.item, Menu.group, or Menu.builder. Let me know if I am mistaken. If I am not not, may I put in a feature request for these items. For the time being I will just hard code it as follows (which is not a big deal to me at this time): ul class=menu lia href=/foo1 class=activespanFoo1/span/foo lia href=/foo2spanFoo2/span/foo lia href=/foo3spanFoo3/span/foo /ul Thanks again for the great support :) Bradford On Mar 24, 12:08 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Mar 24, 2009 at 9:02 AM, Charles F. Munat c...@munat.com wrote: David Pollak wrote: What's the best practice: For more information about lift:Menu.item name=foo1 /. For more information about lift:Menu.item name=foo2 /. Or For more information about a href=/foo1foo1/a. For more information about a href=/foo2foo2/a. The latter. This allows you to move the pages around on the filesystem without having to grep through all you source files looking for what needs to be changed. Am I missing something, or did you mean the former? D'oh! That brain-finger connection is always getting messed up. I meant the former. Thanks for correcting me! Chas. -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: lift:Menu.group
Please don't shoot me for bringing this up again. I still don't think the current behavior of Menu.item makes sense. If the user doesn't want that link to appear on the page, then they shouldn't include lift:Menu.item name=foo1 / in its source. Most people put text around their link: lift:Menu.item name=foo1 / | lift:Menu.item name=foo2 / | lift:Menu.item name=foo3 / which, on foo2, would render as _foo1_ | | _foo3_ or For a good time lift:Menu.item name=foo1click here/ llift:Menu.item. For a not so good time lift:Menu.item name=foo2click here/llift:Menu.item. which, on foo2, would render as For a good time _click here_. For a not so good time . Regards, Bradford On Mar 25, 7:53 am, bradford fingerm...@gmail.com wrote: David, you're right that needing to surround the element text of a with span is a unique case and should be a custom snippet. I've removed the span now and think that Derek's addition of always would be just what I need. Adding group=foo to Menu.builder would suffice as well. Thanks for the tips, Chas. Derek, if you do add always can you please let me know so that I can update my code. Thanks, Bradford On Mar 24, 10:37 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: The general case is that a page won't link to itself, I think, which is why the default isn't to show it when the page matches. Unless anyone has objections I can add an always attribute. As for #1, the Menu.item makes a link using whatever the contents of the Menu.item tag are for the link text: lift:Menu.item name=foospanGo here/span/lift:Menu.item should become a href={foo location}spanGo here/span/a Am I misunderstanding what you're looking for there? As for #2, you should be able to add a class using the prefixed attribute: lift:Menu.builder li_item:class=bar / In this context, li_item is the menu item that matches the current page. With Menu.group, you can specify the binding template: ul lift:Menu.group group=help li class=barmenu:bind //li /lift:Menu.group /ul But there's no provision to do anything special for the current page. Let me know if that's not sufficient or if I'm misunderstanding your requirement. Derek On Tue, Mar 24, 2009 at 3:50 PM, bradford fingerm...@gmail.com wrote: Thanks for the clarification, David, and for your snippet, Derek. I think adding an always attribute to Menu.item would be very beneficial. I still don't understand why that's not its default behavior. It looks like I will not be able to use any of lift's Menu tags at this time, because 1) I need to surround the item text with span and 2) I need a way to add class=active to the li_item. Both are not possible with Menu.item, Menu.group, or Menu.builder. Let me know if I am mistaken. If I am not not, may I put in a feature request for these items. For the time being I will just hard code it as follows (which is not a big deal to me at this time): ul class=menu lia href=/foo1 class=activespanFoo1/span/foo lia href=/foo2spanFoo2/span/foo lia href=/foo3spanFoo3/span/foo /ul Thanks again for the great support :) Bradford On Mar 24, 12:08 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Mar 24, 2009 at 9:02 AM, Charles F. Munat c...@munat.com wrote: David Pollak wrote: What's the best practice: For more information about lift:Menu.item name=foo1 /. For more information about lift:Menu.item name=foo2 /. Or For more information about a href=/foo1foo1/a. For more information about a href=/foo2foo2/a. The latter. This allows you to move the pages around on the filesystem without having to grep through all you source files looking for what needs to be changed. Am I missing something, or did you mean the former? D'oh! That brain-finger connection is always getting messed up. I meant the former. Thanks for correcting me! Chas. -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: lift:Menu.group
Thanks Derek. I'll give this a shot when I get home. I don't quite understand the purpose of Menu.item, then. Isn't Menu.item what you all use to create links so that they aren't hard coded in all of the pages? What's the best practice: For more information about lift:Menu.item name=foo1 /. For more information about lift:Menu.item name=foo2 /. Or For more information about a href=/foo1foo1/a. For more information about a href=/foo2foo2/a. Or something else? Thanks again. On Mar 23, 9:43 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: That's actually the correct behavior as it's currently written for the Menu.item. For the Menu.group, you can provide your own template for each menu item that's rendered: ul class=menu lift:Menu.group group=foo limenu:bind //li /lift:Menu.group /ul I could see adding an always attribute to the Menu.item snippet such that when it's defined the Menu item is always rendered. Derek On Mon, Mar 23, 2009 at 6:48 PM, bradford fingerm...@gmail.com wrote: Also, I'm using 1.1-snapshot and lift:Menu.item name=foo1 / will always show except when i am on /foo1. For this case it doesn't even render. On Mar 23, 8:41 pm, bradford fingerm...@gmail.com wrote: The idea of LocGroup is great. I have a few Menu's with LocGroup (group1). I want to generate: ul class=menu lia href=/foo1spanFoo1/span/foo lia href=/foo1spanFoo1/span/foo lia href=/foo1spanFoo1/span/foo /ul for just group1. It appears that lift:Menu.group / does not print ul and li, and lift:Menu.builder won't recognize group. What are my alternatives? Also, I need to surround the item text with span /. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: lift:Menu.group
On Tue, Mar 24, 2009 at 6:55 AM, bradford fingerm...@gmail.com wrote: Thanks Derek. I'll give this a shot when I get home. I don't quite understand the purpose of Menu.item, then. Isn't Menu.item what you all use to create links so that they aren't hard coded in all of the pages? Yes. What's the best practice: For more information about lift:Menu.item name=foo1 /. For more information about lift:Menu.item name=foo2 /. Or For more information about a href=/foo1foo1/a. For more information about a href=/foo2foo2/a. The latter. This allows you to move the pages around on the filesystem without having to grep through all you source files looking for what needs to be changed. Or something else? Thanks again. On Mar 23, 9:43 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: That's actually the correct behavior as it's currently written for the Menu.item. For the Menu.group, you can provide your own template for each menu item that's rendered: ul class=menu lift:Menu.group group=foo limenu:bind //li /lift:Menu.group /ul I could see adding an always attribute to the Menu.item snippet such that when it's defined the Menu item is always rendered. Derek On Mon, Mar 23, 2009 at 6:48 PM, bradford fingerm...@gmail.com wrote: Also, I'm using 1.1-snapshot and lift:Menu.item name=foo1 / will always show except when i am on /foo1. For this case it doesn't even render. On Mar 23, 8:41 pm, bradford fingerm...@gmail.com wrote: The idea of LocGroup is great. I have a few Menu's with LocGroup (group1). I want to generate: ul class=menu lia href=/foo1spanFoo1/span/foo lia href=/foo1spanFoo1/span/foo lia href=/foo1spanFoo1/span/foo /ul for just group1. It appears that lift:Menu.group / does not print ul and li, and lift:Menu.builder won't recognize group. What are my alternatives? Also, I need to surround the item text with span /. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: lift:Menu.group
Thanks for the clarification, David, and for your snippet, Derek. I think adding an always attribute to Menu.item would be very beneficial. I still don't understand why that's not its default behavior. It looks like I will not be able to use any of lift's Menu tags at this time, because 1) I need to surround the item text with span and 2) I need a way to add class=active to the li_item. Both are not possible with Menu.item, Menu.group, or Menu.builder. Let me know if I am mistaken. If I am not not, may I put in a feature request for these items. For the time being I will just hard code it as follows (which is not a big deal to me at this time): ul class=menu lia href=/foo1 class=activespanFoo1/span/foo lia href=/foo2spanFoo2/span/foo lia href=/foo3spanFoo3/span/foo /ul Thanks again for the great support :) Bradford On Mar 24, 12:08 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Mar 24, 2009 at 9:02 AM, Charles F. Munat c...@munat.com wrote: David Pollak wrote: What's the best practice: For more information about lift:Menu.item name=foo1 /. For more information about lift:Menu.item name=foo2 /. Or For more information about a href=/foo1foo1/a. For more information about a href=/foo2foo2/a. The latter. This allows you to move the pages around on the filesystem without having to grep through all you source files looking for what needs to be changed. Am I missing something, or did you mean the former? D'oh! That brain-finger connection is always getting messed up. I meant the former. Thanks for correcting me! Chas. -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: lift:Menu.group
Bradford, It's easy to change this. I needed similar capabilities. So I simply copied the Menu.scala file into my own file and changed it to MyMenu.scala. Then it's a very quick fix to adapt the item, etc. methods to your own purposes. Took me five minutes, and I had complete control. Just because it's built into Lift doesn't mean you can't override it. And by copying the Lift code, I had most of the work done for me. I've done this with lots of other code. For example, I just recently rewrote the Msgs code so that I could include a default NodeSeq and it outputs that when there is no notice, warning, or error. If something seems to be worth it to other people, sometimes your code will be pulled in. I rewrote S once to make it easy to add attributes to things, and David ended up using those changes (after rewriting them into much better Scala). Consider it. Chas. bradford wrote: Thanks for the clarification, David, and for your snippet, Derek. I think adding an always attribute to Menu.item would be very beneficial. I still don't understand why that's not its default behavior. It looks like I will not be able to use any of lift's Menu tags at this time, because 1) I need to surround the item text with span and 2) I need a way to add class=active to the li_item. Both are not possible with Menu.item, Menu.group, or Menu.builder. Let me know if I am mistaken. If I am not not, may I put in a feature request for these items. For the time being I will just hard code it as follows (which is not a big deal to me at this time): ul class=menu lia href=/foo1 class=activespanFoo1/span/foo lia href=/foo2spanFoo2/span/foo lia href=/foo3spanFoo3/span/foo /ul Thanks again for the great support :) Bradford On Mar 24, 12:08 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Mar 24, 2009 at 9:02 AM, Charles F. Munat c...@munat.com wrote: David Pollak wrote: What's the best practice: For more information about lift:Menu.item name=foo1 /. For more information about lift:Menu.item name=foo2 /. Or For more information about a href=/foo1foo1/a. For more information about a href=/foo2foo2/a. The latter. This allows you to move the pages around on the filesystem without having to grep through all you source files looking for what needs to be changed. Am I missing something, or did you mean the former? D'oh! That brain-finger connection is always getting messed up. I meant the former. Thanks for correcting me! Chas. -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: lift:Menu.group
The general case is that a page won't link to itself, I think, which is why the default isn't to show it when the page matches. Unless anyone has objections I can add an always attribute. As for #1, the Menu.item makes a link using whatever the contents of the Menu.item tag are for the link text: lift:Menu.item name=foospanGo here/span/lift:Menu.item should become a href={foo location}spanGo here/span/a Am I misunderstanding what you're looking for there? As for #2, you should be able to add a class using the prefixed attribute: lift:Menu.builder li_item:class=bar / In this context, li_item is the menu item that matches the current page. With Menu.group, you can specify the binding template: ul lift:Menu.group group=help li class=barmenu:bind //li /lift:Menu.group /ul But there's no provision to do anything special for the current page. Let me know if that's not sufficient or if I'm misunderstanding your requirement. Derek On Tue, Mar 24, 2009 at 3:50 PM, bradford fingerm...@gmail.com wrote: Thanks for the clarification, David, and for your snippet, Derek. I think adding an always attribute to Menu.item would be very beneficial. I still don't understand why that's not its default behavior. It looks like I will not be able to use any of lift's Menu tags at this time, because 1) I need to surround the item text with span and 2) I need a way to add class=active to the li_item. Both are not possible with Menu.item, Menu.group, or Menu.builder. Let me know if I am mistaken. If I am not not, may I put in a feature request for these items. For the time being I will just hard code it as follows (which is not a big deal to me at this time): ul class=menu lia href=/foo1 class=activespanFoo1/span/foo lia href=/foo2spanFoo2/span/foo lia href=/foo3spanFoo3/span/foo /ul Thanks again for the great support :) Bradford On Mar 24, 12:08 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Mar 24, 2009 at 9:02 AM, Charles F. Munat c...@munat.com wrote: David Pollak wrote: What's the best practice: For more information about lift:Menu.item name=foo1 /. For more information about lift:Menu.item name=foo2 /. Or For more information about a href=/foo1foo1/a. For more information about a href=/foo2foo2/a. The latter. This allows you to move the pages around on the filesystem without having to grep through all you source files looking for what needs to be changed. Am I missing something, or did you mean the former? D'oh! That brain-finger connection is always getting messed up. I meant the former. Thanks for correcting me! Chas. -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: lift:Menu.group
Also, I'm using 1.1-snapshot and lift:Menu.item name=foo1 / will always show except when i am on /foo1. For this case it doesn't even render. On Mar 23, 8:41 pm, bradford fingerm...@gmail.com wrote: The idea of LocGroup is great. I have a few Menu's with LocGroup (group1). I want to generate: ul class=menu lia href=/foo1spanFoo1/span/foo lia href=/foo1spanFoo1/span/foo lia href=/foo1spanFoo1/span/foo /ul for just group1. It appears that lift:Menu.group / does not print ul and li, and lift:Menu.builder won't recognize group. What are my alternatives? Also, I need to surround the item text with span /. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: lift:Menu.group
I apologize for all of the messages. I got a little hasty with this email. This is what I'm looking for: ul class=menu lia href=/foo1spanFoo1/span/foo lia href=/foo2spanFoo2/span/foo lia href=/foo3spanFoo3/span/foo /ul On Mar 23, 8:41 pm, bradford fingerm...@gmail.com wrote: The idea of LocGroup is great. I have a few Menu's with LocGroup (group1). I want to generate: ul class=menu lia href=/foo1spanFoo1/span/foo lia href=/foo1spanFoo1/span/foo lia href=/foo1spanFoo1/span/foo /ul for just group1. It appears that lift:Menu.group / does not print ul and li, and lift:Menu.builder won't recognize group. What are my alternatives? Also, I need to surround the item text with span /. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---