Skip to content

Commit

Permalink
Formatting docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Etiene committed Jul 6, 2015
1 parent bf2b307 commit 7448696
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 45 deletions.
84 changes: 56 additions & 28 deletions docs/manual_form_module.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
This module will generate html to be used on forms that capture data for a model. It is handy and recommended. This module needs to be required on the view: `local form = require "sailor.form"`. Also please note that on views, `<%= var %>` is equal to `<?lua page:print( var ) ?>`.
####form.text(model,attribute,html_options)
Generates a text field input.
* model: object, an instantiated object from a model.
* attribute: string, name of the attribute to which the value of this attribute will be sent to.
* html_options: string, other things to be added inside the input tag.

* model: object, an instantiated object from a model.

* attribute: string, name of the attribute to which the value of this attribute will be sent to.

* html_options: string, other things to be added inside the input tag.

Example 1:

Expand All @@ -14,31 +17,42 @@ Example 1:

####form.textarea(model,attribute,html_options)
Generates a text area input.
* model: object, an instantiated object from a model.
* attribute: string, name of the attribute to which the value of this attribute will be sent to.
* html_options: string, other things to be added inside the input tag.

* model: object, an instantiated object from a model.

* attribute: string, name of the attribute to which the value of this attribute will be sent to.

* html_options: string, other things to be added inside the input tag.

Example 1:

<%= form.textarea(user, 'description', 'class="cute-form-input" width="300"') %>

####form.file(model,attribute,html_options)
Generates a file input.
* model: object, an instantiated object from a model.
* attribute: string, name of the attribute to which the value of this attribute will be sent to.
* html_options: string, other things to be added inside the input tag.

* model: object, an instantiated object from a model.

* attribute: string, name of the attribute to which the value of this attribute will be sent to.

* html_options: string, other things to be added inside the input tag.

Example 1:

<%= form.file(user, 'profile_picture', 'class="cute-form-input" width="300"') %>

####form.dropdown(model,attribute,list,prompt,html_options)
Generates a dropdown list.
* model: object, an instantiated object from a model.
* attribute: string, name of the attribute to which the value of this attribute will be sent to.
* list: table, contains lists of options to be selected.
* prompt: string, first option that contains a nil value.
* html_options: string, other things to be added inside the select tag.

* model: object, an instantiated object from a model.

* attribute: string, name of the attribute to which the value of this attribute will be sent to.

* list: table, contains lists of options to be selected.

* prompt: string, first option that contains a nil value.

* html_options: string, other things to be added inside the select tag.

Example 1:

Expand All @@ -53,22 +67,31 @@ Example 1:

####form.password(model,attribute,html_options)
Generates a password input.
* model: object, an instantiated object from a model.
* attribute: string, name of the attribute to which the value of this attribute will be sent to.
* html_options: string, other things to be added inside the input tag.

* model: object, an instantiated object from a model.

* attribute: string, name of the attribute to which the value of this attribute will be sent to.

* html_options: string, other things to be added inside the input tag.

Example 1:

<%= form.password(user, 'password', 'class="cute-form-input" width="300"') %>

####form.radio_list(model,attribute,list,default,layout,html_options)
Generates a set of radio buttons.
* model: object, an instantiated object from a model.
* attribute: string, name of the attribute to which the value of this attribute will be sent to.
* list: table, contains lists of radios to be selected.
* default: string or nil, which value should be selected by default.
* layout: string or nil, 'vertical' or 'horizontal' (default when nil).
* html_options: string, other things to be added inside the input tag.

* model: object, an instantiated object from a model.

* attribute: string, name of the attribute to which the value of this attribute will be sent to.

* list: table, contains lists of radios to be selected.

* default: string or nil, which value should be selected by default.

* layout: string or nil, 'vertical' or 'horizontal' (default when nil).

* html_options: string, other things to be added inside the input tag.

Example 1:

Expand All @@ -84,11 +107,16 @@ Example 1:

####form.checkbox(model,attribute,label,checked,html_options)
Generates a checkbox.
* model: object, an instantiated object from a model.
* attribute: string, name of the attribute to which the value of this attribute will be sent to.
* label: string or nil, text that will go next to the checkbox, defaults to attribute name when nil.
* checked: boolean, whether or not the checkbox is checked by default.
* html_options: string, other things to be added inside the input tag.

* model: object, an instantiated object from a model.

* attribute: string, name of the attribute to which the value of this attribute will be sent to.

* label: string or nil, text that will go next to the checkbox, defaults to attribute name when nil.

* checked: boolean, whether or not the checkbox is checked by default.

* html_options: string, other things to be added inside the input tag.

Example 1:

Expand Down
18 changes: 12 additions & 6 deletions docs/manual_model_module.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Example:

####model:find( where_string )
(NOT ESCAPED, DO NOT USE THIS FUNCTION UNLESS YOU WRITE THE WHERE_STRING YOURSELF) Finds an object based on the given part of the SQL query after the WHERE. Returns the object found or nil.
* where_string: string that will go after 'WHERE' on your query.

* where_string: string that will go after 'WHERE' on your query.

Example:

Expand All @@ -37,7 +38,8 @@ Example:

