librelist archives

« back to archive

Plugin help for beginners

Plugin help for beginners

From:
Oliver Nixon
Date:
2012-05-27 @ 20:26
Hi,

Could someone point me in the right direction for information on how to add
custom routes in Nesta. Ultimately I'm looking to be able to provide a form
and then handle a post back but don't really know where to start.

Thanks.

Re: [nesta] Plugin help for beginners

From:
Graham Ashton
Date:
2012-05-28 @ 08:01
On 27 May 2012, at 21:26, Oliver Nixon wrote:

> Could someone point me in the right direction for information on how to 
add custom routes in Nesta. Ultimately I'm looking to be able to provide a
form and then handle a post back but don't really know where to start.

If you create a file called app.rb at the top level of your project, 
you'll be able to put Sinatra route handlers in it. Sinatra will see yours
before it sees the default ones, so the default ones will still work if 
none of your own route handlers match.

Syntax looks like this:

$ cat app.rb
module Nesta
  class App
    get '/path' do
      # your code
    end

    post '/path' do
      # your code
    end
  end
end

The Sinatra docs will help you fill in the bits inside the get and post blocks.

(Incidentally - these aren't Nesta plugins; they're something else again)

Cheers,
Graham

--
Graham Ashton
Founder, The Agile Planner
http://theagileplanner.com | @agileplanner | @grahamashton


Re: [nesta] Plugin help for beginners

From:
Brian Gonzalez
Date:
2012-05-27 @ 22:48
Since Nesta is built on top of Sinatra, I would start by looking into
Sinatra routing. In essence, you'll need to add routes to your app.rb
file.

Sent from my BriPhone

On May 27, 2012, at 1:27 PM, Oliver Nixon <oll@clockhill.co.uk> wrote:

> Hi,
>
> Could someone point me in the right direction for information on how to 
add custom routes in Nesta. Ultimately I'm looking to be able to provide a
form and then handle a post back but don't really know where to start.
>
> Thanks.