[Lift] Set Expires headers for certain pages, files, etc

2010-03-03 Thread Alex Black
I asked about this before:

http://groups.google.com/group/liftweb/browse_thread/thread/9daa4692acbfce6/00be519d77901fb0

Can anyone suggest a good way to set Expires headers?
- I'd like our images, JS and CSS to have expires headers perhaps 1
month in the future
- I'd like to set certain pages' expires headers perhaps 1 day in the
future

This way browsers can avoid re-fetching resources (pages, images, css
files etc) over and over again when they haven't changed.

I managed to do this using LiftRules.defaultHeaders, but it doesn't
seem to have any effect on images (we're serving them out of a /images
folder).

any ideas?

thx

- Alex

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Cached CSS (and Javascript?) issue

2010-02-16 Thread Alex Black
> calculating an md5 of a file would induce additional computation time
> and we'd need to maintain hashes for each resource file. The prototype
> that I have now is a function in LiftRules that by default returns a
> random value generated on startup. Applications that needs MD5 per
> file could calculate that and maintain them.

Hi Marius, what does the proposed token represent? It looks to me like
it represents a given resource (css file) per running instance of
Jetty.

By using MD5 it instead represents the file itself.

Problems with using a token that represents a given resource per
running instance of jetty:
- if the server restarts you use a new token, so all clients are
forced to re-get the 'new' resource
- if you run more than one server, then each server has different
tokens, so clients think there are different resources

I also like the suggestion that a solution to the consolidation
problem be kept separate from the problem of generating unique urls
for cachable resources (such as CSS, javascript, etc).


>
>
>
> > 2. Consolidation of CSS files on a given page for performance firstly, and 
> > secondly for caching.
>
> > Would there be times when people would not want the behaviour of 2? Im 
> > generally not a huge fan of things that mess with user code or could 
> > provide uneasy behaviour; im thinking specifically when people build there 
> > templates where CSS values are overridden by values loaded after initial 
> > value ad unless its munged together right, it might damage the expected 
> > behaviour (think blueprint)...? Can I suggest we solve the caching problem 
> > using the known hack of random strings, then deal with this proposal of 
> > resource consolidation?
>
> What I'm playing with is"
>
> 
>   
>   
> 
>
> under the hood this would be a function that return a Stream Response
> that "concatenates" the streams of files in questions serving them
> sequentially in the corresponding order.  So from Lift's perspective
> there is no additional computation involved comparing with current
> situation except we serve desired resources in one response.
>
> To sum up the random string is what I think we should start with. IMO
> it is a fairly good solution that can evolve in time towards something
> else.
>
>
>
> > Cheers
>
> > Tim
>
> > On 13 Feb 2010, at 08:45, Marius wrote:
>
> > > On 12 feb., 23:04, Alex Black  wrote:
> > >>> Yes, that's how it should work if everything was configured correctly
> > >>> (which I think it wasn't for the OP)
>
> > >> Heh, I'm the OP.
>
> > >> I'll have to dig into why its not working as expected I guess.
>
> > >>> But what we were discussing (at least I was :-) was more that Lift
> > >>> should serve resources with an "Expires" date in the far future. That
> > >>> way the browser will only make a single request for a resource (as
> > >>> long as the file is cached). This works well for returning visitors.
> > >>> But of course an updated resource should be fetched, hence the unique
> > >>> filenames.
>
> > >> There are some things I like about that solution, but the unique
> > >> filenames just seems wrong.
>
> > >> So I see that a far in the future expires works, but the reason you
> > >> need the unique filenames is because it doesn't really work. The far
> > >> in the future expires says "you can cache this for a long time cause
> > >> it won't change".
>
> > >> The other option is say "you can cache this for like the next hour"
> > >> but every time you fetch it, you can tell me when you last got it
> > >> (conditional GET), and I won't send it to you if it hasn't changed
> > >> (304 not modified).  This results in more requests, but no need for
> > >> unique filenames or anything, instead if the file changes then the
> > >> server will serve it up to whoever needs it.
>
> > > It doesn't sound like today this solution is consistent on all "major"
> > > browsers. Can you confirm that it does?
> > > I used the query string solution in the past (like many others) and
> > > this works reasonably well. It is not a perfect solution
> > > but better then today. Besides if we want to adopt a different
> > > solution that would be pretty easy because this knowledge will be
> > > built
> > > in the snippet and the user code wont really change.
>
> > >>> Co

[Lift] Re: Cached CSS (and Javascript?) issue

2010-02-15 Thread Alex Black
We don't seem to have this problem with images..

Could this have to do with the fact that the CSS files and javascript
are served out of the WAR file, whereas our images are served by a
separate Jetty context?

On Feb 13, 3:35 am, Marius  wrote:
> On 12 feb., 22:56, Alex Black  wrote:
>
> > If this was implemented, it should be a unique id once perCSSchange,
> > not once per application start.
>
> There is no proper API to see when file names are changed unless we
> poll. I prefer to have  LiftRules function that by default takes a
> value generated at startup. User's can override it to generate the
> token more frequently depending on their use-case.
>
>
>
> > E.g. we deploy to production every few weeks, and client browsers
> > should be able to cache files that entire time until change them,
> > regardless of reboots.
>
> > But obviously a value once per application start is much easier.
>
> > I think what this points out is that its the file's datetime that is
> > the state that needs to be used here, and the existing mechanism of
> > HTTP looks like the way to go.  Perhaps I'll dig into it and try to
> > understand why this is not working as one would expect.
>
> If you can dig deeper that would be useful.
>
>
>
>
>
> > On Feb 12, 1:28 pm, Marius  wrote:
>
> > > Oh yes I did and I hate it. Ironically I was about to propose a
> > > solution for this.
>
> > > instead of
>
> > > 
>
> > > do something like:
>
> > > 
>
> > > this would render:
>
> > > 
>
> > > the query string parameter would be generated at application start-up.
> > > If you update youcss/js and restart the application the browser will
> > > refresh it. Potentially generating the random query string param could
> > > be a LiftRules function that by default generates a sequence once per
> > > application time. Thus you could potentially set your own function
> > > that reads this for a config file?
>
> > > Similarly  would do the same.
>
> > > Br's,
> > > Marius
>
> > > On 12 feb., 19:25, Alex Black  wrote:
>
> > > > I'm wondering if other people have encountered this issue, or if we're
> > > > doing something wrong, or if there is a nice solution to this.
>
> > > > Whenever we update our site, with new code andCSSand JS, any user
> > > > who visits it gets OLDcssand js files (from their browser cache)
> > > > unless they force a refresh.
>
> > > > This is a jarring experience, users's see the site with oldCSSand
> > > > old JS which is effectively broken.
>
> > > > Any thoughts? If it helps, our site is athttp://snapsort.com.  We're
> > > > using Jetty, behind nginx.
>
> > > > I notice that when the browser requests theCSSfiles, the server
> > > > responds 304 not modified, so I figured if theCSSwas modified (when
> > > > we update) then the server would not respond 304 not modified :)
>
> > > > - Alex

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Cached CSS (and Javascript?) issue

2010-02-15 Thread Alex Black
> There is no proper API to see when file names are changed unless we
> poll. I prefer to have  LiftRules function that by default takes a
> value generated at startup. User's can override it to generate the
> token more frequently depending on their use-case.

I was interested in less-frequently (not more).

What did you think of Jeppe's proposal to use the MD5 hash of the file
as the token?

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Cached CSS (and Javascript?) issue

2010-02-12 Thread Alex Black
This looks a bit complex:

http://www.samaxes.com/2009/05/combine-and-minimize-javascript-and-css-files-for-faster-loading/

but its an example of how other people have handled combining css and
javascript files.

On Feb 12, 4:11 pm, Jeppe Nejsum Madsen  wrote:
> On Fri, Feb 12, 2010 at 10:04 PM, Alex Black  wrote:
> >> Yes, that's how it should work if everything was configured correctly
> >> (which I think it wasn't for the OP)
>
> > Heh, I'm the OP.
>
> Ahh sorry :-)
>
> > The other option is say "you can cache this for like the next hour"
> > but every time you fetch it, you can tell me when you last got it
> > (conditional GET), and I won't send it to you if it hasn't changed
> > (304 not modified).  This results in more requests, but no need for
> > unique filenames or anything, instead if the file changes then the
> > server will serve it up to whoever needs it.
>
> But it's the "more requests" part I'm not interested in :-) For a
> moderately complex page, there can easily be 20+ requests for
> images/css/js etc. I would like to avoid that if possible.
>
> /Jeppe

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Cached CSS (and Javascript?) issue

2010-02-12 Thread Alex Black
> Or just the MD5 hash of the contents...

ah, now you're talking.  That sounds like a good solution.

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Cached CSS (and Javascript?) issue

2010-02-12 Thread Alex Black
> Yes, that's how it should work if everything was configured correctly
> (which I think it wasn't for the OP)

Heh, I'm the OP.

I'll have to dig into why its not working as expected I guess.

> But what we were discussing (at least I was :-) was more that Lift
> should serve resources with an "Expires" date in the far future. That
> way the browser will only make a single request for a resource (as
> long as the file is cached). This works well for returning visitors.
> But of course an updated resource should be fetched, hence the unique
> filenames.

There are some things I like about that solution, but the unique
filenames just seems wrong.

So I see that a far in the future expires works, but the reason you
need the unique filenames is because it doesn't really work. The far
in the future expires says "you can cache this for a long time cause
it won't change".

The other option is say "you can cache this for like the next hour"
but every time you fetch it, you can tell me when you last got it
(conditional GET), and I won't send it to you if it hasn't changed
(304 not modified).  This results in more requests, but no need for
unique filenames or anything, instead if the file changes then the
server will serve it up to whoever needs it.

> Combining individual files will improve load times for first time
> visitors by reducing the number of requests.

That sounds like a great idea.. would like the same thing for JS.
Does the YUI compressor tool that lift uses with maven have this type
of feature? I Thought I read that it did.

>
> /Jeppe

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Cached CSS (and Javascript?) issue

2010-02-12 Thread Alex Black
I'd vote for: figure out if this can be done properly (e.g. rely on
file system date/time file and HTTP), and if necessary add a hack to
support browsers like IE6.

On Feb 12, 3:54 pm, Ross Mellgren  wrote:
> It does normally, but not for CSS resources. I just did a quick google and I 
> found one page that said it will send a HEAD for a cached CSS but only when 
> the browser session is restarted. I know that at my work we've had to do the 
> filename hack because nothing else works with IE6.
>
> And IE6 may be dying out to some degree, but it's still popular enough (and 
> particularly in certain industries) that it has to be supported for many 
> companies :-/
>
> -Ross
>
> On Feb 12, 2010, at 3:51 PM, Alex Black wrote:
>
> > 1. Luckily IE6 is dying out :) unlesshttp://saveie6.com/works
> > 2. surely even IE6 obeys expires headers or some caching rules?
>
> > On Feb 12, 3:48 pm, Ross Mellgren  wrote:
> >> I believe IE6 does not follow the correct process you describe and will 
> >> always cache CSS files of the same name.
>
> >> -Ross
>
> >> On Feb 12, 2010, at 3:48 PM, Alex Black wrote:
>
> >>> hey guys, I love the enthusiasm, but putting a unique value on the css
> >>> filenames seems like a hack, surely we can do better?
>
> >>> Whats supposed to happen is:
> >>> - browser requests resource (e.g. styles.css) with a conditonal get
> >>> (if newer than X)
> >>> - server checks to see if resource is newer than X
> >>> - if it is new than x then: return resource
> >>> - if it is not newer than x, then return 304 not modified
>
> >>> - Alex
>
> >>> On Feb 12, 2:35 pm, Marius  wrote:
> >>>> On 12 feb., 21:31, Jeppe Nejsum Madsen  wrote:
>
> >>>>> On Fri, Feb 12, 2010 at 8:20 PM, Marius  wrote:
> >>>>>> Jeppe probably we can combine the two proposals.
>
> >>>>> Yes, that would be natural
>
> >>>>>> Perhaps something like:
>
> >>>>>> 
>
> >>>>>> thus Lift could generate:
>
> >>>>>> 
>
> >>>>>> compound_2434rfe34534.css is a synthetic name that would contain the
> >>>>>> mycss.css, some_other.css. /classpath/baz.css concatenated. Same thing
> >>>>>> for JS. This content could potentially be compressed.
>
> >>>>> One thing that I think will be important (at some point :-) is to do
> >>>>> combining of individual tags. If a page is constructed from several
> >>>>> snippets/widgets, each emitting different js files (think jQuery
> >>>>> plugins) and css files, these need to be combined somehow. This means
> >>>>> that each page will get it's own unique synthetic css/js file. This
> >>>>> probably needs to be configurable in some way :-)
>
> >>>> Yeah that is a slightly different use-case that require more noodling.
> >>>> But would worth considering in the future.
>
> >>>>>> I can open a ticket and start looking into this.
>
> >>>>> Awesome! I'll watch from the sideline!
>
> >>>>> /Jeppe
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups 
> >>> "Lift" group.
> >>> To post to this group, send email to lift...@googlegroups.com.
> >>> To unsubscribe from this group, send email to 
> >>> liftweb+unsubscr...@googlegroups.com.
> >>> For more options, visit this group 
> >>> athttp://groups.google.com/group/liftweb?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Cached CSS (and Javascript?) issue

2010-02-12 Thread Alex Black
If this was implemented, it should be a unique id once per CSS change,
not once per application start.

E.g. we deploy to production every few weeks, and client browsers
should be able to cache files that entire time until change them,
regardless of reboots.

But obviously a value once per application start is much easier.

I think what this points out is that its the file's datetime that is
the state that needs to be used here, and the existing mechanism of
HTTP looks like the way to go.  Perhaps I'll dig into it and try to
understand why this is not working as one would expect.

On Feb 12, 1:28 pm, Marius  wrote:
> Oh yes I did and I hate it. Ironically I was about to propose a
> solution for this.
>
> instead of
>
> 
>
> do something like:
>
> 
>
> this would render:
>
> 
>
> the query string parameter would be generated at application start-up.
> If you update you css/js and restart the application the browser will
> refresh it. Potentially generating the random query string param could
> be a LiftRules function that by default generates a sequence once per
> application time. Thus you could potentially set your own function
> that reads this for a config file?
>
> Similarly  would do the same.
>
> Br's,
> Marius
>
> On 12 feb., 19:25, Alex Black  wrote:
>
> > I'm wondering if other people have encountered this issue, or if we're
> > doing something wrong, or if there is a nice solution to this.
>
> > Whenever we update our site, with new code and CSS and JS, any user
> > who visits it gets OLD css and js files (from their browser cache)
> > unless they force a refresh.
>
> > This is a jarring experience, users's see the site with old CSS and
> > old JS which is effectively broken.
>
> > Any thoughts? If it helps, our site is athttp://snapsort.com.  We're
> > using Jetty, behind nginx.
>
> > I notice that when the browser requests the CSS files, the server
> > responds 304 not modified, so I figured if the CSS was modified (when
> > we update) then the server would not respond 304 not modified :)
>
> > - Alex

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Cached CSS (and Javascript?) issue

2010-02-12 Thread Alex Black
1. Luckily IE6 is dying out :) unless http://saveie6.com/ works
2. surely even IE6 obeys expires headers or some caching rules?

On Feb 12, 3:48 pm, Ross Mellgren  wrote:
> I believe IE6 does not follow the correct process you describe and will 
> always cache CSS files of the same name.
>
> -Ross
>
> On Feb 12, 2010, at 3:48 PM, Alex Black wrote:
>
> > hey guys, I love the enthusiasm, but putting a unique value on the css
> > filenames seems like a hack, surely we can do better?
>
> > Whats supposed to happen is:
> > - browser requests resource (e.g. styles.css) with a conditonal get
> > (if newer than X)
> > - server checks to see if resource is newer than X
> > - if it is new than x then: return resource
> > - if it is not newer than x, then return 304 not modified
>
> > - Alex
>
> > On Feb 12, 2:35 pm, Marius  wrote:
> >> On 12 feb., 21:31, Jeppe Nejsum Madsen  wrote:
>
> >>> On Fri, Feb 12, 2010 at 8:20 PM, Marius  wrote:
> >>>> Jeppe probably we can combine the two proposals.
>
> >>> Yes, that would be natural
>
> >>>> Perhaps something like:
>
> >>>> 
>
> >>>> thus Lift could generate:
>
> >>>> 
>
> >>>> compound_2434rfe34534.css is a synthetic name that would contain the
> >>>> mycss.css, some_other.css. /classpath/baz.css concatenated. Same thing
> >>>> for JS. This content could potentially be compressed.
>
> >>> One thing that I think will be important (at some point :-) is to do
> >>> combining of individual tags. If a page is constructed from several
> >>> snippets/widgets, each emitting different js files (think jQuery
> >>> plugins) and css files, these need to be combined somehow. This means
> >>> that each page will get it's own unique synthetic css/js file. This
> >>> probably needs to be configurable in some way :-)
>
> >> Yeah that is a slightly different use-case that require more noodling.
> >> But would worth considering in the future.
>
> >>>> I can open a ticket and start looking into this.
>
> >>> Awesome! I'll watch from the sideline!
>
> >>> /Jeppe
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Cached CSS (and Javascript?) issue

2010-02-12 Thread Alex Black
hey guys, I love the enthusiasm, but putting a unique value on the css
filenames seems like a hack, surely we can do better?

Whats supposed to happen is:
- browser requests resource (e.g. styles.css) with a conditonal get
(if newer than X)
- server checks to see if resource is newer than X
- if it is new than x then: return resource
- if it is not newer than x, then return 304 not modified

- Alex

On Feb 12, 2:35 pm, Marius  wrote:
> On 12 feb., 21:31, Jeppe Nejsum Madsen  wrote:
>
>
>
> > On Fri, Feb 12, 2010 at 8:20 PM, Marius  wrote:
> > > Jeppe probably we can combine the two proposals.
>
> > Yes, that would be natural
>
> > > Perhaps something like:
>
> > > 
>
> > > thus Lift could generate:
>
> > > 
>
> > > compound_2434rfe34534.css is a synthetic name that would contain the
> > > mycss.css, some_other.css. /classpath/baz.css concatenated. Same thing
> > > for JS. This content could potentially be compressed.
>
> > One thing that I think will be important (at some point :-) is to do
> > combining of individual tags. If a page is constructed from several
> > snippets/widgets, each emitting different js files (think jQuery
> > plugins) and css files, these need to be combined somehow. This means
> > that each page will get it's own unique synthetic css/js file. This
> > probably needs to be configurable in some way :-)
>
> Yeah that is a slightly different use-case that require more noodling.
> But would worth considering in the future.
>
>
>
> > > I can open a ticket and start looking into this.
>
> > Awesome! I'll watch from the sideline!
>
> > /Jeppe

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] Cached CSS (and Javascript?) issue

2010-02-12 Thread Alex Black
I'm wondering if other people have encountered this issue, or if we're
doing something wrong, or if there is a nice solution to this.

Whenever we update our site, with new code and CSS and JS, any user
who visits it gets OLD css and js files (from their browser cache)
unless they force a refresh.

This is a jarring experience, users's see the site with old CSS and
old JS which is effectively broken.

Any thoughts? If it helps, our site is at http://snapsort.com.  We're
using Jetty, behind nginx.

I notice that when the browser requests the CSS files, the server
responds 304 not modified, so I figured if the CSS was modified (when
we update) then the server would not respond 304 not modified :)

- Alex

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] Url Rewriting Extractors - Inheritance? Composition?

2010-02-08 Thread Alex Black
Has anyone found a good pattern/method of re-using Url Rewriting
extractors?

I've got a url like this:

/products/manufacturer/productId

And an extractor for that, that given a product gives you a URL
(apply) and given a ParsePath gives you an Option[Product].

I'd then like to support a sub url like this:

/products/manufacturer/productId/view/viewName

so I'd like to make a class to handle view and ViewName (or anything
else that comes below productId), and re-use the functionality in
ProductURL extractor.

I can't seem to figure out a way to do it for unapply. thoughts?

- Alex

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: URL Rewriting - 'nested' ParsePath?

2010-02-06 Thread Alex Black
Hi Philip, thanks for the response.

That looks relevant to what i'm doing... but I think the key thing I'm
looking for is for the case not to match if the product does not exist
for that manufacturer, so I can show a 404.  I think Jeppe's approach
will work well.

I'm not 100% following your example, but it looks to me like your case
statements always match /page/level1/level2 etc without a check like
does this particular level 2 (say "foo") make sense for this level1
("bar"), but maybe I misunderstood.

- Alex

