[Lift] Re: Nice 404s sans Redirect

2010-01-01 Thread Marius
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

[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 marius.dan...@gmail.com 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

[Lift] Re: Nice 404s sans Redirect

2009-12-31 Thread Marius
You could put a Script tag and inside set the title via JavaScript? But I'm still working on the solution I proposed which treats 404 as a normal page. Not sure if Dave will like it (probably not) but I'll send him a diff. Br's, Marius On Dec 31, 5:43 am, Alex Black a...@alexblack.ca wrote:

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

2009-12-31 Thread David Pollak
On Wed, Dec 30, 2009 at 7:43 PM, Alex Black a...@alexblack.ca wrote: Ok, I tried this, it gets closer. I noticed one issue: the head merge didn't get done, so I have two head 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

[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 feeder.of.the.be...@gmail.com wrote: On Wed, Dec 30, 2009 at 7:43 PM, Alex Black a...@alexblack.ca wrote: Ok, I tried this, it gets closer. I noticed one

[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] 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 a...@alexblack.ca 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

[Lift] Re: Nice 404s sans Redirect

2009-12-30 Thread Marius
On Dec 30, 5:05 pm, Alex Black a...@alexblack.ca 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

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

2009-12-30 Thread Ross Mellgren
Ouch, it does sound ugly. Is there some alternative way to change the currently requested URI, for the purposes of sitemap generation and so on? It seems like the alternative is spinning one's own SiteMap menu snippet that knows to do this work? Also, it seems odd there's no way to invoke

[Lift] Re: Nice 404s sans Redirect

2009-12-30 Thread Marius
Please see my previous reply and the proposed solution. Br's, Marius On Dec 30, 6:12 pm, Ross Mellgren dri...@gmail.com wrote: Ouch, it does sound ugly. Is there some alternative way to change the   currently requested URI, for the purposes of sitemap generation and so   on? It seems like the

[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

[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

[Lift] Re: Nice 404s sans Redirect

2009-12-30 Thread Marius
Please open a defect here http://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

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

2009-12-30 Thread Ross Mellgren
Oh no problem, I was intending this as a reply to the you guys Marius used, to make it clear that I don't have a particular use case, though I do agree about the soft 404s. -Ross On Dec 30, 2009, at 11:22 AM, Alex Black wrote: At any rate, I'm just trying to help Alex, I'm not invested in

[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 marius.dan...@gmail.com wrote: Please open a defect herehttp://github.com/dpp/liftweb/issues... whether or not this

[Lift] Re: Nice 404s sans Redirect

2009-12-30 Thread Marius
perfect, thanks. On Dec 30, 6:40 pm, Alex Black a...@alexblack.ca wrote: 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 marius.dan...@gmail.com wrote: Please open

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

2009-12-30 Thread Naftoli Gugenheim
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. - Mariusmarius.dan...@gmail.com wrote: Please open a defect here

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

2009-12-30 Thread David Pollak
On Wed, Dec 30, 2009 at 8:26 AM, Marius marius.dan...@gmail.com wrote: Please open a defect here http://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

[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.

[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

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

2009-12-30 Thread David Pollak
On Wed, Dec 30, 2009 at 10:30 AM, Alex Black a...@alexblack.ca wrote: 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. It's not rewriting. Rewriting is the change of the

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

2009-12-30 Thread David Pollak
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) {

[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 head 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

[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

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

2009-12-29 Thread Ross Mellgren
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:

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 dri...@gmail.com wrote: Switch to 1.1-M8, if you can. -Ross On Dec 29, 2009, at 1:04 PM, Alex Black wrote: To be clear,

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

2009-12-29 Thread Ross Mellgren
M8 is pretty stable, yes. M7 was not, and so M6 was recommended before that. I haven't heard of any reason to recommend M6 over M8, but maybe dpp has some reasons. -Ross On Dec 29, 2009, at 1:11 PM, Alex Black wrote: Is M8 pretty stable? A little while back DavidP recommended M6 as

[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

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

2009-12-29 Thread Indrajit Raychaudhuri
Quite so, go for M8. M6 was recommended when M8 hadn't come out. Cheers, Indrajit On 29/12/09 11:44 PM, Ross Mellgren wrote: M8 is pretty stable, yes. M7 was not, and so M6 was recommended before that. I haven't heard of any reason to recommend M6 over M8, but maybe dpp has some reasons.

[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 = lift:embed what=404 / // Catch 404s LiftRules.uriNotFound.prepend { case (req, _) = XhtmlTemplateResponse(notFoundNode, 404) } // If you're

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

2009-12-29 Thread David Pollak
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 _ =

[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

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

2009-12-29 Thread Ross Mellgren
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,

[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

[Lift] Re: Nice 404s sans Redirect

2009-12-29 Thread Alex Black
One more detail: notFoundNode is defined like this: val notFoundNode = lift:embed what=404 / and 404.html like this: lift:surround with=default at=content head titlePage Not Found/title /head h1Page Not Found/h1 pWe couldn't find the page you were looking

[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

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

2009-12-29 Thread Ross Mellgren
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 = lift:embed what=404 / LiftRules.uriNotFound.prepend {