Sha256: 34d6195c190c16d42122ad59cbee40e362c7fa020fa8f9a93b9818d567ca9443

Contents?: true

Size: 880 Bytes

Versions: 2

Compression:

Stored size: 880 Bytes

Contents

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

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

include Nitro

class Wee < Controller

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

		o.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 => '127.0.0.1',
	:port => 9999,
	:dispatcher => Dispatcher.new(Wee)
}

Webrick.start(conf)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nitro-0.16.0 examples/wee_style/run.rb
nitro-0.17.0 examples/wee_style/run.rb