Sha256: f9fd252d9d8f626e63f6b61a0a7260136e8246aa81573cfb22f85d89e7bd397f

Contents?: true

Size: 744 Bytes

Versions: 17

Compression:

Stored size: 744 Bytes

Contents

require 'rubygems'
require 'ramaze'

require 'model/history'
require 'model/message'

class MainController < Ramaze::Controller
  HISTORY = History.new

  layout '/layout'

  def index
    if request.post?
      session[:nick] = request[:nick]
      redirect Rs(:chat)
    end
  end

  def chat
    redirect Rs(:/) unless session[:nick]
  end

  def say
    if nick = session[:nick] and text = request['text']
      HISTORY.write(nick, text)
    end
  end

  def listen
    respond HISTORY.to_html
  end

  [ "Hello, World!",
    "My name is manveru",
    "I welcome you to my realm",
    "The unique and most awesome examples/chat.rb!",
  ].each{|text| HISTORY.write('manveru', text) }
end

Ramaze.start :middleware => true, :adapter => :thin

Version data entries

17 entries across 17 versions & 4 rubygems

Version Path
Pistos-ramaze-2008.09 examples/app/chat/start.rb
Pistos-ramaze-2008.12 examples/app/chat/start.rb
Pistos-ramaze-2009.01 examples/app/chat/start.rb
Pistos-ramaze-2009.02 examples/app/chat/start.rb
manveru-ramaze-2008.07 examples/app/chat/start.rb
manveru-ramaze-2008.08 examples/app/chat/start.rb
manveru-ramaze-2008.09 examples/app/chat/start.rb
manveru-ramaze-2008.10 examples/app/chat/start.rb
manveru-ramaze-2008.12 examples/app/chat/start.rb
manveru-ramaze-2009.01 examples/app/chat/start.rb
ptomato-ramaze-2009.02.1 examples/app/chat/start.rb
ptomato-ramaze-2009.02 examples/app/chat/start.rb
ramaze-2008.06 examples/app/chat/start.rb
ramaze-2008.11 examples/app/chat/start.rb
ramaze-2009.01 examples/app/chat/start.rb
ramaze-2009.03 examples/app/chat/start.rb
ramaze-2009.02 examples/app/chat/start.rb