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.
> 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.
> You can override that to customize the response for various error codes.
> //Andreas
> 2012/11/6 Marek Setnicka <mset...@gmail.com <javascript:>>
>> 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.
> 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.
> You can override that to customize the response for various error
> codes.
> //Andreas
> 2012/11/6 Marek Setnicka <mset...@gmail.com <javascript:>>
> 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.
> 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,
>> 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.
> 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:
>>> 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.
> 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,
>>> 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.
> 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,
>>>> 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.
> On 7 nov. 2012, at 10:31, Andreas Stenius wrote:
> Not bad at all! :)
> 2012/11/6 Marc Worrell <mwor...@me.com <javascript:>>
>> 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:
>>>> 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.