####model:find_all( )
(NOT ESCAPED, DO NOT USE THIS FUNCTION UNLESS YOU WRITE THE WHERE_STRING YOURSELF) Finds all objects based on the given part of the SQL query after the WHERE. Returns a table with the objects found or an empty table.
* where_string: string that will go after 'WHERE' on your query.

* where_string: string that will go after 'WHERE' on your query.

Example:

Expand All @@ -59,7 +61,8 @@ Example:

####model:find_by_id( id )
(The alue passed will be escaped) Finds one object with the given id. Returns the object found or nil.
* id: string or number. The id that will be compared to whatever attribute name that is set on your model as db.key.

* id: string or number. The id that will be compared to whatever attribute name that is set on your model as db.key.

Example:

Expand All @@ -70,7 +73,8 @@ Example:

####model.generate_CRUD( model_name )
This will need the model module to be required. Generates a CRUD based on the given model, model must already exist. This function is used in the autogen module and will not correctly intepretate how plurals work in English so you might have to rename some things after the CRUD is created.
* model_name: string, the name of the model.

* model_name: string, the name of the model.

Generated files are:

Expand All @@ -86,11 +90,13 @@ Generated files are:

####model.generate_model( table_name )
This will need the model module to be required. Generates a model based on a given table. This function is used in the autogen module and will not autogenerate model's relations or attributes' rules. A file with the same name of the table will be created under /model.
* table_name, the name of the table

* table_name, the name of the table

####model:get_post( POST )
Will read through POST and search for information posted via sailor's form module and apply them to object. Works based on the fact that input names generated by the form module follow a certain format.
* POST: table containing the post information. Usually page.POST.

* POST: table containing the post information. Usually page.POST.

Example:

Expand Down
22 changes: 14 additions & 8 deletions docs/manual_page_object.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,37 @@ Example: `page:render( 'index', {msg = 'hello'} )`

####page:include( path [*, parms*] )
Includes a .lp file from a .lp file
* path: string, full file path
* parms: [optional] table, vars being passed ahead (env).

* path: string, full file path

* parms: [optional] table, vars being passed ahead (env).

Example: `page:include( '/views/incs/_defaultmenu' )`

####page:redirect( route [*, args*] )
Redirects to another action if the route string doesn't start with 'http://' or another address if it does.
* route: string, "controller_name/action_name" or some website address.
* args: [optional] table, vars being passed as get parameters (only for internal redirect).

* route: string, "controller_name/action_name" or some website address.

* args: [optional] table, vars being passed as get parameters (only for internal redirect).

Example 1: `page:redirect( 'user/update', {id = 2} )`

Example 2: `page:redirect( 'http://google.com' )`

####page:write( data )
Writes a single string to the response body.
* data: string

* data: string

Example 1: `page:write( "Hello world!")`

####page:print( data )
(Apache2): Sends one or more variables to the response body.

(Other webservers): Does the same as page:write does and writes a single string to the response body.
* data: string

* data: string

Example 1: `page:print( "Hello world!")`

Expand All @@ -61,9 +67,9 @@ Example 1: `page:inspect( page.POST )`
* string *writeable*: Sailor comes bundled with a default theme, using Bootstrap. This is the name of a folder inside /themes folder. You can modify the default theme of your application by edditing conf.sailor.theme. You can modify the theme of just one page by setting page.theme to something else on the controller action before rendering your page. You can set it to nil for displaying no theme at all, like for serving a JSON, for example.

####page.layout
* string *writeable*: Sailor default's theme only comes with one layout, main. This refers to a .lp file inside the theme folder. You can create multiple layouts inside one same theme, like 1-column and 2-columns, for example. You can modify the default layout of your application by edditing conf.sailor.layout. You can modify the layout of just one page by setting page.layout to something else on the controller action before rendering your page.
* string *writeable*: Sailor default's theme only comes with one layout, main. This refers to a .lp file inside the theme folder. You can create multiple layouts inside one same theme, like 1-column and 2-columns, for example. You can modify the default layout of your application by edditing conf.sailor.layout. You can modify the layout of just one page by setting page.layout to something else on the controller action before rendering your page.

####page.r
* userdata: request_rec structure that varies according to the webserver, comes with built-in functions.
* userdata: request_rec structure that varies according to the webserver, comes with built-in functions.

(Apache2): [The request_rec structure](http://modlua.org/api/request).
9 changes: 6 additions & 3 deletions docs/manual_sailor_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ Can be used anywhere in a Sailor web application.

####sailor.make_url( route [*, params*] )
Creates a url for an internal app route depending on friendly url configuration
* route: string, controller/action or controller.
* params: [optional] table, vars and values to be sent via GET.

* route: string, controller/action or controller.

* params: [optional] table, vars and values to be sent via GET.

Example 1: `sailor.make_url( 'post/view', {id = 5, title = 'Manual'} )`

####sailor.model( model_name )
Creates a sailor model that can be instantiated in objects with :new().
* model_name: string, model's name. There must be a .lua file with the model's name under /model

* model_name: string, model's name. There must be a .lua file with the model's name under /model

Example 1:

Expand Down

0 comments on commit 7448696

Please sign in to comment.