mxit-rails 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +101 -2
- data/lib/mxit_rails/engine.rb +3 -0
- data/lib/mxit_rails/version.rb +1 -1
- data/test/dummy/log/development.log +57 -0
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -1,3 +1,102 @@
|
|
1
|
-
|
1
|
+
Mxit Rails
|
2
|
+
==========
|
2
3
|
|
3
|
-
|
4
|
+
A gem that includes a simple and opinionated templating framework for Rails-based Mxit apps.
|
5
|
+
This includes a rough layout, support for styles similar to CSS classes, wrapped inputs, and
|
6
|
+
an elegant way to support Mxit's conversation-based interface.
|
7
|
+
|
8
|
+
Later versions will also include wrappers for important Mxit APIs.
|
9
|
+
|
10
|
+
Sample App
|
11
|
+
----------
|
12
|
+
A basic to-do app has been set up as an example of the gem in use. It can be seen at [mxit-to-do](https://github.com/linsen/mxit-to-do).
|
13
|
+
|
14
|
+
Installation
|
15
|
+
------------
|
16
|
+
To use the gem, just include the gem your rails projects' gemfile:
|
17
|
+
|
18
|
+
gem 'mxit-rails', '~> 0.1.2'
|
19
|
+
|
20
|
+
The newest version is 0.1.2 - it is not recommended to use any earlier versions.
|
21
|
+
|
22
|
+
Basic usage
|
23
|
+
-----------
|
24
|
+
To set up a controller to use the gem, you need to include the `MxitRails::Page` module:
|
25
|
+
|
26
|
+
include MxitRails::Page
|
27
|
+
|
28
|
+
This creates a few helper methods that can be used within that controller
|
29
|
+
|
30
|
+
- `input input_name, input_label` - Define the page's input field with a name (symbol) and text label
|
31
|
+
- `validate type, [parameter], message` - Set up validations on the input field.
|
32
|
+
- `validate message, &block` - A custom message with a block providing a `true` (valid) or `false` (invalid) value.
|
33
|
+
Note that the block must not use a `return` statement
|
34
|
+
- `submit &block` - A code block that will only be executed if the input was submitted and passed all validations.
|
35
|
+
|
36
|
+
### Validations
|
37
|
+
Currently the following validations are available:
|
38
|
+
- `:not_blank`
|
39
|
+
- `:numeric`
|
40
|
+
- `:length, exact_length`
|
41
|
+
- `:min_length, min`
|
42
|
+
- `:max_length, max`
|
43
|
+
|
44
|
+
|
45
|
+
Multi-step forms
|
46
|
+
----------------
|
47
|
+
The gem allows the easy set up of multi-step forms within a single controller action. Forms are defined as follows:
|
48
|
+
|
49
|
+
form do
|
50
|
+
step :first do
|
51
|
+
...
|
52
|
+
end
|
53
|
+
step :second do
|
54
|
+
...
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
The order in which steps are defined will be the order they are presented to users in. Each step should have its own view file, in
|
59
|
+
`app/views/controller/action/step`. Each step has access to the same helper methods as the controller itself. For steps that don't
|
60
|
+
have an input field, a `proceed` helper method is provided
|
61
|
+
|
62
|
+
- `proceed message` - Show a proceed link rather than a form input
|
63
|
+
|
64
|
+
Users will only proceed to the next step in the form if all validations of the previous step pass.
|
65
|
+
|
66
|
+
If the action has a `submit` block (defined outside of the `form`), it will only be executed after the last step is completed.
|
67
|
+
|
68
|
+
|
69
|
+
Styles
|
70
|
+
------
|
71
|
+
Mxit-rails has a basic styling engine that functions similarly to CSS classes. Styles are identified by a symbol,
|
72
|
+
and can be declared in any controller with the `mxit_style` macro. It is recommended to declare them in application controller.
|
73
|
+
|
74
|
+
mxit_style :author, 'background-color:#F8F3EA; color:#000000'
|
75
|
+
|
76
|
+
To include a style in a template, use the `mxit_style` helper method. Any number of styles can be given as parameters to this method.
|
77
|
+
|
78
|
+
<p style="<%= mxit_style :author %>">Lewis Carroll</p>
|
79
|
+
|
80
|
+
The following special styles are used in the overall layout, and it is thus recommended that they be defined. Note that links can only be styled per-page, not per link.
|
81
|
+
|
82
|
+
- `:body` - The page body (`body` element in html)
|
83
|
+
- `:title` - The page title
|
84
|
+
- `:link` - The colour of links in the page
|
85
|
+
- `:link_hover` - The colour and background colour of highlighted links.
|
86
|
+
|
87
|
+
|
88
|
+
Layout
|
89
|
+
------
|
90
|
+
The gem currently includes a default layout that has a title bar, an optional navigation link, and a form input below the body where appropriate.
|
91
|
+
The title and navigation should be defined with `content_for` blocks, addressing `:title` and `:navigation` respectively.
|
92
|
+
|
93
|
+
|
94
|
+
Emulator
|
95
|
+
--------
|
96
|
+
The mxit-rails gem is provided with an emulator to aid development. It can be accessed at `/emulator`. The url will dynamically update to show
|
97
|
+
the current URL of the page shown as a suffix, e.g. `emulator/path_to/page`. Certain parts of the app can similarly be loaded directly by
|
98
|
+
navigating to their corresponding URL.
|
99
|
+
|
100
|
+
To set the root URL of the emulator, add the following line to `config/application.rb`:
|
101
|
+
|
102
|
+
config.mxit_root = 'mxit'
|
data/lib/mxit_rails/engine.rb
CHANGED
data/lib/mxit_rails/version.rb
CHANGED
@@ -45411,3 +45411,60 @@ Completed 200 OK in 4ms (Views: 3.6ms | ActiveRecord: 0.0ms)
|
|
45411
45411
|
|
45412
45412
|
Started GET "/assets/mxit_rails/included.css?body=1" for 127.0.0.1 at 2012-09-18 08:06:19 +0200
|
45413
45413
|
Served asset /mxit_rails/included.css - 304 Not Modified (0ms)
|
45414
|
+
|
45415
|
+
|
45416
|
+
Started GET "/emulator/" for 127.0.0.1 at 2012-09-18 12:11:43 +0200
|
45417
|
+
Connecting to database specified by database.yml
|
45418
|
+
Processing by EmulatorController#index as HTML
|
45419
|
+
Rendered /Users/linsenloots/Dev/payments/mxit-rails/app/views/emulator/index.html.erb (24.5ms)
|
45420
|
+
Completed 200 OK in 34ms (Views: 34.1ms | ActiveRecord: 0.0ms)
|
45421
|
+
|
45422
|
+
|
45423
|
+
Started GET "/assets/mxit_rails/emulator.css?body=1" for 127.0.0.1 at 2012-09-18 12:11:43 +0200
|
45424
|
+
Served asset /mxit_rails/emulator.css - 200 OK (2ms)
|
45425
|
+
|
45426
|
+
|
45427
|
+
Started GET "/assets/mxit_rails/jquery-1.8.0.min.js?body=1" for 127.0.0.1 at 2012-09-18 12:11:43 +0200
|
45428
|
+
Served asset /mxit_rails/jquery-1.8.0.min.js - 304 Not Modified (32ms)
|
45429
|
+
|
45430
|
+
|
45431
|
+
Started GET "/assets/mxit_rails/jquery.cookie.js?body=1" for 127.0.0.1 at 2012-09-18 12:11:44 +0200
|
45432
|
+
Served asset /mxit_rails/jquery.cookie.js - 304 Not Modified (3ms)
|
45433
|
+
|
45434
|
+
|
45435
|
+
Started GET "/assets/mxit_rails/jquery.history.js?body=1" for 127.0.0.1 at 2012-09-18 12:11:44 +0200
|
45436
|
+
Served asset /mxit_rails/jquery.history.js - 304 Not Modified (2ms)
|
45437
|
+
|
45438
|
+
|
45439
|
+
Started GET "/assets/mxit_rails/emulator.js?body=1" for 127.0.0.1 at 2012-09-18 12:11:44 +0200
|
45440
|
+
Served asset /mxit_rails/emulator.js - 304 Not Modified (6ms)
|
45441
|
+
|
45442
|
+
|
45443
|
+
Started GET "/assets/mxit_rails/nokia-5310-frame.png" for 127.0.0.1 at 2012-09-18 12:11:44 +0200
|
45444
|
+
Served asset /mxit_rails/nokia-5310-frame.png - 304 Not Modified (12ms)
|
45445
|
+
|
45446
|
+
|
45447
|
+
Started GET "/assets/mxit_rails/go.png" for 127.0.0.1 at 2012-09-18 12:11:44 +0200
|
45448
|
+
Served asset /mxit_rails/go.png - 304 Not Modified (2ms)
|
45449
|
+
|
45450
|
+
|
45451
|
+
Started GET "/assets/mxit_rails/out.png" for 127.0.0.1 at 2012-09-18 12:11:44 +0200
|
45452
|
+
Served asset /mxit_rails/out.png - 304 Not Modified (2ms)
|
45453
|
+
|
45454
|
+
|
45455
|
+
Started GET "/assets/mxit_rails/refresh.png" for 127.0.0.1 at 2012-09-18 12:11:44 +0200
|
45456
|
+
Served asset /mxit_rails/refresh.png - 304 Not Modified (2ms)
|
45457
|
+
|
45458
|
+
|
45459
|
+
Started GET "/mxit" for 127.0.0.1 at 2012-09-18 12:11:44 +0200
|
45460
|
+
Processing by IndexController#index as HTML
|
45461
|
+
Rendered index/index.html.erb within layouts/mxit (0.6ms)
|
45462
|
+
Completed 200 OK in 10ms (Views: 9.5ms | ActiveRecord: 0.0ms)
|
45463
|
+
|
45464
|
+
|
45465
|
+
Started GET "/assets/mxit_rails/included.css?body=1" for 127.0.0.1 at 2012-09-18 12:11:44 +0200
|
45466
|
+
Served asset /mxit_rails/included.css - 200 OK (3ms)
|
45467
|
+
|
45468
|
+
|
45469
|
+
Started GET "/assets/mxit_rails/favicon.ico" for 127.0.0.1 at 2012-09-18 12:11:44 +0200
|
45470
|
+
Served asset /mxit_rails/favicon.ico - 304 Not Modified (3ms)
|