Skip to content
This repository
Newer
Older
100644 781 lines (545 sloc) 32.429 kb
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
1 = Padrino (padrino-core)
469974fd » nesquena
2009-11-17 Initial commit after merging padrino subgems into single repo
2
3 Padrino is the godfather of Sinatra.
4
0b6a6019 » nesquena
2009-11-18 Migrated existing README's from sinatra_more over to padrino gems
5 == Preface
6
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
7 Padrino is a ruby framework built upon the excellent {Sinatra Microframework}[http://www.sinatrarb.com].
8 Sinatra is a DSL for creating simple web applications in Ruby with speed and minimal effort.
9 This framework tries hard to make it as fun and easy as possible to code much more advanced web applications by
10 building upon the Sinatra philosophies and foundation.
0b6a6019 » nesquena
2009-11-18 Migrated existing README's from sinatra_more over to padrino gems
11
12 == Introduction
13
408aefd8 » nesquena
2009-11-19 Cleaning up preface and introduction in the README
14 Many people love Sinatra's simplicity and lightweight but often quickly come to miss a great deal
15 of functionality provided by other web frameworks such as Rails when building non-trivial applications.
0b6a6019 » nesquena
2009-11-18 Migrated existing README's from sinatra_more over to padrino gems
16
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
17 Our goal with this framework is to match the essence of Sinatra and at the same time create a standard library
0b6a6019 » nesquena
2009-11-18 Migrated existing README's from sinatra_more over to padrino gems
18 of tools, helpers and components that will make Sinatra suitable for more complex applications.
19
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
20 Here is a brief overview of functionality provided by the Padrino framework:
0b6a6019 » nesquena
2009-11-18 Migrated existing README's from sinatra_more over to padrino gems
21
eaad183c » nesquena
2010-02-26 [padrino-core] Fixes features table in readme
22 Agnostic:: Full support for many popular testing, templating, mocking, and data storage choices.
23 Generators:: Create Padrino applications, models, controllers i.e: padrino-gen project.
24 Mountable:: Unlike other ruby frameworks, principally designed for mounting multiple apps.
25 Routing:: Full url named routes, named params, respond_to support, before/after filter support.
26 Tag Helpers:: View helpers such as: tag, content_tag, input_tag.
27 Asset Helpers:: View helpers such as: link_to, image_tag, javascript_include_tag.
28 Form Helpers:: Builder support such as: form_tag, form_for, field_set_tag, text_field.
29 Text Helpers:: Useful formatting like: relative_time_ago, js_escape_html, sanitize_html.
30 Mailer:: Fast and simple delivery support for sending emails (akin to ActionMailer).
31 Admin:: Builtin Admin interface (like Django)
32 Logging:: Provide a unified logger that can interact with your ORM or any library.
33 Reloading:: Automatically reloads server code during development.
34 Localization:: Full support of I18n language localization and can auto-set user’s locale.
0b6a6019 » nesquena
2009-11-18 Migrated existing README's from sinatra_more over to padrino gems
35
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
36 Keep in mind, the user will be able to pull in these components
37 {seperately into existing Sinatra applications}[http://wiki.github.com/padrino/padrino-framework/standalone-usage-in-sinatra]
0b6a6019 » nesquena
2009-11-18 Migrated existing README's from sinatra_more over to padrino gems
38 or use them altogether for a comprehensive upgrade to Sinatra (a full-stack Padrino application).
39
40 == Installation
41
42 To install the padrino framework, simply grab the latest version from gemcutter:
43
bfb8b7ed » nesquena
2010-02-21 Updated a few parts of the README
44 $ sudo gem install padrino
0b6a6019 » nesquena
2009-11-18 Migrated existing README's from sinatra_more over to padrino gems
45
46 This will install the necessary padrino gems to get you started.
886c46ae » nesquena
2009-11-19 Added skeleton for explaining padrino enhancements in parent README
47 Now you are ready to use this gem to enhance your sinatra projects or to create new Padrino applications.
48
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
49 For a more detailed look at Padrino installation,
50 check out the {Installation Guide}[http://wiki.github.com/padrino/padrino-framework/installation].
51
886c46ae » nesquena
2009-11-19 Added skeleton for explaining padrino enhancements in parent README
52 == Usage
53
54 Padrino is a framework which builds on the existing functionality and Sinatra and provides a variety of
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
55 additional tools and helpers to build upon that foundation. This README and Padrino documentation in general will focus
886c46ae » nesquena
2009-11-19 Added skeleton for explaining padrino enhancements in parent README
56 on the enhancements to the core Sinatra functionality. To use Padrino, one should be familiar with the basic
57 usage of Sinatra itself. Resources for Sinatra are listed below:
58
ce0f1dfe » nesquena
2009-11-21 Use proper hyperlink syntax for links within README
59 * {Sinatra Introduction}[http://www.sinatrarb.com/intro.html]
60 * {Sinatra Book}[http://www.sinatrarb.com/book.html]
61 * {Sinatra Github Repo}[http://github.com/sinatra/sinatra]
886c46ae » nesquena
2009-11-19 Added skeleton for explaining padrino enhancements in parent README
62
63 Below is a guide to how this gem enhances the Sinatra framework as part of a 'full-stack' padrino application.
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
64 For information on how to use a specific gem in isolation within an existing Sinatra project, checkout the guide for
65 {Using Padrino in Sinatra}[http://wiki.github.com/padrino/padrino-framework/standalone-usage-in-sinatra].
886c46ae » nesquena
2009-11-19 Added skeleton for explaining padrino enhancements in parent README
66
f654a2e1 » nesquena
2009-11-19 Fleshed out even more of the 'Enhanced Base Application' README
67 == Enhanced Base Application (padrino-core)
886c46ae » nesquena
2009-11-19 Added skeleton for explaining padrino enhancements in parent README
68
ab24abd1 » nesquena
2009-11-19 Add todo note consider not force boot.rb to be in config folder or fo…
69 Sinatra has support for classes which can be extended to create an application: <tt>Sinatra::Base</tt> and <tt>Sinatra::Application</tt>
70 These classes can be extended in order to create a Sinatra web application. These classes provide support for all the basic
71 functionality afforded by Sinatra.
72
73 Padrino has support for an enhanced base application class <tt>Padrino::Application</tt>. <tt>Padrino::Application</tt>
74 expands the capabilities of Sinatra::Application and automatically provides the resulting application access to all of
75 the padrino framework's functionalities.
886c46ae » nesquena
2009-11-19 Added skeleton for explaining padrino enhancements in parent README
76
cdf2adee » nesquena
2009-11-19 Fix rdoc header formatting to remove suffix marks
77 === Simple Application Definition
f654a2e1 » nesquena
2009-11-19 Fleshed out even more of the 'Enhanced Base Application' README
78
cf073239 » nesquena
2009-11-19 Added First piece of README overview to padrino
79 Let us first take a look at the simplest possible Padrino application:
80
81 # app.rb
82 PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT
83 require 'padrino'
84 Padrino.load!
85
3bea5ad5 » nesquena
2009-11-20 Small whitespace cleanup in README
86 class SimpleApp < Padrino::Application
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
87 get '/' do
cf073239 » nesquena
2009-11-19 Added First piece of README overview to padrino
88 'Hello world'
89 end
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
90
91 # and for read better we can divide with controllers
92 controller '/admin' do
93 get '/foo' do
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
94 'Url is /admin/foo'
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
95 end
96 end
cf073239 » nesquena
2009-11-19 Added First piece of README overview to padrino
97 end
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
98
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
99 === Enhanced Route Definitions and Controllers
100
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
101 For a complete overview of the Padrino routing and controller system,
102 check out the {Routing and Controller guide}[http://wiki.github.com/padrino/padrino-framework/controllers].
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
103
104 Suppose we wanted to add additional routes to our Padrino application, and we want to organize the routes
105 within a more structured layout. Simply add a <tt>controllers</tt> or <tt>app/controllers</tt> folder and create a file as such:
106
107 # Simple Example
108 SimpleApp.controllers do
109 get "/test" do
110 "Text to return"
111 end
112 end
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
113
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
114 You can also do more complex route alias definitions:
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
115
116 # app/controllers/example.rb
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
117 SimpleApp.controllers :posts do
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
118 get :index do
119 ...
120 end
121
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
122 get :show, :with => :id do
123 # url generated is '/posts/show/:id'
124 # access params[:id]
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
125 end
126 end
127
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
128 as well as mapping the route aliases to an explicit url:
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
129
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
130 # app/controllers/example.rb
131 SimpleApp.controllers do
132 get :index, :map => '/index' do
133 ...
134 end
135
136 get :account, :map => '/the/accounts/:name/and/:id' do
137 # access params[:name] and params[:index]
138 end
139 end
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
140
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
141 and even configure the respond_to for each route:
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
142
fc8b33cf » Davide D'Agostino
2010-01-12 Doc Fix
143 # app/controllers/example.rb
144 SimpleApp.controllers :admin do
145 get :show, :with => :id, :respond_to => :js do
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
146 "Url is /admin/show/#{params[:id]}.#{params[:format]}"
fc8b33cf » Davide D'Agostino
2010-01-12 Doc Fix
147 end
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
148
fc8b33cf » Davide D'Agostino
2010-01-12 Doc Fix
149 get :other, with => [:id, :name], respond_to => [:html, :json] do
150 case content_type
151 when :js then ... end
152 when :json then ... end
153 end
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
154 end
155 end
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
156
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
157 For a complete overview of the routing and controller system, check out the
158 {Routing and Controller guide}[http://wiki.github.com/padrino/padrino-framework/controllers].
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
159
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
160 === Rendering
161
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
162 Unlike Sinatra, Padrino supports automatic template lookups such as:
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
163
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
164 # searches for 'account/index.{erb,haml,...}
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
165 render 'account/index'
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
166
167 This render does not require any template engine to be specified and will choose the first one that is discovered.
168 The existing render function works as well if an engine type should be specified:
169
170 # example.haml
171 render :haml, 'account/index'
172
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
173 For a complete overview of the Padrino rendering system, check out the
174 {Routing and Controller guide}[http://wiki.github.com/padrino/padrino-framework/controllers].
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
175
176 === Layout
177
178 With Padrino you can (like rails do) use for your custom layout, disable it
179
180 class SimpleApp < Padrino::Application
181
182 # Disable layouts
183 disable layout
184
185 # Use the layout located in views/layouts/custom.haml
186 layout :custom
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
187
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
188 For a complete overview of the layout functionality,
189 check out the {Routing and Controller guide}[http://wiki.github.com/padrino/padrino-framework/controllers].
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
190
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
191 === Mounting Applications
192
193 Padrino applications are all automatically mountable into other Padrino projects. This means that a given Padrino
194 project directory can easily mount multiple applications. This allows for better organization of complex applications,
195 re-usable applications that can be applied (i.e admin, auth, blog) and even more flexibility.
cf073239 » nesquena
2009-11-19 Added First piece of README overview to padrino
196
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
197 You can think of mountable applications as a 'full-featured' merb slice or rails engine. Instead of a separate construct,
198 any application can simply be packaged and mounted into another project.
199
200 Padrino stores application mounting information by default within <tt>config/apps.rb</tt>. This file is intended
201 to keep all information regarding what applications are mounted to which uri's.
202
203 For a complete look at mounting applications within a Padrino project,
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
204 check out the guide on {Mounting Applications}[http://wiki.github.com/padrino/padrino-framework/mounting-applications].
cf073239 » nesquena
2009-11-19 Added First piece of README overview to padrino
205
452cb68b » nesquena
2009-11-19 Further README cleanups for formatting
206 === Auto Load Paths
f654a2e1 » nesquena
2009-11-19 Fleshed out even more of the 'Enhanced Base Application' README
207
cf073239 » nesquena
2009-11-19 Added First piece of README overview to padrino
208 Padrino also intelligently supports requiring useful files within your application automatically and provides
f654a2e1 » nesquena
2009-11-19 Fleshed out even more of the 'Enhanced Base Application' README
209 functionality for easily splitting up your application into separate files. Padrino automatically requires <tt>config/database.rb</tt>
210 as a convention for establishing database connection. Also, any files within the <tt>lib</tt> folder will be required
211 automatically by Padrino.
212
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
213 For a complete overview of auto-loaded paths within Padrino,
214 check out the {Padrino Development Guide}[http://wiki.github.com/padrino/padrino-framework/development-and-terminal-commands].
cf073239 » nesquena
2009-11-19 Added First piece of README overview to padrino
215
cdf2adee » nesquena
2009-11-19 Fix rdoc header formatting to remove suffix marks
216 === Application Logging
cf073239 » nesquena
2009-11-19 Added First piece of README overview to padrino
217
f654a2e1 » nesquena
2009-11-19 Fleshed out even more of the 'Enhanced Base Application' README
218 Padrino also supports robust logging capabilities. By default, logging information will
219 go to the STDOUT in development (for use in a console) and in an environment-specific log file <tt>log/development.log</tt>
220 in test and production environments.
221
222 To use the logger within a Padrino application, simply refer to the <tt>logger</tt> method accessible
223 within your app and any controller or views:
224
225 # controllers/example.rb
17766cc2 » nesquena
2009-11-19 Change all ::controllers, ::urls, ::helpers to invoke directly (i.e B…
226 SimpleApp.controllers do
f654a2e1 » nesquena
2009-11-19 Fleshed out even more of the 'Enhanced Base Application' README
227 get("/test") { logger.info "This is a test" }
228 end
229
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
230 For a complete overview of Padrino logger functionality, check out the
231 {Padrino Development Guide}[http://wiki.github.com/padrino/padrino-framework/development-and-terminal-commands].
f654a2e1 » nesquena
2009-11-19 Fleshed out even more of the 'Enhanced Base Application' README
232
cdf2adee » nesquena
2009-11-19 Fix rdoc header formatting to remove suffix marks
233 === Development Reloader
f654a2e1 » nesquena
2009-11-19 Fleshed out even more of the 'Enhanced Base Application' README
234
235 Padrino applications also have the enabled ability to automatically reload all changing application files without
236 the need to restart the server. Through the use of a customized Rack middleware, all files on the 'load path'
237 are monitored and reloaded whenever changes are applied.
238
239 This makes rapid development much easier and provides a better alternative to 'shotgun' or 'rerun'
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
240 which requires the application server to be restarted which makes requests take much longer to complete.
f654a2e1 » nesquena
2009-11-19 Fleshed out even more of the 'Enhanced Base Application' README
241
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
242 For a complete overview of code reloading in development,
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
243 check out the {Padrino Development Guide}[http://wiki.github.com/padrino/padrino-framework/development-and-terminal-commands].
7566d1d2 » Davide D'Agostino
2010-01-27 Updated main readme with new instructions of admin uploader and examp…
244
cdf2adee » nesquena
2009-11-19 Fix rdoc header formatting to remove suffix marks
245 === Terminal Commands
f654a2e1 » nesquena
2009-11-19 Fleshed out even more of the 'Enhanced Base Application' README
246
247 Padrino also comes equipped with multiple useful terminal commands which can be activated to perform
248 common tasks such as starting / stopping the application, executing the unit tests or activating an irb session.
249
250 The following commands are available:
251
252 # starts the app server (non-daemonized)
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
253 $ padrino start
f654a2e1 » nesquena
2009-11-19 Fleshed out even more of the 'Enhanced Base Application' README
254 # starts the app server (daemonized) with given port, environment and adapter
255 $ padrino start -d -p 3000 -e development -a thin
256
257 # Stops a daemonized app server
258 $ padrino stop
259
260 # Bootup the Padrino console (irb)
261 $ padrino console
cf073239 » nesquena
2009-11-19 Added First piece of README overview to padrino
262
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
263 # Run/List tasks
264 $ padrino rake
265
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
266 You can also create custom rake tasks as well. Using these commands can simplify common tasks
267 making development that much smoother.
cf073239 » nesquena
2009-11-19 Added First piece of README overview to padrino
268
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
269 For a complete overview of Padrino terminal commands, check out the
270 {Padrino Commands Guide}[http://wiki.github.com/padrino/padrino-framework/development-and-terminal-commands].
7566d1d2 » Davide D'Agostino
2010-01-27 Updated main readme with new instructions of admin uploader and examp…
271
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
272 = Agnostic Application Generators (padrino-gen)
273
274 === Overview
275
276 Padrino comes preloaded with flexible code generators powered in part by the excellent Thor gem
277 (incidentally also used in the Rails 3 generators). These generators are intended to allow for easy code generation
278 both in creating new applications and building on existing ones. The generators have been built to be as library agnostic
279 as possible, supporting a myriad of test frameworks, js libraries, mocking libraries, etc.
280
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
281 See the guide for {Padrino Generators}[http://wiki.github.com/padrino/padrino-framework/generators] for a
282 more in-depth look at the system.
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
283
284 === Application Generator
285
286 Padrino provides generator support for quickly creating new Padrino applications. This provides many benefits
287 such as constructing the recommended Padrino application structure, auto-generating a Gemfile listing
288 all starting dependencies and guidelines provided within the generated files to help orient a new user
289 to using Padrino.
290
291 One important feature of the generators is that they were built from the ground up to support a wide variety
292 of tools, libraries and gems for use within your padrino application.
293
294 The simplest possible command to generate a base application would be:
295
ae706207 » DAddYE
2010-02-14 From now we have
296 $ padrino-gen project demo_project
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
297
298 This would construct a Padrino application DemoApp (which extends from Padrino::Application)
ae706207 » DAddYE
2010-02-14 From now we have
299 inside the folder 'demo_project' at our current path. Inside the application there would be configuration and
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
300 setup performed for the default components.
301
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
302 You can define specific components to be used:
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
303
ae706207 » DAddYE
2010-02-14 From now we have
304 $ padrino-gen project demo_project -t rspec -r haml -m rr -s jquery -d datamapper
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
305
306 You can also instruct the generator to skip a certain component to avoid using one at all (or to use your own):
307
ae706207 » DAddYE
2010-02-14 From now we have
308 $ padrino-gen project demo_project --test none --renderer none
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
309
310 The available components and their default options are listed below:
311
0799497a » DAddYE
2010-02-24 Added Cucumber also in our docs.
312 test:: rspec (default), bacon, shoulda, cucumber, testspec, riot
95c43f1a » DAddYE
2010-02-17 Updated Readme.
313 renderer:: haml (default), erb
4127ca70 » nesquena
2010-02-24 [padrino-gen] Added mootools as a javascript option in project generator
314 mock:: none (default), mocha, rr
315 script:: none (default), jquery, prototype, mootools, rightjs
0700a256 » DAddYE
2010-02-25 Added Mongoid in padrino-gen and in padrino-admin
316 orm:: none (default), mongomapper, mongoid, activerecord, sequel, couchrest
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
317
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
318 To learn more about the project generator, check out the guide to
319 {Padrino Generators}[http://wiki.github.com/padrino/padrino-framework/generators].
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
320
ae706207 » DAddYE
2010-02-14 From now we have
321 === Sub App Generator
322
323 Unlike other ruby frameworks Padrino is principally designed for mounting multiple apps at the same time.
324
325 First you need to create a project
326
327 $ padrino-gen project demo_project
328 $ cd demo_project
329
330 Now you are in demo_project and you can create your apps:
331
332 $ padrino-gen app one
333 $ padrino-gen app two
334
335 By default these apps are mounted under:
336
337 * /one
338 * /two
339
340 but you can edit config/apps.rb and change it.
341
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
342 To learn more about the subapp generator, check out the guide to
343 {Padrino Generators}[http://wiki.github.com/padrino/padrino-framework/generators].
344
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
345 === Model Generator
346
347 Padrino provides generator support for quickly creating new models within your Padrino application. Note that
348 the models (and migrations) generated are specifically tailored towards the ORM component and testing framework
349 chosen during application generation.
350
351 Very important to note that model generators are intended primarily to work within applications
352 created through the Padrino application generator and that follow Padrino conventions. Using model generators
353 within an existing application not generated by Padrino will likely not work as expected.
354
355 Using the model generator is as simple as:
356
357 $ padrino-gen model User
358
359 You can also specify desired fields to be contained within your User model:
360
361 $ padrino-gen model User name:string age:integer email:string
362
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
363 To learn more about the model generator, check out the guide to
364 {Padrino Generators}[http://wiki.github.com/padrino/padrino-framework/generators].
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
365
366 === Migration Generator
367
368 Padrino provides generator for quickly generating new migrations to change or manipulate the database schema.
369 These migrations generated will be tailored towards the ORM chosen when generating the application.
370
371 Very important to note that migration generators are intended primarily to work within applications
372 created through the Padrino application generator and that follow Padrino conventions. Using migration generators
373 within an existing application not generated by Padrino will likely not work as expected.
374
375 Using the migration generator is as simple as:
376
377 $ padrino-gen migration AddFieldsToUsers
378 $ padrino-gen migration RemoveFieldsFromUsers
379
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
380 To learn more about the migration generator, check out the guide to
381 {Padrino Generators}[http://wiki.github.com/padrino/padrino-framework/generators].
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
382
383 === Controller Generator
384
385 Padrino provides generator support for quickly creating new controllers within your Padrino application. Note that
386 the controller tests are generated specifically tailored towards the testing framework chosen
387 during application generation.
388
389 Very important to note that controller generators are intended primarily to work within applications
390 created through the Padrino application generator and that follow Padrino conventions.
391
392 Using the controller generator is as simple as:
393
394 $ padrino-gen controller Admin
395
396 You can also specify desired actions to be added to your controller:
397
398 $ padrino-gen controller Admin get:index get:new post:create
399
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
400 To learn more about the controller generator, check out the guide to
401 {Padrino Generators}[http://wiki.github.com/padrino/padrino-framework/generators].
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
402
403 === Mailer Generator
404
405 Padrino provides generator support for quickly creating new mailers within your Padrino application.
406 Very important to note that mailer generators are intended primarily to work within applications
407 created through the Padrino application generator and that follow Padrino conventions.
408
409 Using the mailer generator is as simple as:
410
411 $ padrino-gen mailer UserNotifier
ae706207 » DAddYE
2010-02-14 From now we have
412
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
413 To learn more about the mailer generator, check out the guide to
414 {Padrino Generators}[http://wiki.github.com/padrino/padrino-framework/generators].
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
415
416 = Application Extensions and Helpers (padrino-helpers)
417
418 === Overview
419
420 This component provides a great deal of view helpers related to html markup generation.
421 There are helpers for generating tags, forms, links, images, and more. Most of the basic
422 methods should be very familiar to anyone who has used rails view helpers.
886c46ae » nesquena
2009-11-19 Added skeleton for explaining padrino enhancements in parent README
423
924843b9 » nesquena
2009-11-19 Added padrino-helpers overview to parent README
424 === Output Helpers
425
426 Output helpers are a collection of important methods for managing, capturing and displaying output
427 in various ways and is used frequently to support higher-level helper functions. There are
428 three output helpers worth mentioning: <tt>content_for</tt>, <tt>capture_html</tt>, and <tt>concat_content</tt>
429
430 The content_for functionality supports capturing content and then rendering this into a different place
431 such as within a layout. One such popular example is including assets onto the layout from a template:
432
433 # app/views/site/index.erb
434 ...
435 <% content_for :assets do %>
436 <%= stylesheet_link_tag 'index', 'custom' %>
437 <% end %>
438 ...
439
440 Added to a template, this will capture the includes from the block and allow them to be yielded into the layout:
441
442 # app/views/layout.erb
443 ...
444 <head>
445 <title>Example</title>
446 <%= stylesheet_link_tag 'style' %>
447 <%= yield_content :assets %>
448 </head>
449 ...
450
451 This will automatically insert the contents of the block (in this case a stylesheet include) into the
452 location the content is yielded within the layout.
453
454 The capture_html and the concat_content methods allow content to be manipulated and stored for use in building
455 additional helpers accepting blocks or displaying information in a template. One example is the use of
456 these in constructing a simplified 'form_tag' helper which accepts a block.
457
458 # form_tag '/register' do ... end
459 def form_tag(url, options={}, &block)
460 # ... truncated ...
461 inner_form_html = capture_html(&block)
462 concat_content '<form>' + inner_form_html + '</form>'
463 end
464
465 This will capture the template body passed into the form_tag block and then append the content
466 to the template through the use of <tt>concat_content</tt>. Note have been built to work for both haml and erb
467 templates using the same syntax.
468
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
469 For more information on using output helpers, check out the guide for
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
470 {Padrino Helpers}[http://wiki.github.com/padrino/padrino-framework/application-helpers].
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
471
924843b9 » nesquena
2009-11-19 Added padrino-helpers overview to parent README
472 === Tag Helpers
473
474 Tag helpers are the basic building blocks used to construct html 'tags' within a view template. There
475 are three major functions for this category: <tt>tag</tt>, <tt>content_tag</tt> and <tt>input_tag</tt>.
476
477 The tag and content_tag are for building arbitrary html tags with a name and specified options. If
478 the tag contains 'content' within then <tt>content_tag</tt> is used. For example:
479
480 tag(:br, :style => ‘clear:both’) => <br style="clear:both" />
481 content_tag(:p, "demo", :class => ‘light’) => <p class="light">demo</p>
482
483 The input_tag is used to build tags that are related to accepting input from the user:
484
485 input_tag :text, :class => "demo" => <input type='text' class='demo' />
486 input_tag :password, :value => "secret", :class => "demo"
487
488 Note that all of these accept html options and result in returning a string containing html tags.
489
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
490 For more information on using tag helpers, check out the guide for
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
491 {Padrino Helpers}[http://wiki.github.com/padrino/padrino-framework/application-helpers].
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
492
924843b9 » nesquena
2009-11-19 Added padrino-helpers overview to parent README
493 === Asset Helpers
494
495 Asset helpers are intended to help insert useful html onto a view template such as 'flash' notices,
496 hyperlinks, mail_to links, images, stylesheets and javascript. An example of their uses would be on a
497 simple view template:
498
499 # app/views/example.haml
500 ...
501 %head
502 = stylesheet_link_tag 'layout'
503 = javascript_include_tag 'application'
504 %body
505 ...
506 = flash_tag :notice
507 %p= link_to 'Blog', '/blog', :class => 'example'
508 %p Mail me at #{mail_to 'fake@faker.com', "Fake Email Link", :cc => "test@demo.com"}
509 %p= image_tag 'padrino.png', :width => '35', :class => 'logo'
510
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
511 For more information on using asset helpers, check out the guide for
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
512 {Padrino Helpers}[http://wiki.github.com/padrino/padrino-framework/application-helpers].
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
513
924843b9 » nesquena
2009-11-19 Added padrino-helpers overview to parent README
514 === Form Helpers
515
516 Form helpers are the 'standard' form tag helpers you would come to expect when building forms. A simple
517 example of constructing a non-object form would be:
518
519 - form_tag '/destroy', :class => 'destroy-form', :method => 'delete' do
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
520 = flash_tag(:notice)
521 - field_set_tag do
522 %p
523 = label_tag :username, :class => 'first'
524 = text_field_tag :username, :value => params[:username]
525 %p
526 = label_tag :password, :class => 'first'
527 = password_field_tag :password, :value => params[:password]
528 %p
529 = label_tag :strategy
530 = select_tag :strategy, :options => ['delete', 'destroy'], :selected => 'delete'
531 %p
532 = check_box_tag :confirm_delete
533 - field_set_tag(:class => 'buttons') do
534 = submit_tag "Remove"
535
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
536 For more information on using form helpers, check out the guide for
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
537 {Padrino Helpers}[http://wiki.github.com/padrino/padrino-framework/application-helpers].
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
538
539 === FormBuilders
540
541 Form builders are full-featured objects allowing the construction of complex object-based forms
542 using a simple, intuitive syntax.
543
544 A form_for using these basic fields might look like:
545
546 - form_for @user, '/register', :id => 'register' do |f|
547 = f.error_messages
924843b9 » nesquena
2009-11-19 Added padrino-helpers overview to parent README
548 %p
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
549 = f.label :username, :caption => "Nickname"
550 = f.text_field :username
924843b9 » nesquena
2009-11-19 Added padrino-helpers overview to parent README
551 %p
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
552 = f.label :email
553 = f.text_field :email
924843b9 » nesquena
2009-11-19 Added padrino-helpers overview to parent README
554 %p
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
555 = f.label :password
556 = f.password_field :password
924843b9 » nesquena
2009-11-19 Added padrino-helpers overview to parent README
557 %p
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
558 = f.label :is_admin, :caption => "Admin User?"
559 = f.check_box :is_admin
560 %p
561 = f.label :color, :caption => "Favorite Color?"
562 = f.select :color, :options => ['red', 'black']
563 %p
564 - fields_for @user.location do |location|
565 = location.text_field :street
566 = location.text_field :city
567 %p
568 = f.submit "Create", :class => 'button'
569
570 There is also an additional StandardFormBuilder which builds on the abstract fields that can be used within a form_for.
924843b9 » nesquena
2009-11-19 Added padrino-helpers overview to parent README
571
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
572 A form_for using these standard fields might be:
924843b9 » nesquena
2009-11-19 Added padrino-helpers overview to parent README
573
574 - form_for @user, '/register', :id => 'register' do |f|
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
575 = f.error_messages
576 = f.text_field_block :name, :caption => "Full name"
577 = f.text_field_block :email
578 = f.check_box_block :remember_me
579 = f.select_block :fav_color, :options => ['red', 'blue']
580 = f.password_field_block :password
581 = f.submit_block "Create", :class => 'button'
582
583 and would generate this html (with each input contained in a paragraph and containing a label):
584
585 <form id="register" action="/register" method="post">
586 <p><label for="user_name">Full name: </label><input type="text" id="user_name" name="user[name]"></p>
587 ...omitted...
588 <p><input type="submit" value="Create" class="button"></p>
589 </form>
590
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
591 You can also easily build your own FormBuilder which allows for customized fields and behavior.
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
592
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
593 For more information on using the Padrino form builders, check out the guide for
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
594 {Padrino Helpers}[http://wiki.github.com/padrino/padrino-framework/application-helpers].
924843b9 » nesquena
2009-11-19 Added padrino-helpers overview to parent README
595
596 === Format Helpers
597
598 Format helpers are several useful utilities for manipulating the format of text to achieve a goal.
599 The four format helpers are <tt>escape_html</tt>, <tt>relative_time_ago</tt>, <tt>time_in_words</tt>,
600 and <tt>js_escape_html</tt>.
601
602 The escape_html and js_escape_html function are for taking an html string and escaping certain characters.
603 <tt>escape_html</tt> will escape ampersands, brackets and quotes to their HTML/XML entities. This is useful
604 to sanitize user content before displaying this on a template. <tt>js_escape_html</tt> is used for
605 passing javascript information from a js template to a javascript function.
606
607 escape_html('<hello>&<goodbye>') # => &lt;hello&gt;&amp;&lt;goodbye&gt;
608
e2a5ff21 » nesquena
2009-11-21 Beefed up padrino-helpers README
609 There is also an alias for escape_html called <tt>h</tt> for even easier usage within templates.
924843b9 » nesquena
2009-11-19 Added padrino-helpers overview to parent README
610
e37c21ce » nesquena
2009-11-24 [padrino-helpers] Added support for simple_format, pluralize, truncat…
611 Format helpers also includes a number of useful text manipulation functions such as <tt>simple_format</tt>,
612 <tt>pluralize</tt>, <tt>word_wrap</tt>, and <tt>truncate</tt>.
613
614 simple_format("hello\nworld") # => "<p>hello<br/>world</p>"
615 pluralize(2, 'person') => '2 people'
616 word_wrap('Once upon a time', :line_width => 8) => "Once upon\na time"
617 truncate("Once upon a time in a world far far away", :length => 8) => "Once upon..."
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
618
e37c21ce » nesquena
2009-11-24 [padrino-helpers] Added support for simple_format, pluralize, truncat…
619 These helpers can be invoked from any route or view within your application.
620
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
621 For more information on using the format helpers, check out the guide for
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
622 {Padrino Helpers}[http://wiki.github.com/padrino/padrino-framework/application-helpers].
e37c21ce » nesquena
2009-11-24 [padrino-helpers] Added support for simple_format, pluralize, truncat…
623
924843b9 » nesquena
2009-11-19 Added padrino-helpers overview to parent README
624 === Render Helpers
625
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
626 This component provides a number of rendering helpers making the process of displaying templates a bit easier.
627 This plugin also has support for useful additions such as partials (with support for :collection) for the templating system.
c368dcf8 » nesquena
2009-11-20 Adds mailer documentation to parent README (padrino)
628
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
629 Using render plugin helpers is extremely simple. If you want to render an erb template in your view path:
c368dcf8 » nesquena
2009-11-20 Adds mailer documentation to parent README (padrino)
630
bfb8b7ed » nesquena
2010-02-21 Updated a few parts of the README
631 render :erb, 'path/to/erb/template'
c368dcf8 » nesquena
2009-11-20 Adds mailer documentation to parent README (padrino)
632
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
633 or using haml templates works just as well:
93c87d2f » nesquena
2009-11-20 Added section in README about generators (padrino-core, padrino-gen)
634
bfb8b7ed » nesquena
2010-02-21 Updated a few parts of the README
635 render :haml, 'path/to/haml/template'
93c87d2f » nesquena
2009-11-20 Added section in README about generators (padrino-core, padrino-gen)
636
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
637 There is also a method which renders the first view matching the path and removes the need to define an engine:
93c87d2f » nesquena
2009-11-20 Added section in README about generators (padrino-core, padrino-gen)
638
bfb8b7ed » nesquena
2010-02-21 Updated a few parts of the README
639 render 'path/to/any/template'
93c87d2f » nesquena
2009-11-20 Added section in README about generators (padrino-core, padrino-gen)
640
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
641 Finally, we have the all-important partials support for rendering mini-templates onto a page:
93c87d2f » nesquena
2009-11-20 Added section in README about generators (padrino-core, padrino-gen)
642
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
643 partial 'photo/_item', :object => @photo, :locals => { :foo => 'bar' }
644 partial 'photo/_item', :collection => @photos
cb1be6bf » achiu
2010-01-01 updated readme with padrino-gen destroy option
645
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
646 For more information on using the render and partial helpers, check out the guide for
e632ee39 » nesquena
2010-02-25 [padrino] Truncating README's to shorten them and link to guides.
647 {Padrino Helpers}[http://wiki.github.com/padrino/padrino-framework/application-helpers].
886c46ae » nesquena
2009-11-19 Added skeleton for explaining padrino enhancements in parent README
648
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
649 = Admin Dashboard and Authentication (padrino-admin)
cb1be6bf » achiu
2010-01-01 updated readme with padrino-gen destroy option
650
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
651 === Overview
886c46ae » nesquena
2009-11-19 Added skeleton for explaining padrino enhancements in parent README
652
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
653 Padrino has a beautiful Admin management dashboard with these features:
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
654
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
655 Orm Agnostic:: Data Adapters for Datamapper, Activerecord, Mongomapper, Mongoid
c46643c5 » DAddYE
2010-02-25 [padrino-admin] Template Agnosticism: generates erb or haml views.
656 Template Agnostic:: Erb and Haml Renderer
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
657 Authentication:: Support for Account authentication, Account Permission managment
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
658 Scaffold:: You can simply create a new "admin interface" by providing a Model
659 Access Control:: Supports authentication and role permissions for your application
660
661 === Admin Dashboard Usage
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
662
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
663 For a complete look at usage of the Admin dashboard functionality, be sure to check out the
664 {Padrino Admin}[http://wiki.github.com/padrino/padrino-framework/padrino-admin] guide.
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
665
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
666 Create a new project:
ba3eead0 » Davide D'Agostino
2010-01-14 [padrino-gen] Small fix
667
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
668 $ padrino-gen project demo
669 $ cd demo
ba3eead0 » Davide D'Agostino
2010-01-14 [padrino-gen] Small fix
670
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
671 Create the admin subapplication:
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
672
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
673 demo$ padrino-gen admin
ba3eead0 » Davide D'Agostino
2010-01-14 [padrino-gen] Small fix
674
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
675 Next, follow the admin setup steps:
ba3eead0 » Davide D'Agostino
2010-01-14 [padrino-gen] Small fix
676
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
677 * configure your <tt>config/database.rb</tt> to connect to the correct data.
678 * run <tt>padrino rake dm:migrate</tt> # or ar:migrate if you use activerecord
679 * run <tt>padrino rake seed</tt>
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
680
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
681 Your admin panel now is ready and you can start your server with <tt>padrino start</tt> and point your browser to <tt>/admin</tt>!
df2054e9 » Davide D'Agostino
2010-01-14 [padrino-admin] More docs!
682
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
683 To create a new "scaffold" you need to provide only a Model name to the command:
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
684
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
685 demo$ padrino-gen model post --skip-migration # edit your post.rb model and add some fields
686 demo$ padrino-gen rake dm:auto:migrate
687 demo$ padrino-gen admin_page post
688 demo$ padrino start # and go to http://localhost:3000/admin
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
689
690 That's all!!
691
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
692 === Admin Access Control
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
693
3b40c99c » nesquena
2010-02-24 Minor cleanup to README's
694 Padrino Admin use a model Account for manage role, membership and permissions.
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
695
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
696 For an ecommerce website, usually certain actions require permissions and authentication. This is supported
697 by the admin access control features:
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
698
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
699 class EcommerceSite < Padrino::Application
3b40c99c » nesquena
2010-02-24 Minor cleanup to README's
700 enable :authentication
701 enable :store_location
702 set :login_page, "/login"
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
703
3b40c99c » nesquena
2010-02-24 Minor cleanup to README's
704 access_control.roles_for :any do |role|
705 role.protect "/customer/orders"
706 role.protect "/cart/checkout"
f7b13c66 » Davide D'Agostino
2010-01-12 [padrino-core] Improved Doc
707 end
708 end
709
3b40c99c » nesquena
2010-02-24 Minor cleanup to README's
710 In this example +if+ we visit urls that start with /+customer+/+orders+ or /+cart/checkout+ we will be redirected
711 to our :+login_page+ "/login". Once we are correctly logged in we can visit these pages.
61cf9231 » Davide D'Agostino
2010-01-26 Updated readme with Admin Upload Instructions.
712
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
713 For a more complete look at using the Admin panel functionality and access features, be sure to check out the
714 {Padrino Admin}[http://wiki.github.com/padrino/padrino-framework/padrino-admin] guide.
61cf9231 » Davide D'Agostino
2010-01-26 Updated readme with Admin Upload Instructions.
715
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
716 = Simple Mailer Support (padrino-mailer)
717
718 === Overview
719
720 This component uses an enhanced version of the excellent <tt>pony</tt> library (vendored) for a powerful but simple
721 mailer system within Padrino (and Sinatra). There is full support for using an html content type as well as for file attachments.
722 The MailerPlugin has many similarities to ActionMailer but is much lighterweight and (arguably) easier to use.
723
724 === Usage
725
726 Let's take a look at using the MailerPlugin in an application. By default, MailerPlugin uses the built-in sendmail
727 functionality on the server. However, smtp is also supported using the following configuration:
728
729 Padrino::Mailer::Base.smtp_settings = {
730 :host => 'smtp.gmail.com',
731 :port => '587',
732 :tls => true,
733 :user => 'user',
734 :pass => 'pass',
735 :auth => :plain
736 }
737
738 Once those have been defined, the default will become smtp delivery unless overwritten in an individual mail definition.
739 Next, we should define a custom mailer extended from <tt>Padrino::Mailer::Base</tt>.
740
741 # app/mailers/sample_mailer.rb
742 class SampleMailer < Padrino::Mailer::Base
743 def registration_email(name, user_email_address)
744 from 'admin@site.com'
745 to user_email_address
746 subject 'Welcome to the site!'
747 body :name => name
748 type 'html' # optional, defaults to plain/text
749 charset 'windows-1252' # optional, defaults to utf-8
750 via :sendmail # optional, to smtp if defined otherwise sendmail
751 end
752 end
753
754 This defines a mail called '<tt>registration_mail</tt>' with the specified attributes for delivery. The <tt>body</tt> method
755 is passing the <tt>name</tt> attribute to the body message template which should be defined in
756 <tt>[views_path]/sample_mailer/registration_email.erb</tt> as shown below:
757
758 # ./views/sample_mailer/registration_email.erb
759 This is the body of the email and can access the <%= name %> that was passed in from the mailer definition
760 That's all there is to defining the body of the email which can be plain text or html
761
762 Once the mailer definition has been completed and the template has been defined, the email can be sent using:
763
764 SampleMailer.deliver(:registration_email, "Bob", "bob@bobby.com")
765
766 or if you like the method_missing approach:
767
768 SampleMailer.deliver_registration_email "Bob", 'bob@bobby.com'
769
770 And that will then deliver the email according the the configured options. This is really all you need to send emails.
771
c856f2e0 » nesquena
2010-02-26 [padrino] Truncating and fixing up additional parts of the README. Of…
772 Be sure to check out the
773 {Padrino Mailer}[http://wiki.github.com/padrino/padrino-framework/padrino-mailer] guide for more details on usage.
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
774
775 = Painless Page and Fragment Caching (padrino-cache)
776
777 Not implemented yet.
778
779 == Copyright
93c87d2f » nesquena
2009-11-20 Added section in README about generators (padrino-core, padrino-gen)
780
73015905 » Davide D'Agostino
2010-01-14 [ALL] Adapted test to new changes.
781 Copyright (c) 2010 Padrino. See LICENSE for details.
Something went wrong with that request. Please try again.