Message from discussion
Customisation of the 404 page
Received: by 10.236.193.106 with SMTP id j70mr3609040yhn.11.1352317044308;
Wed, 07 Nov 2012 11:37:24 -0800 (PST)
X-BeenThere: zotonic-users@googlegroups.com
Received: by 10.101.200.1 with SMTP id c1ls490943anq.3.gmail; Wed, 07 Nov 2012
11:37:23 -0800 (PST)
Received: by 10.236.193.106 with SMTP id j70mr3609013yhn.11.1352317043572;
Wed, 07 Nov 2012 11:37:23 -0800 (PST)
Received: by 10.236.193.106 with SMTP id j70mr3609012yhn.11.1352317043552;
Wed, 07 Nov 2012 11:37:23 -0800 (PST)
Return-Path: <mworr...@me.com>
Received: from st11p02mm-asmtp003.mac.com (st11p02mm-asmtp003.mac.com. [17.172.220.238])
by gmr-mx.google.com with ESMTP id h50si1538778yhi.3.2012.11.07.11.37.23;
Wed, 07 Nov 2012 11:37:23 -0800 (PST)
Received-SPF: pass (google.com: domain of mworr...@me.com designates 17.172.220.238 as permitted sender) client-ip=17.172.220.238;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of mworr...@me.com designates 17.172.220.238 as permitted sender) smtp.mail=mworr...@me.com
MIME-version: 1.0
Content-type: multipart/alternative;
boundary="Boundary_(ID_mwdt4I5FMxa5XKXJ1GGuyw)"
Received: from [192.168.1.16]
(5469A6C2.cm-12-2c.dynamic.ziggo.nl [84.105.166.194])
by st11p02mm-asmtp003.mac.com
(Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Jan
3 2012)) with ESMTPSA id <0MD4005OJUI9B...@st11p02mm-asmtp003.mac.com> for
zotonic-users@googlegroups.com; Wed, 07 Nov 2012 19:37:23 +0000 (GMT)
From: Marc Worrell <mworr...@me.com>
Subject: Re: [Zotonic-Usr] Customisation of the 404 page
Date: Wed, 07 Nov 2012 20:37:20 +0100
In-reply-to: <CABCxKrcGbn8X4p43qR+AaskfELJEcNzN7gxbHqKeMaAJOeJASQ@mail.gmail.com>
To: zotonic-users@googlegroups.com
References: <87491c57-7b97-4247-8218-64168fa4abd2@googlegroups.com>
<CABCxKrfdz5WHbhYZ3VEny4j_zuO2BN+LOnLseEJSeF0h=KkivQ@mail.gmail.com>
<eb8a3d5f-75e8-4d3b-ba77-3673278d8c5a@googlegroups.com>
<50998610.1050000@scherpenisse.net>
<8AB0FF48-677A-4FF5-93FA-3CF0A74B2BCE@me.com>
<CABCxKrcGbn8X4p43qR+AaskfELJEcNzN7gxbHqKeMaAJOeJ...@mail.gmail.com>
Message-id: <79A3DDBD-13FB-48BA-99DF-A3AA85915...@me.com>
X-Mailer: Apple Mail (2.1278)
--Boundary_(ID_mwdt4I5FMxa5XKXJ1GGuyw)
Content-type: text/plain; CHARSET=US-ASCII
Content-transfer-encoding: 7BIT
Please check this issue and see if this would do the job:
https://github.com/zotonic/zotonic/issues/450
- Marc
On 7 nov. 2012, at 10:31, Andreas Stenius wrote:
> Not bad at all! :)
>
>
> 2012/11/6 Marc Worrell <mworr...@me.com>
> Such a "rsc_gone" table would be nice.
> Especially when you can also give a new url and/or resource id.
>
> - Marc
>
>
> On 6 nov. 2012, at 22:50, Arjan Scherpenisse wrote:
>
>>
>> On 11/06/2012 05:31 PM, Marek Setnicka wrote:
>>> Many thanks, Andreas.
>>>
>>> Any idea how to generate a 410 (Gone) page instead of 404?
>>
>> The templates only allow customization of the HTML content of the error page, not of the error codes itself. Those codes are created by the controller that is used to serve the URL that was requested.
>>
>> When you're talking about 410 Gone I assume you want to have that indication when you delete a page (rsc) from the database. The default page controller (controller_page) does not yet have the functionality to emit 410 error codes, as this would need an administration of pages which once existed but are now gone ("tombstones").
>>
>> Patches welcome, of course ;-)
>>
>> For example, the controller_page could implement webmachine's previously_existed/2 function, which might do a lookup in a tombstone table, which would be filled when a rsc gets deleted.
>>
>> Arjan
>>
>>>
>>> Marek
>>>
>>>
>>> On Tuesday, 6 November 2012 09:13:20 UTC, Andreas Stenius wrote:
>>> Hi,
>>>
>>> Take a look at error.tpl from mod_base ( https://github.com/zotonic/zotonic/blob/master/modules/mod_base/templates/error.tpl ).
>>>
>>> You can override that to customize the response for various error codes.
>>>
>>> //Andreas
>>>
>>>
>>>
>>> 2012/11/6 Marek Setnicka <mset...@gmail.com>
>>> Hi guys,
>>>
>>> what is the best way to conditionally serve the 404 (or 410) page?
>>> My scenario is simple: I'd like to be able to show a 404 (410) page with a customised content (different from the standard 404 that Zotonic returns) and based on a condition depending on data in the database.
>>>
>>> I am not very experienced with Erlang or using Webmachine for that matter.
>>> I have looked at all various options, from using resource_html to using webmachine_resource and have been primarily looking for a Zotonic way. I haven't found such a way.
>>> The way I see doable is to use resource_html and in the html/1 function retrieve the ReqData from z_context (get_reqdata/1), append a custom body to it using webmachine_request:append_to_response_body/2 and then send response back using webmachine_request:send_response/2.
>>> Is there a better way to achieve what I need? Any hints will be much appreciated.
>>>
>>>
>>> Have a sunny day,
>>> Marek
>>>
>>
>
>
--Boundary_(ID_mwdt4I5FMxa5XKXJ1GGuyw)
Content-type: text/html; CHARSET=US-ASCII
Content-transfer-encoding: 7BIT
<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Please check this issue and see if this would do the job:<div><br></div><div><a href="https://github.com/zotonic/zotonic/issues/450">https://github.com/zotonic/zotonic/issues/450</a></div><div><br></div><div>- Marc</div><div><br></div><div><br><div><div>On 7 nov. 2012, at 10:31, Andreas Stenius wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Not bad at all! :)<div class="gmail_extra"><br><br><div class="gmail_quote">2012/11/6 Marc Worrell <span dir="ltr"><<a href="mailto:mworr...@me.com" target="_blank">mworr...@me.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Such a "rsc_gone" table would be nice.<div>Especially when you can also give a new url and/or resource id.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>- Marc</div>
</font></span><div><div class="h5"><div><br></div><div><br></div><div><div><div>On 6 nov. 2012, at 22:50, Arjan Scherpenisse wrote:</div><br><blockquote type="cite">
<div text="#000000" bgcolor="#FFFFFF">
<br>
<div>On 11/06/2012 05:31 PM, Marek Setnicka
wrote:<br>
</div>
<blockquote type="cite">Many thanks, Andreas.<br>
<br>
Any idea how to generate a 410 (Gone) page instead of 404?<br>
</blockquote>
<br>
The templates only allow customization of the HTML content of the
error page, not of the error codes itself. Those codes are created
by the controller that is used to serve the URL that was requested.<br>
<br>
When you're talking about 410 Gone I assume you want to have that
indication when you delete a page (rsc) from the database. The
default page controller (controller_page) does not yet have the
functionality to emit 410 error codes, as this would need an
administration of pages which once existed but are now gone
("tombstones").<br>
<br>
Patches welcome, of course ;-)<br>
<br>
For example, the controller_page could implement webmachine's<i>
previously_existed/2</i> function, which might do a lookup in a
tombstone table, which would be filled when a rsc gets deleted.<br>
<br>
Arjan<br>
<br>
<blockquote type="cite"><br>
Marek<br>
<br>
<br>
On Tuesday, 6 November 2012 09:13:20 UTC, Andreas Stenius wrote:
<blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,
<div><br>
</div>
<div>Take a look at error.tpl from mod_base ( <a href="https://github.com/zotonic/zotonic/blob/master/modules/mod_base/templates/error.tpl" target="_blank">https://github.com/zotonic/<u></u>zotonic/blob/master/modules/<u></u>mod_base/templates/error.tpl</a> )<u></u>.</div>
<div><br>
</div>
<div>You can override that to customize the response for various
error codes.</div>
<div><br>
</div>
<div>//Andreas</div>
<div><br>
</div>
<div><br>
<br>
<div class="gmail_quote">2012/11/6 Marek Setnicka <span dir="ltr"><<a>mset...@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi guys,<br>
<br>
what is the best way to conditionally serve the 404 (or
410) page? <br>
My scenario is simple: I'd like to be able to show a 404
(410) page with a customised content (different from the
standard 404 that Zotonic returns) and based on a
condition depending on data in the database.<br>
<br>
I am not very experienced with Erlang or using Webmachine
for that matter.<br>
I have looked at all various options, from using
resource_html to using webmachine_resource and have been
primarily looking for a Zotonic way. I haven't found such
a way. <br>
The way I see doable is to use resource_html and in the
html/1 function retrieve the ReqData from z_context
(get_reqdata/1), append a custom body to it using
webmachine_request:append_to_<u></u>response_body/2 and then
send response back using webmachine_request:send_<u></u>response/2.
<br>
Is there a better way to achieve what I need? Any hints
will be much appreciated.<br>
<br>
<br>
Have a sunny day,<br>
Marek<br>
</blockquote>
</div>
<br>
</div>
</blockquote>
</blockquote>
<br>
</div>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>
</blockquote></div><br></div></body></html>
--Boundary_(ID_mwdt4I5FMxa5XKXJ1GGuyw)--