ramaze 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +360 -0
- data/bin/ramaze +152 -0
- data/doc/CHANGELOG +2021 -0
- data/doc/COPYING +56 -0
- data/doc/COPYING.ja +51 -0
- data/doc/README +275 -0
- data/doc/TODO +33 -0
- data/doc/allison/LICENSE +184 -0
- data/doc/allison/README +37 -0
- data/doc/allison/allison.css +300 -0
- data/doc/allison/allison.gif +0 -0
- data/doc/allison/allison.js +307 -0
- data/doc/allison/allison.rb +287 -0
- data/doc/allison/cache/BODY +588 -0
- data/doc/allison/cache/CLASS_INDEX +4 -0
- data/doc/allison/cache/CLASS_PAGE +1 -0
- data/doc/allison/cache/FILE_INDEX +4 -0
- data/doc/allison/cache/FILE_PAGE +1 -0
- data/doc/allison/cache/FONTS +1 -0
- data/doc/allison/cache/FR_INDEX_BODY +1 -0
- data/doc/allison/cache/IMGPATH +1 -0
- data/doc/allison/cache/INDEX +1 -0
- data/doc/allison/cache/JAVASCRIPT +307 -0
- data/doc/allison/cache/METHOD_INDEX +4 -0
- data/doc/allison/cache/METHOD_LIST +1 -0
- data/doc/allison/cache/SRC_PAGE +1 -0
- data/doc/allison/cache/STYLE +322 -0
- data/doc/allison/cache/URL +1 -0
- data/examples/blog/main.rb +16 -0
- data/examples/blog/public/screen.css +106 -0
- data/examples/blog/src/controller.rb +50 -0
- data/examples/blog/src/element.rb +53 -0
- data/examples/blog/src/model.rb +29 -0
- data/examples/blog/template/edit.xhtml +6 -0
- data/examples/blog/template/index.xhtml +24 -0
- data/examples/blog/template/new.xhtml +5 -0
- data/examples/blog/template/view.xhtml +15 -0
- data/examples/blog/test/tc_entry.rb +18 -0
- data/examples/caching.rb +23 -0
- data/examples/element.rb +40 -0
- data/examples/hello.rb +23 -0
- data/examples/simple.rb +60 -0
- data/examples/templates/template/external.haml +21 -0
- data/examples/templates/template/external.liquid +28 -0
- data/examples/templates/template/external.mab +27 -0
- data/examples/templates/template/external.rhtml +29 -0
- data/examples/templates/template/external.rmze +24 -0
- data/examples/templates/template_erubis.rb +50 -0
- data/examples/templates/template_haml.rb +48 -0
- data/examples/templates/template_liquid.rb +64 -0
- data/examples/templates/template_markaby.rb +52 -0
- data/examples/templates/template_ramaze.rb +49 -0
- data/examples/whywiki/main.rb +56 -0
- data/examples/whywiki/template/edit.xhtml +14 -0
- data/examples/whywiki/template/show.xhtml +17 -0
- data/lib/proto/conf/benchmark.yaml +35 -0
- data/lib/proto/conf/debug.yaml +34 -0
- data/lib/proto/conf/live.yaml +33 -0
- data/lib/proto/conf/silent.yaml +31 -0
- data/lib/proto/conf/stage.yaml +33 -0
- data/lib/proto/main.rb +18 -0
- data/lib/proto/public/404.jpg +0 -0
- data/lib/proto/public/css/coderay.css +105 -0
- data/lib/proto/public/css/ramaze_error.css +42 -0
- data/lib/proto/public/error.xhtml +74 -0
- data/lib/proto/public/favicon.ico +0 -0
- data/lib/proto/public/js/jquery.js +1923 -0
- data/lib/proto/public/ramaze.png +0 -0
- data/lib/proto/src/controller/main.rb +7 -0
- data/lib/proto/src/element/page.rb +16 -0
- data/lib/proto/src/model.rb +5 -0
- data/lib/proto/template/index.xhtml +6 -0
- data/lib/ramaze.rb +317 -0
- data/lib/ramaze/adapter/mongrel.rb +111 -0
- data/lib/ramaze/adapter/webrick.rb +161 -0
- data/lib/ramaze/cache.rb +11 -0
- data/lib/ramaze/cache/memcached.rb +52 -0
- data/lib/ramaze/cache/memory.rb +6 -0
- data/lib/ramaze/cache/yaml_store.rb +37 -0
- data/lib/ramaze/controller.rb +10 -0
- data/lib/ramaze/dispatcher.rb +315 -0
- data/lib/ramaze/error.rb +11 -0
- data/lib/ramaze/gestalt.rb +108 -0
- data/lib/ramaze/global.rb +120 -0
- data/lib/ramaze/helper.rb +32 -0
- data/lib/ramaze/helper/aspect.rb +189 -0
- data/lib/ramaze/helper/auth.rb +120 -0
- data/lib/ramaze/helper/cache.rb +52 -0
- data/lib/ramaze/helper/feed.rb +135 -0
- data/lib/ramaze/helper/form.rb +204 -0
- data/lib/ramaze/helper/link.rb +80 -0
- data/lib/ramaze/helper/redirect.rb +48 -0
- data/lib/ramaze/helper/stack.rb +67 -0
- data/lib/ramaze/http_status.rb +66 -0
- data/lib/ramaze/inform.rb +166 -0
- data/lib/ramaze/snippets.rb +5 -0
- data/lib/ramaze/snippets/hash/keys_to_sym.rb +19 -0
- data/lib/ramaze/snippets/kernel/aquire.rb +22 -0
- data/lib/ramaze/snippets/kernel/autoreload.rb +79 -0
- data/lib/ramaze/snippets/kernel/caller_lines.rb +58 -0
- data/lib/ramaze/snippets/kernel/constant.rb +24 -0
- data/lib/ramaze/snippets/kernel/rescue_require.rb +12 -0
- data/lib/ramaze/snippets/kernel/self_method.rb +41 -0
- data/lib/ramaze/snippets/kernel/silently.rb +13 -0
- data/lib/ramaze/snippets/object/traits.rb +60 -0
- data/lib/ramaze/snippets/openstruct/temp.rb +10 -0
- data/lib/ramaze/snippets/string/DIVIDE.rb +16 -0
- data/lib/ramaze/snippets/string/camel_case.rb +14 -0
- data/lib/ramaze/snippets/string/snake_case.rb +12 -0
- data/lib/ramaze/snippets/symbol/to_proc.rb +14 -0
- data/lib/ramaze/snippets/thread/deadQUESTIONMARK.rb +11 -0
- data/lib/ramaze/store/default.rb +48 -0
- data/lib/ramaze/template.rb +102 -0
- data/lib/ramaze/template/amrita2.rb +40 -0
- data/lib/ramaze/template/erubis.rb +58 -0
- data/lib/ramaze/template/haml.rb +65 -0
- data/lib/ramaze/template/haml/actionview_stub.rb +20 -0
- data/lib/ramaze/template/liquid.rb +74 -0
- data/lib/ramaze/template/markaby.rb +68 -0
- data/lib/ramaze/template/ramaze.rb +177 -0
- data/lib/ramaze/template/ramaze/element.rb +166 -0
- data/lib/ramaze/template/ramaze/morpher.rb +156 -0
- data/lib/ramaze/tool/create.rb +70 -0
- data/lib/ramaze/tool/tidy.rb +71 -0
- data/lib/ramaze/trinity.rb +38 -0
- data/lib/ramaze/trinity/request.rb +244 -0
- data/lib/ramaze/trinity/response.rb +41 -0
- data/lib/ramaze/trinity/session.rb +129 -0
- data/lib/ramaze/version.rb +14 -0
- data/spec/spec_all.rb +73 -0
- data/spec/spec_helper.rb +215 -0
- data/spec/tc_adapter_mongrel.rb +24 -0
- data/spec/tc_adapter_webrick.rb +22 -0
- data/spec/tc_cache.rb +79 -0
- data/spec/tc_controller.rb +39 -0
- data/spec/tc_element.rb +100 -0
- data/spec/tc_error.rb +23 -0
- data/spec/tc_gestalt.rb +90 -0
- data/spec/tc_global.rb +46 -0
- data/spec/tc_helper_aspect.rb +65 -0
- data/spec/tc_helper_auth.rb +61 -0
- data/spec/tc_helper_cache.rb +81 -0
- data/spec/tc_helper_feed.rb +129 -0
- data/spec/tc_helper_form.rb +146 -0
- data/spec/tc_helper_link.rb +58 -0
- data/spec/tc_helper_redirect.rb +51 -0
- data/spec/tc_helper_stack.rb +55 -0
- data/spec/tc_morpher.rb +90 -0
- data/spec/tc_params.rb +84 -0
- data/spec/tc_request.rb +111 -0
- data/spec/tc_session.rb +56 -0
- data/spec/tc_store.rb +25 -0
- data/spec/tc_template_amrita2.rb +34 -0
- data/spec/tc_template_erubis.rb +41 -0
- data/spec/tc_template_haml.rb +44 -0
- data/spec/tc_template_liquid.rb +98 -0
- data/spec/tc_template_markaby.rb +74 -0
- data/spec/tc_template_ramaze.rb +54 -0
- data/spec/tc_tidy.rb +14 -0
- data/spec/template/amrita2/data.html +6 -0
- data/spec/template/amrita2/index.html +1 -0
- data/spec/template/amrita2/sum.html +1 -0
- data/spec/template/erubis/sum.rhtml +1 -0
- data/spec/template/haml/index.haml +5 -0
- data/spec/template/haml/with_vars.haml +4 -0
- data/spec/template/liquid/index.liquid +1 -0
- data/spec/template/liquid/products.liquid +45 -0
- data/spec/template/markaby/external.mab +8 -0
- data/spec/template/markaby/sum.mab +1 -0
- data/spec/template/ramaze/file_only.rmze +1 -0
- data/spec/template/ramaze/index.rmze +1 -0
- data/spec/template/ramaze/nested.rmze +1 -0
- data/spec/template/ramaze/sum.rmze +1 -0
- metadata +317 -0
@@ -0,0 +1 @@
|
|
1
|
+
http://blog.evanweaver.com/articles/2006/06/02/allison
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'yaml'
|
5
|
+
require 'bluecloth'
|
6
|
+
require 'ramaze'
|
7
|
+
|
8
|
+
require 'src/model'
|
9
|
+
|
10
|
+
include Ramaze
|
11
|
+
require 'src/controller'
|
12
|
+
require 'src/element'
|
13
|
+
|
14
|
+
Global.setup(YAML.load_file('conf/global.yaml'))
|
15
|
+
|
16
|
+
start
|
@@ -0,0 +1,106 @@
|
|
1
|
+
body {
|
2
|
+
background: #111;
|
3
|
+
margin: auto;
|
4
|
+
padding: 1em;
|
5
|
+
color: #fff;
|
6
|
+
}
|
7
|
+
|
8
|
+
span#title {
|
9
|
+
font-size: 1.5em;
|
10
|
+
text-align: right;
|
11
|
+
}
|
12
|
+
|
13
|
+
span#login {
|
14
|
+
font-size: 0.5em;
|
15
|
+
float: right;
|
16
|
+
margin-top: -2em;
|
17
|
+
}
|
18
|
+
|
19
|
+
a {
|
20
|
+
text-decoration: none;
|
21
|
+
color: #afa;
|
22
|
+
}
|
23
|
+
|
24
|
+
div#menu {
|
25
|
+
text-align: center;
|
26
|
+
padding: 0.2em;
|
27
|
+
margin-top: -0.5em;
|
28
|
+
margin-right: -0.5em;
|
29
|
+
margin-left: -0.5em;
|
30
|
+
margin-bottom: 0.5em;
|
31
|
+
background: #222;
|
32
|
+
font-size: 2em;
|
33
|
+
}
|
34
|
+
|
35
|
+
div#sidebar {
|
36
|
+
width: 12%;
|
37
|
+
height: 50%;
|
38
|
+
float: right;
|
39
|
+
margin-right: -0.3em;
|
40
|
+
background: #222;
|
41
|
+
padding: 0.5em;
|
42
|
+
border: #333 1px solid;
|
43
|
+
text-align: center;
|
44
|
+
}
|
45
|
+
|
46
|
+
div#sidebar h1 {
|
47
|
+
font-size: 1.1em;
|
48
|
+
color: #0da;
|
49
|
+
background: #011;
|
50
|
+
margin: -0.4em;
|
51
|
+
margin-bottom: 0.4em;
|
52
|
+
text-align: center;
|
53
|
+
}
|
54
|
+
|
55
|
+
div.blog_entry {
|
56
|
+
background: #222;
|
57
|
+
width: 80%;
|
58
|
+
padding: 0.4em;
|
59
|
+
margin-bottom: 1em;
|
60
|
+
margin-left: 5%;
|
61
|
+
margin-right: 15%;
|
62
|
+
border: #333 1px solid;
|
63
|
+
}
|
64
|
+
|
65
|
+
div.blog_entry div.title {
|
66
|
+
background: #111;
|
67
|
+
text-align: center;
|
68
|
+
}
|
69
|
+
|
70
|
+
div.blog_entry div.title div.date {
|
71
|
+
color: #aaa;
|
72
|
+
text-align: right;
|
73
|
+
font-size: 0.8em;
|
74
|
+
}
|
75
|
+
|
76
|
+
div.blog_entry div.title div.title {
|
77
|
+
font-size: 1.5em;
|
78
|
+
}
|
79
|
+
|
80
|
+
div.blog_entry div.text {
|
81
|
+
background: #111;
|
82
|
+
margin: 0.4em;
|
83
|
+
padding: 0.4em;
|
84
|
+
padding-top: 2em;
|
85
|
+
padding-bottom: 1.5em;
|
86
|
+
}
|
87
|
+
|
88
|
+
div.blog_entry div.menu {
|
89
|
+
background: #111;
|
90
|
+
text-align: center;
|
91
|
+
margin: 0.4em;
|
92
|
+
}
|
93
|
+
|
94
|
+
form {
|
95
|
+
margin: auto;
|
96
|
+
width: 70%;
|
97
|
+
}
|
98
|
+
|
99
|
+
form input {
|
100
|
+
width: 100%;
|
101
|
+
}
|
102
|
+
|
103
|
+
form textarea {
|
104
|
+
width: 100%;
|
105
|
+
height: 70%;
|
106
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
class MainController < Template::Ramaze
|
5
|
+
helper :form, :auth, :aspect
|
6
|
+
|
7
|
+
def index
|
8
|
+
@title = 'Ramaze Blog'
|
9
|
+
@entries = Entry.all.reverse
|
10
|
+
end
|
11
|
+
|
12
|
+
def view oid
|
13
|
+
@entry = Entry[oid.to_i]
|
14
|
+
end
|
15
|
+
|
16
|
+
def new
|
17
|
+
@title = "Add Entry"
|
18
|
+
end
|
19
|
+
|
20
|
+
def add
|
21
|
+
entry = Entry.new.assign(request.params)
|
22
|
+
entry.time = Time.now
|
23
|
+
session[:result] = "#{entry.title} added successfully" if entry.save
|
24
|
+
redirect :/
|
25
|
+
end
|
26
|
+
|
27
|
+
def edit oid
|
28
|
+
@entry = Entry[oid.to_i]
|
29
|
+
end
|
30
|
+
|
31
|
+
def save
|
32
|
+
redirect_referer unless oid = request.params.delete('oid').to_i
|
33
|
+
entry = Entry[oid].assign(request.params)
|
34
|
+
session[:result] = "#{entry.title} saved successfully" if entry.save
|
35
|
+
redirect :/
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete oid
|
39
|
+
if entry = Entry[oid.to_i]
|
40
|
+
if entry.delete
|
41
|
+
session[:result] = "#{entry.title} deleted successfully"
|
42
|
+
else
|
43
|
+
session[:result] = "Couldn't delete #{entry.title}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
redirect_referer
|
47
|
+
end
|
48
|
+
|
49
|
+
pre :all, :logged_in?, :except => [:index, :view]
|
50
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class Page < Element
|
2
|
+
include Trinity
|
3
|
+
helper :auth
|
4
|
+
|
5
|
+
def render
|
6
|
+
%{
|
7
|
+
<html>
|
8
|
+
<head>
|
9
|
+
<title>#{@title}</title>
|
10
|
+
<link href="/screen.css" type="text/css" rel="stylesheet">
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
#{menu}
|
14
|
+
#{sidebar}
|
15
|
+
#{content}
|
16
|
+
</body>
|
17
|
+
</html>
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def menu
|
22
|
+
%{
|
23
|
+
<div id="menu">
|
24
|
+
<span id="title">
|
25
|
+
<a href="#{R :/}">#{@title || 'Blogging Ramaze'}</a>
|
26
|
+
</span>
|
27
|
+
<?r if check_login ?>
|
28
|
+
<span id="login"> #{link R(:logout), :title => 'logout'} </span>
|
29
|
+
<?r else ?>
|
30
|
+
<span id="login"> #{link R(:login), :title => 'login'} </span>
|
31
|
+
<?r end ?>
|
32
|
+
</div>
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def sidebar
|
37
|
+
entries =
|
38
|
+
Entry.all.map do |e|
|
39
|
+
%{
|
40
|
+
<div>
|
41
|
+
#{link R(:/, :view, e.oid), :title => e.title}
|
42
|
+
</div>
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
%{
|
47
|
+
<div id="sidebar">
|
48
|
+
<h1>Recent Entries</h1>
|
49
|
+
#{entries}
|
50
|
+
</div>
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubygems'
|
6
|
+
gem 'facets', '=1.4.5'
|
7
|
+
require '/home/manveru/prog/projects/nitroproject/glycerin'
|
8
|
+
rescue LoadError
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'og'
|
12
|
+
|
13
|
+
class Comment
|
14
|
+
attr_accessor :text, String
|
15
|
+
attr_accessor :time, Time
|
16
|
+
attr_accessor :author_name, String
|
17
|
+
attr_accessor :author_email, String
|
18
|
+
end
|
19
|
+
|
20
|
+
class Entry
|
21
|
+
attr_accessor :title, String
|
22
|
+
attr_accessor :text, String, :control => :textarea
|
23
|
+
attr_accessor :time, Time
|
24
|
+
has_many Comment
|
25
|
+
end
|
26
|
+
|
27
|
+
unless defined? Entry.ogmanager
|
28
|
+
Og.setup
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<Page title="Ramaze Blog">
|
2
|
+
<?r if @entries.empty? ?>
|
3
|
+
<p>No Entries</p>
|
4
|
+
<?r end ?>
|
5
|
+
<?r @entries.each_with_index do |entry, i| ?>
|
6
|
+
<div class="blog_entry">
|
7
|
+
<div class="title">
|
8
|
+
<div class="title">#{link self, :view, entry.oid, :title => entry.title}</div>
|
9
|
+
<div class="date">#{entry.time}</div>
|
10
|
+
</div>
|
11
|
+
<div class="text">
|
12
|
+
#{BlueCloth.new(entry.text.to_s).to_html}
|
13
|
+
</div>
|
14
|
+
<div class="menu">
|
15
|
+
<?r if check_login ?>
|
16
|
+
#{link self, :delete, entry.oid, :title => 'Delete'}
|
17
|
+
#{link self, :edit, entry.oid, :title => 'Edit'}<br />
|
18
|
+
<?r end ?>
|
19
|
+
Entry #{@entries.size - i}/#{@entries.size}
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<?r end ?>
|
23
|
+
#{link(self, :new, :title => 'New Entry') if check_login}
|
24
|
+
</Page>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<Page>
|
2
|
+
<div class="blog_entry">
|
3
|
+
<div class="title">
|
4
|
+
<div class="title">#{link self, :view, @entry.oid, :title => @entry.title}</div>
|
5
|
+
<div class="date">#{@entry.time}</div>
|
6
|
+
</div>
|
7
|
+
<div class="text">
|
8
|
+
#{@entry.text}
|
9
|
+
</div>
|
10
|
+
<div class="menu">
|
11
|
+
#{link self, :delete, @entry.oid, :title => 'Delete'}
|
12
|
+
#{link self, :edit, @entry.oid, :title => 'Edit'}<br />
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
</Page>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'ramaze'
|
2
|
+
require 'ramaze/../test/test_helper'
|
3
|
+
|
4
|
+
require 'main'
|
5
|
+
|
6
|
+
ramaze do
|
7
|
+
context "Entry" do
|
8
|
+
specify "list" do
|
9
|
+
get('/entry').should =~ %r(<h1>Entry list</h1>)
|
10
|
+
end
|
11
|
+
|
12
|
+
specify "add" do
|
13
|
+
new = get('/entry/new')
|
14
|
+
new.should =~ %r(<input type="text")
|
15
|
+
new.should =~ %r(<textarea name="text")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/examples/caching.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'ramaze'
|
2
|
+
|
3
|
+
include Ramaze
|
4
|
+
|
5
|
+
class MainController < Template::Ramaze
|
6
|
+
helper :cache
|
7
|
+
|
8
|
+
def index
|
9
|
+
calc = "100_000 ** 100_00"
|
10
|
+
%[
|
11
|
+
Hello, i'm a little method with this calculation:
|
12
|
+
#{calc} = #{eval(calc)}
|
13
|
+
]
|
14
|
+
end
|
15
|
+
|
16
|
+
def invalidate
|
17
|
+
uncache_all
|
18
|
+
end
|
19
|
+
|
20
|
+
cache :index
|
21
|
+
end
|
22
|
+
|
23
|
+
run
|
data/examples/element.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'ramaze'
|
2
|
+
include Ramaze
|
3
|
+
|
4
|
+
class Page < Template::Ramaze::Element
|
5
|
+
def render
|
6
|
+
%{
|
7
|
+
<html>
|
8
|
+
<h1>
|
9
|
+
#{@hash['title']}
|
10
|
+
</h1>
|
11
|
+
#{content}
|
12
|
+
</html>
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class SideBar < Template::Ramaze::Element
|
18
|
+
def render
|
19
|
+
%{
|
20
|
+
<div class="sidebar">
|
21
|
+
<a href="http://something.com">something</a>
|
22
|
+
</div>
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class MainController < Template::Ramaze
|
28
|
+
def index
|
29
|
+
%{
|
30
|
+
<Page title="Test">
|
31
|
+
<SideBar />
|
32
|
+
<p>
|
33
|
+
Hello, World!
|
34
|
+
</p>
|
35
|
+
</Page>
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
start
|
data/examples/hello.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'ramaze'
|
5
|
+
|
6
|
+
include Ramaze
|
7
|
+
|
8
|
+
# This is named MainController to automagically map it to '/'
|
9
|
+
# Global.mapping['/'] => MainController
|
10
|
+
# would do the same thing.
|
11
|
+
# you can access it now with http://localhost:7000/
|
12
|
+
# This should output
|
13
|
+
# Hello, World!
|
14
|
+
# in your browser
|
15
|
+
|
16
|
+
class MainController < Template::Ramaze
|
17
|
+
def index
|
18
|
+
"Hello, World!"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# use this to start your app if you don't want to use the `ramaze` bin
|
23
|
+
# start
|
data/examples/simple.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'ramaze'
|
5
|
+
|
6
|
+
# A very simple little application, you can simply run it and
|
7
|
+
# point your browser to http://localhost:7000
|
8
|
+
# you can change the port by setting
|
9
|
+
# Global.port = 80
|
10
|
+
# this most likely requires root-privileges though.
|
11
|
+
|
12
|
+
# This example shows following (requests to the mentioned base-url) :
|
13
|
+
# - simple text-output from the controller [ / ]
|
14
|
+
# - showing you what your request looked like [ /simple ]
|
15
|
+
# - joining two strings [ /join/string1/string2 ]
|
16
|
+
# - join arbitary strings [ /join_all/string1/string2/string3 ... ]
|
17
|
+
# - sum two numbers [ /sum/1/3 ]
|
18
|
+
# - show if you made a POST or GET request [ /post_or_get ]
|
19
|
+
# - How to map your controllers to urls [ /other ]
|
20
|
+
# - Also try out the error-page, just pass something odd ;)
|
21
|
+
|
22
|
+
|
23
|
+
include Ramaze
|
24
|
+
|
25
|
+
class SimpleController < Template::Ramaze
|
26
|
+
def index
|
27
|
+
"simple"
|
28
|
+
end
|
29
|
+
|
30
|
+
def simple
|
31
|
+
request.inspect
|
32
|
+
end
|
33
|
+
|
34
|
+
def join first, second
|
35
|
+
[first, second].join
|
36
|
+
end
|
37
|
+
|
38
|
+
def join_all *strings
|
39
|
+
strings.join
|
40
|
+
end
|
41
|
+
|
42
|
+
def sum first, second
|
43
|
+
first.to_i + second.to_i
|
44
|
+
end
|
45
|
+
|
46
|
+
def post_or_get
|
47
|
+
request.post? ? 'POST' : 'GET'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class OtherController < Template::Ramaze
|
52
|
+
def index
|
53
|
+
"Hello, World from #{self.class.name}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
Global.mapping = {
|
58
|
+
'/' => SimpleController,
|
59
|
+
'/other' => OtherController
|
60
|
+
}
|