On Feb 6, 8:25 pm, philip  wrote:
> Hi Alex,
>
> I am making a CMS, so I had to get database content for any page up to
> 4 levels under the URLhttp://site/page/leve1/level2/etc... Here is
> some example code from this:
>
> class Boot {
>   def selectTemplate(template: String, subPages: List[String]):
> RewriteResponse =
>     {
>       var levels = Map() ++ (List[String]("level1", "level2",
> "level3", "level4") zip subPages)
>       levels = levels + ("totalLevels" -> levels.size.toString)
>       RewriteResponse(template :: Nil, levels)
>     }
>
>   def boot {
> ... lots of stuff
>
>     LiftRules.rewrite.prepend(NamedPF("inner pages")
>         {
>           case RewriteRequest(ParsePath("page" :: subPages, _, _, _),
> _, _) => selectTemplate("innerpage", subPages)
>           case RewriteRequest(ParsePath("intercitizen" :: subPages, _,
> _, _), _, _) => selectTemplate("intercitizentemplate", subPages)
>         })
>
> This means that anything that goes tohttp://site/page/one/twogoes to
> a file called innerpage.html and the innerpage.html contains
>
> 
> 
>       
>       
> 
> 
>
> And the snippit contains
>
> package com.orsa.iom3.snippet
>
> import xml.{Text, NodeSeq}
> import net.liftweb.http.S
> import com.orsa.iom3.model.SiteContent
> import net.liftweb.util.{Log, Helpers}
> import com.orsa.util.Constants
>
> /**
>  */
>
> class Content
> {
>   def display(in: NodeSeq): NodeSeq =
>     {
>       //val name = S.attr("name") openOr "0"
>
>       // Get the site content from the database
>       val totalLevels:String = S.param("totalLevels") openOr "0"
>       // Build the path for the levels
>       var path = Constants.CMS_ROOT_PATH
>       for (i <- 1 to totalLevels.toInt)
>         path = path + Constants.CMS_PATH_SEP + S.param("level" +
> i).openOr("0")
>
>       val content:SiteContent = SiteContent.findByUniqueName(path)
> openOr new SiteContent
>       // Return the content inside a DIV
>       {scala.xml.Unparsed(content.page_Content_Html.toString)} div>
>     }
>
> }
>
> On 2月6日, 上午9時14分, Alex Black  wrote:
>
>
>
> > Hi, I'd like to rewrite a url like this:
>
> > /manufacturer/product
>
> > e.g.
>
> >     LiftRules.statelessRewrite.append( {
> >       case RewriteRequest(
> >         ParsePath( manufacturerName :: productName :: Nil, _, _,_), _,
> > _)  =>
>
> >         RewriteResponse("productView" :: Nil)
> >     })
>
> > But, I'd like to the ParsePath case to not 'catch' for non-existant
> > manufacturers, and non-existant products by the manufacturer.
>
> > So, I might do this:
>
> >     LiftRules.statelessRewrite.append( {
> >       case RewriteRequest(
> >         ParsePath( Manufacturer(manufacturer) :: Product(product) ::
> > Nil, _, _,_), _, _)  =>
>
> >         RewriteResponse("productView" :: Nil)
> >     })
>
> > Where Manufacturer and Product objects provide an extractor which does
> > a lookup.
>
> > However, the product lookup depends on the manufacturer.. is there a
> > way to handle that?
>
> > ideas:
> > 1. use an if guard
>
> >       case RewriteRequest(
> >         ParsePath( Manufacturer(manufacturer) :: productName :: Nil,
> > _, _,_), _, _)  if manufacturer.contains(productName) =>
> >           val product = manufacturer.getProduct(productName)
>
> > sucks because it looks up the product twice.
>
> > 2. some time of nested case?
>
> >       case RewriteRequest(
> >         ParsePath( Manufacturer(manufacturer) :: Product(manufacturer,
> > product) :: Nil, _, _,_), _, _)  =>
>
> > obviously doesn't work..
>
> > any suggestions welcome, thanks!
>
> > - Alex

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: URL Rewriting - 'nested' ParsePath?

2010-02-06 Thread Alex Black
Hi Jeppe, thanks, that looks like what I need!

On Feb 6, 3:03 am, Jeppe Nejsum Madsen  wrote:
> Alex Black  writes:
> > Hi, I'd like to rewrite a url like this:
>
> > /manufacturer/product
>
> > e.g.
>
> >     LiftRules.statelessRewrite.append( {
> >       case RewriteRequest(
> >         ParsePath( manufacturerName :: productName :: Nil, _, _,_), _,
> > _)  =>
>
> >         RewriteResponse("productView" :: Nil)
> >     })
>
> > But, I'd like to the ParsePath case to not 'catch' for non-existant
> > manufacturers, and non-existant products by the manufacturer.
>
> > So, I might do this:
>
> >     LiftRules.statelessRewrite.append( {
> >       case RewriteRequest(
> >         ParsePath( Manufacturer(manufacturer) :: Product(product) ::
> > Nil, _, _,_), _, _)  =>
>
> >         RewriteResponse("productView" :: Nil)
> >     })
>
> > Where Manufacturer and Product objects provide an extractor which does
> > a lookup.
>
> > However, the product lookup depends on the manufacturer.. is there a
> > way to handle that?
>
> > ideas:
> > 1. use an if guard
>
> >       case RewriteRequest(
> >         ParsePath( Manufacturer(manufacturer) :: productName :: Nil,
> > _, _,_), _, _)  if manufacturer.contains(productName) =>
> >           val product = manufacturer.getProduct(productName)
>
> > sucks because it looks up the product twice.
>
> > 2. some time of nested case?
>
> >       case RewriteRequest(
> >         ParsePath( Manufacturer(manufacturer) :: Product(manufacturer,
> > product) :: Nil, _, _,_), _, _)  =>
>
> > obviously doesn't work..
>
> > any suggestions welcome, thanks!
>
> You could write you own extractor. Here's an example from production
> code :-)
>
>  override val rewrite: LocRewrite = Full(NamedPF(name) {
>               case RewriteRequest(ParamsExtractor(account,orgUnit) , _, _) => 
> (RewriteResponse(path), Full(account, orgUnit))
>           })
>
>     object ParamsExtractor {
>       def unapply(pp:ParsePath): Option[(Account, OrgUnit)] = {
>         val result:Box[(Account, OrgUnit)] = if 
> (pp.wholePath.startsWith(path) && pp.wholePath.length == (path.length + 2)) {
>           val res = for {decrypted1 <- 
> FleetZoneRules.decrypt(pp.wholePath(path.length))
>                          account <- 
> urlAccount.is.choice(Full(_))(Account.find(decrypted1))
>                          decrypted2 <- 
> FleetZoneRules.decrypt(pp.wholePath.last)
>                          orgUnit <- 
> urlOrgUnit.is.choice(Full(_))(OrgUnit.find(decrypted2)) if (orgUnit.account 
> == account)} yield {
>                            urlAccount(Full(account))
>                            urlOrgUnit(Full(orgUnit))
>                            (account, orgUnit)
>                          }
>           log.debug("Decoded URL: %s=%s".format(pp,res))
>           res
>           }
>         else
>           None
>         result
>       }
>     }
>
> /Jeppe

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Help embedding lift in jetty

2010-02-05 Thread Alex Black
There is a RunWebApp.scala that seems to be included in the generated
projects from the maven archetype, you can probably copy it?

object RunWebApp extends Application {
  val server = new Server(8080)
  val context = new WebAppContext()
  context.setServer(server)
  context.setContextPath("/")
  context.setWar("src/main/webapp")

  server.addHandler(context)

  try {
println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO
STOP")
server.start()
while (System.in.available() == 0) {
  Thread.sleep(5000)
}
server.stop()
server.join()
  } catch {
case exc : Exception => {
  exc.printStackTrace()
  System.exit(100)
}
  }
}


On Feb 5, 6:22 pm, parki  wrote:
> Hello - newbie to scala and (esp) lift.
>
> I'm trying to get lift embedded into a server I wrote which also
> embeds jetty, so trying to avoid making war files, etc (the init code
> is at the end of this email) and thought someone out there might be
> able to point me in the right direction. I am using lift-util-1.0.jar
> and lift-webkit-1.0.jar, a bunch of the jetty jars, and any other jars
> needed to resolve dependencies. I may be a sucker for punishment, but
> everything works fine - the LiftServlet and LiftFilter are installed
> into jetty, and when I surf to :
>
> http://localhost:8081/lift/
>
> I get a 'broken link' error response to the browser, and the scala
> console outputs:
>
> scala> INFO - Service request (GET) /lift/ took 136 Milliseconds
>
> So, it looks like it's getting to lift, but likely lift thinks that
> there are no web apps, and hence the error (or something).
>
> I have a directory containing a simple hello world lift app created
> with maven archetype:generate, and I'd like to point the LiftServlet
> to that, if at all possible. Or copy that project structure somewhere
> underneath jetty...
>
> I've tried copying the lift app to cwd, the classes directory, the lib
> directory, etc to no avail.
>
> Does anyone know how to get the LiftServlet to find the web apps?
>
> Any help is appreciated.
>
> brian...
>
> --- x8 snip
>
> import com.whatevernot.liaison.servlet.HelloServlet
> import net.liftweb.http.
> import org.eclipse.jetty.server.
> import org.eclipse.jetty.servlet._
>
> val server = new Server(8081)
> val context = new
> ServletContextHandler(ServletContextHandler.SESSIONS)
>
> context.addFilter(new FilterHolder(new LiftFilter()), "/lift/", 1)
> context.addServlet(new ServletHolder(new HelloServlet()), "/hello/")
> context.addServlet(new ServletHolder(new LiftServlet()), "/lift/*")
> context.setContextPath("/")
>
> server.setHandler(context)
> server.start

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] URL Rewriting - 'nested' ParsePath?

2010-02-05 Thread Alex Black
Hi, I'd like to rewrite a url like this:

/manufacturer/product

e.g.

LiftRules.statelessRewrite.append( {
  case RewriteRequest(
ParsePath( manufacturerName :: productName :: Nil, _, _,_), _,
_)  =>

RewriteResponse("productView" :: Nil)
})

But, I'd like to the ParsePath case to not 'catch' for non-existant
manufacturers, and non-existant products by the manufacturer.

So, I might do this:

LiftRules.statelessRewrite.append( {
  case RewriteRequest(
ParsePath( Manufacturer(manufacturer) :: Product(product) ::
Nil, _, _,_), _, _)  =>

RewriteResponse("productView" :: Nil)
})

Where Manufacturer and Product objects provide an extractor which does
a lookup.

However, the product lookup depends on the manufacturer.. is there a
way to handle that?

ideas:
1. use an if guard

  case RewriteRequest(
ParsePath( Manufacturer(manufacturer) :: productName :: Nil,
_, _,_), _, _)  if manufacturer.contains(productName) =>
  val product = manufacturer.getProduct(productName)

sucks because it looks up the product twice.

2. some time of nested case?

  case RewriteRequest(
ParsePath( Manufacturer(manufacturer) :: Product(manufacturer,
product) :: Nil, _, _,_), _, _)  =>

obviously doesn't work..

any suggestions welcome, thanks!

- Alex

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: what provides classpath/jquery.js?

2010-01-10 Thread Alex Black
hmm.  We just upload a single WAR file to our server, its got
everything in it including JS etc.

On Jan 10, 5:16 pm, Alex Boisvert  wrote:
> One reason is to bundle html/js/... along with their corresponding snippet
> in a jar file.
>
> Alex
>
> On Jan 10, 2010 3:34 PM, "Alex Black"  wrote:
>
> Hi Marius, I haven't heard of ResourceServer before, sounds
> interesting.
>
> Right now, our CSS and JS files are just in subfolders of webapp, e.g
> "src/main/webapp/js", what are the advantages of (or reasons behind)
> putting js files in resources?
>
> - Alex
>
> On Jan 9, 3:04 am, Marius  wrote: > It is given by
> LiftRules.resourceServe...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to lift...@googlegroups.com.
> To unsubscribe from this group, send email to
> liftweb+unsubscr...@googlegroups.com
> .
> For more options, visit this group 
> athttp://groups.google.com/group/liftweb?hl=en.
-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: what provides classpath/jquery.js?

2010-01-10 Thread Alex Black
Hi Marius, I haven't heard of ResourceServer before, sounds
interesting.

Right now, our CSS and JS files are just in subfolders of webapp, e.g
"src/main/webapp/js", what are the advantages of (or reasons behind)
putting js files in resources?

- Alex

On Jan 9, 3:04 am, Marius  wrote:
> It is given by LiftRules.resourceServerPath. Resources places in /src/
> resources/toserve fodler are not served by container, but they are
> served by Lift. There is a ResourceServer class that manages that. if
> you put your own resources here you need to call ResourceServer.allow
> (in your boot) and grant access to those resources. This is a security
> related mechanism.
>
> Br's,
> Marius
>
> On Jan 9, 3:38 am, harmanjd  wrote:
>
> > I am working through the StartingWithLift document and saw that the
> > page includes /classpath/jquery.js.
>
> > Is that something that jetty supplies, or is that supplied by the lift
> > framework?  I didn't see that path mapped in the Boot class or
> > anything.
>
> > Thanks,
>
> > James
-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Permit caching of certain pages

2010-01-08 Thread Alex Black
I got something working like this:

LiftRules.defaultHeaders = {
  // Permit caching of our home page
  case (_, Req(List("index"),_,_)) =>
  List("Cache-Control" -> "private, max-age=10800, pre-
check=10800",
 "Pragma" -> "private",
 "Expires" -> getExpiresDate)
  case _ =>
  List("Expires" -> "Mon, 26 Jul 1997 05:00:00 GMT",
 "Cache-Control" ->
 "no-cache; private; no-store; must-revalidate;
max-stale=0; post-check=0; pre-check=0; max-age=0",
     "Pragma" -> "no-cache")
}*/

thoughts?

On Jan 8, 4:00 pm, David Pollak  wrote:
> On Fri, Jan 8, 2010 at 12:28 PM, Alex Black  wrote:
> > It looks like Lift sets response headers to prohibit caching of
> > responses.  I have some pages I need to permit the browser to cache,
> > whats the best way to go about that?
>
> Open a ticket and we'll add the feature. ;-)
>
>
>
>
>
> > Can I overwrite/change the response headers? I don't see a method to
> > do this on S, I do see S.getHeaders?
>
> > Thanks!
>
> > - ALex
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Surf the harmonics
-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] Permit caching of certain pages

2010-01-08 Thread Alex Black
It looks like Lift sets response headers to prohibit caching of
responses.  I have some pages I need to permit the browser to cache,
whats the best way to go about that?

Can I overwrite/change the response headers? I don't see a method to
do this on S, I do see S.getHeaders?

Thanks!

- ALex
-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Thanks for the all the help so far...

2010-01-07 Thread Alex Black
> I love how the site looks like. VERY cool job !

Thanks!
-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] Thanks for the all the help so far...

2010-01-06 Thread Alex Black
I've been a member of this group for a little while now and I wanted
to thank everyone for your help so far! Hopefully I'll be able to
start helping back in the future as I get more experienced with
Lift.

We've found Lift to be a great tool, and being able to get help from
the community has really helped, saved us hours of crawling around in
the dark :)

We just launched our site yesterday, running on Lift: http://snapsort.com.
Today its just got one feature: you can compare two digital cameras to
see the differences.  Our plan is to do personalized product
recommendation, similar to a real-time personalized consumer reports.

- Alex
-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Simple deployment of Lift apps on Jetty/Nginx

2010-01-05 Thread Alex Black
> You can have more than one domain per IP address served by different
> applications with Nginx up front.  You can swap from one instance of an
> application to another (semi-seamless upgrades) with Nginx up front.  You
> can front many different Lift instances (some running on other machines)
> with Nginx up front (there are some high volume Lift sites that do this).

Thats good to know, thanks!
-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: IE6 Strict mode - skip header

2010-01-05 Thread Alex Black
Yep, that works great, thanks!

> Lift automatically detects IE and IE6 and "does the right thing" in terms of
> headers as well as the  header.  Please take a look at the HTML and
> headers actually emitted when IE6 is detected... it should be correct.
>
>
>
>
>
> > - Alex
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Surf the harmonics
-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] IE6 Strict mode - skip header

2010-01-04 Thread Alex Black
I've read here:

http://css-discuss.incutio.com/?page=RenderingMode

and here:

http://hsivonen.iki.fi/doctype/

that if you include the xml declaration:



Then IE6 (and others?) go into quirks mode.  Is there a way in lift to
omit this from IE? I tried removing it from my default.html template,
but Lift still spits it out.

We're using:




along with Content-Type=application/xhtml+xml; charset=utf-8

I'm also open to thoughts on other pragmatic solutions to getting
browsers to render our XHTML nicely :)

- Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Nice 404s sans Redirect

2010-01-01 Thread Alex Black
That sounds like a great approach to me Marius!

