Sha256: 2f8d5086c63a51793e6ad7d42d2504f5553b6c062b09edafd0b4aa411319de9f

Contents?: true

Size: 887 Bytes

Versions: 1

Compression:

Stored size: 887 Bytes

Contents

# * George Moschovitis  <gm@navel.gr>
# (c) 2004-2005 Navel, all rights reserved.
# $Id: run.rb 260 2005-02-15 08:58:04Z gmosx $

require 'nitro'
require 'nitro/adapters/webrick'

include N

class Wee < Controller

	def index
		counter = session[:counter] || 0

		(o = @out).html {
			o.comment 'This is a comment!'
			o.h1 'Hello world'
			o.text 'This is ' 
			o.b 'BOLD'
			o.br.br
			o.p 'Here comes some text'
			o.br.br
			o.p "Here is the counter: #{counter}"
			o.p {
				o.a('Increase', :href => 'inc_counter').text(' the counter.')
			}
			o.p '<a href="reset_counter">Reset</a> the counter.'
			o.hr
			o.text 'Powered by Nitro.'
		}
	end

	def inc_counter
		session[:counter] ||= 0
		session[:counter] += 1
	end
	
	def reset_counter
		session[:counter] = 0
	end

end

conf = {
	:host => 'localhost',
	:port => 8069,
	:dispatcher => Dispatcher.new(Wee)
}

Webrick.start(conf)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nitro-0.10.0 examples/wee_style/run.rb