Sha256: 90f1729317c59836b8f23fee8f265b2b909a8deabbbeb06a8a398712949fc09c

Contents?: true

Size: 876 Bytes

Versions: 3

Compression:

Stored size: 876 Bytes

Contents

# * George Moschovitis  <gm@navel.gr>
# (c) 2004-2005 Navel, all rights reserved.
# $Id: run.rb 266 2005-02-28 14:50:48Z gmosx $

require 'nitro'; include N
require 'nitro/adapters/webrick'

class Wee < Component

	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

3 entries across 3 versions & 1 rubygems

Version Path
nitro-0.11.0 examples/wee_style/run.rb
nitro-0.12.0 examples/wee_style/run.rb
nitro-0.13.0 examples/wee_style/run.rb