librelist archives

« back to archive

status draft for pages

status draft for pages

From:
Misha Reyzlin
Date:
2011-08-03 @ 15:07
Hey!

I'd like to use metadata and add status to my pages.

So I'd have:
status: draft

In pages metadata section and would be able act upon that. While I know I
can refer to it by page.metadata('status') and I do, how would I go about
making these pages not accessible on production environment? (I can easily
not show them in the summary section, for example, by verifying the status
in views, but what about making them completely inaccessible?)

Thanks!

Re: [nesta] status draft for pages

From:
Graham Ashton
Date:
2011-08-04 @ 08:50
On 3 Aug 2011, at 16:07, Misha Reyzlin wrote:

> I'd like to use metadata and add status to my pages.
> 
> status: draft
> 
> While I know I can refer to it by page.metadata('status') and I do, how 
would I go about making these pages not accessible on production 
environment?

You really want Sinatra to raise a Sinatra::NotFound exception when you're
in production. I'd do it like this:

1. Copy the routing actions that ship with the Nesta gem to a local app.rb file.

2. Edit the one that handles pages, raising the exception when necessary.

Your app.rb file should look something like this:

https://gist.github.com/1124750

I copied all that code from lib/nesta/app.rb in the gem, and then edited 
lines 42-44. By default it only raises if @page.nil?.

I haven't tested this, but it should get you started. The production? call
is a Sinatra method that just checks the Rack environment.

It's a shame that you need to include lines 3 to 35 (the reasons were 
discussed a week or two on the list).

Re: [nesta] status draft for pages

From:
Misha Reyzlin
Date:
2011-08-04 @ 08:57
Thank you very much, Graham,
will try this little later.

On Thu, Aug 4, 2011 at 11:50 AM, Graham Ashton <graham@effectif.com> wrote:

> On 3 Aug 2011, at 16:07, Misha Reyzlin wrote:
>
> > I'd like to use metadata and add status to my pages.
> >
> > status: draft
> >
> > While I know I can refer to it by page.metadata('status') and I do, how
> would I go about making these pages not accessible on production
> environment?
>
> You really want Sinatra to raise a Sinatra::NotFound exception when you're
> in production. I'd do it like this:
>
> 1. Copy the routing actions that ship with the Nesta gem to a local app.rb
> file.
>
> 2. Edit the one that handles pages, raising the exception when necessary.
>
> Your app.rb file should look something like this:
>
> https://gist.github.com/1124750
>
> I copied all that code from lib/nesta/app.rb in the gem, and then edited
> lines 42-44. By default it only raises if @page.nil?.
>
> I haven't tested this, but it should get you started. The production? call
> is a Sinatra method that just checks the Rack environment.
>
> It's a shame that you need to include lines 3 to 35 (the reasons were
> discussed a week or two on the list).
>
>