ramaze 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/ramaze +58 -26
- data/doc/AUTHORS +2 -0
- data/doc/CHANGELOG +401 -0
- data/doc/README +14 -9
- data/doc/README.html +737 -0
- data/doc/TODO +14 -14
- data/doc/changes.txt +401 -0
- data/doc/changes.xml +401 -0
- data/doc/meta/announcement.txt +28 -15
- data/doc/meta/configuration.txt +3 -3
- data/doc/meta/internals.txt +2 -2
- data/doc/meta/users.kml +62 -0
- data/doc/readme_chunks/examples.txt +1 -1
- data/doc/readme_chunks/features.txt +13 -8
- data/doc/tutorial/todolist.html +2 -2
- data/doc/tutorial/todolist.mkd +2 -2
- data/examples/blog/README +3 -0
- data/examples/blog/spec/blog.rb +101 -0
- data/examples/blog/{main.rb → start.rb} +0 -0
- data/examples/caching.rb +16 -5
- data/examples/layout.rb +41 -0
- data/examples/templates/template_amrita2.rb +1 -1
- data/examples/templates/template_erubis.rb +1 -1
- data/examples/templates/template_ezamar.rb +1 -1
- data/examples/templates/template_haml.rb +1 -1
- data/examples/templates/template_liquid.rb +1 -1
- data/examples/templates/template_markaby.rb +1 -1
- data/examples/templates/template_remarkably.rb +1 -1
- data/examples/todolist/README +1 -0
- data/{spec/examples → examples/todolist/spec}/todolist.rb +3 -3
- data/examples/todolist/{main.rb → start.rb} +0 -0
- data/examples/whywiki/{main.rb → start.rb} +0 -0
- data/examples/wiktacular/README +2 -0
- data/examples/wiktacular/spec/wiktacular.rb +146 -0
- data/examples/wiktacular/src/controller.rb +11 -0
- data/examples/wiktacular/src/model.rb +5 -1
- data/examples/wiktacular/{main.rb → start.rb} +0 -1
- data/examples/wiktacular/template/edit.xhtml +1 -2
- data/examples/wiktacular/template/html_layout.xhtml +27 -0
- data/examples/wiktacular/template/index.xhtml +8 -10
- data/examples/wiktacular/template/new.xhtml +1 -2
- data/lib/proto/{main.rb → start.rb} +0 -0
- data/lib/proto/template/index.xhtml +1 -1
- data/lib/ramaze/action/render.rb +58 -4
- data/lib/ramaze/action.rb +20 -0
- data/lib/ramaze/adapter/cgi.rb +7 -4
- data/lib/ramaze/adapter/fcgi.rb +6 -4
- data/lib/ramaze/adapter/mongrel.rb +4 -0
- data/lib/ramaze/adapter/webrick.rb +20 -9
- data/lib/ramaze/adapter.rb +3 -1
- data/lib/ramaze/cache/memcached.rb +2 -26
- data/lib/ramaze/cache.rb +8 -4
- data/lib/ramaze/controller/resolve.rb +26 -8
- data/lib/ramaze/controller.rb +44 -7
- data/lib/ramaze/dispatcher/action.rb +5 -1
- data/lib/ramaze/dispatcher/directory.rb +115 -0
- data/lib/ramaze/dispatcher/error.rb +19 -5
- data/lib/ramaze/dispatcher/file.rb +2 -2
- data/lib/ramaze/dispatcher.rb +52 -39
- data/lib/ramaze/global/dsl.rb +3 -2
- data/lib/ramaze/global/globalstruct.rb +26 -4
- data/lib/ramaze/global.rb +20 -11
- data/lib/ramaze/helper/aspect.rb +29 -11
- data/lib/ramaze/helper/auth.rb +2 -2
- data/lib/ramaze/helper/cache.rb +2 -0
- data/lib/ramaze/helper/identity.rb +21 -6
- data/lib/ramaze/helper/link.rb +1 -1
- data/lib/ramaze/helper/pager.rb +158 -100
- data/lib/ramaze/helper/partial.rb +22 -0
- data/lib/ramaze/helper/redirect.rb +1 -2
- data/lib/ramaze/helper/stack.rb +1 -1
- data/lib/ramaze/inform/informer.rb +20 -0
- data/lib/ramaze/inform/syslog.rb +5 -0
- data/lib/ramaze/snippets/kernel/__dir__.rb +21 -0
- data/lib/ramaze/snippets/kernel/aquire.rb +22 -12
- data/lib/ramaze/snippets/numeric/human_readable_filesize_format.rb +33 -0
- data/lib/ramaze/snippets/ramaze/caller_lines.rb +1 -1
- data/lib/ramaze/snippets/struct/values_at.rb +11 -4
- data/lib/ramaze/sourcereload.rb +29 -1
- data/{spec → lib/ramaze/spec}/helper/context.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/layout.rb +1 -1
- data/{spec → lib/ramaze/spec}/helper/minimal.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/mock_http.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/requester.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/simple_http.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/wrap.rb +0 -0
- data/lib/ramaze/spec/helper.rb +60 -0
- data/lib/ramaze/store/default.rb +3 -0
- data/lib/ramaze/template/ezamar/render_partial.rb +3 -0
- data/lib/ramaze/template/sass.rb +45 -0
- data/lib/ramaze/template.rb +1 -1
- data/lib/ramaze/tool/create.rb +5 -5
- data/lib/ramaze/tool/localize.rb +26 -5
- data/lib/ramaze/tool/mime.rb +7 -0
- data/lib/ramaze/trinity/response.rb +15 -0
- data/lib/ramaze/trinity/session.rb +1 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze.rb +5 -0
- data/rake_tasks/conf.rake +4 -4
- data/rake_tasks/maintaince.rake +12 -7
- data/rake_tasks/spec.rake +7 -4
- data/spec/examples/caching.rb +6 -8
- data/spec/helper.rb +3 -60
- data/spec/ramaze/action/basics.rb +17 -0
- data/spec/ramaze/action/cache.rb +28 -0
- data/spec/ramaze/action/layout.rb +110 -0
- data/spec/ramaze/action/render.rb +14 -0
- data/spec/ramaze/action/template/bar.xhtml +1 -0
- data/spec/ramaze/action/template/other_wrapper.xhtml +1 -0
- data/spec/ramaze/action/template/single_wrapper.xhtml +1 -0
- data/spec/ramaze/controller/template/edit/content.xhtml +1 -0
- data/spec/ramaze/controller/template/edit.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +2 -2
- data/spec/ramaze/dispatcher/directory.rb +53 -0
- data/spec/ramaze/dispatcher/file.rb +0 -3
- data/spec/ramaze/error.rb +17 -2
- data/spec/ramaze/helper/aspect.rb +14 -20
- data/spec/ramaze/helper/pager.rb +83 -1
- data/spec/ramaze/helper/partial.rb +1 -1
- data/spec/ramaze/helper/template/test_template.xhtml +1 -0
- data/spec/ramaze/inform/informer.rb +37 -5
- data/spec/ramaze/localize.rb +1 -1
- data/spec/ramaze/template/haml.rb +5 -5
- data/spec/ramaze/template/sass/file.css.sass +5 -0
- data/spec/ramaze/template/sass.rb +46 -0
- data/spec/ramaze/template.rb +1 -1
- data/spec/ramaze/trinity/session.rb +27 -0
- data/spec/snippets/kernel/__dir__.rb +8 -0
- data/spec/snippets/kernel/aquire.rb +71 -0
- data/spec/snippets/kernel/constant.rb +27 -0
- data/spec/snippets/numeric/human_readable_filesize_format.rb +11 -0
- data/spec/snippets/ramaze/caller_info.rb +39 -0
- data/spec/snippets/ramaze/caller_lines.rb +27 -0
- data/spec/snippets/string/DIVIDE.rb +18 -0
- data/spec/snippets/string/camel_case.rb +25 -0
- data/spec/snippets/string/color.rb +11 -0
- data/spec/snippets/string/snake_case.rb +17 -0
- data/spec/snippets/struct/fill.rb +27 -0
- data/spec/snippets/struct/values_at.rb +39 -0
- metadata +71 -31
- data/examples/todolist/todolist.db +0 -5
- data/examples/wiktacular/src/page.rb +0 -66
- data/lib/ramaze/helper/feed.rb +0 -135
- data/lib/ramaze/helper/form.rb +0 -204
- data/lib/ramaze/snippets/openstruct/temp.rb +0 -13
- data/lib/ramaze/store/yaml.rb +0 -170
- data/spec/ramaze/helper/feed.rb +0 -127
- data/spec/ramaze/helper/form.rb +0 -146
- data/spec/ramaze/store/yaml.rb +0 -76
data/doc/meta/announcement.txt
CHANGED
|
@@ -1,46 +1,59 @@
|
|
|
1
|
-
This time we are proud to announce Version 0.1.
|
|
1
|
+
This time we are proud to announce Version 0.1.4 of the Ramaze framework, a
|
|
2
2
|
light and modular open source web framework.
|
|
3
3
|
|
|
4
|
-
Since the last release
|
|
5
|
-
|
|
4
|
+
Since the last release hundreds of lines of documentation and specs have been
|
|
5
|
+
written. Ramaze was ported to JRuby and received lots of special love regarding
|
|
6
|
+
bugfixes and polishing the overall API.
|
|
6
7
|
|
|
7
8
|
An extensive set of specs is covering almost every detail of the implementation
|
|
8
9
|
and usage. It is developed by several people and already in production-use at
|
|
9
10
|
some companies.
|
|
10
11
|
|
|
12
|
+
Special (alphabetic) thanks go to:
|
|
13
|
+
|
|
14
|
+
Aman 'tmm1' Gupta - specs, Sass support
|
|
15
|
+
Fabian Buch - porting to JRuby
|
|
16
|
+
Gabriele 'riffraff' Renzi - specs, documentation, cleanup
|
|
17
|
+
Jonathan 'Kashia' Buch - documentation
|
|
18
|
+
Riku Räisänen - extensive testing
|
|
19
|
+
|
|
11
20
|
|
|
12
21
|
Home page: http://ramaze.rubyforge.org
|
|
13
22
|
IRC: #ramaze on irc.freenode.net
|
|
14
23
|
|
|
15
24
|
|
|
16
|
-
Short summary of changes from 0.1.
|
|
25
|
+
Short summary of changes from 0.1.3 to 0.1.4:
|
|
26
|
+
|
|
27
|
+
- Even better error handling.
|
|
28
|
+
|
|
29
|
+
- Many bugs fixed.
|
|
17
30
|
|
|
18
|
-
-
|
|
31
|
+
- Support for Sass CSS templates.
|
|
19
32
|
|
|
20
|
-
-
|
|
33
|
+
- Layouts for actions.
|
|
21
34
|
|
|
22
|
-
-
|
|
35
|
+
- Close to 100% documented methods/classes/methods.
|
|
23
36
|
|
|
24
|
-
-
|
|
37
|
+
- Primitive filebased action-cache.
|
|
25
38
|
|
|
26
|
-
-
|
|
39
|
+
- Runs on JRuby.
|
|
27
40
|
|
|
28
|
-
-
|
|
41
|
+
- Easier integration of ramazes spec-helpers for your own applications.
|
|
29
42
|
|
|
30
|
-
-
|
|
43
|
+
- Dirlisting functionality.
|
|
31
44
|
|
|
32
45
|
|
|
33
|
-
A complete Changelog is available at http://manveru.
|
|
46
|
+
A complete Changelog is available at http://manveru.net/ramaze/doc/CHANGELOG
|
|
34
47
|
|
|
35
48
|
|
|
36
49
|
Known issues:
|
|
37
50
|
|
|
38
|
-
-
|
|
51
|
+
- none yet, waiting for your reports :)
|
|
39
52
|
|
|
40
53
|
|
|
41
54
|
Features:
|
|
42
|
-
- Builds on top of the
|
|
43
|
-
|
|
55
|
+
- Builds on top of the Rack library, which provides easy use of adapters like
|
|
56
|
+
Mongrel, WEBrick, CGI or FCGI.
|
|
44
57
|
|
|
45
58
|
- Supports a wide range of templating-engines like:
|
|
46
59
|
Amrita2, Erubis, Haml, Liquid, Markaby, Remarkably and its own engine
|
data/doc/meta/configuration.txt
CHANGED
|
@@ -110,9 +110,9 @@ cache consists of the controller and parameters, when repeated requests are
|
|
|
110
110
|
made it will always serve the same (now static) page.
|
|
111
111
|
|
|
112
112
|
|
|
113
|
-
:
|
|
113
|
+
:sessions => true
|
|
114
114
|
|
|
115
|
-
Enables
|
|
115
|
+
Enables creation of sessions and automatic creation/setting of cookies.
|
|
116
116
|
Please note that many functionalities of Ramaze depend on an intact session and
|
|
117
117
|
you will have to be careful not to use these.
|
|
118
118
|
This is most likely useful in combination with `cache_all`
|
|
@@ -156,7 +156,7 @@ spec/spec_helper.
|
|
|
156
156
|
:template_root => 'template'
|
|
157
157
|
|
|
158
158
|
The template_root is the point your templates are located relative to the
|
|
159
|
-
location of the entry-file (usually
|
|
159
|
+
location of the entry-file (usually start.rb)
|
|
160
160
|
It is also worth to mention that inside this directory the `mapping` is used
|
|
161
161
|
to locate templates for each controller, only the controller mapped to '/' uses
|
|
162
162
|
the templates directly from the `template_root`
|
data/doc/meta/internals.txt
CHANGED
|
@@ -45,10 +45,10 @@ this path. In our example the file found is a favicon.ico from
|
|
|
45
45
|
Global.public_proto.
|
|
46
46
|
|
|
47
47
|
The contents of FILTER have to return a Ramaze::Response, either the (possibly
|
|
48
|
-
modified) original (
|
|
48
|
+
modified) original (Response#build helps with that) or a totally new
|
|
49
49
|
one.
|
|
50
50
|
|
|
51
|
-
In our case, Dispatcher::File uses
|
|
51
|
+
In our case, Dispatcher::File uses response#build with an opened filehandler as
|
|
52
52
|
body, '200 OK' as status and the Content-Type set to what Tool::MIME.type_for
|
|
53
53
|
tells it is the correct mimetype for this file.
|
|
54
54
|
|
data/doc/meta/users.kml
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<kml xmlns="http://earth.google.com/kml/2.1">
|
|
3
|
+
<Placemark>
|
|
4
|
+
<name>manveru</name>
|
|
5
|
+
<description><![CDATA[ <img src="http://manveru.mine.nu/public/me.png" /><br />
|
|
6
|
+
Tokyo, Japan ]]>
|
|
7
|
+
</description>
|
|
8
|
+
<Point>
|
|
9
|
+
<coordinates>139.667846,35.614759</coordinates>
|
|
10
|
+
</Point>
|
|
11
|
+
</Placemark>
|
|
12
|
+
<Placemark>
|
|
13
|
+
<name>Pistos</name>
|
|
14
|
+
<description>
|
|
15
|
+
<![CDATA[
|
|
16
|
+
<img src="http://purepistos.net/favicon32.png" alt="Pistos" /><br />
|
|
17
|
+
Toronto, Canada<br />
|
|
18
|
+
<a href="http://blog.purepistos.net">blog.purepistos.net</a>
|
|
19
|
+
]]>
|
|
20
|
+
</description>
|
|
21
|
+
<Point>
|
|
22
|
+
<coordinates>-79.386985,43.642515,0</coordinates>
|
|
23
|
+
</Point>
|
|
24
|
+
</Placemark>
|
|
25
|
+
<Placemark>
|
|
26
|
+
<name>MonoDelDiablo</name>
|
|
27
|
+
<description><![CDATA[ Seattle, Washington, United States ]]></description>
|
|
28
|
+
<Point>
|
|
29
|
+
<coordinates>-122.266881,47.682765,0</coordinates>
|
|
30
|
+
</Point>
|
|
31
|
+
</Placemark>
|
|
32
|
+
<Placemark>
|
|
33
|
+
<name>Kashia</name>
|
|
34
|
+
<description><![CDATA[ Helsinki, Etela-Suomen Laani, Finland ]]></description>
|
|
35
|
+
<Point>
|
|
36
|
+
<coordinates>8.447204,49.028928,0</coordinates>
|
|
37
|
+
</Point>
|
|
38
|
+
</Placemark>
|
|
39
|
+
<Placemark>
|
|
40
|
+
<name>zenix</name>
|
|
41
|
+
<description><![CDATA[ Gaithersburg, Maryland, United States ]]></description>
|
|
42
|
+
<Point>
|
|
43
|
+
<coordinates>-77.183338,39.137049,0</coordinates>
|
|
44
|
+
</Point>
|
|
45
|
+
</Placemark>
|
|
46
|
+
<Placemark>
|
|
47
|
+
<name>tmm1</name>
|
|
48
|
+
<description><![CDATA[ <img src="http://tmm1.net/me.jpg" /><br />
|
|
49
|
+
Boston, Massachussetts ]]>
|
|
50
|
+
</description>
|
|
51
|
+
<Point>
|
|
52
|
+
<coordinates>-71.084371,42.365975,0</coordinates>
|
|
53
|
+
</Point>
|
|
54
|
+
</Placemark>
|
|
55
|
+
<Placemark>
|
|
56
|
+
<name>riffraff</name>
|
|
57
|
+
<description><![CDATA[ Rome, Italia ]]></description>
|
|
58
|
+
<Point>
|
|
59
|
+
<coordinates>41.993372,12.087193,0</coordinates>
|
|
60
|
+
</Point>
|
|
61
|
+
</Placemark>
|
|
62
|
+
</kml>
|
|
@@ -55,6 +55,11 @@ Ramaze offers following features at the moment:
|
|
|
55
55
|
|
|
56
56
|
Markaby means Markup as Ruby.
|
|
57
57
|
|
|
58
|
+
* [Sass](http://haml.hamptoncatlin.com/docs/sass)
|
|
59
|
+
|
|
60
|
+
Sass is a meta-language on top of CSS that‘s used to describe the style of
|
|
61
|
+
a document cleanly and structurally, with more power than flat CSS allows.
|
|
62
|
+
|
|
58
63
|
* Ezamar
|
|
59
64
|
|
|
60
65
|
A simple homage to [Nitro](http://nitroproject.org)s templating, is shipped
|
|
@@ -101,14 +106,6 @@ Ramaze offers following features at the moment:
|
|
|
101
106
|
|
|
102
107
|
Easy caching Actions and values.
|
|
103
108
|
|
|
104
|
-
* Feed
|
|
105
|
-
|
|
106
|
-
Programmatically generate feeds from any Class.
|
|
107
|
-
|
|
108
|
-
* Form
|
|
109
|
-
|
|
110
|
-
In development, help appreciated.
|
|
111
|
-
|
|
112
109
|
* Identity
|
|
113
110
|
|
|
114
111
|
For ease of use of the OpenID authentication mechanism.
|
|
@@ -131,6 +128,14 @@ Ramaze offers following features at the moment:
|
|
|
131
128
|
|
|
132
129
|
Authentication via OpenID made easy.
|
|
133
130
|
|
|
131
|
+
* Pager
|
|
132
|
+
|
|
133
|
+
Displays a collection of entitities in multiple pages.
|
|
134
|
+
|
|
135
|
+
* Partial
|
|
136
|
+
|
|
137
|
+
Renders so-called partials.
|
|
138
|
+
|
|
134
139
|
* Stack
|
|
135
140
|
|
|
136
141
|
Allows you to use a call/answer mechanism for things like redirection to the
|
data/doc/tutorial/todolist.html
CHANGED
|
@@ -617,7 +617,7 @@ options, since they are bound to change over time.</p>
|
|
|
617
617
|
|
|
618
618
|
<p>First of all, the default port Ramaze runs on is 7000, but to make it a usual
|
|
619
619
|
webserver it has to run on port 80. So, let's add following line in your
|
|
620
|
-
|
|
620
|
+
start.rb right after the lines of require you added before:</p>
|
|
621
621
|
|
|
622
622
|
<pre><code>Ramaze::Global.port = 80
|
|
623
623
|
</code></pre>
|
|
@@ -645,7 +645,7 @@ options, which is either using flags on the ramaze executable, or like this:</p>
|
|
|
645
645
|
</code></pre>
|
|
646
646
|
|
|
647
647
|
<p>We haven't started Ramaze directly as of yet, but this allows you to ignore the
|
|
648
|
-
ramaze executable and just run your application by <code>ruby
|
|
648
|
+
ramaze executable and just run your application by <code>ruby start.rb</code>.</p>
|
|
649
649
|
|
|
650
650
|
<a name="Eleventh_Step,_Refactor_with_AspectHelper"><h2>Eleventh Step, Refactor with AspectHelper</h2></a>
|
|
651
651
|
|
data/doc/tutorial/todolist.mkd
CHANGED
|
@@ -549,7 +549,7 @@ options, since they are bound to change over time.
|
|
|
549
549
|
|
|
550
550
|
First of all, the default port Ramaze runs on is 7000, but to make it a usual
|
|
551
551
|
webserver it has to run on port 80. So, let's add following line in your
|
|
552
|
-
|
|
552
|
+
start.rb right after the lines of require you added before:
|
|
553
553
|
|
|
554
554
|
Ramaze::Global.port = 80
|
|
555
555
|
|
|
@@ -573,7 +573,7 @@ options, which is either using flags on the ramaze executable, or like this:
|
|
|
573
573
|
Ramaze.start :port => 80, :adapter => :mongrel
|
|
574
574
|
|
|
575
575
|
We haven't started Ramaze directly as of yet, but this allows you to ignore the
|
|
576
|
-
ramaze executable and just run your application by `ruby
|
|
576
|
+
ramaze executable and just run your application by `ruby start.rb`.
|
|
577
577
|
|
|
578
578
|
|
|
579
579
|
## Eleventh Step, Refactor with AspectHelper
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
require 'ramaze/spec/helper'
|
|
2
|
+
|
|
3
|
+
# if these libraries are missing there is no sense in running the tests,
|
|
4
|
+
# cause they won't work at all.
|
|
5
|
+
testcase_requires 'og'
|
|
6
|
+
testcase_requires 'hpricot'
|
|
7
|
+
|
|
8
|
+
# Og sets this in the global namespace and uses the STDERR to write messages
|
|
9
|
+
# We can replace it with Ramaze's logger that does The Right Thing (TM)
|
|
10
|
+
class Logger
|
|
11
|
+
@@global_logger = Ramaze::Inform
|
|
12
|
+
end
|
|
13
|
+
$:.unshift 'examples/blog'
|
|
14
|
+
require 'start'
|
|
15
|
+
|
|
16
|
+
# fix the paths to template and public for the spec
|
|
17
|
+
# this is not needed usually, but this tests are also part of ramaze's suite
|
|
18
|
+
class MainController
|
|
19
|
+
template_root __DIR__ / '../template'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe 'blog' do
|
|
23
|
+
|
|
24
|
+
def check_page(name)
|
|
25
|
+
page = get('/'+name)
|
|
26
|
+
page.status.should == 200
|
|
27
|
+
page.body.should_not be_nil
|
|
28
|
+
|
|
29
|
+
doc = Hpricot(page.body)
|
|
30
|
+
doc.at('title').inner_html.should == 'bl_Og'
|
|
31
|
+
doc.at('h1').inner_html.should == 'bl_Og'
|
|
32
|
+
|
|
33
|
+
doc.search('div#entries').length.should == 1
|
|
34
|
+
|
|
35
|
+
doc
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'should start' do
|
|
39
|
+
ramaze :public_root => 'examples/blog/public', :port => 7001
|
|
40
|
+
get('/').status.should == 200
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'should have main page' do
|
|
44
|
+
doc = check_page('')
|
|
45
|
+
doc.at('div#actions>a').inner_html.should == 'new entry'
|
|
46
|
+
doc.search('div.entry').length.should == 1
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'should have new entry page' do
|
|
50
|
+
doc = check_page('new')
|
|
51
|
+
form = doc.at('div.entry>form')
|
|
52
|
+
form.at('input[@name=title]')['value'].should == ''
|
|
53
|
+
form.at('textarea').inner_html.should == ''
|
|
54
|
+
form.at('input[@type=submit]')['value'].should == 'Add Entry'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def create_page(title,content)
|
|
58
|
+
page = post('/create','title'=>title,'content'=>content)
|
|
59
|
+
page.status.should == 303
|
|
60
|
+
page.location.should == '/'
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'should add new pages' do
|
|
64
|
+
create_page('new page', 'cool! a new page')
|
|
65
|
+
doc = check_page('')
|
|
66
|
+
entry = doc.search('div.entry')
|
|
67
|
+
entry.length.should == 2
|
|
68
|
+
entry = entry.last
|
|
69
|
+
|
|
70
|
+
entry.at('div.title').inner_html == 'new page'
|
|
71
|
+
entry.at('div.content').inner_html == 'cool! a new page'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'should edit existing pages' do
|
|
75
|
+
create_page('new page', 'cool! a new page')
|
|
76
|
+
post('/save','oid'=>'2','title'=>'new title','content'=>'bla bla')
|
|
77
|
+
doc = check_page('')
|
|
78
|
+
entry = doc.search('div.entry')
|
|
79
|
+
entry.length.should == 2
|
|
80
|
+
entry = entry.first
|
|
81
|
+
|
|
82
|
+
entry.at('div.title').inner_html == 'new title'
|
|
83
|
+
entry.at('div.content').inner_html == 'bla bla'
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it 'should delete existing pages' do
|
|
87
|
+
create_page("page to delete", 'content')
|
|
88
|
+
check_page('').search('div.entry').length.should == 2
|
|
89
|
+
page = get('/delete/2')
|
|
90
|
+
page.status.should == 303
|
|
91
|
+
page.location.should == '/'
|
|
92
|
+
check_page('').search('div.entry').length.should == 1
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
after do
|
|
96
|
+
Entry.all.each do |e|
|
|
97
|
+
e.delete unless e.oid == 1
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
end
|
|
File without changes
|
data/examples/caching.rb
CHANGED
|
@@ -7,14 +7,25 @@ class MainController < Controller
|
|
|
7
7
|
helper :cache
|
|
8
8
|
trait :actions_cached => [:index]
|
|
9
9
|
|
|
10
|
-
def index
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
def index
|
|
11
|
+
%[
|
|
12
|
+
<html>
|
|
13
|
+
<head><title>examples/caching</title></head>
|
|
14
|
+
<body>
|
|
15
|
+
<p>
|
|
16
|
+
This action just shows you a random number: #{rand * 100}.<br />
|
|
17
|
+
If you <a href="/">refresh</a> the page it won't change since you see a cached version.<br />
|
|
18
|
+
But if you <a href="/invalidate">invalidate</a> it, the page will be regenerated.
|
|
19
|
+
</p>
|
|
20
|
+
</body>
|
|
21
|
+
</html>
|
|
22
|
+
]
|
|
15
23
|
end
|
|
16
24
|
|
|
17
25
|
def invalidate
|
|
18
26
|
action_cache.clear
|
|
27
|
+
redirect :/
|
|
19
28
|
end
|
|
20
29
|
end
|
|
30
|
+
|
|
31
|
+
Ramaze.start
|
data/examples/layout.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'ramaze'
|
|
2
|
+
include Ramaze
|
|
3
|
+
|
|
4
|
+
class SideBar < Ezamar::Element
|
|
5
|
+
def render
|
|
6
|
+
%{
|
|
7
|
+
<div class="sidebar">
|
|
8
|
+
<a href="http://something.com">something</a>
|
|
9
|
+
</div>
|
|
10
|
+
}
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class MainController < Controller
|
|
15
|
+
map '/'
|
|
16
|
+
layout :page
|
|
17
|
+
|
|
18
|
+
def index
|
|
19
|
+
@title = "Test"
|
|
20
|
+
%{
|
|
21
|
+
<SideBar />
|
|
22
|
+
<p>Hello, World!</p>
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def page
|
|
27
|
+
%{
|
|
28
|
+
<html>
|
|
29
|
+
<head>
|
|
30
|
+
<title>examples/element</title>
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
<h1>#@title</h1>
|
|
34
|
+
#@content
|
|
35
|
+
</body>
|
|
36
|
+
</html>
|
|
37
|
+
}
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
Ramaze.start
|