On Jan 1, 6:31 am, Marius  wrote:
> It probably should ... but personally I still believe in equal rights
> of 404 pages with any other template.
>
> David's solution is great and definitely works. But this thread made
> me realize that a higher/easier level of addressing this is helpful.
> From user perspective saying something like ".. .if a template cannot
> be found, just use the template denominated by this path (i.e.
> "foo" :: "bar" :: "404" :: Nil) instead.". Lift then would process
> this template as the regular one with the difference that it will use
> 404 status code automatically.
>
> Currently I have a prototype implementation and an offline discussion
> with David about other more internal implications. We'll see where it
> goes.
>
> Br's,
> Marius
>
> On Jan 1, 12:12 am, Alex Black  wrote:
>
> > That sounds great.
>
> > Just curious though, is there any chance runTemplate should just do
> > the head merge?
>
> > On Dec 31, 3:12 pm, David Pollak 
> > wrote:
>
> > > On Wed, Dec 30, 2009 at 7:43 PM, Alex Black  wrote:
> > > > Ok, I tried this, it gets closer.
>
> > > > I noticed one issue: the head merge didn't get done, so I have two
> > > >  tags in the result.  I'm attempting to set the title in the
> > > > 404.html template, maybe there is a way I can set the title without
> > > > using head merge?
>
> > > I'm opening up the merge method, so once the code is in master, you'll be
> > > able to do:
>
> > >   def generate404(): LiftResponse = {
> > >     import scala.xml.Node
>
> > >     val resp: Box[Node] =  S.setVars("expandAll" -> "true")  {
> > >       for {
> > >     session <- S.session
> > >     req <- S.request
> > >         rendered <- S.runTemplate("404" :: Nil)
> > >       } yield session.performHeadMerge(rendered, req)
> > >     }
>
> > >     XhtmlResponse(resp openOr Got a 404,
> > >                   Empty, List("Content-Type" -> "text/html; 
> > > charset=utf-8"),
>
> > >           Nil, 404, S.ieMode)
> > >   }
>
> > > This will do the head merge and give you the ability to do anything Lift
> > > does.
>
> > > > - Alex
>
> > > > On Dec 30, 2:54 pm, David Pollak 
> > > > wrote:
> > > > > In Boot.scala (the boot method):
>
> > > > >     LiftRules.passNotFoundToChain = false
>
> > > > >     LiftRules.uriNotFound.prepend {
> > > > >       case _ => generate404()
> > > > >     }
>
> > > > > In the Boot class:
>
> > > > >   def generate404(): LiftResponse = {
> > > > >     import scala.xml.Node
>
> > > > >     val resp: Box[Node] =  S.setVars("expandAll" -> "true")  {
> > > > >       for {
> > > > >         rendered <- S.runTemplate("404" :: Nil)
> > > > >       } yield rendered(0)
> > > > >     }
>
> > > > >     XhtmlResponse(resp openOr Got a 404,
> > > > >                   Empty, List("Content-Type" -> "text/html;
> > > > charset=utf-8"),
> > > > > Nil, 404, S.ieMode)
> > > > >   }
>
> > > > > And a 404.html file (which can be localized):
>
> > > > > 
> > > > > Couldn't find your page... sorry
> > > > > 
>
> > > > > The uriNotFound code is executed within the S scope, so you've got all
> > > > the
> > > > > goodness of knowing who the current user is, etc.
>
> > > > > The reason that the menu was not being rendered in your example is 
> > > > > that
> > > > menu
> > > > > rendering is based on the location property in the Req(uest).  If 
> > > > > there
> > > > is
> > > > > no location (as defined in the SiteMap), then no menu can be rendered.
> > > > > There's an option for displaying the entire sitemap by setting the
> > > > > expandAll="true" attribute when invoking the Menu.builder snippet.  
> > > > > But
> > > > you
> > > > > don't really want to show the entire menu on all pages, so the
> > > > > S.setVars("expandAll&q

[Lift] Re: warning: value rewrite in object LiftRules is deprecated

2009-12-31 Thread Alex Black
Thanks!

On Dec 31, 5:03 pm, Ross Mellgren  wrote:
> Instead of LiftRules.rewrite, use LiftRules.statelessRewrite if you  
> want the old behavior (e.g. rewriting while S is not available)
>
> If you have rewrites that require S to be available, then you can use  
> the new LiftRules.statefulRewrite
>
> I'm not sure about the SiteMap question.
>
> -Ross
>
> On Dec 31, 2009, at 4:55 PM, Alex Black wrote:
>
> > Two questions:
>
> > 1. Whats the replacement for LiftRules.rewrite?
> > 2. Is there a way I can write a custom Loc so that SiteMap is aware of
> > the re-writing?
>
> > I'm following the AccountLoc extends Loc[AccountInfo] example in the
> > book, but my rewriting is not having any effect yet, I am trying to
> > figure out what I am missing.
>
> > - Alex
>
> > --
>
> > You received this message because you are subscribed to the Google  
> > Groups "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en
> > .

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Sitemap: Using "" instead of "index" and still having the current menu selected?

2009-12-31 Thread Alex Black
That sounds great, much appreciated.

On Dec 31, 2:52 pm, David Pollak 
wrote:
> I was in SiteMap for another project today.  I'll add a flag on the SiteMap
> object that facilitates / rather than /index.
>
>
>
> On Wed, Dec 30, 2009 at 7:47 PM, Alex Black  wrote:
> > Would it be reasonable for me to open a ticket to allow people to
> > change this default behaviour?  Its important to me that when people
> > are at our site's home page, its just "http://oursite.com";, not
> > "http://oursite.com/index";.
>
> > Then for people who are using a container where this is a problem, it
> > will work fine, but others can avoid the "index" in the url.
>
> > - Alex
>
> > On Dec 30, 12:49 pm, David Pollak 
> > wrote:
> > > On Wed, Dec 30, 2009 at 9:43 AM, Alex Black  wrote:
> > > > > In a 1.1-M8 based project,
> > > >http://localhost:8080/andhttp://localhost:8080/indexbothcausethe
> > "Home"
> > > > menu item to be
> > > > > non-clickable.  The definition of the Home menu item is
> > Menu(Loc("Home",
> > > > > List("index"), "Home"))
>
> > > > Understood.
>
> > > > However, in this scenario, when the user clicks on "home" they get
> > > > taken tohttp://localhost:8080/index, I think it would be even better
> > > > if they could be taken tohttp://localhost:8080/.  Its mostly
> > > > aesthetic, but its cleaner/shorter, and it saves having two URLs for
> > > > the same thing (e.g.http://localhost:8080/and
> > > >http://localhost:8080/index).
>
> > > > Is there any way to do that while maintaining the nice Sitemap feature
> > > > that makes Home non clickable?
>
> > > As I said already, we had thehttp://localhost:8080/asthe place where the
> > > top level takes you.  That broke some containers (I don't remember the
> > > specifics) so the top level is /index.  There's no way to change it and
> > it
> > > is this way for the reason that I've now had to state twice in two days.
>
> > > > - Alex
>
> > > > > > > Also, why do you using "Pair(List(...), false)"?
>
> > > > > > > Pair is deprecated/frowned on... it's much more idomatic to use
> > > > > > (List(...),
> > > > > > > false), but that's not needed as there's an implicit conversion
> > you
> > > > can
> > > > > > > simply declare the List().
>
> > > > > > Thanks for the tip.
>
> > > > > > > > to
>
> > > > > > > >    Menu(Loc("index", Pair("" :: Nil, false), "Home")) ::
>
> > > > > > > > So that my "Home" link goes to mysite.com/ instead of
> > mysite.com/
> > > > > > > > index.  But, I notice, when you're at mysite.com/ the sitemap
> > > > doesn't
> > > > > > > > show "Home" as selected, is there a way to fix that? Perhaps
> > I've
> > > > got
> > > > > > > > something wrong here.
>
> > > > > > > > Thanks,
>
> > > > > > > > - Alex
>
> > > > > > > > --
>
> > > > > > > > You received this message because you are subscribed to the
> > Google
> > > > > > Groups
> > > > > > > > "Lift" group.
> > > > > > > > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> > > > > > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > > > > > Follow me:http://twitter.com/dpp
> > > > > > > Surf the harmonics
>
> > > > > > --
>
> > > > > > You received this message because yo

[Lift] Re: Nice 404s sans Redirect

2009-12-31 Thread Alex Black
That sounds great.

Just curious though, is there any chance runTemplate should just do
the head merge?

On Dec 31, 3:12 pm, David Pollak 
wrote:
> On Wed, Dec 30, 2009 at 7:43 PM, Alex Black  wrote:
> > Ok, I tried this, it gets closer.
>
> > I noticed one issue: the head merge didn't get done, so I have two
> >  tags in the result.  I'm attempting to set the title in the
> > 404.html template, maybe there is a way I can set the title without
> > using head merge?
>
> I'm opening up the merge method, so once the code is in master, you'll be
> able to do:
>
>   def generate404(): LiftResponse = {
>     import scala.xml.Node
>
>     val resp: Box[Node] =  S.setVars("expandAll" -> "true")  {
>       for {
>     session <- S.session
>     req <- S.request
>         rendered <- S.runTemplate("404" :: Nil)
>       } yield session.performHeadMerge(rendered, req)
>     }
>
>     XhtmlResponse(resp openOr Got a 404,
>                   Empty, List("Content-Type" -> "text/html; charset=utf-8"),
>
>           Nil, 404, S.ieMode)
>   }
>
> This will do the head merge and give you the ability to do anything Lift
> does.
>
>
>
> > - Alex
>
> > On Dec 30, 2:54 pm, David Pollak 
> > wrote:
> > > In Boot.scala (the boot method):
>
> > >     LiftRules.passNotFoundToChain = false
>
> > >     LiftRules.uriNotFound.prepend {
> > >       case _ => generate404()
> > >     }
>
> > > In the Boot class:
>
> > >   def generate404(): LiftResponse = {
> > >     import scala.xml.Node
>
> > >     val resp: Box[Node] =  S.setVars("expandAll" -> "true")  {
> > >       for {
> > >         rendered <- S.runTemplate("404" :: Nil)
> > >       } yield rendered(0)
> > >     }
>
> > >     XhtmlResponse(resp openOr Got a 404,
> > >                   Empty, List("Content-Type" -> "text/html;
> > charset=utf-8"),
> > > Nil, 404, S.ieMode)
> > >   }
>
> > > And a 404.html file (which can be localized):
>
> > > 
> > > Couldn't find your page... sorry
> > > 
>
> > > The uriNotFound code is executed within the S scope, so you've got all
> > the
> > > goodness of knowing who the current user is, etc.
>
> > > The reason that the menu was not being rendered in your example is that
> > menu
> > > rendering is based on the location property in the Req(uest).  If there
> > is
> > > no location (as defined in the SiteMap), then no menu can be rendered.
> > > There's an option for displaying the entire sitemap by setting the
> > > expandAll="true" attribute when invoking the Menu.builder snippet.  But
> > you
> > > don't really want to show the entire menu on all pages, so the
> > > S.setVars("expandAll" -> "true") {...} method (which is a good candidate
> > for
> > > renaming for all you renamers out there) allows us to set the expandAll
> > > attribute for the duration of the code block.
>
> > > Then we use S.runTemplate() to locate and run the 404.html template.
>
> > > Finally, we create the XhtmlResponse with the 404 error code.
>
> > > So, you can put whatever you want in the 404.html template (including
> > > snippets) and all will work as expected.
>
> > > Thanks,
>
> > > David
>
> > > On Wed, Dec 30, 2009 at 10:45 AM, Alex Black  wrote:
> > > > > It's not rewriting.
>
> > > > I didn't say it was. I just said it seemed most similar to re-writing.
>
> > > > > Trying to mix the two will muddy the concept of rewriting and when it
> > > > > happens.
>
> > > > Makes sense.
>
> > > > > As far as I can tell, the two problems you are facing are:
>
> > > > >    1. There's a non-trivial amount of your code that needs to run to
> > > > render
> > > > >    the 404 error page.  This would be corrected by the suggestion
> > that I
> > > > posted
> > > > >    regarding a LiftRule that generates the default 404 template.
> > > > >    2. Putting navigation on the page.  I'm still noodling how to
> > address
> > > > >    this particular issue.
>
> > > > > If there are issues other than 1 and 2, please enumerate them.
>
> > > > Those do sound like th

[Lift] warning: value rewrite in object LiftRules is deprecated

2009-12-31 Thread Alex Black
Two questions:

1. Whats the replacement for LiftRules.rewrite?
2. Is there a way I can write a custom Loc so that SiteMap is aware of
the re-writing?

I'm following the AccountLoc extends Loc[AccountInfo] example in the
book, but my rewriting is not having any effect yet, I am trying to
figure out what I am missing.

- Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Sitemap: Using "" instead of "index" and still having the current menu selected?

2009-12-30 Thread Alex Black
Would it be reasonable for me to open a ticket to allow people to
change this default behaviour?  Its important to me that when people
are at our site's home page, its just "http://oursite.com";, not
"http://oursite.com/index";.

Then for people who are using a container where this is a problem, it
will work fine, but others can avoid the "index" in the url.

- Alex

On Dec 30, 12:49 pm, David Pollak 
wrote:
> On Wed, Dec 30, 2009 at 9:43 AM, Alex Black  wrote:
> > > In a 1.1-M8 based project,
> >http://localhost:8080/andhttp://localhost:8080/indexbothcause the "Home"
> > menu item to be
> > > non-clickable.  The definition of the Home menu item is Menu(Loc("Home",
> > > List("index"), "Home"))
>
> > Understood.
>
> > However, in this scenario, when the user clicks on "home" they get
> > taken tohttp://localhost:8080/index, I think it would be even better
> > if they could be taken tohttp://localhost:8080/.  Its mostly
> > aesthetic, but its cleaner/shorter, and it saves having two URLs for
> > the same thing (e.g.http://localhost:8080/and
> >http://localhost:8080/index).
>
> > Is there any way to do that while maintaining the nice Sitemap feature
> > that makes Home non clickable?
>
> As I said already, we had thehttp://localhost:8080/as the place where the
> top level takes you.  That broke some containers (I don't remember the
> specifics) so the top level is /index.  There's no way to change it and it
> is this way for the reason that I've now had to state twice in two days.
>
>
>
>
>
> > - Alex
>
> > > > > Also, why do you using "Pair(List(...), false)"?
>
> > > > > Pair is deprecated/frowned on... it's much more idomatic to use
> > > > (List(...),
> > > > > false), but that's not needed as there's an implicit conversion you
> > can
> > > > > simply declare the List().
>
> > > > Thanks for the tip.
>
> > > > > > to
>
> > > > > >    Menu(Loc("index", Pair("" :: Nil, false), "Home")) ::
>
> > > > > > So that my "Home" link goes to mysite.com/ instead of mysite.com/
> > > > > > index.  But, I notice, when you're at mysite.com/ the sitemap
> > doesn't
> > > > > > show "Home" as selected, is there a way to fix that? Perhaps I've
> > got
> > > > > > something wrong here.
>
> > > > > > Thanks,
>
> > > > > > - Alex
>
> > > > > > --
>
> > > > > > You received this message because you are subscribed to the Google
> > > > Groups
> > > > > > "Lift" group.
> > > > > > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> > > > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > > > Follow me:http://twitter.com/dpp
> > > > > Surf the harmonics
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Lift" group.
> > > > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > Follow me:http://twitter.com/dpp
> > > Surf the harmonics
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Nice 404s sans Redirect

2009-12-30 Thread Alex Black
Ok, I tried this, it gets closer.

I noticed one issue: the head merge didn't get done, so I have two
 tags in the result.  I'm attempting to set the title in the
404.html template, maybe there is a way I can set the title without
using head merge?

- Alex

On Dec 30, 2:54 pm, David Pollak 
wrote:
> In Boot.scala (the boot method):
>
>     LiftRules.passNotFoundToChain = false
>
>     LiftRules.uriNotFound.prepend {
>       case _ => generate404()
>     }
>
> In the Boot class:
>
>   def generate404(): LiftResponse = {
>     import scala.xml.Node
>
>     val resp: Box[Node] =  S.setVars("expandAll" -> "true")  {
>       for {
>         rendered <- S.runTemplate("404" :: Nil)
>       } yield rendered(0)
>     }
>
>     XhtmlResponse(resp openOr Got a 404,
>                   Empty, List("Content-Type" -> "text/html; charset=utf-8"),
> Nil, 404, S.ieMode)
>   }
>
> And a 404.html file (which can be localized):
>
> 
> Couldn't find your page... sorry
> 
>
> The uriNotFound code is executed within the S scope, so you've got all the
> goodness of knowing who the current user is, etc.
>
> The reason that the menu was not being rendered in your example is that menu
> rendering is based on the location property in the Req(uest).  If there is
> no location (as defined in the SiteMap), then no menu can be rendered.
> There's an option for displaying the entire sitemap by setting the
> expandAll="true" attribute when invoking the Menu.builder snippet.  But you
> don't really want to show the entire menu on all pages, so the
> S.setVars("expandAll" -> "true") {...} method (which is a good candidate for
> renaming for all you renamers out there) allows us to set the expandAll
> attribute for the duration of the code block.
>
> Then we use S.runTemplate() to locate and run the 404.html template.
>
> Finally, we create the XhtmlResponse with the 404 error code.
>
> So, you can put whatever you want in the 404.html template (including
> snippets) and all will work as expected.
>
> Thanks,
>
> David
>
>
>
> On Wed, Dec 30, 2009 at 10:45 AM, Alex Black  wrote:
> > > It's not rewriting.
>
> > I didn't say it was. I just said it seemed most similar to re-writing.
>
> > > Trying to mix the two will muddy the concept of rewriting and when it
> > > happens.
>
> > Makes sense.
>
> > > As far as I can tell, the two problems you are facing are:
>
> > >    1. There's a non-trivial amount of your code that needs to run to
> > render
> > >    the 404 error page.  This would be corrected by the suggestion that I
> > posted
> > >    regarding a LiftRule that generates the default 404 template.
> > >    2. Putting navigation on the page.  I'm still noodling how to address
> > >    this particular issue.
>
> > > If there are issues other than 1 and 2, please enumerate them.
>
> > Those do sound like the issues.  Just to reflect it back to you from
> > my perspective (in case one of us is missing something), the issue as
> > I see it is that I've designed a nice 404 template using lift features
> > (like surround, sitemap, headmerge), and I'd like to display it to the
> > user when no handler can be found
>
> > Whats preventing me from doing this is: the current notfound mechanism
> > takes a liftResponse, not a template to render, and as such forces me
> > to render the template itself, and although Russ proposed a way to do
> > that Marius indicated this could have side effects and feels like the
> > wrong approach.
>
> > > > What about Either[RewriteResponse, LiftResponse]? E.g. same as what
> > > > Marius suggested but use RewriteResponse instead of String.
>
> > > > On Dec 30, 1:26 pm, Marius  wrote:
> > > > > I thought of that but that is problematic because:
>
> > > > > 1. Having a TemplateResponse holding a path without the rendering
> > > > > logic, people could use that to send a response to the client, which
> > > > > would be incorrect as having a LiftResponse holding /a/b/c doesn;t
> > > > > mean anything to a client. And this would alter the semantics of a
> > > > > LiftResponse. That's why I proposed an Either.
>
> > > > > 2. On the other hand if we have a TemplateResponse holding the logic
> > > > > of processing a template (similar to the one proposed on this thread)
> > > > > would mean that we're doing the pro

[Lift] Re: Nice 404s sans Redirect

2009-12-30 Thread Alex Black
> It's not rewriting.

I didn't say it was. I just said it seemed most similar to re-writing.

> Trying to mix the two will muddy the concept of rewriting and when it
> happens.

Makes sense.

> As far as I can tell, the two problems you are facing are:
>
>    1. There's a non-trivial amount of your code that needs to run to render
>    the 404 error page.  This would be corrected by the suggestion that I 
> posted
>    regarding a LiftRule that generates the default 404 template.
>    2. Putting navigation on the page.  I'm still noodling how to address
>    this particular issue.
>
> If there are issues other than 1 and 2, please enumerate them.
>

Those do sound like the issues.  Just to reflect it back to you from
my perspective (in case one of us is missing something), the issue as
I see it is that I've designed a nice 404 template using lift features
(like surround, sitemap, headmerge), and I'd like to display it to the
user when no handler can be found

Whats preventing me from doing this is: the current notfound mechanism
takes a liftResponse, not a template to render, and as such forces me
to render the template itself, and although Russ proposed a way to do
that Marius indicated this could have side effects and feels like the
wrong approach.


>
>
>
>
> > What about Either[RewriteResponse, LiftResponse]? E.g. same as what
> > Marius suggested but use RewriteResponse instead of String.
>
> > On Dec 30, 1:26 pm, Marius  wrote:
> > > I thought of that but that is problematic because:
>
> > > 1. Having a TemplateResponse holding a path without the rendering
> > > logic, people could use that to send a response to the client, which
> > > would be incorrect as having a LiftResponse holding /a/b/c doesn;t
> > > mean anything to a client. And this would alter the semantics of a
> > > LiftResponse. That's why I proposed an Either.
>
> > > 2. On the other hand if we have a TemplateResponse holding the logic
> > > of processing a template (similar to the one proposed on this thread)
> > > would mean that we're doing the processing outside of the normal
> > > rendering pipeline which has the downsides discussed.
>
> > > Br's,
> > > Marius
>
> > > On Dec 30, 8:18 pm, Naftoli Gugenheim  wrote:
>
> > > > Would it not be possible to have a LiftResponse that runs through the
> > regular plumbing? This way instead of introducing Either you can just use a
> > TemplateResponse etc.
>
> > > > -
>
> > > > Marius wrote:
>
> > > > Please open a defect herehttp://github.com/dpp/liftweb/issues...
> > > > whether or not this solution will make it in master will be subject
> > > > for reviewboard. The solution I proposed has a breaking change by the
> > > > introduction of Either[List[String], LiftResponse] instead of
> > > > LiftResponse but I don't think that many people are using uriNotFound
> > > > and it's really quite a small change which regardless needs to be
> > > > announced.
>
> > > > Other opinions on this?
>
> > > > Br's,
> > > > Marius
>
> > > > On Dec 30, 6:20 pm, Alex Black  wrote:
>
> > > > > > While I totally agree that a plain 404 + markup is much more
> > > > > > straightforward,
> > > > > > "breaks internet" are too big words :) .. sending back a
> > > > > > 302 or 301 tells the UA "you asked me for a resource that I know I
> > > > > > don't have but I wont tell
> > > > > > you explicitely, instead I want you to go to this location as an
> > > > > > alternative resource". Somehow it's like scratching with the wrong
> > > > > > hand and purely from HTTP protocol perspective this is not quite
> > > > > > straightforward as 404 + template, but I don't necessarily see it
> > as a
> > > > > > so bad thing.
>
> > > > > Heh, I apologise, definitely "breaking the internet" is a bit
> > > > > dramatic.  I do have a different view than you though, I think its
> > > > > incorrect to return a 301 or 302 in these scenarios, the correct
> > > > > response is 404.  Not only is it the correct response, but given most
> > > > > sites get 50%-90% of their traffic from Google, and Google thinks its
> > > > > also correct to return 404 (http://www.google.com/url?sa=D&q=http://
> > > > > go

[Lift] Re: Nice 404s sans Redirect

2009-12-30 Thread Alex Black
Overall this feature seems most similar to 'rewriting'.  E.g. the url
comes in as "http://localhost/foobar";, we don't recognize it, so we'll
re-write it to template "404".

What about Either[RewriteResponse, LiftResponse]? E.g. same as what
Marius suggested but use RewriteResponse instead of String.

On Dec 30, 1:26 pm, Marius  wrote:
> I thought of that but that is problematic because:
>
> 1. Having a TemplateResponse holding a path without the rendering
> logic, people could use that to send a response to the client, which
> would be incorrect as having a LiftResponse holding /a/b/c doesn;t
> mean anything to a client. And this would alter the semantics of a
> LiftResponse. That's why I proposed an Either.
>
> 2. On the other hand if we have a TemplateResponse holding the logic
> of processing a template (similar to the one proposed on this thread)
> would mean that we're doing the processing outside of the normal
> rendering pipeline which has the downsides discussed.
>
> Br's,
> Marius
>
> On Dec 30, 8:18 pm, Naftoli Gugenheim  wrote:
>
> > Would it not be possible to have a LiftResponse that runs through the 
> > regular plumbing? This way instead of introducing Either you can just use a 
> > TemplateResponse etc.
>
> > -
>
> > Marius wrote:
>
> > Please open a defect herehttp://github.com/dpp/liftweb/issues...
> > whether or not this solution will make it in master will be subject
> > for reviewboard. The solution I proposed has a breaking change by the
> > introduction of Either[List[String], LiftResponse] instead of
> > LiftResponse but I don't think that many people are using uriNotFound
> > and it's really quite a small change which regardless needs to be
> > announced.
>
> > Other opinions on this?
>
> > Br's,
> > Marius
>
> > On Dec 30, 6:20 pm, Alex Black  wrote:
>
> > > > While I totally agree that a plain 404 + markup is much more
> > > > straightforward,
> > > > "breaks internet" are too big words :) .. sending back a
> > > > 302 or 301 tells the UA "you asked me for a resource that I know I
> > > > don't have but I wont tell
> > > > you explicitely, instead I want you to go to this location as an
> > > > alternative resource". Somehow it's like scratching with the wrong
> > > > hand and purely from HTTP protocol perspective this is not quite
> > > > straightforward as 404 + template, but I don't necessarily see it as a
> > > > so bad thing.
>
> > > Heh, I apologise, definitely "breaking the internet" is a bit
> > > dramatic.  I do have a different view than you though, I think its
> > > incorrect to return a 301 or 302 in these scenarios, the correct
> > > response is 404.  Not only is it the correct response, but given most
> > > sites get 50%-90% of their traffic from Google, and Google thinks its
> > > also correct to return 404 (http://www.google.com/url?sa=D&q=http://
> > > googlewebmastercentral.blogspot.com/2008/08/farewell-to-
> > > soft-404s.html, its in our best financial interest to play nice with
> > > Google.
>
> > > > Specifically for 404 (when a template is not found we could do
> > > > something like:
>
> > > > 1. In LiftRules instead of:
>
> > > > type URINotFoundPF = PartialFunction[(Req, Box[Failure]),
> > > > LiftResponse]
>
> > > > use
>
> > > > type URINotFoundPF = PartialFunction[(Req, Box[Failure]), Either[List
> > > > [String], LiftResponse]]
>
> > > > so that function can return a template path instead of response.
>
> > > > 2. In LiftSession#processRequest instead of applying the normal
> > > > request pipeline only if the addressed template is found, we can use
> > > > the path obtained from LiftRules.uriNotFound if Lift fails to find the
> > > > normal tempalte. Hence apply the normal rendering pipeline to the
> > > > template referenced by uriNotFound.
>
> > > > This approach allows your 404 case to be handled by the normal
> > > > rendering pipeline without other hacks.
>
> > > > Unless someone thinks this is a bad solution, Alex you could open an
> > > > issue and I'll work on it.
>
> > > Thanks for proposing that solution Marius.  I can't really comment on
> > > whether or not its the right way to do it from Lift's point of view,
> > > but as a user of Lift it sounds like it would work well.
>
> > > - Alex
>
> > --
>
> > You received this message because you are subscribed to the Google Groups 
> > "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en.

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Sitemap: Using "" instead of "index" and still having the current menu selected?

2009-12-30 Thread Alex Black
David, I'm not trying to anger you, and although you do constantly
reply with helpful information (which I appreciate) the tone of your
messages makes me think you think I am an idiot.

I'd appreciate it if you'd bear with me, I'm only human.

Thanks for explaining.  I don't yet fully understand, perhaps because
I am missing some perspective or experience with Lift.  But,
regardless, in my website, the top level is not /index, its /, and
I've achieved that by defining home slightly differently than you
did.  It works well for me, except Home remains clickable, I guess I
will live with that issue.

thx

- Alex

On Dec 30, 12:49 pm, David Pollak 
wrote:
> On Wed, Dec 30, 2009 at 9:43 AM, Alex Black  wrote:
> > > In a 1.1-M8 based project,
> >http://localhost:8080/andhttp://localhost:8080/indexbothcause the "Home"
> > menu item to be
> > > non-clickable.  The definition of the Home menu item is Menu(Loc("Home",
> > > List("index"), "Home"))
>
> > Understood.
>
> > However, in this scenario, when the user clicks on "home" they get
> > taken tohttp://localhost:8080/index, I think it would be even better
> > if they could be taken tohttp://localhost:8080/.  Its mostly
> > aesthetic, but its cleaner/shorter, and it saves having two URLs for
> > the same thing (e.g.http://localhost:8080/and
> >http://localhost:8080/index).
>
> > Is there any way to do that while maintaining the nice Sitemap feature
> > that makes Home non clickable?
>
> As I said already, we had thehttp://localhost:8080/as the place where the
> top level takes you.  That broke some containers (I don't remember the
> specifics) so the top level is /index.  There's no way to change it and it
> is this way for the reason that I've now had to state twice in two days.
>
>
>
>
>
> > - Alex
>
> > > > > Also, why do you using "Pair(List(...), false)"?
>
> > > > > Pair is deprecated/frowned on... it's much more idomatic to use
> > > > (List(...),
> > > > > false), but that's not needed as there's an implicit conversion you
> > can
> > > > > simply declare the List().
>
> > > > Thanks for the tip.
>
> > > > > > to
>
> > > > > >    Menu(Loc("index", Pair("" :: Nil, false), "Home")) ::
>
> > > > > > So that my "Home" link goes to mysite.com/ instead of mysite.com/
> > > > > > index.  But, I notice, when you're at mysite.com/ the sitemap
> > doesn't
> > > > > > show "Home" as selected, is there a way to fix that? Perhaps I've
> > got
> > > > > > something wrong here.
>
> > > > > > Thanks,
>
> > > > > > - Alex
>
> > > > > > --
>
> > > > > > You received this message because you are subscribed to the Google
> > > > Groups
> > > > > > "Lift" group.
> > > > > > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> > > > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > > > Follow me:http://twitter.com/dpp
> > > > > Surf the harmonics
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Lift" group.
> > > > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > Follow me:http://twitter.com/dpp
> > > Surf the harmonics
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Sitemap: Using "" instead of "index" and still having the current menu selected?

2009-12-30 Thread Alex Black
> In a 1.1-M8 based 
> project,http://localhost:8080/andhttp://localhost:8080/indexboth cause the 
> "Home" menu item to be
> non-clickable.  The definition of the Home menu item is Menu(Loc("Home",
> List("index"), "Home"))

Understood.

However, in this scenario, when the user clicks on "home" they get
taken to http://localhost:8080/index, I think it would be even better
if they could be taken to http://localhost:8080/.  Its mostly
aesthetic, but its cleaner/shorter, and it saves having two URLs for
the same thing (e.g. http://localhost:8080/ and http://localhost:8080/index).

Is there any way to do that while maintaining the nice Sitemap feature
that makes Home non clickable?

- Alex

>
>
>
>
>
> > > Also, why do you using "Pair(List(...), false)"?
>
> > > Pair is deprecated/frowned on... it's much more idomatic to use
> > (List(...),
> > > false), but that's not needed as there's an implicit conversion you can
> > > simply declare the List().
>
> > Thanks for the tip.
>
> > > > to
>
> > > >    Menu(Loc("index", Pair("" :: Nil, false), "Home")) ::
>
> > > > So that my "Home" link goes to mysite.com/ instead of mysite.com/
> > > > index.  But, I notice, when you're at mysite.com/ the sitemap doesn't
> > > > show "Home" as selected, is there a way to fix that? Perhaps I've got
> > > > something wrong here.
>
> > > > Thanks,
>
> > > > - Alex
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Lift" group.
> > > > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > Follow me:http://twitter.com/dpp
> > > Surf the harmonics
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Nice 404s sans Redirect

2009-12-30 Thread Alex Black
I opened a ticket: http://github.com/dpp/liftweb/issues/#issue/265

I hope I wrote it in a reasonable/acceptable way, its my first ticket.

- Alex

On Dec 30, 11:26 am, Marius  wrote:
> Please open a defect herehttp://github.com/dpp/liftweb/issues...
> whether or not this solution will make it in master will be subject
> for reviewboard. The solution I proposed has a breaking change by the
> introduction of Either[List[String], LiftResponse] instead of
> LiftResponse but I don't think that many people are using uriNotFound
> and it's really quite a small change which regardless needs to be
> announced.
>
> Other opinions on this?
>
> Br's,
> Marius
>
> On Dec 30, 6:20 pm, Alex Black  wrote:
>
> > > While I totally agree that a plain 404 + markup is much more
> > > straightforward,
> > > "breaks internet" are too big words :) .. sending back a
> > > 302 or 301 tells the UA "you asked me for a resource that I know I
> > > don't have but I wont tell
> > > you explicitely, instead I want you to go to this location as an
> > > alternative resource". Somehow it's like scratching with the wrong
> > > hand and purely from HTTP protocol perspective this is not quite
> > > straightforward as 404 + template, but I don't necessarily see it as a
> > > so bad thing.
>
> > Heh, I apologise, definitely "breaking the internet" is a bit
> > dramatic.  I do have a different view than you though, I think its
> > incorrect to return a 301 or 302 in these scenarios, the correct
> > response is 404.  Not only is it the correct response, but given most
> > sites get 50%-90% of their traffic from Google, and Google thinks its
> > also correct to return 404 (http://www.google.com/url?sa=D&q=http://
> > googlewebmastercentral.blogspot.com/2008/08/farewell-to-
> > soft-404s.html, its in our best financial interest to play nice with
> > Google.
>
> > > Specifically for 404 (when a template is not found we could do
> > > something like:
>
> > > 1. In LiftRules instead of:
>
> > > type URINotFoundPF = PartialFunction[(Req, Box[Failure]),
> > > LiftResponse]
>
> > > use
>
> > > type URINotFoundPF = PartialFunction[(Req, Box[Failure]), Either[List
> > > [String], LiftResponse]]
>
> > > so that function can return a template path instead of response.
>
> > > 2. In LiftSession#processRequest instead of applying the normal
> > > request pipeline only if the addressed template is found, we can use
> > > the path obtained from LiftRules.uriNotFound if Lift fails to find the
> > > normal tempalte. Hence apply the normal rendering pipeline to the
> > > template referenced by uriNotFound.
>
> > > This approach allows your 404 case to be handled by the normal
> > > rendering pipeline without other hacks.
>
> > > Unless someone thinks this is a bad solution, Alex you could open an
> > > issue and I'll work on it.
>
> > Thanks for proposing that solution Marius.  I can't really comment on
> > whether or not its the right way to do it from Lift's point of view,
> > but as a user of Lift it sounds like it would work well.
>
> > - Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Nice 404s sans Redirect

2009-12-30 Thread Alex Black
> At any rate, I'm just trying to help Alex, I'm not invested in any  
> reason other than it's informative to try and solve. Is there any way  
> to get a templated 404 response?

Sorry Ross, perhaps my response didn't convey my appreciation for your
help, or maybe it came off sounding negative, I didn't mean that.

What I meant was: thanks for offering that solution, it looks like a
step forward, I appreciate your help, but based on my gut feeling
looking at that code and based on Marius's opinon, I don't think we're
yet at an elegant robust solution, so lets keep coming up with more
ideas.

- Alex

>
> -Ross
>
> On Dec 30, 2009, at 4:32 AM, Marius wrote:
>
> > Re init-ing S is a very risky thing to do. You loose all your context
> > information. uriNotFound is called by Lift from several key points.
> > From those key points, Lift uses the S context and updates the
> > function Map. With your example if your template is binding Scala
> > functions, those function will be written to a function map that will
> > not be seen by Lift as you're writing to a different S context.
>
> > I would advice no doing such things or if you do, then expect side
> > effects. In general avoid bypassing Lift's rendering pipeline. Lift
> > does a lot of things some of them internal and missing those you can
> > get into nasty hidden problems.
>
> > For head merge you could use HeadHelper.scala but note that internally
> > Lift doesn't use this ... it uses a more sophisticated head merge ...
> > see LiftMerge.scala. HeadHelper holds the old merge. IMO it should be
> > removed.
>
> > I'm not really sure why you guys don't like redirects, probably to
> > avoid traffic, but IMO this is not very relevant. But regardless, you
> > guys have your own reasons.
>
> > Br's,
> > Marius
>
> > On Dec 30, 9:39 am, Ross Mellgren  wrote:
> >> I think the problem with the site map is that the request you have  
> >> is for a page that doesn't exist so it can't build the current-page-
> >> relative sitemap.
>
> >> Here's a version that works:
>
> >> In Boot:
>
> >>         val notFoundNode = 
> >>         LiftRules.uriNotFound.prepend {
> >>             case _ => XhtmlTemplateResponse(notFoundNode, 404)
> >>         }
>
> >> And the other part:
>
> >> object XhtmlTemplateResponse extends HeaderStuff {
> >>     def apply(nodeToRender: NodeSeq, statusCode: Int): LiftResponse  
> >> = {
> >>         val renderedNode = {
> >>             val forceToRoot: LiftRules.RewritePF = { case _ =>  
> >> RewriteResponse(Req.parsePath("/"), TreeMap.empty, true) }
> >>             for (req <- S.request; session <- S.session) yield
> >>                 S.init(Req(req, forceToRoot::Nil), session) {
> >>                     session.processSurroundAndInclude("/",  
> >> nodeToRender)
> >>                 }
> >>         } openOr {
> >>             error("No session")
> >>         }
>
> >>         new XhtmlResponse(Group(renderedNode), Empty, headers,  
> >> cookies, statusCode, false)
> >>     }
>
> >> }
>
> >> The secret sauce is reiniting S with a new request that has been  
> >> rewritten to seem as if it were a hit to /
>
> >> I'm not sure if this is a good idea, but it seems to work for the  
> >> site map thing.
>
> >> However, I can't find a way to make the head merge work properly.  
> >> It looks like the head merging lies in the code path inside  
> >> LiftSession that is private to Lift. You could rearrange your  
> >> template to make only one head I guess, or wait until someone more  
> >> wise than I can direct you as far as that goes.
>
> >> -Ross
>
> >> On Dec 30, 2009, at 12:32 AM, Alex Black wrote:
>
> >>> I noticed another problem: the head merge is not working in this
> >>> scenario, the resulting page is not valid XHTML because it has two
> >>> head tags :)  So, this makes me think I'm going about things the  
> >>> wrong
> >>> way.
>
> >>> I'm hoping you can suggest the right way, to create a custom 404  
> >>> page,
> >>> correctly (without a redirect, with 404 status code), and  
> >>> processed by
> >>> the template engine so it uses our default template with sitemap  
> >>> etc.
>
> >>> - Alex
>
> 

[Lift] Re: Nice 404s sans Redirect

2009-12-30 Thread Alex Black
> While I totally agree that a plain 404 + markup is much more
> straightforward,
> "breaks internet" are too big words :) .. sending back a
> 302 or 301 tells the UA "you asked me for a resource that I know I
> don't have but I wont tell
> you explicitely, instead I want you to go to this location as an
> alternative resource". Somehow it's like scratching with the wrong
> hand and purely from HTTP protocol perspective this is not quite
> straightforward as 404 + template, but I don't necessarily see it as a
> so bad thing.

Heh, I apologise, definitely "breaking the internet" is a bit
dramatic.  I do have a different view than you though, I think its
incorrect to return a 301 or 302 in these scenarios, the correct
response is 404.  Not only is it the correct response, but given most
sites get 50%-90% of their traffic from Google, and Google thinks its
also correct to return 404 (http://www.google.com/url?sa=D&q=http://
googlewebmastercentral.blogspot.com/2008/08/farewell-to-
soft-404s.html, its in our best financial interest to play nice with
Google.

> Specifically for 404 (when a template is not found we could do
> something like:
>
> 1. In LiftRules instead of:
>
> type URINotFoundPF = PartialFunction[(Req, Box[Failure]),
> LiftResponse]
>
> use
>
> type URINotFoundPF = PartialFunction[(Req, Box[Failure]), Either[List
> [String], LiftResponse]]
>
> so that function can return a template path instead of response.
>
> 2. In LiftSession#processRequest instead of applying the normal
> request pipeline only if the addressed template is found, we can use
> the path obtained from LiftRules.uriNotFound if Lift fails to find the
> normal tempalte. Hence apply the normal rendering pipeline to the
> template referenced by uriNotFound.
>
> This approach allows your 404 case to be handled by the normal
> rendering pipeline without other hacks.
>
> Unless someone thinks this is a bad solution, Alex you could open an
> issue and I'll work on it.

Thanks for proposing that solution Marius.  I can't really comment on
whether or not its the right way to do it from Lift's point of view,
but as a user of Lift it sounds like it would work well.

- Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Nice 404s sans Redirect

2009-12-30 Thread Alex Black
Google's opinion:

http://googlewebmastercentral.blogspot.com/2008/08/farewell-to-soft-404s.html

On Dec 30, 10:05 am, Alex Black  wrote:
> I'll try out that solution Russ, thanks.  Although as the solution
> gets a bit more complex, and taking into account Marius's advice, it
> sounds like this might not be the right direction to go in.
>
> Stepping back a moment, conceptually what I'd like to do is: create a
> nice 404.html template (using lift features like head merge and
> surround tags and sitemap), and then tell Lift to show this page to my
> users when it can't find a handler for the url requested.
>
> Conceptually a nice solution might be:
>
> LiftRules.uriNotFound.prepend {
>             case _ => RewriteResponse("404.html")
>         }
>
> Any other opinions on Russ's solution? Is it the right way to go? Or
> is there another way? Or perhaps could we propose an enhancement to
> Lift to handle this well?
>
> To Marius's question about why I (and perhaps others) don't want to
> use a redirect:
>
> It breaks the internet.  The way its meant to work is: a user-agent
> (either browser, or crawler etc) asks a web server for a resource by
> url, the web server should respond with code 404 if it can't find the
> resource.  Your proposal would have it respond with code 301 which
> tells the user-agent that the resource was located but its moved.
>
> LIft is generally very good I've found at making it easy to build good
> internet applications the *right* way.  Examples include: its easy to
> build rest-ful APIs and return the correct response codes, its easy to
> re-write urls to have friendly urls for users, its easy to build XHTML
> compliant pages etc.
>
> This is one of those areas where we (the lift community) should make
> sure that Lift makes it easy to do things the right way.  Unlike say
> Microsoft of the past where they continually broke internet standards
> and made it easy to do things the wrong way!
>
> - Alex
>
> On Dec 30, 4:32 am, Marius  wrote:
>
> > Re init-ing S is a very risky thing to do. You loose all your context
> > information. uriNotFound is called by Lift from several key points.
> > From those key points, Lift uses the S context and updates the
> > function Map. With your example if your template is binding Scala
> > functions, those function will be written to a function map that will
> > not be seen by Lift as you're writing to a different S context.
>
> > I would advice no doing such things or if you do, then expect side
> > effects. In general avoid bypassing Lift's rendering pipeline. Lift
> > does a lot of things some of them internal and missing those you can
> > get into nasty hidden problems.
>
> > For head merge you could use HeadHelper.scala but note that internally
> > Lift doesn't use this ... it uses a more sophisticated head merge ...
> > see LiftMerge.scala. HeadHelper holds the old merge. IMO it should be
> > removed.
>
> > I'm not really sure why you guys don't like redirects, probably to
> > avoid traffic, but IMO this is not very relevant. But regardless, you
> > guys have your own reasons.
>
> > Br's,
> > Marius
>
> > On Dec 30, 9:39 am, Ross Mellgren  wrote:
>
> > > I think the problem with the site map is that the request you have is for 
> > > a page that doesn't exist so it can't build the current-page-relative 
> > > sitemap.
>
> > > Here's a version that works:
>
> > > In Boot:
>
> > >         val notFoundNode = 
> > >         LiftRules.uriNotFound.prepend {
> > >             case _ => XhtmlTemplateResponse(notFoundNode, 404)
> > >         }
>
> > > And the other part:
>
> > > object XhtmlTemplateResponse extends HeaderStuff {
> > >     def apply(nodeToRender: NodeSeq, statusCode: Int): LiftResponse = {
> > >         val renderedNode = {
> > >             val forceToRoot: LiftRules.RewritePF = { case _ => 
> > > RewriteResponse(Req.parsePath("/"), TreeMap.empty, true) }
> > >             for (req <- S.request; session <- S.session) yield
> > >                 S.init(Req(req, forceToRoot::Nil), session) {
> > >                     session.processSurroundAndInclude("/", nodeToRender)
> > >                 }
> > >         } openOr {
> > >             error("No session")
> > >         }
>
> > >         new XhtmlResponse(Group(renderedNode), Empty, headers, cookies, 
> > > statusCode, false)
> > >     }   

[Lift] Re: Nice 404s sans Redirect

2009-12-30 Thread Alex Black
I'll try out that solution Russ, thanks.  Although as the solution
gets a bit more complex, and taking into account Marius's advice, it
sounds like this might not be the right direction to go in.

Stepping back a moment, conceptually what I'd like to do is: create a
nice 404.html template (using lift features like head merge and
surround tags and sitemap), and then tell Lift to show this page to my
users when it can't find a handler for the url requested.

Conceptually a nice solution might be:

LiftRules.uriNotFound.prepend {
case _ => RewriteResponse("404.html")
}

Any other opinions on Russ's solution? Is it the right way to go? Or
is there another way? Or perhaps could we propose an enhancement to
Lift to handle this well?

To Marius's question about why I (and perhaps others) don't want to
use a redirect:

It breaks the internet.  The way its meant to work is: a user-agent
(either browser, or crawler etc) asks a web server for a resource by
url, the web server should respond with code 404 if it can't find the
resource.  Your proposal would have it respond with code 301 which
tells the user-agent that the resource was located but its moved.

LIft is generally very good I've found at making it easy to build good
internet applications the *right* way.  Examples include: its easy to
build rest-ful APIs and return the correct response codes, its easy to
re-write urls to have friendly urls for users, its easy to build XHTML
compliant pages etc.

This is one of those areas where we (the lift community) should make
sure that Lift makes it easy to do things the right way.  Unlike say
Microsoft of the past where they continually broke internet standards
and made it easy to do things the wrong way!

- Alex

On Dec 30, 4:32 am, Marius  wrote:
> Re init-ing S is a very risky thing to do. You loose all your context
> information. uriNotFound is called by Lift from several key points.
> From those key points, Lift uses the S context and updates the
> function Map. With your example if your template is binding Scala
> functions, those function will be written to a function map that will
> not be seen by Lift as you're writing to a different S context.
>
> I would advice no doing such things or if you do, then expect side
> effects. In general avoid bypassing Lift's rendering pipeline. Lift
> does a lot of things some of them internal and missing those you can
> get into nasty hidden problems.
>
> For head merge you could use HeadHelper.scala but note that internally
> Lift doesn't use this ... it uses a more sophisticated head merge ...
> see LiftMerge.scala. HeadHelper holds the old merge. IMO it should be
> removed.
>
> I'm not really sure why you guys don't like redirects, probably to
> avoid traffic, but IMO this is not very relevant. But regardless, you
> guys have your own reasons.
>
> Br's,
> Marius
>
> On Dec 30, 9:39 am, Ross Mellgren  wrote:
>
> > I think the problem with the site map is that the request you have is for a 
> > page that doesn't exist so it can't build the current-page-relative sitemap.
>
> > Here's a version that works:
>
> > In Boot:
>
> >         val notFoundNode = 
> >         LiftRules.uriNotFound.prepend {
> >             case _ => XhtmlTemplateResponse(notFoundNode, 404)
> >         }
>
> > And the other part:
>
> > object XhtmlTemplateResponse extends HeaderStuff {
> >     def apply(nodeToRender: NodeSeq, statusCode: Int): LiftResponse = {
> >         val renderedNode = {
> >             val forceToRoot: LiftRules.RewritePF = { case _ => 
> > RewriteResponse(Req.parsePath("/"), TreeMap.empty, true) }
> >             for (req <- S.request; session <- S.session) yield
> >                 S.init(Req(req, forceToRoot::Nil), session) {
> >                     session.processSurroundAndInclude("/", nodeToRender)
> >                 }
> >         } openOr {
> >             error("No session")
> >         }
>
> >         new XhtmlResponse(Group(renderedNode), Empty, headers, cookies, 
> > statusCode, false)
> >     }            
>
> > }
>
> > The secret sauce is reiniting S with a new request that has been rewritten 
> > to seem as if it were a hit to /
>
> > I'm not sure if this is a good idea, but it seems to work for the site map 
> > thing.
>
> > However, I can't find a way to make the head merge work properly. It looks 
> > like the head merging lies in the code path inside LiftSession that is 
> > private to Lift. You could rearrange your template to make only one head I 
> > guess, or wait until someone mo

[Lift] Re: Nice 404s sans Redirect

2009-12-29 Thread Alex Black
I noticed another problem: the head merge is not working in this
scenario, the resulting page is not valid XHTML because it has two
head tags :)  So, this makes me think I'm going about things the wrong
way.

I'm hoping you can suggest the right way, to create a custom 404 page,
correctly (without a redirect, with 404 status code), and processed by
the template engine so it uses our default template with sitemap etc.

- Alex

On Dec 30, 12:22 am, Alex Black  wrote:
> One more detail:
>
> notFoundNode is defined like this:
>
>   val notFoundNode = 
>
> and 404.html like this:
>
> 
>     
>         Page Not Found
>     
>         Page Not Found
>         We couldn't find the page you were looking for.
> 
>
> And my default.html hidden template has a site map tag in it, and the
> sitemap contains a number of entries.
>
> On Dec 30, 12:14 am, Alex Black  wrote:
>
> > I emailed Ross directly and said I did run with -Drun.mode=production.
>
> > Here's what I'm seeing:
> > 1. If I run with -Drun.mode=production, and I access a not found url,
> > say mysite.com/foobar, then, I *do* see the custom 404 page as
> > expected, but, where I normally see my sitemap I see "No Navigation
> > Defined".
> > 2. If I run *without* that production flag, and I access a not found
> > url, I get a blank white screen that says "The requested page was not
> > defined in your SiteMap, so access was blocked.  (This message is
> > displayed in development mode only)".
>
> > So #2 is expected, #1 is not.
>
> > Ross, when you emailed me you said you tried to reproduce this, but I
> > think one difference between your scenario and mine is that on my 404
> > page I have a sitemap rendered.
>
> > So instead of what dpp had:
>
> > LiftRules.uriNotFound.prepend {
> >       case _ =>  XhtmlResponse(( Silly goose  > html>),
> >                                Empty, List("Content-Type" -> "text/
> > html;
> > charset=utf-8"), Nil, 404, S.ieMode)
> >     }
>
> > I have:
>
> >     // Catch 404s
> >     LiftRules.uriNotFound.prepend {
> >       case (req, _) => XhtmlTemplateResponse(notFoundNode, 404)
> >     }
>
> > with
>
> > object XhtmlTemplateResponse extends HeaderStuff {
> >   def apply(nodeToRender: Node, statusCode: Int): LiftResponse = {
> >     val renderedNode = S.render(nodeToRender,
> > S.request.get.request).first
> >     new XhtmlResponse(renderedNode, Empty, headers, cookies,
> > statusCode, false)
> >   }
>
> > }
>
> > - Alex
>
> > On Dec 29, 7:49 pm, Ross Mellgren  wrote:
>
> > > This is the production run mode thing dpp talked about. Try your app with 
> > > -Drun.mode=production
>
> > > -Ross
>
> > > On Dec 29, 2009, at 7:39 PM, Alex Black wrote:
>
> > > > Thanks for pointing that out, the catch-all sounds dangerous.
>
> > > > I tried your suggestion, and it works well except I'm encountering one
> > > > issue, my sitemap renders as "No Navigation Defined." for urls that
> > > > are not found.   I'm using 1.1-M8, I launched jetty in production mode
> > > > as you indicated, and added the passNotFoundToChain = false.
>
> > > > Did you expect that - or is the passNotFoundToChain meant to solve the
> > > > sitemap issue?
>
> > > > - Alex
>
> > > > On Dec 29, 6:10 pm, David Pollak 
> > > > wrote:
> > > >> Keep in mind that Lift's behavior for 404s differs between development 
> > > >> and
> > > >> production mode in Lift 1.1-xxx
>
> > > >> To have your app/Lift handle a 404 rather than passing it to your web
> > > >> container, in Boot.scala:
>
> > > >>     LiftRules.passNotFoundToChain = false
>
> > > >>     LiftRules.uriNotFound.prepend {
> > > >>       case _ =>  XhtmlResponse(( Silly goose 
> > > >> ),
> > > >>                                Empty, List("Content-Type" -> 
> > > >> "text/html;
> > > >> charset=utf-8"), Nil, 404, S.ieMode)
> > > >>     }
>
> > > >> In development mode, Lift will tell you about SiteMap as this was a 
> > > >> common
> > > >> confusion point among new developers.  In production mode, Lift will 
> > > >> use
> > > >> that code.  To put Lift in production mode:
>
> > > >

[Lift] Re: Nice 404s sans Redirect

2009-12-29 Thread Alex Black
One more detail:

notFoundNode is defined like this:

  val notFoundNode = 

and 404.html like this:



Page Not Found

Page Not Found
We couldn't find the page you were looking for.


And my default.html hidden template has a site map tag in it, and the
sitemap contains a number of entries.

On Dec 30, 12:14 am, Alex Black  wrote:
> I emailed Ross directly and said I did run with -Drun.mode=production.
>
> Here's what I'm seeing:
> 1. If I run with -Drun.mode=production, and I access a not found url,
> say mysite.com/foobar, then, I *do* see the custom 404 page as
> expected, but, where I normally see my sitemap I see "No Navigation
> Defined".
> 2. If I run *without* that production flag, and I access a not found
> url, I get a blank white screen that says "The requested page was not
> defined in your SiteMap, so access was blocked.  (This message is
> displayed in development mode only)".
>
> So #2 is expected, #1 is not.
>
> Ross, when you emailed me you said you tried to reproduce this, but I
> think one difference between your scenario and mine is that on my 404
> page I have a sitemap rendered.
>
> So instead of what dpp had:
>
> LiftRules.uriNotFound.prepend {
>       case _ =>  XhtmlResponse(( Silly goose  html>),
>                                Empty, List("Content-Type" -> "text/
> html;
> charset=utf-8"), Nil, 404, S.ieMode)
>     }
>
> I have:
>
>     // Catch 404s
>     LiftRules.uriNotFound.prepend {
>       case (req, _) => XhtmlTemplateResponse(notFoundNode, 404)
>     }
>
> with
>
> object XhtmlTemplateResponse extends HeaderStuff {
>   def apply(nodeToRender: Node, statusCode: Int): LiftResponse = {
>     val renderedNode = S.render(nodeToRender,
> S.request.get.request).first
>     new XhtmlResponse(renderedNode, Empty, headers, cookies,
> statusCode, false)
>   }
>
> }
>
> - Alex
>
> On Dec 29, 7:49 pm, Ross Mellgren  wrote:
>
> > This is the production run mode thing dpp talked about. Try your app with 
> > -Drun.mode=production
>
> > -Ross
>
> > On Dec 29, 2009, at 7:39 PM, Alex Black wrote:
>
> > > Thanks for pointing that out, the catch-all sounds dangerous.
>
> > > I tried your suggestion, and it works well except I'm encountering one
> > > issue, my sitemap renders as "No Navigation Defined." for urls that
> > > are not found.   I'm using 1.1-M8, I launched jetty in production mode
> > > as you indicated, and added the passNotFoundToChain = false.
>
> > > Did you expect that - or is the passNotFoundToChain meant to solve the
> > > sitemap issue?
>
> > > - Alex
>
> > > On Dec 29, 6:10 pm, David Pollak 
> > > wrote:
> > >> Keep in mind that Lift's behavior for 404s differs between development 
> > >> and
> > >> production mode in Lift 1.1-xxx
>
> > >> To have your app/Lift handle a 404 rather than passing it to your web
> > >> container, in Boot.scala:
>
> > >>     LiftRules.passNotFoundToChain = false
>
> > >>     LiftRules.uriNotFound.prepend {
> > >>       case _ =>  XhtmlResponse(( Silly goose ),
> > >>                                Empty, List("Content-Type" -> "text/html;
> > >> charset=utf-8"), Nil, 404, S.ieMode)
> > >>     }
>
> > >> In development mode, Lift will tell you about SiteMap as this was a 
> > >> common
> > >> confusion point among new developers.  In production mode, Lift will use
> > >> that code.  To put Lift in production mode:
>
> > >> mvn -Drun.mode=production jetty:run
>
> > >> I would strongly recommend against a "catch-all" entry in SiteMap as it 
> > >> will
> > >> expose every page on your site to access.
>
> > >> On Tue, Dec 29, 2009 at 11:17 AM, Alex Black  wrote:
> > >>> Ok, I got this working, with 1.1-M8 using S.render.
>
> > >>>  // A node which embeds our 404 template (e.g. 404.html)
> > >>>  val notFoundNode =
> > >>>    
>
> > >>>    // Catch 404s
> > >>>    LiftRules.uriNotFound.prepend {
> > >>>      case (req, _) => XhtmlTemplateResponse(notFoundNode, 404)
> > >>>    }
>
> > >>>  // If you're using a sitemap, make sure you have a catch-all item,
> > >>> e.g
> > >>>  //    Menu(Loc("Catchall", Pair(Nil, true), "", Hidden :: Nil)) ::
>
> 

[Lift] Re: Sitemap: Using "" instead of "index" and still having the current menu selected?

2009-12-29 Thread Alex Black
> > I've changed my sitemap from:
>
> >    Menu(Loc("index", Pair("index" :: Nil, false), "Home")) ::
>
> Yes, the / directory will be rendered by Lift as /index  There's no way
> around that one.

Can you explain? I don't understand.  I'm not sure what "rendered"
means in this context, and I'm not as far as I know seeing anything
rendered as "/index".  What I am seeing is when I click on the "home"
link, I correctly arrive at "mysite.com/" but the home link is not
visually selected.  Whereas, when I click on other links, like "about"
they then appear selected.

> Also, why do you using "Pair(List(...), false)"?
>
> Pair is deprecated/frowned on... it's much more idomatic to use (List(...),
> false), but that's not needed as there's an implicit conversion you can
> simply declare the List().

Thanks for the tip.

>
>
>
>
>
> > to
>
> >    Menu(Loc("index", Pair("" :: Nil, false), "Home")) ::
>
> > So that my "Home" link goes to mysite.com/ instead of mysite.com/
> > index.  But, I notice, when you're at mysite.com/ the sitemap doesn't
> > show "Home" as selected, is there a way to fix that? Perhaps I've got
> > something wrong here.
>
> > Thanks,
>
> > - Alex
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: How can I set a custom response StatusCode in a snippet?

2009-12-29 Thread Alex Black
I don't have another use case currently.

On Dec 29, 5:44 pm, David Pollak 
wrote:
> As has been discussed, there are lots of ways to do a custom 404 in Lift or
> in the container.  What other use cases are there for changing the response
> code for an XHTML page?
>
>
>
> On Tue, Dec 29, 2009 at 1:40 PM, Alex Black  wrote:
> > Hi Marius, I was trying to find a way to give a custom 404 response
> > without changing the url (e.g. using a redirect) and returning a 404
> > status code.
>
> > Before I found a solution, I found an almost solution which let me use
> > a sitemap menu to display a page when no other page matched but the
> > status code was still 200, so I posted this question to find out if I
> > could change it to 404.
>
> > I found another solution, here:
> >http://groups.google.com/group/liftweb/browse_thread/thread/4a9806a63...
>
> > On Dec 29, 4:34 pm, Marius  wrote:
> > > This can be easily done with
>
> > > LiftRules.responseTransformers.append{
>
> > >   case liftResponse => ... do your thing and return a LiftResponse
>
> > > }
>
> > > May I ask what is the usecase of this need?
>
> > > Br's,
> > > Marius
>
> > > On Dec 29, 8:01 pm, Ross Mellgren  wrote:
>
> > > > I don't think this addresses his question directly, which is how to
> > > > change the response code while already yielding control of the
> > > > generated LiftResponse to the template mechanism.
>
> > > > If that's what the question is, then the answer (without a change to
> > > > lift) is probably to alter LiftRules.convertResponse, which is where
> > > > the 200 response code looks to be generated from right now. It looks
> > > > like it wouldn't be trivial, but it would be doable.
>
> > > > -Ross
>
> > > > On Dec 29, 2009, at 12:57 PM, Timothy Perrett wrote:
>
> > > > > I would certainly recommend you take a closer look at the
> > > > > LiftResponse subclasses your other question in another thread
> > > > > (that I already answered) is equally solved by looking at
> > > > > LiftResponse.
>
> > > > > It depends what type of response you want, but at a base level,
> > > > > InMemoryResponse will do what you want... as I said, you need to
> > > > > look at LiftResponse subclasses and find the one that suits your
> > > > > needs.
>
> > > > > Cheers, Tim
>
> > > > > On 29 Dec 2009, at 17:07, Alex Black wrote:
>
> > > > >> In my snippet I'd like to change the response status code from the
> > > > >> default 200 to something else, say 201, or 404. (see
> > > > >>http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
>
> > > > >> I see there is a method on S to change the doctype, but I don't see
> > > > >> one to change the status code.
>
> > > > >> Thanks,
>
> > > > >> - Alex
>
> > > > >> --
>
> > > > >> You received this message because you are subscribed to the Google
> > > > >> Groups "Lift" group.
> > > > >> To post to this group, send email to lift...@googlegroups.com.
> > > > >> To unsubscribe from this group, send email to
> > liftweb+unsubscr...@googlegroups.com
> > > > >> .
> > > > >> For more options, visit this group athttp://
> > groups.google.com/group/liftweb?hl=en
> > > > >> .
>
> > > > > --
>
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "Lift" group.
> > > > > To post to this group, send email to lift...@googlegroups.com.
> > > > > To unsubscribe from this group, send email to
> > liftweb+unsubscr...@googlegroups.com
> > > > > .
> > > > > For more options, visit this group athttp://
> > groups.google.com/group/liftweb?hl=en
> > > > > .
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Nice 404s sans Redirect

2009-12-29 Thread Alex Black
I emailed Ross directly and said I did run with -Drun.mode=production.

Here's what I'm seeing:
1. If I run with -Drun.mode=production, and I access a not found url,
say mysite.com/foobar, then, I *do* see the custom 404 page as
expected, but, where I normally see my sitemap I see "No Navigation
Defined".
2. If I run *without* that production flag, and I access a not found
url, I get a blank white screen that says "The requested page was not
defined in your SiteMap, so access was blocked.  (This message is
displayed in development mode only)".

So #2 is expected, #1 is not.

Ross, when you emailed me you said you tried to reproduce this, but I
think one difference between your scenario and mine is that on my 404
page I have a sitemap rendered.

So instead of what dpp had:

LiftRules.uriNotFound.prepend {
  case _ =>  XhtmlResponse(( Silly goose ),
   Empty, List("Content-Type" -> "text/
html;
charset=utf-8"), Nil, 404, S.ieMode)
}

I have:

// Catch 404s
LiftRules.uriNotFound.prepend {
  case (req, _) => XhtmlTemplateResponse(notFoundNode, 404)
}

with

object XhtmlTemplateResponse extends HeaderStuff {
  def apply(nodeToRender: Node, statusCode: Int): LiftResponse = {
val renderedNode = S.render(nodeToRender,
S.request.get.request).first
new XhtmlResponse(renderedNode, Empty, headers, cookies,
statusCode, false)
  }
}

- Alex

On Dec 29, 7:49 pm, Ross Mellgren  wrote:
> This is the production run mode thing dpp talked about. Try your app with 
> -Drun.mode=production
>
> -Ross
>
> On Dec 29, 2009, at 7:39 PM, Alex Black wrote:
>
> > Thanks for pointing that out, the catch-all sounds dangerous.
>
> > I tried your suggestion, and it works well except I'm encountering one
> > issue, my sitemap renders as "No Navigation Defined." for urls that
> > are not found.   I'm using 1.1-M8, I launched jetty in production mode
> > as you indicated, and added the passNotFoundToChain = false.
>
> > Did you expect that - or is the passNotFoundToChain meant to solve the
> > sitemap issue?
>
> > - Alex
>
> > On Dec 29, 6:10 pm, David Pollak 
> > wrote:
> >> Keep in mind that Lift's behavior for 404s differs between development and
> >> production mode in Lift 1.1-xxx
>
> >> To have your app/Lift handle a 404 rather than passing it to your web
> >> container, in Boot.scala:
>
> >>     LiftRules.passNotFoundToChain = false
>
> >>     LiftRules.uriNotFound.prepend {
> >>       case _ =>  XhtmlResponse(( Silly goose ),
> >>                                Empty, List("Content-Type" -> "text/html;
> >> charset=utf-8"), Nil, 404, S.ieMode)
> >>     }
>
> >> In development mode, Lift will tell you about SiteMap as this was a common
> >> confusion point among new developers.  In production mode, Lift will use
> >> that code.  To put Lift in production mode:
>
> >> mvn -Drun.mode=production jetty:run
>
> >> I would strongly recommend against a "catch-all" entry in SiteMap as it 
> >> will
> >> expose every page on your site to access.
>
> >> On Tue, Dec 29, 2009 at 11:17 AM, Alex Black  wrote:
> >>> Ok, I got this working, with 1.1-M8 using S.render.
>
> >>>  // A node which embeds our 404 template (e.g. 404.html)
> >>>  val notFoundNode =
> >>>    
>
> >>>    // Catch 404s
> >>>    LiftRules.uriNotFound.prepend {
> >>>      case (req, _) => XhtmlTemplateResponse(notFoundNode, 404)
> >>>    }
>
> >>>  // If you're using a sitemap, make sure you have a catch-all item,
> >>> e.g
> >>>  //    Menu(Loc("Catchall", Pair(Nil, true), "", Hidden :: Nil)) ::
>
> >>> using this object:
>
> >>>  object XhtmlTemplateResponse extends HeaderStuff {
> >>>    def apply(nodeToRender: Node, statusCode: Int): LiftResponse = {
> >>>      val renderedNode = S.render(nodeToRender,
> >>> S.request.get.request).first
> >>>      new XhtmlResponse(renderedNode, Empty, headers, cookies,
> >>> statusCode, false)
> >>>    }
> >>>  }
>
> >>> I think the wiki page:
> >>>http://wiki.liftweb.net/index.php/Setting_up_a_custom_404_page
> >>> should be updated.  The current code hides the 404 status code and
> >>> changes the url.
>
> >>> I'd offer to write the new wiki page - is there a way for me to get an
> >>> account on that wiki - or is it just for co

[Lift] Re: Nice 404s sans Redirect

2009-12-29 Thread Alex Black
Thanks for pointing that out, the catch-all sounds dangerous.

I tried your suggestion, and it works well except I'm encountering one
issue, my sitemap renders as "No Navigation Defined." for urls that
are not found.   I'm using 1.1-M8, I launched jetty in production mode
as you indicated, and added the passNotFoundToChain = false.

Did you expect that - or is the passNotFoundToChain meant to solve the
sitemap issue?

- Alex

On Dec 29, 6:10 pm, David Pollak 
wrote:
> Keep in mind that Lift's behavior for 404s differs between development and
> production mode in Lift 1.1-xxx
>
> To have your app/Lift handle a 404 rather than passing it to your web
> container, in Boot.scala:
>
>     LiftRules.passNotFoundToChain = false
>
>     LiftRules.uriNotFound.prepend {
>       case _ =>  XhtmlResponse(( Silly goose ),
>                                Empty, List("Content-Type" -> "text/html;
> charset=utf-8"), Nil, 404, S.ieMode)
>     }
>
> In development mode, Lift will tell you about SiteMap as this was a common
> confusion point among new developers.  In production mode, Lift will use
> that code.  To put Lift in production mode:
>
> mvn -Drun.mode=production jetty:run
>
> I would strongly recommend against a "catch-all" entry in SiteMap as it will
> expose every page on your site to access.
>
>
>
> On Tue, Dec 29, 2009 at 11:17 AM, Alex Black  wrote:
> > Ok, I got this working, with 1.1-M8 using S.render.
>
> >  // A node which embeds our 404 template (e.g. 404.html)
> >  val notFoundNode =
> >    
>
> >    // Catch 404s
> >    LiftRules.uriNotFound.prepend {
> >      case (req, _) => XhtmlTemplateResponse(notFoundNode, 404)
> >    }
>
> >  // If you're using a sitemap, make sure you have a catch-all item,
> > e.g
> >  //    Menu(Loc("Catchall", Pair(Nil, true), "", Hidden :: Nil)) ::
>
> > using this object:
>
> >  object XhtmlTemplateResponse extends HeaderStuff {
> >    def apply(nodeToRender: Node, statusCode: Int): LiftResponse = {
> >      val renderedNode = S.render(nodeToRender,
> > S.request.get.request).first
> >      new XhtmlResponse(renderedNode, Empty, headers, cookies,
> > statusCode, false)
> >    }
> >  }
>
> > I think the wiki page:
> >http://wiki.liftweb.net/index.php/Setting_up_a_custom_404_page
> > should be updated.  The current code hides the 404 status code and
> > changes the url.
>
> > I'd offer to write the new wiki page - is there a way for me to get an
> > account on that wiki - or is it just for contributors?
>
> > - Alex
>
> > On Dec 29, 1:20 pm, Alex Black  wrote:
> > > > If you want to display the contents of your 404.html, checkout
> > NodeResponse... just load up your template using the template helpers (this
> > will give you NodeSeq) and then you can present that back to the user. Job
> > done.
>
> > > I am familiar with NodeResponse and its subclasses.  I've used them in
> > > our REST api.  But, what I can't figure out, is how to use them in
> > > conjuction with the templating engine as you seem to be alluding to
> > > (with the template helpers).
>
> > > Can you point me in the right direction? I am going to try switching
> > > to M8 and then using S.render like this:
>
> > >     val node404 = 
> > >       Not Found
> > >     
>
> > >     LiftRules.uriNotFound.prepend {
> > >       case (req, _) => XhtmlResponse(S.render(node404, req), _,
> > > headers, cookies, 404, false)
> > >     }
>
> > > > Cheers, Tim
>
> > > > On 29 Dec 2009, at 15:23, Alex Black wrote:
>
> > > > > But of course RewriteResponse is not a LiftResponse.  Whats the best
> > > > > way to do this?  Basically I've got a template called 404.html which
> > > > > I'd like to display whenever there is a 404.
>
> > > > > I Just thought of something, perhaps I could add a RewriteRule that
> > > > > matches everything?
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: How can I set a custom response StatusCode in a snippet?

2009-12-29 Thread Alex Black
Hi Marius, I was trying to find a way to give a custom 404 response
without changing the url (e.g. using a redirect) and returning a 404
status code.

Before I found a solution, I found an almost solution which let me use
a sitemap menu to display a page when no other page matched but the
status code was still 200, so I posted this question to find out if I
could change it to 404.

I found another solution, here: 
http://groups.google.com/group/liftweb/browse_thread/thread/4a9806a63419644f

On Dec 29, 4:34 pm, Marius  wrote:
> This can be easily done with
>
> LiftRules.responseTransformers.append{
>
>   case liftResponse => ... do your thing and return a LiftResponse
>
> }
>
> May I ask what is the usecase of this need?
>
> Br's,
> Marius
>
> On Dec 29, 8:01 pm, Ross Mellgren  wrote:
>
> > I don't think this addresses his question directly, which is how to  
> > change the response code while already yielding control of the  
> > generated LiftResponse to the template mechanism.
>
> > If that's what the question is, then the answer (without a change to  
> > lift) is probably to alter LiftRules.convertResponse, which is where  
> > the 200 response code looks to be generated from right now. It looks  
> > like it wouldn't be trivial, but it would be doable.
>
> > -Ross
>
> > On Dec 29, 2009, at 12:57 PM, Timothy Perrett wrote:
>
> > > I would certainly recommend you take a closer look at the  
> > > LiftResponse subclasses your other question in another thread  
> > > (that I already answered) is equally solved by looking at  
> > > LiftResponse.
>
> > > It depends what type of response you want, but at a base level,  
> > > InMemoryResponse will do what you want... as I said, you need to  
> > > look at LiftResponse subclasses and find the one that suits your  
> > > needs.
>
> > > Cheers, Tim
>
> > > On 29 Dec 2009, at 17:07, Alex Black wrote:
>
> > >> In my snippet I'd like to change the response status code from the
> > >> default 200 to something else, say 201, or 404. (see
> > >>http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
>
> > >> I see there is a method on S to change the doctype, but I don't see
> > >> one to change the status code.
>
> > >> Thanks,
>
> > >> - Alex
>
> > >> --
>
> > >> You received this message because you are subscribed to the Google  
> > >> Groups "Lift" group.
> > >> To post to this group, send email to lift...@googlegroups.com.
> > >> To unsubscribe from this group, send email to 
> > >> liftweb+unsubscr...@googlegroups.com
> > >> .
> > >> For more options, visit this group 
> > >> athttp://groups.google.com/group/liftweb?hl=en
> > >> .
>
> > > --
>
> > > You received this message because you are subscribed to the Google  
> > > Groups "Lift" group.
> > > To post to this group, send email to lift...@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > liftweb+unsubscr...@googlegroups.com
> > > .
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/liftweb?hl=en
> > > .

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] Sitemap: Using "" instead of "index" and still having the current menu selected?

2009-12-29 Thread Alex Black
I've changed my sitemap from:

Menu(Loc("index", Pair("index" :: Nil, false), "Home")) ::

to

Menu(Loc("index", Pair("" :: Nil, false), "Home")) ::

So that my "Home" link goes to mysite.com/ instead of mysite.com/
index.  But, I notice, when you're at mysite.com/ the sitemap doesn't
show "Home" as selected, is there a way to fix that? Perhaps I've got
something wrong here.

Thanks,

- Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Nice 404s sans Redirect

2009-12-29 Thread Alex Black
Ok, I got this working, with 1.1-M8 using S.render.

  // A node which embeds our 404 template (e.g. 404.html)
  val notFoundNode =


// Catch 404s
LiftRules.uriNotFound.prepend {
  case (req, _) => XhtmlTemplateResponse(notFoundNode, 404)
}

  // If you're using a sitemap, make sure you have a catch-all item,
e.g
  //Menu(Loc("Catchall", Pair(Nil, true), "", Hidden :: Nil)) ::

using this object:

  object XhtmlTemplateResponse extends HeaderStuff {
def apply(nodeToRender: Node, statusCode: Int): LiftResponse = {
  val renderedNode = S.render(nodeToRender,
S.request.get.request).first
  new XhtmlResponse(renderedNode, Empty, headers, cookies,
statusCode, false)
}
  }

I think the wiki page: 
http://wiki.liftweb.net/index.php/Setting_up_a_custom_404_page
should be updated.  The current code hides the 404 status code and
changes the url.

I'd offer to write the new wiki page - is there a way for me to get an
account on that wiki - or is it just for contributors?

- Alex

On Dec 29, 1:20 pm, Alex Black  wrote:
> > If you want to display the contents of your 404.html, checkout 
> > NodeResponse... just load up your template using the template helpers (this 
> > will give you NodeSeq) and then you can present that back to the user. Job 
> > done.
>
> I am familiar with NodeResponse and its subclasses.  I've used them in
> our REST api.  But, what I can't figure out, is how to use them in
> conjuction with the templating engine as you seem to be alluding to
> (with the template helpers).
>
> Can you point me in the right direction? I am going to try switching
> to M8 and then using S.render like this:
>
>     val node404 = 
>       Not Found
>     
>
>     LiftRules.uriNotFound.prepend {
>       case (req, _) => XhtmlResponse(S.render(node404, req), _,
> headers, cookies, 404, false)
>     }
>
>
>
> > Cheers, Tim
>
> > On 29 Dec 2009, at 15:23, Alex Black wrote:
>
> > > But of course RewriteResponse is not a LiftResponse.  Whats the best
> > > way to do this?  Basically I've got a template called 404.html which
> > > I'd like to display whenever there is a 404.
>
> > > I Just thought of something, perhaps I could add a RewriteRule that
> > > matches everything?

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: How can I set a custom response StatusCode in a snippet?

2009-12-29 Thread Alex Black
> If that's what the question is, then the answer (without a change to  
> lift) is probably to alter LiftRules.convertResponse, which is where  
> the 200 response code looks to be generated from right now. It looks  
> like it wouldn't be trivial, but it would be doable.

Yes, that is what my question is, thanks for interpreting :)

I was looking into this just to support solving my 404 issue, where I
want to show a custom not found page with 404 status and no redirect.

Tim's suggestion in the other thread looks promising so I am going to
look more into that.

- Alex

>
> -Ross
>
> On Dec 29, 2009, at 12:57 PM, Timothy Perrett wrote:
>
> > I would certainly recommend you take a closer look at the  
> > LiftResponse subclasses your other question in another thread  
> > (that I already answered) is equally solved by looking at  
> > LiftResponse.
>
> > It depends what type of response you want, but at a base level,  
> > InMemoryResponse will do what you want... as I said, you need to  
> > look at LiftResponse subclasses and find the one that suits your  
> > needs.
>
> > Cheers, Tim
>
> > On 29 Dec 2009, at 17:07, Alex Black wrote:
>
> >> In my snippet I'd like to change the response status code from the
> >> default 200 to something else, say 201, or 404. (see
> >>http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
>
> >> I see there is a method on S to change the doctype, but I don't see
> >> one to change the status code.
>
> >> Thanks,
>
> >> - Alex
>
> >> --
>
> >> You received this message because you are subscribed to the Google  
> >> Groups "Lift" group.
> >> To post to this group, send email to lift...@googlegroups.com.
> >> To unsubscribe from this group, send email to 
> >> liftweb+unsubscr...@googlegroups.com
> >> .
> >> For more options, visit this group 
> >> athttp://groups.google.com/group/liftweb?hl=en
> >> .
>
> > --
>
> > You received this message because you are subscribed to the Google  
> > Groups "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en
> > .

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Nice 404s sans Redirect

2009-12-29 Thread Alex Black
> If you want to display the contents of your 404.html, checkout 
> NodeResponse... just load up your template using the template helpers (this 
> will give you NodeSeq) and then you can present that back to the user. Job 
> done.

I am familiar with NodeResponse and its subclasses.  I've used them in
our REST api.  But, what I can't figure out, is how to use them in
conjuction with the templating engine as you seem to be alluding to
(with the template helpers).

Can you point me in the right direction? I am going to try switching
to M8 and then using S.render like this:

val node404 = 
  Not Found


LiftRules.uriNotFound.prepend {
  case (req, _) => XhtmlResponse(S.render(node404, req), _,
headers, cookies, 404, false)
}



>
> Cheers, Tim
>
> On 29 Dec 2009, at 15:23, Alex Black wrote:
>
> > But of course RewriteResponse is not a LiftResponse.  Whats the best
> > way to do this?  Basically I've got a template called 404.html which
> > I'd like to display whenever there is a 404.
>
> > I Just thought of something, perhaps I could add a RewriteRule that
> > matches everything?

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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.




Re: [Lift] Re: Nice 404s sans Redirect

2009-12-29 Thread Alex Black
Is M8 pretty stable? A little while back DavidP recommended M6 as being the
most stable of the milestones.

On Tue, Dec 29, 2009 at 1:07 PM, Ross Mellgren  wrote:

> Switch to 1.1-M8, if you can.
>
> -Ross
>
> On Dec 29, 2009, at 1:04 PM, Alex Black wrote:
>
> >
> >> To be clear, RewriteResponse is a LiftResponse, and therefore, valid.
> >
> > I had tried it, and got a compile error, keep in mind I'm still on
> > 1.0:
> >
> >
> http://scala-tools.org/scaladocs/liftweb/1.0/net/liftweb/http/RewriteResponse.html
> >
> >> If you want to display the contents of your 404.html, checkout
> >> NodeResponse... just load up your template using the template
> >> helpers (this will give you NodeSeq) and then you can present that
> >> back to the user. Job done.
> >
> > I'll take a look, that sounds promising, thx.  What are the template
> > helpers? This sounds similar to using S.render, but I wasn't able to
> > use that since I'm still on 1.0, it looks like it was added later. (I
> > am considering moving to 1.1-M6).
> >
> > - Alex
> >
> >>
> >> Cheers, Tim
> >>
> >> On 29 Dec 2009, at 15:23, Alex Black wrote:
> >>
> >>> But of course RewriteResponse is not a LiftResponse.  Whats the best
> >>> way to do this?  Basically I've got a template called 404.html which
> >>> I'd like to display whenever there is a 404.
> >>
> >>> I Just thought of something, perhaps I could add a RewriteRule that
> >>> matches everything?
> >
> > --
> >
> > You received this message because you are subscribed to the Google
> > Groups "Lift" group.
> > To post to this group, send email to lift...@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
> > .
> >
> >
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to lift...@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.
>
>
>


-- 
http://blog.alexblack.ca
http://twitter.com/waterlooalex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Nice 404s sans Redirect

2009-12-29 Thread Alex Black

> To be clear, RewriteResponse is a LiftResponse, and therefore, valid.

I had tried it, and got a compile error, keep in mind I'm still on
1.0:

http://scala-tools.org/scaladocs/liftweb/1.0/net/liftweb/http/RewriteResponse.html

> If you want to display the contents of your 404.html, checkout 
> NodeResponse... just load up your template using the template helpers (this 
> will give you NodeSeq) and then you can present that back to the user. Job 
> done.

I'll take a look, that sounds promising, thx.  What are the template
helpers? This sounds similar to using S.render, but I wasn't able to
use that since I'm still on 1.0, it looks like it was added later. (I
am considering moving to 1.1-M6).

- Alex

>
> Cheers, Tim
>
> On 29 Dec 2009, at 15:23, Alex Black wrote:
>
> > But of course RewriteResponse is not a LiftResponse.  Whats the best
> > way to do this?  Basically I've got a template called 404.html which
> > I'd like to display whenever there is a 404.
>
> > I Just thought of something, perhaps I could add a RewriteRule that
> > matches everything?

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Sitemap - A catch-all loc?

2009-12-29 Thread Alex Black
I got this working, like this:

Menu(Loc("Catchall", Pair(Nil, true), "", homepageTemp1 ::
Hidden :: Nil)) ::

If you add this as the last item in your sitemap, it will catch
everything that the other menus don't catch, and render it with the
template you defined in homepageTemp1.

This *almost* works for 404 handling, except you still get a 200 OK
response when you would expect a 404.  I am hoping there is some
mechanism in lift to let me change the status code to 404 for this
menu.

- Alex

On Dec 29, 11:10 am, Alex Black  wrote:
> In my effort to handle 404s without a redirect 
> (seehttp://groups.google.com/group/liftweb/browse_thread/thread/4a9806a63...),
> I am wondering if there is a way to add an item at the end of a
> sitemap which matches every url?
>
> E.g. Lift would look through the sitemap for a match, and always match
> on the last item if none of the others match.
>
> I've tried this:
>
>   val homepageTemp1 = Template({ () =>
>     
>       Found me!
>      })
>
> with this at the end of my sitemap:
>
>     Menu(Loc("Catchall", Pair("" :: Nil, true), "", homepageTemp1)) ::
>
> But it doesn't work, it never matches.  However:
>
>     Menu(Loc("Catchall", Pair("bob" :: Nil, true), "",
> homepageTemp1)) ::
>
> That one does match one urls like mysite.com/bob and mysite.com/bob/
> 1234  etc.
>
> - Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] How can I set a custom response StatusCode in a snippet?

2009-12-29 Thread Alex Black
In my snippet I'd like to change the response status code from the
default 200 to something else, say 201, or 404. (see
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).

I see there is a method on S to change the doctype, but I don't see
one to change the status code.

Thanks,

- Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] Sitemap - A catch-all loc?

2009-12-29 Thread Alex Black
In my effort to handle 404s without a redirect (see
http://groups.google.com/group/liftweb/browse_thread/thread/4a9806a63419644f),
I am wondering if there is a way to add an item at the end of a
sitemap which matches every url?

E.g. Lift would look through the sitemap for a match, and always match
on the last item if none of the others match.

I've tried this:

  val homepageTemp1 = Template({ () =>

  Found me!
 })

with this at the end of my sitemap:

Menu(Loc("Catchall", Pair("" :: Nil, true), "", homepageTemp1)) ::

But it doesn't work, it never matches.  However:

Menu(Loc("Catchall", Pair("bob" :: Nil, true), "",
homepageTemp1)) ::

That one does match one urls like mysite.com/bob and mysite.com/bob/
1234  etc.

- Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Sitemap - rendering "title" attributes for the links

2009-12-29 Thread Alex Black
Thanks Chris, I'll look into that.

On Dec 24, 4:23 am, Chris Reeves  wrote:
> I believe you'll need to subclass Loc to do that, though you may be
> able to do it with a Link subclass. There may be an easier way to do
> it, but I'm still new at lifting so I'm not very familiar with all 
> ofsitemap'sconveniences.
>
> I'd start with net.liftweb.sitemap.Loc.Link.createLink and then move
> on to net.liftweb.sitemap.Loc.createLink if that doesn't work. I
> suppose ideally you'd end up with something like
> Menu(Loc("SomeLink", MyLink("path" :: "to" :: "link" :: Nil, "title
> goes here"), "Some  Link", ...))
>
> Thanks, Chris
>
> On Wed, Dec 23, 2009 at 2:25 PM, Alex Black  wrote:
> > Hi Xuefeng, I think will produce 1 tooltip for the entiresitemap,
> > what i'm looking for is a tooltip for each link in thesitemap.
>
> > On Dec 21, 11:39 pm, Xuefeng Wu  wrote:
> >> Sorry I misunderstand you.
>
> >> And I do not know how to too.
>
> >> Maybe you should use
> >>  >> name="about"/>
> >> instead of 
>
> >> On Tue, Dec 22, 2009 at 11:29 AM, Alex Black  wrote:
> >> > Hi Xuefeng,
>
> >> > I'm using the default LiftSitemap, so I don't think I can use either
> >> > of your suggestions, or, I don't see how to use them.  Thesitemap
> >> > renders the links for me... I have seen how to set the class of the
> >> > elements that it renders, but not how to add other attributes such as
> >> > title.
>
> >> > - Alex
>
> >> > > You could add MetaData 'title' by Elem 's method '%'
> >> > > some page % ("title" -> "what will happen when you
> >> > click
> >> > > on this
> >> > > link")
>
> >> > > or use { }
> >> > > some page
>
> >> > > On Mon, Dec 21, 2009 at 10:38 PM, Alex Black  wrote:
> >> > > > Can someone point me in the right direction to get tooltips (title
> >> > > > attributes) rendered in mysitemap?
>
> >> > > > I'd like to add text to each link, so they get rendered like this:
>
> >> > > > some page
>
> >> > > > thx
>
> >> > > > - Alex
>
> >> > > > --
>
> >> > > > You received this message because you are subscribed to the Google
> >> > Groups
> >> > > > "Lift" group.
> >> > > > To post to this group, send email to lift...@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.
>
> >> > > --
> >> > > Scala中文社区:  http://groups.google.com/group/scalacn
>
> >> > --
>
> >> > You received this message because you are subscribed to the Google Groups
> >> > "Lift" group.
> >> > To post to this group, send email to lift...@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.
>
> >> --
> >> Scala中文社区:  http://groups.google.com/group/scalacn
>
> > --
>
> > You received this message because you are subscribed to the Google Groups 
> > "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en.

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] Nice 404s sans Redirect

2009-12-29 Thread Alex Black
I'd like to handle 404s on my site in such a way that:
- there is no redirect, e.g. if you type in a url like mysite.com/
foobarme, you'll stay at that url, so maybe you can correct it
- the status code returned is 404 (not 200 OK)

See stackoverflow:

http://stackoverflow.com/bob

So I tried something like this:

// Catch 404s
LiftRules.uriNotFound.prepend {
  case (req, _) => RewriteResponse("404" :: Nil)
}

But of course RewriteResponse is not a LiftResponse.  Whats the best
way to do this?  Basically I've got a template called 404.html which
I'd like to display whenever there is a 404.

I Just thought of something, perhaps I could add a RewriteRule that
matches everything?

- Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Advanced lift binding, parameters?

2009-12-27 Thread Alex Black
Yeah that looks like exactly what I'm looking for.

I'm just debating the two options: 1. Use many snippets and pass the
current item down through a request var.  2. Use one snippet (composed
of many internal function calls) and pass the current item down as a
parameter.

I'll give both a shot, thanks for your help.  Intuitively I seem to be
leaning towards #1 I think for the same reason I don't normally use
just one snippet call per xhtml page, instead I make several smaller
snippet calls for each page.

I appreciate all the ideas and advice.

- Alex

On Dec 23, 10:22 pm, Ross Mellgren  wrote:
> I guess I could see something that keeps track of which item to show and 
> advances it each time, but I think it's still a good idea to pass the item 
> explicitly down to subsidiary "snippets". You can still break up each of the 
> sub snippets, the only difference is you call them without the lift: prefix. 
> This is analogous to composing functions.
>
> Maybe something like this?
>
> object MySnippet {
>     object nextItems extends RequestVar[Iterator[ModelObject]](calcNextItems)
>
>     def nextItem: Box[ModelObject] = {
>         val it = nextItems.is
>         if (it.hasNext) Full(it.next) else Empty
>     }
>
>     private def calcNextItems: List[ModelObject] =
>         for (startIndex <- S.attr("index").flatMap(asInt).openOr 0)
>             yield ModelObject.findAll(StartAt(startIndex), 
> MaxRows(2)).elements
>
> }
>
> class MySnippet extends DispatchSnippet {
>     import MySnippet._
>
>     val dispatch: DispatchIt = {
>         case "displayNext" => displayNextItem
>     }
>
>     def displayNext(ns: NodeSeq): NodeSeq) =
>         nextItem.map(renderItem(ns) _).openOr(NodeSeq.Empty)
>
>     def renderItem(item: ModelObject)(ns: NodeSeq): NodeSeq =
>         bind("item", ns, "which" -> item.title,
>              "points" -> renderPointsOf(item) _,
>              // other "sub" snippet which need a current item here
>              "picture" -> renderPictureOf(item) _)
>
>     def renderPointsOf(item: ModelObject)(ns: NodeSeq): NodeSeq =
>         item.points.flatMap(point => bind("point", ns, "name" -> point.name))
>
>     def renderPictureOf(item: ModelObject)(ns: NodeSeq): NodeSeq =
>         
>
> }
>
> And template item-index-2up.html:
>
> Items
>
> 
>     
> 
> 
>     
> 
>
> templates-hidden/standard-item-template.html:
>
> 
>
> 
>     
> 
>
> 
>
> I fear I'm not quite understanding what you're looking for, though.
>
> -Ross
>
> On Dec 23, 2009, at 9:43 PM,AlexBlackwrote:
>
>
>
> > Hi Ross, I am learning more about Lift every day :)
>
> > Reflecting that last point back to you, if I make it just one snippet
> > call, then that snippet call can pass parameters to inner snippet
> > functions, e.g. first or second.
>
> > So, that works, but I as you mentioned, I think that snippet will get
> > complex.  You then pointed out it can be broken into sub snippet
> > calls, which helps, but I still feel like we'd have this big complex
> > snippet call that is tightly coupled to the big complex xhtml block.
> > E.g. it'd be like doing an entire page in one snippet call instead of
> > lots of little ones.
>
> > Btw, the 'blocks' I keep referring to are product (camera)
> > specifications, so its like we're displaying two products on one page.
>
> > I had an idea, could the first snippet set a requestVar for the
> > current item, then the other snippet calls read that? e.g.
>
> > Items
>
> > 
> > 
> > 
> >  
> >    
> >  
> > 
> > 
> > 
>
> > // Emit the block twice, once for each item (first,second).
> > def firstAndSecond(xhtml: NodeSeq): NodeSeq = {
> >  List(first,second).flatMap( item => renderItem(xhtml, item) )
> > }
>
> > def renderItem( xhtml: NodeSeq, item: Item): NodeSeq = {
> >  _currentItem(item)
> >   // do stuff
> > }
>
> > def points( xhtml: NodeSeq ): NodeSeq = {
> >   // do stuff based on _currentItem.is
> > }
>
> > -Alex
>
> > On Dec 23, 5:05 pm, Ross Mellgren  wrote:
> >> So, with nested snippets you have two basic execution model options:
>
> >>    1) the default, the inner snippets get executed after the outer  
> >> snippet has executed completely. the outer snippet sees as it's  
> >> content the original content from the template, complete with  
> >> lift:Item.points tags and so on.
> >>    2) when eager_eval="true" is specified on the outer snippet, the  
> >> inner snippets get executed completely before the outer snippet gets  
> >> executed. the outer snippet sees the _result_ of processing the  
> >> children from the template, so it sees whatever the lift:Item.points  
> >> snippet gives back.
>
> >> So, this means that fundamentally you couldn't tell the inner snippet  
> >> which is the current one, without rewriting the call to the inner  
> >> snippet (e.g. find the  tag and write in an  
> >> attribute -- this seems like a grody hack)
>
> >> If you really want an inner snippet running _during_ the processing of  
> >> the outer snippet, I think you need to do that  
> >>

[Lift] Re: Advanced lift binding, parameters?

2009-12-23 Thread Alex Black
Hi Ross, I am learning more about Lift every day :)

Reflecting that last point back to you, if I make it just one snippet
call, then that snippet call can pass parameters to inner snippet
functions, e.g. first or second.

So, that works, but I as you mentioned, I think that snippet will get
complex.  You then pointed out it can be broken into sub snippet
calls, which helps, but I still feel like we'd have this big complex
snippet call that is tightly coupled to the big complex xhtml block.
E.g. it'd be like doing an entire page in one snippet call instead of
lots of little ones.

Btw, the 'blocks' I keep referring to are product (camera)
specifications, so its like we're displaying two products on one page.

I had an idea, could the first snippet set a requestVar for the
current item, then the other snippet calls read that? e.g.

Items




  

  




// Emit the block twice, once for each item (first,second).
def firstAndSecond(xhtml: NodeSeq): NodeSeq = {
  List(first,second).flatMap( item => renderItem(xhtml, item) )
}

def renderItem( xhtml: NodeSeq, item: Item): NodeSeq = {
  _currentItem(item)
   // do stuff
}

def points( xhtml: NodeSeq ): NodeSeq = {
   // do stuff based on _currentItem.is
}

- Alex

On Dec 23, 5:05 pm, Ross Mellgren  wrote:
> So, with nested snippets you have two basic execution model options:
>
>    1) the default, the inner snippets get executed after the outer  
> snippet has executed completely. the outer snippet sees as it's  
> content the original content from the template, complete with  
> lift:Item.points tags and so on.
>    2) when eager_eval="true" is specified on the outer snippet, the  
> inner snippets get executed completely before the outer snippet gets  
> executed. the outer snippet sees the _result_ of processing the  
> children from the template, so it sees whatever the lift:Item.points  
> snippet gives back.
>
> So, this means that fundamentally you couldn't tell the inner snippet  
> which is the current one, without rewriting the call to the inner  
> snippet (e.g. find the  tag and write in an  
> attribute -- this seems like a grody hack)
>
> If you really want an inner snippet running _during_ the processing of  
> the outer snippet, I think you need to do that  
> processSurroundAndInclude thing in the outer snippet code.
>
> If you're not tied to the inner snippet, then omit it, like this:
>
> class Item extends DispatchSnippet {
>      val dispatch: DispatchIt = {
>          case "firstAndSecond" => firstAndSecond
>      }
>
>      def firstAndSecond(ns: NodeSeq): NodeSeq =
>          List(("first", firstSeqOfThings), ("second",  
> secondSeqOfThings)).flatMap {
>              case (label, items) =>
>                  bind("item", ns,
>                       "which" -> label,
>                       "points" -> { (ns: NodeSeq) => items.flatMap  
> { item =>
>                           bind("point", ns, "name" -> item.name)
>                       })
>          }
>
> }
>
> And the template would be:
>
> Items
>
> 
>      
>      
>          
>              
>          
>      
>      
> 
>
> If you're concerned about embedding so much code in the snippet (which  
> seems to be why you want to break into multiple snippets?) then just  
> break them out into separate functions, like I showed you in the  
> foreach example.
>
> I think it helps to remember that snippets are really just XML -> XML  
> functions, and there's little special about them other than that they  
> can be named in templates. You can always call snippets from other  
> snippets directly (e.g. (new MySnippet).thatSnippet(nodes)), though if  
> you use any stateful stuff in those snippets that depends on the  
> current expansion point (e.g. S.attr) then you'd need to break the  
> snippet into two pieces, e.g.
>
> class MySnippet extends DispatchSnippet {
>      val dispatch: DispatchIt = {
>          case "foobar" => foobar
>      }
>
>      def foobar(ns: NodeSeq): NodeSeq = {
>          S.attr("itemId").map(lookupItemById _) match {
>              case Full(item) => foobar(item)(ns)
>              case _ => error("could not find item -- itemId attribute  
> not given or invalid")
>          }
>      }
>
>      def foobar(item: ItemModel)(ns: NodeSeq): NodeSeq =
>          bind(...)
>
> }
>
> Now if you're calling from template, you say  itemId="1234">..., but if you're in some other  
> snippet you say MySnippet.foobar(theItem)(...)
>
> Hope that helps,
> -Ross
>
>

[Lift] Re: Advanced lift binding, parameters?

2009-12-23 Thread Alex Black
Thanks Ross, I think I get that.. I'm not seeing the full picture yet,
let me show a bit more of my thinking:

So, extending my previous example, I'd like to write it like this:

Items




  

  




// Emit the block twice, once for each item (first,second).
def firstAndSecond(xhtml: NodeSeq): NodeSeq = {
  List(first,second).flatMap( item => renderItem(xhtml, item) )
}

How then do I implement Item.picture, Item.points to know *which* item
is currently being rendered?

thx

- Alex






On Dec 23, 4:18 pm, Ross Mellgren  wrote:
> S.attr gives you attributes of the current snippet calling tag, e.g.
>
> class Item extends DispatchSnippet {
>      val dispatch: DispatchIt = {
>          case "points" => points
>      }
>
>      def points(ns: NodeSeq): NodeSeq = {
>          val points = S.attr("item") match {
>              case Full("first") => loadFirstListOfPoints()
>              case Full("second") => loadSecondListOfPoints()
>              case _ => error("missing item attribute or has incorrect  
> value")
>          }
>
>          bind(...)
>      }
>
> }
>
> -Ross
>
> On Dec 23, 2009, at 4:07 PM, Alex Black wrote:
>
> > I've got some xhtml blocks in one of my templates that are basically
> > identical, and I'd like to avoid the duplication, by either writing
> > the block once in my template and using a snippet to write it out
> > twice (with different values) or put it in its own template.
>
> > Items
>
> > First
> > 
> >  
> >    
> >  
> > 
> > 
>
> > Second
> > 
> >  
> >    
> >  
> > 
> > 
>
> > My question is: If I write this block once, and surround it in a
> > snippet which emits it twice, how can the snippet parameterize the
> > nested snippet calls?
>
> > I realize I could bind the entire block with one snippet call, but
> > because my real blocks are big and complex I'd like to keep the many
> > snippet calls per block.
>
> > So, more specifically, how can i write  and
> >  more like this:  > item="@curItem">
>
> > thx
>
> > - Alex
>
> > --
>
> > You received this message because you are subscribed to the Google  
> > Groups "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en
> > .

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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 binding: is ChooseTemplate always necessary with nested tags?

2009-12-23 Thread Alex Black
Slick, thats perfect, thanks.

On Dec 23, 4:16 pm, Ross Mellgren  wrote:
> bind("alsoKnownAs", in, "list" -> { (ns: NodeSeq) => bind("list", ns,  
> "label" -> ... ) })
>
> -Ross
>
> On Dec 23, 2009, at 3:59 PM, Alex Black wrote:
>
> > I've got this xhtml in my template:
>
> > 
> >  Also known as:
> >  
> >    
> >      
> >    
> >  
> > 
>
> > with this snippet code:
>
> > def alsoKnownAs( xhtml: NodeSeq, product: Product): NodeSeq =  {
> >    def list( xhtml: NodeSeq, product: Product): NodeSeq = {
> >      product
> >        .alternateLabels
> >        .flatMap( l =>
> >          bind("list", xhtml,
> >                "label" -> l
> >          )
> >        )
> >    }
>
> >    product.alternateLabels match {
> >      // Remove the entire block (including title if there are no
> > alternate labels)
> >      case Nil => Nil
> >      case _ => bind("alsoKnownAs", xhtml, "list" -> list
> > (chooseTemplate("alsoKnownAs","list", xhtml), product))
> >    }
> >  }
>
> > This works well:
> > - The entire XHTML is removed if there are no alternateLabels
> > - If there are alternateLabels, the "Also known as:" text is not
> > repeated, just the LI elements in the list
>
> > However, in my bind call:
>
> >      case _ => bind("alsoKnownAs", xhtml, "list" -> list
> > (chooseTemplate("alsoKnownAs","list", xhtml), product))
>
> > I specified alsoKnownAs:list twice, it feels a bit redundant... The
> > intent of the code is: find the thing called alsoKnownAs:list, grab
> > the xhtml below it, pass it into the list function, and replace its
> > value with the output of list.
>
> > Is there some trick I'm missing here to avoid specifying things twice?
>
> > Just curious - the solution is pretty elegant as is.
>
> > - Alex
>
> > --
>
> > You received this message because you are subscribed to the Google  
> > Groups "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en
> > .

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] Advanced lift binding, parameters?

2009-12-23 Thread Alex Black
I've got some xhtml blocks in one of my templates that are basically
identical, and I'd like to avoid the duplication, by either writing
the block once in my template and using a snippet to write it out
twice (with different values) or put it in its own template.

Items

First

  

  



Second

  

  



My question is: If I write this block once, and surround it in a
snippet which emits it twice, how can the snippet parameterize the
nested snippet calls?

I realize I could bind the entire block with one snippet call, but
because my real blocks are big and complex I'd like to keep the many
snippet calls per block.

So, more specifically, how can i write  and
 more like this: 

thx

- Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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 binding: is ChooseTemplate always necessary with nested tags?

2009-12-23 Thread Alex Black
I missed a bit of code, probably not relevant, but just in case
someone notices the issue:

  def loserAlsoKnownAs( xhtml: NodeSeq ): NodeSeq = {
alsoKnownAs(xhtml, loser)
  }

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] Lift binding: is ChooseTemplate always necessary with nested tags?

2009-12-23 Thread Alex Black
I've got this xhtml in my template:


  Also known as:
  

  

  


with this snippet code:

def alsoKnownAs( xhtml: NodeSeq, product: Product): NodeSeq =  {
def list( xhtml: NodeSeq, product: Product): NodeSeq = {
  product
.alternateLabels
.flatMap( l =>
  bind("list", xhtml,
"label" -> l
  )
)
}

product.alternateLabels match {
  // Remove the entire block (including title if there are no
alternate labels)
  case Nil => Nil
  case _ => bind("alsoKnownAs", xhtml, "list" -> list
(chooseTemplate("alsoKnownAs","list", xhtml), product))
}
  }

This works well:
- The entire XHTML is removed if there are no alternateLabels
- If there are alternateLabels, the "Also known as:" text is not
repeated, just the LI elements in the list

However, in my bind call:

  case _ => bind("alsoKnownAs", xhtml, "list" -> list
(chooseTemplate("alsoKnownAs","list", xhtml), product))

I specified alsoKnownAs:list twice, it feels a bit redundant... The
intent of the code is: find the thing called alsoKnownAs:list, grab
the xhtml below it, pass it into the list function, and replace its
value with the output of list.

Is there some trick I'm missing here to avoid specifying things twice?

Just curious - the solution is pretty elegant as is.

- Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Sitemap - rendering "title" attributes for the links

2009-12-23 Thread Alex Black
Hi Xuefeng, I think will produce 1 tooltip for the entire sitemap,
what i'm looking for is a tooltip for each link in the sitemap.

On Dec 21, 11:39 pm, Xuefeng Wu  wrote:
> Sorry I misunderstand you.
>
> And I do not know how to too.
>
> Maybe you should use
> 
> instead of 
>
>
>
> On Tue, Dec 22, 2009 at 11:29 AM, Alex Black  wrote:
> > Hi Xuefeng,
>
> > I'm using the default Lift Sitemap, so I don't think I can use either
> > of your suggestions, or, I don't see how to use them.  The sitemap
> > renders the links for me... I have seen how to set the class of the
> > elements that it renders, but not how to add other attributes such as
> > title.
>
> > - Alex
>
> > > You could add MetaData 'title' by Elem 's method '%'
> > > some page % ("title" -> "what will happen when you
> > click
> > > on this
> > > link")
>
> > > or use { }
> > > some page
>
> > > On Mon, Dec 21, 2009 at 10:38 PM, Alex Black  wrote:
> > > > Can someone point me in the right direction to get tooltips (title
> > > > attributes) rendered in my sitemap?
>
> > > > I'd like to add text to each link, so they get rendered like this:
>
> > > > some page
>
> > > > thx
>
> > > > - Alex
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Lift" group.
> > > > To post to this group, send email to lift...@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.
>
> > > --
> > > Scala中文社区:  http://groups.google.com/group/scalacn
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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.
>
> --
> Scala中文社区:  http://groups.google.com/group/scalacn

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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 and chunked transfer-encoding

2009-12-22 Thread Alex Black
That could definitely work.

I'd still (even for curiosity's sake) be interested in lower level
access to the response, e.g. response.write that goes right out to the
client.

On Dec 22, 7:36 pm, David Pollak 
wrote:
> On Tue, Dec 22, 2009 at 4:28 PM, Alex Black  wrote:
> > Hi David,
>
> > Its a huge-ass google sitemap, so I'm forming XML for it, and its
> > really large, and I thought I'd send chunks of it out at a time rather
> > than composing all of it in RAM before sending it out.
>
> How about composing it as a big file on disk and use the StreamingResponse
> class?
>
>
>
>
>
>
>
> > - Alex
>
> > On Dec 22, 5:56 pm, David Pollak 
> > wrote:
> > > On Tue, Dec 22, 2009 at 2:38 PM, Alex Black  wrote:
> > > > I've got a large response I'd like to send out, and I'd like to chunk
> > > > it up.
>
> > > >http://en.wikipedia.org/wiki/Chunked_transfer_encoding
>
> > > > Does Lift provide any built in support for this?
>
> > > No.
>
> > > > I've explored using StreamingResponse, but it expects a dataLength,
> > > > which I don't have.  I had hoped to provide it a stream which would
> > > > provide each chunk.
>
> > > > Is there a lower level mechanism to write data out?
>
> > > Not really.  Can you describe your use case a little more?  For very
> > large
> > > responses (e.g., a large PDF), in what case would you not know the
> > length?
>
> > > > - Alex
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Lift" group.
> > > > To post to this group, send email to lift...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > liftweb+unsubscr...@googlegroups.com > > >  >
> >  > s.com>>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/liftweb?hl=en.
>
> > > --
> > > Lift, the simply functional web frameworkhttp://liftweb.net
> > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > Follow me:http://twitter.com/dpp
> > > Surf the harmonics
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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 and chunked transfer-encoding

2009-12-22 Thread Alex Black
Hi David,

Its a huge-ass google sitemap, so I'm forming XML for it, and its
really large, and I thought I'd send chunks of it out at a time rather
than composing all of it in RAM before sending it out.

- Alex

On Dec 22, 5:56 pm, David Pollak 
wrote:
> On Tue, Dec 22, 2009 at 2:38 PM, Alex Black  wrote:
> > I've got a large response I'd like to send out, and I'd like to chunk
> > it up.
>
> >http://en.wikipedia.org/wiki/Chunked_transfer_encoding
>
> > Does Lift provide any built in support for this?
>
> No.
>
>
>
> > I've explored using StreamingResponse, but it expects a dataLength,
> > which I don't have.  I had hoped to provide it a stream which would
> > provide each chunk.
>
> > Is there a lower level mechanism to write data out?
>
> Not really.  Can you describe your use case a little more?  For very large
> responses (e.g., a large PDF), in what case would you not know the length?
>
>
>
>
>
>
>
> > - Alex
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] Lift and chunked transfer-encoding

2009-12-22 Thread Alex Black
I've got a large response I'd like to send out, and I'd like to chunk
it up.

http://en.wikipedia.org/wiki/Chunked_transfer_encoding

Does Lift provide any built in support for this?

I've explored using StreamingResponse, but it expects a dataLength,
which I don't have.  I had hoped to provide it a stream which would
provide each chunk.

Is there a lower level mechanism to write data out?

- Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Sitemap - rendering "title" attributes for the links

2009-12-21 Thread Alex Black
Hi Xuefeng,

I'm using the default Lift Sitemap, so I don't think I can use either
of your suggestions, or, I don't see how to use them.  The sitemap
renders the links for me... I have seen how to set the class of the
elements that it renders, but not how to add other attributes such as
title.

- Alex

> You could add MetaData 'title' by Elem 's method '%'
> some page % ("title" -> "what will happen when you click
> on this
> link")
>
> or use { }
> some page
>
>
>
> On Mon, Dec 21, 2009 at 10:38 PM, Alex Black  wrote:
> > Can someone point me in the right direction to get tooltips (title
> > attributes) rendered in my sitemap?
>
> > I'd like to add text to each link, so they get rendered like this:
>
> > some page
>
> > thx
>
> > - Alex
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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.
>
> --
> Scala中文社区:  http://groups.google.com/group/scalacn

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] Sitemap - rendering "title" attributes for the links

2009-12-21 Thread Alex Black
Can someone point me in the right direction to get tooltips (title
attributes) rendered in my sitemap?

I'd like to add text to each link, so they get rendered like this:

some page

thx

- Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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_successRegisterGC()

2009-12-16 Thread Alex Black
Heh.  We're only using basic templates/snippets, and url rewriting/
dispatching.  We're not using lift forms, ajax, comet, mapper etc.  We
just wanted a templating engine that worked well with Scala, and Lift
seems to do that pretty nicely

I'm stubborn - I'm holding to my views that web servers should be as
stateless as possible - using state for callbacks doesn't sit well
with me, yet.

- Alex

On Dec 16, 4:35 pm, David Pollak 
wrote:
> On Wed, Dec 16, 2009 at 1:30 PM, Alex Black  wrote:
> > cool, thanks for the info. We're not using those features yet, so
> > we'll leave this off for now.
>
> If you're not "using those features" what part of Lift are you using?
>
> Can you send the raw HTML (via view source in your browser) of a page?  I'm
> betting that you're using some GUID <-> function stuff... it's pretty hard
> not to in Lift.
>
>
>
>
>
> > On Dec 16, 4:03 pm, David Pollak 
> > wrote:
> > > On Wed, Dec 16, 2009 at 5:56 AM, Alex Black  wrote:
> > > > > Are you using any Comet or Ajax or any Lift generated form elements?
> >  If
> > > > you
> > > > > are using any of these (anything where Lift is storing a function on
> > the
> > > > > server-side and presenting the function as a GUID on the client
> > side),
> > > > then
> > > > > it is strongly advised that you enable GC.
>
> > > To disable Garbage Collection:
>
> > > LiftRules.enableLiftGC = false
>
> > > Each GUID that's shipped to the client for form callbacks, Comet
> > callbacks,
> > > Ajax callbacks, JSON callbacks, etc. is associated with a function.  That
> > > function is stored in a session-specific table that maps from GUIDs to
> > > functions.  Without garbage collection, the functions associated with the
> > > GUIDs build up for the duration of a given session.  The can be memory
> > > intensive.  So, we've implemented a mechanism where every 75 seconds (a
> > > tunable parameter), the browser does an Ajax call to the server saying
> > "page
> > > " is still live.  All GUIDs associated with that page are "kept
> > > around."  If a GUID hasn't been seen on a page in 10 minutes and is not
> > > associated with a Comet component that's still live, then the function is
> > > removed from the GUID mapping table and will ultimately be removed from
> > > memory by the JVM garbage collector.
>
> > > > We're not using Comet or Lift generated form elements.  We are using a
> > > > jQuery plugin to do autocomplete which uses ajax. Can you tell me a
> > > > bit more about GC, is it a jQuery thing?
>
> > > > I've turned off auto ajax also:
>
> > > >  // For now, disable all Lift ajax stuff
> > > >    LiftRules.autoIncludeAjax = session => false
>
> > > > So, I get this error on every page:
>
> > > > Error: lift_successRegisterGC is not defined
>
> > > > and this error on pages that don't use jQuery:
>
> > > > Error: jQuery is not defined
>
> > > > > > Thanks!
>
> > > > > > - Alex
>
> > > > > > --
>
> > > > > > You received this message because you are subscribed to the Google
> > > > Groups
> > > > > > "Lift" group.
> > > > > > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> > > > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > > > Follow me:http://twitter.com/dpp
> > > > > Surf the harmonics
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Lift" group.
> > > > To post to this group, send email to lift...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > liftweb+unsubscr...@googlegroups.com
> > 
>
> > > > .
> > > > For more options, visit this group at

[Lift] Re: lift_successRegisterGC()

2009-12-16 Thread Alex Black
cool, thanks for the info. We're not using those features yet, so
we'll leave this off for now.

On Dec 16, 4:03 pm, David Pollak 
wrote:
> On Wed, Dec 16, 2009 at 5:56 AM, Alex Black  wrote:
> > > Are you using any Comet or Ajax or any Lift generated form elements?  If
> > you
> > > are using any of these (anything where Lift is storing a function on the
> > > server-side and presenting the function as a GUID on the client side),
> > then
> > > it is strongly advised that you enable GC.
>
> To disable Garbage Collection:
>
> LiftRules.enableLiftGC = false
>
> Each GUID that's shipped to the client for form callbacks, Comet callbacks,
> Ajax callbacks, JSON callbacks, etc. is associated with a function.  That
> function is stored in a session-specific table that maps from GUIDs to
> functions.  Without garbage collection, the functions associated with the
> GUIDs build up for the duration of a given session.  The can be memory
> intensive.  So, we've implemented a mechanism where every 75 seconds (a
> tunable parameter), the browser does an Ajax call to the server saying "page
> " is still live.  All GUIDs associated with that page are "kept
> around."  If a GUID hasn't been seen on a page in 10 minutes and is not
> associated with a Comet component that's still live, then the function is
> removed from the GUID mapping table and will ultimately be removed from
> memory by the JVM garbage collector.
>
>
>
> > We're not using Comet or Lift generated form elements.  We are using a
> > jQuery plugin to do autocomplete which uses ajax. Can you tell me a
> > bit more about GC, is it a jQuery thing?
>
> > I've turned off auto ajax also:
>
> >  // For now, disable all Lift ajax stuff
> >    LiftRules.autoIncludeAjax = session => false
>
> > So, I get this error on every page:
>
> > Error: lift_successRegisterGC is not defined
>
> > and this error on pages that don't use jQuery:
>
> > Error: jQuery is not defined
>
> > > > Thanks!
>
> > > > - Alex
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Lift" group.
> > > > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > Follow me:http://twitter.com/dpp
> > > Surf the harmonics
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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_successRegisterGC()

2009-12-16 Thread Alex Black
I found this in another thread:

LiftRules.enableLiftGC = false


On Dec 16, 12:55 pm, Alex Black  wrote:
> Hi David, is there a way to turn off the output of this javascript
> code?
>
> On Dec 16, 8:51 am, David Pollak 
> wrote:
>
> > On Wed, Dec 16, 2009 at 5:47 AM, Alex Black  wrote:
> > > I see the following javascript on each of my pages in my site:
>
> > > // 
>
> > > I don't think its necessary for what I'm doing, is there a way to turn
> > > off this feature?
>
> > Are you using any Comet or Ajax or any Lift generated form elements?  If you
> > are using any of these (anything where Lift is storing a function on the
> > server-side and presenting the function as a GUID on the client side), then
> > it is strongly advised that you enable GC.
>
> > > Thanks!
>
> > > - Alex
>
> > > --
>
> > > You received this message because you are subscribed to the Google Groups
> > > "Lift" group.
> > > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > Follow me:http://twitter.com/dpp
> > Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Please review a simple app for displaying Flickr pictures

2009-12-16 Thread Alex Black
Hey Dave, great site, beautiful photography.

If you had time you might add some URL rewriting, so that galleries
had nice urls like:

http://briccettiphoto.com/show/galleries/kenya

- Alex

On Dec 13, 1:44 am, Dave Briccetti  wrote:
> For a lightning talk at Bay Area Scala Enthusiasts at Twitter HQ
> Monday, I will show BirdShow, a Lift application that shows photos
> from Flickr. The current instantiation is a nature photography Web
> site. Would some of you Lift experts be willing to review the code and
> comment on the application? I want this to be an example of good Scala
> and Lift coding. I will gladly acknowledge your help in the
> presentation.
>
> http://briccettiphoto.comhttp://github.com/dcbriccetti/bird-show

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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_successRegisterGC()

2009-12-16 Thread Alex Black
Hi David, is there a way to turn off the output of this javascript
code?

On Dec 16, 8:51 am, David Pollak 
wrote:
> On Wed, Dec 16, 2009 at 5:47 AM, Alex Black  wrote:
> > I see the following javascript on each of my pages in my site:
>
> > // 
>
> > I don't think its necessary for what I'm doing, is there a way to turn
> > off this feature?
>
> Are you using any Comet or Ajax or any Lift generated form elements?  If you
> are using any of these (anything where Lift is storing a function on the
> server-side and presenting the function as a GUID on the client side), then
> it is strongly advised that you enable GC.
>
>
>
>
>
> > Thanks!
>
> > - Alex
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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_successRegisterGC()

2009-12-16 Thread Alex Black
> Are you using any Comet or Ajax or any Lift generated form elements?  If you
> are using any of these (anything where Lift is storing a function on the
> server-side and presenting the function as a GUID on the client side), then
> it is strongly advised that you enable GC.

We're not using Comet or Lift generated form elements.  We are using a
jQuery plugin to do autocomplete which uses ajax. Can you tell me a
bit more about GC, is it a jQuery thing?

I've turned off auto ajax also:

 // For now, disable all Lift ajax stuff
LiftRules.autoIncludeAjax = session => false

So, I get this error on every page:

Error: lift_successRegisterGC is not defined

and this error on pages that don't use jQuery:

Error: jQuery is not defined




>
>
>
>
>
> > Thanks!
>
> > - Alex
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] lift_successRegisterGC()

2009-12-16 Thread Alex Black
I see the following javascript on each of my pages in my site:

// 

I don't think its necessary for what I'm doing, is there a way to turn
off this feature?

Thanks!

- Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Mapping virtual directories

2009-12-14 Thread Alex Black
Hi Tim, thanks for the suggestions.

I'm new to Jetty etc, so bear with me, but, in your first suggestion,
we're basically telling Lift to ignore those requests.  Once they are
ignored, how do I tell Jetty to look in the mapped folder? Would I
write my own servlet?

Thanks!

- Alex

On Dec 14, 1:21 pm, Timothy Perrett  wrote:
> Two options as I see it. One is:
>
>     LiftRules.liftRequest.prepend {
>       case Req("your" :: "path" :: Nil, "pdf", GetRequest) => false
>     }
>
> This will make lift ignore the request path and the servlet container (jetty 
> in this instance) will serve it. Option 2 is to put a front end rewrite in on 
> your webserver / reverse proxy.
>
> Personally, the former is more portable so tends to be what I do.
>
> Cheers, Tim
>
> On 14 Dec 2009, at 18:06, Alex Black wrote:
>
> > Can anyone recommend a way to map a virtual directory in Jetty/Lift?
> > E.g. I'd like "/images" to point to a file system location that is not
> > in my project.
>
> > Is there a simple Jetty mechanism, or Lift configuration for this type
> > of thing?
>
> > Thx!
>
> > - Alex
>
> > --
>
> > You received this message because you are subscribed to the Google Groups 
> > "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en.

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] Mapping virtual directories

2009-12-14 Thread Alex Black
Can anyone recommend a way to map a virtual directory in Jetty/Lift?
E.g. I'd like "/images" to point to a file system location that is not
in my project.

Is there a simple Jetty mechanism, or Lift configuration for this type
of thing?

Thx!

- Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: How can one bind value-less attributes?

2009-12-07 Thread Alex Black
Thanks for the help on this guys, looks promising.

On Dec 7, 12:57 pm, Ross Mellgren  wrote:
> Sha-bam
>
> http://github.com/dpp/liftweb/issues/#issue/229
>
> -Ross
>
> On Dec 7, 2009, at 12:43 PM, David Pollak wrote:
>
> > Is there a ticket for this?  I'm in ticket-closing mode today ;-)
>
> > On Mon, Dec 7, 2009 at 9:29 AM, Ross Mellgren   
> > wrote:
> > I looked at adding a Box variant, but it wasn't a strictly speaking  
> > trivial change since calcValue on BindParam is of type NodeSeq. I  
> > guess it could become Box[NodeSeq] and then when binding at element  
> > positions convert that to NodeSeq.Empty, but I also have had the  
> > need (which I've worked around) to be able to replace a single bound  
> > attribute with multiple result attributes, so I was thinking that it  
> > would be best to allow AttrBindParams to generate MetaData, not just  
> > a value.
>
> > I had written some code to play with this idea, but I didn't get too  
> > far because I was busy and needed feedback from other committers. I  
> > can return it to working tonight if there's interest.
>
> > -Ross
>
> > On Dec 7, 2009, at 12:22 PM, Alex Boisvert wrote:
>
> >> On Sun, Dec 6, 2009 at 8:28 PM, David Pollak  >> > wrote:
>
> >> On Sun, Dec 6, 2009 at 7:25 PM, Alex Boisvert  >> > wrote:
> >> Using the latest and greatest (master branch), I can't reproduce  
> >> the MatchError but I can reproduce the issue with the attribute  
> >> being generated if the value is null.
>
> >> How about adding a Box alternative rather than perpetuating a  
> >> paradigm based on null?
>
> >> Yes, that's better.  I'll do that.
>
> >> [Side diatribe:  Can't wait for a working scala.NotNull so we can  
> >> implicitly convert (non-null) literal values to Some() or Full()  
> >> instance and reduce verbosity]
>
> >> alex
>
> >> --
>
> >> You received this message because you are subscribed to the Google  
> >> Groups "Lift" group.
> >> To post to this group, send email to lift...@googlegroups.com.
> >> To unsubscribe from this group, send email to 
> >> liftweb+unsubscr...@googlegroups.com
> >> .
> >> For more options, visit this group 
> >> athttp://groups.google.com/group/liftweb?hl=en
> >> .
>
> > --
>
> > You received this message because you are subscribed to the Google  
> > Groups "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en
> > .
>
> > --
> > Lift, the simply functional web frameworkhttp://liftweb.net
> > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > Follow me:http://twitter.com/dpp
> > Surf the harmonics
>
> > --
>
> > You received this message because you are subscribed to the Google  
> > Groups "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en
> > .

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Sharing data between snippet functions during a single HTTP request

2009-12-07 Thread Alex Black
Its not causing me any issue at the moment, just figured it'd be
faster/more correct to call the constructor just once if only one
instance was needed.

- Alex

On Dec 7, 5:25 pm, David Pollak  wrote:
> On Mon, Dec 7, 2009 at 2:23 PM, Alex Black  wrote:
> > > How about starting with a Lift 1.1 project?
>
> > I'll give it a try. I was mimicking how I tried to upgrade my 1.0
> > project.
>
> > > Did you update the version of Scala?
>
> > Nope, it is a 2.7.3 in the pom.
>
> > Just now I updated it to 2.7.7, re-ran, and saw the same behaviour.
>
> > > What is the issue with the constructor being called repeatedly?
>
> > In my test the constructor is getting called with every snippet method
> > call from the same page.
>
> > Given that you'd described only one snippet is used for all those
> > calls, let me put the question back to you: why is the constructor
> > being called 18 times when once would have sufficed?
>
> If there is an actual issue, then identify it.  Throwing questions back at
> me doesn't really engender a lot of motivation for me to help.
>
>
>
> > > > and here is the output:
>
> > > > [INFO] Started Jetty Server
> > > > [INFO] Starting scanner at interval of 5 seconds.
> > > > Constructor
> > > > Constructor
> > > > INFO - Service request (GET) / took 393 Milliseconds
> > > > INFO - Service request (GET) /classpath/jquery.js took 39 Milliseconds
> > > > INFO - Service request (GET) /ajax_request/
> > > > liftAjax.js;jsessionid=11x3vru6uimmg took 11 Milliseconds
> > > > INFO - Service request (GET) /favicon.ico took 6 Milliseconds
> > > > INFO - Service request (POST) /ajax_request/F318697140471TRN/ took 11
> > > > Milliseconds
> > > > INFO - Service request (POST) /ajax_request/F318697140471TRN/ took 1
> > > > Milliseconds
>
> > > > Snippet code:
>
> > > > package com.liftcode.hello.snippet
>
> > > > class HelloWorld {
> > > >  println("Constructor")
>
> > > >  def howdy = Welcome to hello-lift at {new
> > > > _root_.java.util.Date}
> > > > }
>
> > > > index.html:
>
> > > > 
> > > >                Welcome to your project!
> > > >                 
> > > >                
> > > > 
>
> > > > Here is the pom.xml:
>
> > > > http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://
> > > >www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://
> > > > maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd";>
> > > >  4.0.0
> > > >  com.liftcode.hello
> > > >  hello-lift
> > > >  1.0-SNAPSHOT
> > > >  war
> > > >  hello-lift
> > > >  2007
> > > >  
> > > >    2.7.3
> > > >  
>
> > > >  
> > > >    
> > > >      scala-tools.org
> > > >      Scala-Tools Maven2 Repository
> > > >      http://scala-tools.org/repo-releases
> > > >    
> > > >  
>
> > > >  
> > > >    
> > > >      scala-tools.org
> > > >      Scala-Tools Maven2 Repository
> > > >      http://scala-tools.org/repo-releases
> > > >    
> > > >  
>
> > > >  
> > > >    
> > > >      org.scala-lang
> > > >      scala-library
> > > >      ${scala.version}
> > > >    
> > > >    
> > > >      net.liftweb
> > > >      lift-util
> > > >      1.1-M6
> > > >    
> > > >    
> > > >      net.liftweb
> > > >      lift-webkit
> > > >      1.1-M6
> > > >    
> > > >    
> > > >      javax.servlet
> > > >      servlet-api
> > > >      2.5
> > > >      provided
> > > >    
> > > >    
> > > >      junit
> > > >      junit
> > > >      4.5
> > > >      test
> > > >    
> > > >    
> > > >      org.mortbay.jetty
> > > >      jetty
> > > >      [6.1.6,)
> > > >      test
> > > >    
> > > >    
> > > >    
> > > >      org.scala-lang
> > > >      scala-compiler
> > > >      ${scala.version}
> > > >      tes

[Lift] Re: Sharing data between snippet functions during a single HTTP request

2009-12-07 Thread Alex Black
> How about starting with a Lift 1.1 project?

I'll give it a try. I was mimicking how I tried to upgrade my 1.0
project.

> Did you update the version of Scala?

Nope, it is a 2.7.3 in the pom.

Just now I updated it to 2.7.7, re-ran, and saw the same behaviour.

> What is the issue with the constructor being called repeatedly?

In my test the constructor is getting called with every snippet method
call from the same page.

Given that you'd described only one snippet is used for all those
calls, let me put the question back to you: why is the constructor
being called 18 times when once would have sufficed?

>
>
>
> > and here is the output:
>
> > [INFO] Started Jetty Server
> > [INFO] Starting scanner at interval of 5 seconds.
> > Constructor
> > Constructor
> > INFO - Service request (GET) / took 393 Milliseconds
> > INFO - Service request (GET) /classpath/jquery.js took 39 Milliseconds
> > INFO - Service request (GET) /ajax_request/
> > liftAjax.js;jsessionid=11x3vru6uimmg took 11 Milliseconds
> > INFO - Service request (GET) /favicon.ico took 6 Milliseconds
> > INFO - Service request (POST) /ajax_request/F318697140471TRN/ took 11
> > Milliseconds
> > INFO - Service request (POST) /ajax_request/F318697140471TRN/ took 1
> > Milliseconds
>
> > Snippet code:
>
> > package com.liftcode.hello.snippet
>
> > class HelloWorld {
> >  println("Constructor")
>
> >  def howdy = Welcome to hello-lift at {new
> > _root_.java.util.Date}
> > }
>
> > index.html:
>
> > 
> >                Welcome to your project!
> >                 
> >                
> > 
>
> > Here is the pom.xml:
>
> > http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://
> >www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://
> > maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd";>
> >  4.0.0
> >  com.liftcode.hello
> >  hello-lift
> >  1.0-SNAPSHOT
> >  war
> >  hello-lift
> >  2007
> >  
> >    2.7.3
> >  
>
> >  
> >    
> >      scala-tools.org
> >      Scala-Tools Maven2 Repository
> >      http://scala-tools.org/repo-releases
> >    
> >  
>
> >  
> >    
> >      scala-tools.org
> >      Scala-Tools Maven2 Repository
> >      http://scala-tools.org/repo-releases
> >    
> >  
>
> >  
> >    
> >      org.scala-lang
> >      scala-library
> >      ${scala.version}
> >    
> >    
> >      net.liftweb
> >      lift-util
> >      1.1-M6
> >    
> >    
> >      net.liftweb
> >      lift-webkit
> >      1.1-M6
> >    
> >    
> >      javax.servlet
> >      servlet-api
> >      2.5
> >      provided
> >    
> >    
> >      junit
> >      junit
> >      4.5
> >      test
> >    
> >    
> >      org.mortbay.jetty
> >      jetty
> >      [6.1.6,)
> >      test
> >    
> >    
> >    
> >      org.scala-lang
> >      scala-compiler
> >      ${scala.version}
> >      test
> >    
> >  
>
> >  
> >    src/main/scala
> >    src/test/scala
> >    
> >      
> >        org.scala-tools
> >        maven-scala-plugin
> >        
> >          
> >            
> >              compile
> >              testCompile
> >            
> >          
> >        
> >        
> >          ${scala.version}
> >        
> >      
> >      
> >        org.mortbay.jetty
> >        maven-jetty-plugin
> >        
> >          /
> >          5
> >        
> >      
> >      
> >        net.sf.alchim
> >        yuicompressor-maven-plugin
> >        
> >          
> >            
> >              compress
> >            
> >          
> >        
> >        
> >          true
> >        
> >      
> >      
> >        org.apache.maven.plugins
> >        maven-eclipse-plugin
> >        
> >          true
> >          
> >            org.scala-lang:scala-library
> >          
> >          
>
> > ch.epfl.lamp.sdt.launching.SCALA_CONTAINER > classpathContainer>
> >          
> >          
> >            ch.epfl.lamp.sdt.core.scalanature > java.lang.String>
> >            org.eclipse.jdt.core.javanature > java.lang.String>
> >

[Lift] Re: Sharing data between snippet functions during a single HTTP request

2009-12-07 Thread Alex Black
Hi David,

I just tried something similar out.
1. I created a blank 1.0 lift project
2. I updated the pom file to reference lift-1.1M6
3. I added a line to the hello world snippet in its body:
println("Constructor")
4. I modified index.html to call the snippet twice.
5. I then launched the web server (mvn jetty:run) and accessed the
main page once via a browser

The line println("Constructor") gets called twice, I expected it just
to get called once.

Am I doing something wrong? Your test is not exactly the same as the
problem I described, I described the constructor getting called 18
times, I haven't yet verified whether or not the data is shared.

and here is the output:

[INFO] Started Jetty Server
[INFO] Starting scanner at interval of 5 seconds.
Constructor
Constructor
INFO - Service request (GET) / took 393 Milliseconds
INFO - Service request (GET) /classpath/jquery.js took 39 Milliseconds
INFO - Service request (GET) /ajax_request/
liftAjax.js;jsessionid=11x3vru6uimmg took 11 Milliseconds
INFO - Service request (GET) /favicon.ico took 6 Milliseconds
INFO - Service request (POST) /ajax_request/F318697140471TRN/ took 11
Milliseconds
INFO - Service request (POST) /ajax_request/F318697140471TRN/ took 1
Milliseconds

Snippet code:

package com.liftcode.hello.snippet

class HelloWorld {
  println("Constructor")

  def howdy = Welcome to hello-lift at {new
_root_.java.util.Date}
}

index.html:


Welcome to your project!




Here is the pom.xml:

http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://
maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";>
  4.0.0
  com.liftcode.hello
  hello-lift
  1.0-SNAPSHOT
  war
  hello-lift
  2007
  
2.7.3
  

  

  scala-tools.org
  Scala-Tools Maven2 Repository
  http://scala-tools.org/repo-releases

  

  

  scala-tools.org
  Scala-Tools Maven2 Repository
  http://scala-tools.org/repo-releases

  

  

  org.scala-lang
  scala-library
  ${scala.version}


  net.liftweb
  lift-util
  1.1-M6


  net.liftweb
  lift-webkit
  1.1-M6


  javax.servlet
  servlet-api
  2.5
  provided


  junit
  junit
  4.5
  test


  org.mortbay.jetty
  jetty
  [6.1.6,)
  test



  org.scala-lang
  scala-compiler
  ${scala.version}
  test

  

  
src/main/scala
src/test/scala

  
org.scala-tools
maven-scala-plugin

  

  compile
  testCompile

  


  ${scala.version}

  
  
org.mortbay.jetty
maven-jetty-plugin

  /
  5

  
  
net.sf.alchim
yuicompressor-maven-plugin

  

  compress

  


  true

  
  
org.apache.maven.plugins
maven-eclipse-plugin

  true
  
org.scala-lang:scala-library
  
  
 
ch.epfl.lamp.sdt.launching.SCALA_CONTAINER
  
  
ch.epfl.lamp.sdt.core.scalanature
org.eclipse.jdt.core.javanature
  
  
ch.epfl.lamp.sdt.core.scalabuilder
  

  

  
  

  
org.scala-tools
maven-scala-plugin

  ${scala.version}

  

  




On Dec 7, 3:28 pm, David Pollak  wrote:
> On Sun, Dec 6, 2009 at 5:44 AM, Alex Black  wrote:
> > > We made this change for Lift 1.1.  So, if you're using 1.1, the same
> > > instance of a snippet should be used for a given HTTP request.
>
> > Hi David, I've just switch from Lift 1.0 to Lift 1.1-M6, do you think
> > this change is in M6?
>
> Yes.
>
> Snippet:
>
> class HelloWorld {
>   lazy val date: Box[Date] = DependencyFactory.inject[Date] // inject the
> date
>
>   val random = randomString(20)
>
>   def howdy(in: NodeSeq): NodeSeq =
>   Helpers.bind("b", in, "time" -> date.map(d => Text(d.toString)))
>
>   def dog: NodeSeq = String is {random}
>
>   def cat: NodeSeq = From cat String is {random}
>
> }
>
> View:
>
> 
>   Welcome to your project!
>        
>         Welcome to iscached at 
>       
>     
>
>      Dog sez 
>
>      Cat sez 
>
> 
>
> Browser:
>
> Welcome to your project!
>
>         Welcome to iscached at Mon Dec 07 12:26:41 PST 2009
>
>  Dog sez String is 4G2NRM4TBGCJBYNGFCUF
>
>  Cat sez From cat String is 4G2NRM4TBGCJBYNGFCUF
>
&

[Lift] Re: Sharing data between snippet functions during a single HTTP request

2009-12-07 Thread Alex Black
That looks like a great idea, thanks Harry, I didn't know you could
next stuff like that.

On Dec 7, 3:39 pm, harryh  wrote:
> Another strategy, different from what Ross suggests, that I have found
> useful in some circumstances.  In the view do this:
>
> 
>   
>     
>     
>   
>
>   
>     
>     
>   
> 
>
> Then
>
> class YourPage extends RenderSnippet {
>   def render(xhtml: NodeSeq) = {
>     val user = User.currentUser
>
>     def firstSection(xhtml: NodeSeq) = {
>       val foo = whatever
>       bind("firstsection", xhtml", "username" -> user.name, "foo" ->
> foo.name)
>     }
>
>     def secondSection(xhtml: NodeSeq) = {
>       val bar = whatever
>       bind("firstsection", xhtml", "username" -> user.name, "bar" ->
> bar.name)
>     }
>
>     bind("page", xhtml, "firstsection" -> firstSection _,
> "secondSection" -> secondSection)
>   }
>
> }

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: How can one bind value-less attributes?

2009-12-06 Thread Alex Black
> If you output null for theattributevalue, theattributeis not
> rendered:

I've just upgraded from 1.0 to 1.1-M6, and this doesn't seem to work
any more - could this be a bug in M6?

Message: scala.MatchError: null
scala.runtime.ScalaRunTime$.boxArray(ScalaRunTime.scala:136)
net.liftweb.util.BindHelpers$class.mix$1(BindHelpers.scala:612)
net.liftweb.util.BindHelpers$class.net$liftweb$util$BindHelpers$
$bindByNameMixIn(BindHelpers.scala:618)
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1$
$anonfun$apply$27.apply(BindHelpers.scala:440)
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind$1$1$
$anonfun$apply$27.apply(BindHelpers.scala:436)
net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind
$1$1.apply(BindHelpers.scala:436)
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind
$1$1.apply(BindHelpers.scala:424)
scala.Seq$class.flatMap(Seq.scala:294)
scala.xml.NodeSeq.flatMap(NodeSeq.scala:34)
net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1
(BindHelpers.scala:424)
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind
$1$1.apply(BindHelpers.scala:444)
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind
$1$1.apply(BindHelpers.scala:424)
scala.Seq$class.flatMap(Seq.scala:294)
scala.xml.NodeSeq.flatMap(NodeSeq.scala:34)
net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1
(BindHelpers.scala:424)
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind
$1$1.apply(BindHelpers.scala:444)
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind
$1$1.apply(BindHelpers.scala:424)
scala.Seq$class.flatMap(Seq.scala:294)
scala.xml.NodeSeq.flatMap(NodeSeq.scala:34)
net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1
(BindHelpers.scala:424)
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind
$1$1.apply(BindHelpers.scala:444)
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind
$1$1.apply(BindHelpers.scala:424)
scala.Seq$class.flatMap(Seq.scala:294)
scala.xml.NodeSeq.flatMap(NodeSeq.scala:34)
net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1
(BindHelpers.scala:424)
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind
$1$1.apply(BindHelpers.scala:444)
net.liftweb.util.BindHelpers$$anonfun$bind$2$$anonfun$in_bind
$1$1.apply(BindHelpers.scala:424)
scala.Seq$class.flatMap(Seq.scala:294)
scala.xml.NodeSeq.flatMap(NodeSeq.scala:34)
net.liftweb.util.BindHelpers$$anonfun$bind$2.in_bind$1
(BindHelpers.scala:424)
net.liftweb.util.BindHelpers$$anonfun$bind$2.apply(BindHelpers.scala:
449)
net.liftweb.util.BindHelpers$$anonfun$bind$2.apply(BindHelpers.scala:
409)
net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
net.liftweb.util.BindHelpers$class.bind(BindHelpers.scala:409)
net.liftweb.util.Helpers$.bind(Helpers.scala:29)
net.liftweb.util.BindHelpers$class.bind(BindHelpers.scala:380)
net.liftweb.util.Helpers$.bind(Helpers.scala:29)


>
> scala> bind("stuff", , 
> AttrBindParam("s",Text("checked"),"checked"))
> res11: scala.xml.NodeSeq = 
>
> scala> bind("stuff", , 
> AttrBindParam("s",null,"selected"))            
> res12: scala.xml.NodeSeq = 
>
> /Jeppe

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Sharing data between snippet functions during a single HTTP request

2009-12-06 Thread Alex Black
> We made this change for Lift 1.1.  So, if you're using 1.1, the same
> instance of a snippet should be used for a given HTTP request.

Hi David, I've just switch from Lift 1.0 to Lift 1.1-M6, do you think
this change is in M6? It doesn't seem to be... I have many calls to my
snippet for a particular page, and I put a println statement in the
body of the snippet, and it gets called 18 times each request!

- Alex


>
>
>
> > I'd imagine lift could even generate a requestVar representing each
> > snippet for the developers, allowing snippets in a given HTTP request
> > to access each other easily.
>
> I don't think this is technically possible within the bounds of the type
> system.
>
>
>
>
>
> > On Nov 20, 11:09 am, Ross Mellgren  wrote:
> > > RequestVar is the standard way of doing this. For example
>
> > > object MySharedInformation {
> > >      object myData extends RequestVar[List[Thing]](loadThings)
> > >      //                               ^^^  ^^
> > >      //                    Type of thing to store  How to initialize
> > > variable first time it's accessed
>
> > >      private def loadThings: List[Thing] = ...
>
> > > }
>
> > > class Snippet1 {
> > >      import MySharedInformation.myData
> > >      def render(ns: NodeSeq): NodeSeq = {
> > >          myData.is.map(thing => { ... })
> > >      }
>
> > > }
>
> > > class Snippet2 {
> > >      import MySharedInformation.myData
> > >      ...
>
> > > }
>
> > > The lifetime of the value is during the current request processing and
> > > any AJAX calls related to it.
>
> > > If you really want to initialize it in a snippet, then use a Box with
> > > a RequestVar, like this:
>
> > > object MySharedInformation {
> > >      object myData extends RequestVar[Box[List[Thing]]](Empty)
>
> > > }
>
> > > class LoaderSnippet {
> > >      import MySharedInformation.myData
> > >      def render(ns: NodeSeq): NodeSeq = {
> > >          myData.set(Full(...))
> > >      }
>
> > > }
>
> > > class ReaderSnippet {
> > >      import MySharedInformation.myData
> > >      def render(ns: NodeSeq): NodeSeq = {
> > >          // If the data has not been loaded, default to an empty list
> > >          val data = myData.is.openOr(Nil)
> > >          ...
> > >      }
>
> > > }
>
> > > class OtherReaderSnippet {
> > >      import MySharedInformation.myData
> > >      def render(ns: NodeSeq): NodeSeq = {
> > >          // Do two entirely different things if the data has versus
> > > has not been loaded
> > >          myData.is match {
> > >              case Full(data) => // do something when the data has been
> > > loaded
> > >              case _ => // do something when the data has not been loaded
> > >          }
> > >      }
>
> > > }
>
> > > HTH,
> > > -Ross
>
> > > On Nov 20, 2009, at 10:59 AM, Alex Black wrote:
>
> > > > I've got a template page, say foobar.html, that makes a number of
> > > > calls to functions in a snippet, e.g. mysnippet.foo1, mysnippet.foo2,
> > > > mysnippet.foo3.
>
> > > > I'd like to do some initial work in foo1, e.g. retrieve some data and
> > > > do some work on it, then in foo2 and foo3 display parts of that data.
>
> > > > Whats the easiest way to do this? I think I misunderstood the lift
> > > > book:
>
> > > > "That means that for each request, Lift creates a new instance of the
> > > > snippet class to execute. Any changes you make to instance variables
> > > > will be discarded after the request is processed."
>
> > > > I thought this meant that for a given HTTP request, there would be one
> > > > (and only one) instance of my snippet, so I could call several of its
> > > > methods and they could all access the snippet's member variables,
> > > > which would then be discarded at the end of the request.
>
> > > > Am I going about this wrong? should I only have one snippet function
> > > > per template?
>
> > > > Thx
>
> > > > - Alex
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Lift" group.
> > > > T

[Lift] Re: Spaces getting removed from title in head merge?

2009-12-03 Thread Alex Black
Thanks for the info - I'll look into trying out 1.1-M6.

On Dec 3, 4:11 pm, David Pollak  wrote:
> On Thu, Dec 3, 2009 at 12:19 PM, Alex Black  wrote:
> > Ah.. I've worked around the problem for now. If my snippet outputs
> > foo vs bar then the spaces don't get removed.
>
> > I'm waiting on 1.1 to be released before upgrading - but if there is a
> > stable release now I might try it out.
>
> In general, the 1.1-SNAPSHOT release is stable.  There have been a few rare
> cased where SNAPSHOT was not stable.
>
> 1.1-M6 is currently the most stable and best of the milestone releases.
>
> A fair number of high profile sites are running against M6 and M7.
>
> I strongly encourage you to use Lift 1.1, even though it is not officially
> released.
>
>
>
>
>
> > - Alex
>
> > On Dec 3, 3:16 pm, Ross Mellgren  wrote:
> > > Ohh, I created a 1.1-SNAPSHOT one. It's possible, I guess, I'm not
> > > terribly familiar with 1.0. Can you upgrade to 1.1-SNAPSHOT? It's
> > > better in practically every aspect :-)
>
> > > -Ross
>
> > > On Dec 3, 2009, at 3:14 PM, Alex Black wrote:
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Spaces getting removed from title in head merge?

2009-12-03 Thread Alex Black
Ah.. I've worked around the problem for now. If my snippet outputs
foo vs bar then the spaces don't get removed.

I'm waiting on 1.1 to be released before upgrading - but if there is a
stable release now I might try it out.

- Alex

On Dec 3, 3:16 pm, Ross Mellgren  wrote:
> Ohh, I created a 1.1-SNAPSHOT one. It's possible, I guess, I'm not  
> terribly familiar with 1.0. Can you upgrade to 1.1-SNAPSHOT? It's  
> better in practically every aspect :-)
>
> -Ross
>
> On Dec 3, 2009, at 3:14 PM, Alex Black wrote:
>
>

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Spaces getting removed from title in head merge?

2009-12-03 Thread Alex Black
I copy and pasted your template and snippet, and it reproduced the
problem for me... strange.

Keep in mind I am on Lift 1.0, is it possible this behaviour has
changed?

Here is the output from the template:



http://liftweb.net/"; xmlns="http://www.w3.org/1999/
xhtml">





foovsbar



Welcome to your project!





// <![CDATA[
jQuery(document).ready(function() {lift_successRegisterGC();});
var lift_page = 'F856614382395SNQ';
// ]]>




On Dec 3, 3:04 pm, Ross Mellgren  wrote:
> Hmm I can't reproduce it. Here's the whole template I used:
>
> 
>      
>          
>               vs 
>          
>      
>
>      Welcome to your project!
>      
>      
> 
>
> And snippet:
>
> class Compare {
>    def products(in: NodeSeq): NodeSeq =
>        Helpers.bind("compare", in, "product1" -> "foo", "product2" ->  
> "bar")
>
> }
>
> Any more of your surrounding code that might point out the problem?
>
> -Ross
>
> On Dec 3, 2009, at 2:48 PM, Alex Black wrote:
>
> > Here's the actual code:
>
> >    
> >            
> >       vs 
> >            
> >    
>
> > On Dec 3, 2:45 pm, Ross Mellgren  wrote:
> >> The example you posted isn't valid XML (needs to be  or
> >> something along those lines), so I'm wondering if you could post the
> >> actual example code? I can't think of any reason offhand those should
> >> be stripped.
>
> >> -Ross
>
> >> On Dec 3, 2009, at 2:41 PM, Alex Black wrote:
>
> >>> In one of my templates I have this:
>
> >>>    
> >>>    
> >>>       vs 
> >>>    
> >>>    
>
> >>> The XHTML output I get looks like this:
>
> >>>    
> >>>      Output1vsOutput2
> >>>    
>
> >>> Where hello:one is "Output1" and hello:two is "Output2", where did  
> >>> my
> >>> spaces go, between the items and the "vs"?
>
> >>> - Alex
>
> >>> --
>
> >>> You received this message because you are subscribed to the Google
> >>> Groups "Lift" group.
> >>> To post to this group, send email to lift...@googlegroups.com.
> >>> To unsubscribe from this group, send email to 
> >>> liftweb+unsubscr...@googlegroups.com
> >>> .
> >>> For more options, visit this group 
> >>> athttp://groups.google.com/group/liftweb?hl=en
> >>> .
>
> > --
>
> > You received this message because you are subscribed to the Google  
> > Groups "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en
> > .

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: Spaces getting removed from title in head merge?

2009-12-03 Thread Alex Black
Here's the actual code:



   vs 




On Dec 3, 2:45 pm, Ross Mellgren  wrote:
> The example you posted isn't valid XML (needs to be  or  
> something along those lines), so I'm wondering if you could post the  
> actual example code? I can't think of any reason offhand those should  
> be stripped.
>
> -Ross
>
> On Dec 3, 2009, at 2:41 PM, Alex Black wrote:
>
> > In one of my templates I have this:
>
> >    
> >    
> >       vs 
> >    
> >    
>
> > The XHTML output I get looks like this:
>
> >    
> >      Output1vsOutput2
> >    
>
> > Where hello:one is "Output1" and hello:two is "Output2", where did my
> > spaces go, between the items and the "vs"?
>
> > - Alex
>
> > --
>
> > You received this message because you are subscribed to the Google  
> > Groups "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en
> > .

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] Spaces getting removed from title in head merge?

2009-12-03 Thread Alex Black
In one of my templates I have this:




   vs 



The XHTML output I get looks like this:


  Output1vsOutput2


Where hello:one is "Output1" and hello:two is "Output2", where did my
spaces go, between the items and the "vs"?

- Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: How can one bind value-less attributes?

2009-12-02 Thread Alex Black
Thanks Jeppe, that works perfectly.

On Dec 2, 3:32 am, Jeppe Nejsum Madsen  wrote:
> Alex Black  writes:
> > Is there a good/reasonable way to conditionally output
> > checked="checked" or output nothing?
>
> If you output null for the attribute value, the attribute is not
> rendered:
>
> scala> bind("stuff", , 
> AttrBindParam("s",Text("checked"),"checked"))
> res11: scala.xml.NodeSeq = 
>
> scala> bind("stuff", , 
> AttrBindParam("s",null,"selected"))            
> res12: scala.xml.NodeSeq = 
>
> /Jeppe

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: How can one bind value-less attributes?

2009-12-01 Thread Alex Black
I appreciate the suggestion, I did think of that, but one of my goals
is to keep the XHTML out of my code..!

This seems a tough problem in general.. Ideally in snippets there
would be no presentation, just data I think, e.g. in this case a
boolean.  The XHTML template would then form the presentation of that
data, whether it be a checkbox or whatever.

Perhaps I'm approaching this from the wrong angle?

- Alex

On Dec 1, 6:55 pm, Alex Boisvert  wrote:
> Here's one way,
>
> Helpers.bind(...,
>   "myElement" -> (if (condition)  else  myAttribute="value"/>))
>
> I don't think there's a bind helper to conditionally output the attribute.
> Maybe our bind experts know.
>
> alex
>
> On Tue, Dec 1, 2009 at 3:29 PM, Alex Black  wrote:
> > Thanks Alex.  That would work, but I'm looking for a more generic
> > solution.
>
> > Restating the problem: Based on some condition I want to generate an
> > attribute or not generate an attribute, e.g.:
>
> > 
>
> > OR
>
> > 
>
> > - Alex
>
> > On Dec 1, 6:23 pm, Alex Boisvert  wrote:
> > > You can use SHtml.checkbox() to easily generate the checkbox,
>
> > > bind(...,
> > >   "checkbox" -> SHtml.checkbox(isChecked, checked => if (checked)
> > > doSomething())
> > > )
>
> > > The first parameter is whether the checkbox should be checked by default.
>
> > > The second parameter is a function to do something when form is
> > submitted.
>
> > > alex
>
> > > On Tue, Dec 1, 2009 at 2:50 PM, Alex Black  wrote:
> > > > Is there a good/reasonable way to conditionally output
> > > > checked="checked" or output nothing?
>
> > > > My code looks like this:
>
> > > >          bind("manufacturer", xhtml,
> > > >              AttrBindParam("selected", Text("selected"), "selected"))
>
> > > > I can add an if statement, and then output Text("notSelected")
> > > > instead, but that doesn't seem to work - the correct  is not
> > > > selected.
>
> > > > - Alex
>
> > > > On Dec 1, 5:30 pm, Ross Mellgren  wrote:
> > > > > Valueless attributes are prohibited by XML. The proper XHTML
> > > > > formulation is to use the name of the attribute as the value, e.g.
> > > > > checked="checked"
>
> > > > > -Ross
>
> > > > > On Dec 1, 2009, at 5:28 PM, Alex Black wrote:
>
> > > > > > For example, if my html template looks like this:
>
> > > > > > 
> > > > > >                foobar
> > > > > >                
> > > > > >                
> > > > > >                
> > > > > > 
>
> > > > > > I'd like to render it conditionally as:
>
> > > > > >                foobar
> > > > > >                
>
> > > > > > Is there syntax to add the "checked" to the checkbox? perhaps
> > similar
> > > > > > to the syntax to bind attribute values?
>
> > > > > > Thanks!
>
> > > > > > - Alex
>
> > > > > > --
>
> > > > > > You received this message because you are subscribed to the Google
> > > > > > Groups "Lift" group.
> > > > > > To post to this group, send email to lift...@googlegroups.com.
> > > > > > To unsubscribe from this group, send email to
> > > > liftweb+unsubscr...@googlegroups.com
> > 
>
> > > > > > .
> > > > > > For more options, visit this group athttp://
> > > > groups.google.com/group/liftweb?hl=en
> > > > > > .
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Lift" group.
> > > > To post to this group, send email to lift...@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.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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.

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: How can one bind value-less attributes?

2009-12-01 Thread Alex Black
Thanks Alex.  That would work, but I'm looking for a more generic
solution.

Restating the problem: Based on some condition I want to generate an
attribute or not generate an attribute, e.g.:



OR



- Alex

On Dec 1, 6:23 pm, Alex Boisvert  wrote:
> You can use SHtml.checkbox() to easily generate the checkbox,
>
> bind(...,
>   "checkbox" -> SHtml.checkbox(isChecked, checked => if (checked)
> doSomething())
> )
>
> The first parameter is whether the checkbox should be checked by default.
>
> The second parameter is a function to do something when form is submitted.
>
> alex
>
> On Tue, Dec 1, 2009 at 2:50 PM, Alex Black  wrote:
> > Is there a good/reasonable way to conditionally output
> > checked="checked" or output nothing?
>
> > My code looks like this:
>
> >          bind("manufacturer", xhtml,
> >              AttrBindParam("selected", Text("selected"), "selected"))
>
> > I can add an if statement, and then output Text("notSelected")
> > instead, but that doesn't seem to work - the correct  is not
> > selected.
>
> > - Alex
>
> > On Dec 1, 5:30 pm, Ross Mellgren  wrote:
> > > Valueless attributes are prohibited by XML. The proper XHTML
> > > formulation is to use the name of the attribute as the value, e.g.
> > > checked="checked"
>
> > > -Ross
>
> > > On Dec 1, 2009, at 5:28 PM, Alex Black wrote:
>
> > > > For example, if my html template looks like this:
>
> > > > 
> > > >                foobar
> > > >                
> > > >                
> > > >                
> > > > 
>
> > > > I'd like to render it conditionally as:
>
> > > >                foobar
> > > >                
>
> > > > Is there syntax to add the "checked" to the checkbox? perhaps similar
> > > > to the syntax to bind attribute values?
>
> > > > Thanks!
>
> > > > - Alex
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Lift" group.
> > > > To post to this group, send email to lift...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > liftweb+unsubscr...@googlegroups.com
> > > > .
> > > > For more options, visit this group athttp://
> > groups.google.com/group/liftweb?hl=en
> > > > .
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@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.

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: How can one bind value-less attributes?

2009-12-01 Thread Alex Black
Is there a good/reasonable way to conditionally output
checked="checked" or output nothing?

My code looks like this:

  bind("manufacturer", xhtml,
  AttrBindParam("selected", Text("selected"), "selected"))

I can add an if statement, and then output Text("notSelected")
instead, but that doesn't seem to work - the correct  is not
selected.

- Alex


On Dec 1, 5:30 pm, Ross Mellgren  wrote:
> Valueless attributes are prohibited by XML. The proper XHTML  
> formulation is to use the name of the attribute as the value, e.g.  
> checked="checked"
>
> -Ross
>
> On Dec 1, 2009, at 5:28 PM, Alex Black wrote:
>
> > For example, if my html template looks like this:
>
> > 
> >                foobar
> >                
> >                
> >                
> > 
>
> > I'd like to render it conditionally as:
>
> >                foobar
> >                
>
> > Is there syntax to add the "checked" to the checkbox? perhaps similar
> > to the syntax to bind attribute values?
>
> > Thanks!
>
> > - Alex
>
> > --
>
> > You received this message because you are subscribed to the Google  
> > Groups "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en
> > .

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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: How can one bind value-less attributes?

2009-12-01 Thread Alex Black
Thanks, I didn't know that!

On Dec 1, 5:30 pm, Ross Mellgren  wrote:
> Valueless attributes are prohibited by XML. The proper XHTML  
> formulation is to use the name of the attribute as the value, e.g.  
> checked="checked"
>
> -Ross
>
> On Dec 1, 2009, at 5:28 PM, Alex Black wrote:
>
> > For example, if my html template looks like this:
>
> > 
> >                foobar
> >                
> >                
> >                
> > 
>
> > I'd like to render it conditionally as:
>
> >                foobar
> >                
>
> > Is there syntax to add the "checked" to the checkbox? perhaps similar
> > to the syntax to bind attribute values?
>
> > Thanks!
>
> > - Alex
>
> > --
>
> > You received this message because you are subscribed to the Google  
> > Groups "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > liftweb+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/liftweb?hl=en
> > .

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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] How can one bind value-less attributes?

2009-12-01 Thread Alex Black
For example, if my html template looks like this:


foobar





I'd like to render it conditionally as:

foobar


Is there syntax to add the "checked" to the checkbox? perhaps similar
to the syntax to bind attribute values?

Thanks!

- Alex

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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.




  1   2   >