[Radiant] Re: Looking for pointers: Access to request headers, intercept form submission early, etc...

2011-01-10 Thread Marc
On Jan 10, 7:45 pm, William Ross  wrote:
> Radius tags are implemented in the Page model, where you shouldn't have 
> access to the request, but it also defines request and response accessors 
> that are populated by the SiteController, so in a radius tag you can access 
> the request directly. The solid way would be:
>
>         referer = tag.globals.page.request.referer
>
> but since we're rendering inside Page it's usually ok just to say:
>
>         referer = request.referer
>
> The biggest problem you'll find is that in order to display request-specific 
> content you have to disable the page cache. If you just want to pick up 
> googlers you might find it easier to do in javascript.

I was planning on using it to jazz up the file not found response,
i.e. differentiate internal link error from external reference miss. I
get the impression that it already disables the page cache for its
responses.

> > Also I'm was wondering if someone can provide pointers to how I can
> > get at the form post before it is interpreted. I was looking at
> > modifying the mailer extension to use obscured field names (part of
> > gettinghttp://nedbatchelder.com/text/stopbots.htmltechniques
> > working).
>
> I have an old fork of the Mailer that implements a honeypot mechanism quite 
> similar to what's described there but I think a bit less sophisticated. It 
> may show you where to start:
>
>        https://github.com/spanner/radiant-mailer-extension

Cool, I'll have a look.

https://github.com/radiant/radiant/wiki/Using-cells-to-render-arbitrary-Rails-views-within-Radiant-pages
also looks interesting and might prove to offer an alternative route,
but like so many pages on Radiant they presume detailed knowledge of
Rails (I haven't touched Rails and Ruby since 1.x days of Rails, lots
of Googling is the result :) )

> best,
>
> will

Thanks for the response!

Marc


Re: [Radiant] Looking for pointers: Access to request headers, intercept form submission early, etc...

2011-01-10 Thread William Ross
On 10 Jan 2011, at 07:10, Marc wrote:

> Hi,
> 
> I seem to remember from somewhere that radius tags can't get access to
> session state, e.g. HTTP Headers. Specifically "Referer"? Is that
> correct? Just about to start digging into rails and would be nice to
> get hints where to look...

No, it's quite possible but can be slightly awkward in use.

Radius tags are implemented in the Page model, where you shouldn't have access 
to the request, but it also defines request and response accessors that are 
populated by the SiteController, so in a radius tag you can access the request 
directly. The solid way would be:

referer = tag.globals.page.request.referer

but since we're rendering inside Page it's usually ok just to say:

referer = request.referer

The biggest problem you'll find is that in order to display request-specific 
content you have to disable the page cache. If you just want to pick up 
googlers you might find it easier to do in javascript.


> Also I'm was wondering if someone can provide pointers to how I can
> get at the form post before it is interpreted. I was looking at
> modifying the mailer extension to use obscured field names (part of
> getting http://nedbatchelder.com/text/stopbots.html techniques
> working).

I have an old fork of the Mailer that implements a honeypot mechanism quite 
similar to what's described there but I think a bit less sophisticated. It may 
show you where to start:

https://github.com/spanner/radiant-mailer-extension

best,

will