/usr/share/doc/ruby-ramaze/examples/misc/rapp.rb is in ruby-ramaze 2012.12.08-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | # Ramaze version of the merb tutorial
# http://www.socialface.com/slapp/
require 'rubygems'
require 'ramaze'
require 'sequel'
require 'abbrev'
DB = Sequel.sqlite
class Post < Sequel::Model
plugin :schema
plugin :hook_class_methods
set_schema{ primary_key :id; time :created_at; text :text }
before_create{ self.created_at ||= Time.now }
create_table
end
%w[Ramaze Rocks].abbrev.keys.sort.each{|text| Post.create(:text => text) }
class MainController < Ramaze::Controller
def index
@posts = Post.order(:created_at.desc).first(10)
<<-'TEMPLATE'.strip
<html>
<head><title>Rapp</title></head>
<body>
<h1>Welcome to Rapp</h1>
<h2>A minimal chat wall</h2>
<p>Recent Posts:</p>
<div id="posts" class="container">
<?r @posts.each do |post| ?>
<div id="post-#{post.id}" class="post">
<p class="text">#{post.text}</p>
<p class="created">#{post.created_at}</p>
</div>
<?r end ?>
</div>
<p>Post Something:</p>
<form action="#{r(:create)}" method="POST">
<input type="text" size="40" name="text" />
<input type="submit" value="Post Message!" />
</form>
</body>
</html>
TEMPLATE
end
def create
Post.create(:text => request[:text])
redirect r(:/)
end
end
Ramaze.start
|