ACF core principles: Difference between revisions

From Alpine Linux
m (Reverted edits by Nangel (Talk); changed back to last version by 165.228.132.11)
m (Reverted edits by RuthHughes (talk) to last revision by Ttrask)
 
(11 intermediate revisions by 5 users not shown)
Line 1: Line 1:
While the mvc.lua code provides a generic framework for any lua "mvc"-based appliction, "acf" is the component that makes the mvc.lua framework into a configuration Application. Some ideas and rationales for application-wide settings are discussed here.
While the mvc.lua code provides a generic framework for any lua "mvc"-based application, "acf" is the component that makes the mvc.lua framework into a web configuration Application. Some ideas and rationales for application-wide settings are discussed here.


http://jabraheadset.net/397-jabra-bt160.html jabra bt160, http://jabraheadset.net/359-jabra-wireless-headset-for-bluetooth.html headset jabra bluetooth wireless for, http://jabraheadset.net/205-jabra-wireless.html jabra wireless, http://jabraheadset.net/313-jabra-bt150-3.html jabra bt150, http://jabraheadset.net/363-jabra-freespeak-wireless-headset.html freespeak wireless jabra headset, http://jabraheadset.net/301-jabra-charger.html charger jabra, http://jabraheadset.net/421-jx10-headset-fra-jabra.html headset jx10 fra jabra, http://jabraheadset.net/328-jabra-bluetooth-wireless-cellular-headset.html bluetooth wireless headset cellular jabra, http://jabraheadset.net/161-jabra-bt500-review.html jabra review bt500, http://jabraheadset.net/136-jabra-c250.html jabra c250, http://jabraheadset.net/437-jabra-bt500-bluetooth-cell-phone-headset.html bluetooth phone bt500 jabra cell headset, http://jabraheadset.net/137-jabra-bluetooth-stereo-headset.html bluetooth headset stereo jabra, http://jabraheadset.net/150-jabra-bt620s-stereo-headset.html headset jabra stereo bt620s, http://jabraheadset.net/148-jabra-bt350-bluetooth-headset-review-2.html headset bluetooth review jabra bt350, http://jabraheadset.net/263-jabra-headset.html jabra headset,
= Use of ''cfe'' =


All about http://upcoming.yahoo.com/event/328358/?ps=5 jabra bluetooch
A ''cfe'' ('''C'''onfiguration '''F'''ramework '''E'''ntity) is a way to pass data between a model, controller and view in a common way. There are many ways to do this (e.g. closures, AKClass); use of cfe is an arbitrary decision just to keep development moving forward.


http://jabraheadset.net/415-jabra-bluetooth-headset-2.html headset bluetooth jabra, http://jabraheadset.net/440-jabra-bt320s-bluetooth-stereo-headset-2.html headset stereo jabra bluetooth bt320s, http://jabraheadset.net/220-jabra-cell-phone.html phone cell jabra, http://jabraheadset.net/420-jabra-bt150-bluetooth-headset-5.html headset bluetooth jabra bt150, http://jabraheadset.net/390-jabra-bt150-bluetooth-cell-phone-headset-4.html bluetooth bt150 headset phone cell jabra, http://jabraheadset.net/173-jabra-bluetooth-wireless-stereo.html wireless bluetooth stereo jabra, http://jabraheadset.net/293-jabra-bt250v-headset.html bt250v jabra headset, http://jabraheadset.net/403-jabra-bt620-review-2.html review bt620 jabra,
A cfe is a table with some fields guaranteed to exist. It is also a way to abstract user-modifiable data from view-centric HTML input types. ACF isn't necessarily web-only. With a different controller and views, it could be cli (or gui?!). The acf-cli application is an example of this.
 
== Fields in all cfes  ==
 
cfe's are constructed from a function in <tt>mvc.lua</tt> that returns an anonymous table with the following fields
 
{| border=1
! Field !! Default !! Description
|-
|value || "" || The value of the cfe (e.g. the IP address, hostname, password, etc.)
|-
|type || "text" || The type of entity (see below)
|-
|label || ""  || User-readable label for the value
|}
 
The reason for having these fields pre-defined is to allow models, controllers and views to use the indexes without having to first check if they exist. For example the entity will always have a value and type.
 
cfe's can have other fields. Some common fields that may, or may not, be present:
 
{| border=1
! Field !! Description
|-
|errtxt || Text explaining why validation failed
|-
|option || A list of options for this value
|-
|descr || User-readable description for the value
|-
|seq || Numeric sequence suggesting display order for cfe's in a group or form
|-
|default || Default value (can be displayed to user)
|-
|readonly || If present, indicates that the information is to be displayed, but not editable, typically used in forms
|}
 
To set fields or overwrite field defaults, specify a table in the argument list to the cfe constructor:
 
:mycfe = cfe({label="User", value="asdf", errtxt="Invalid User"})
is equivalent to
:mycfe = {label="User", value="asdf", type="text", errtxt="Invalid User"}
 
== cfe types ==
 
The ''type'' field of a cfe can be one of the following:
 
{| border=1
! type !! Description !! Modifiers
|-
| text || a text field, typically one line of text ||
|-
| longtext || a multi-line text field, like a textarea  ||
|-
| select || a select list || ''value'' is the currently selected item <br>''option'' is an array of select options
|-
| multi || a multi-select list || ''value'' is an array of selected items <br>''option'' is an array of select options
|-
| list || a list || ''value'' is an array of strings
|-
| boolean || true or false ||
|-
| raw || raw binary data ||
|-
| form || a set of cfe's that make up a form || ''value'' is a table of cfe's that make up a form (the table should be name-indexed)<br>''option'' is the command name to save changes (button name for HTML)<br>''descr'' or ''errtxt'' may contain the result of a save attempt
|-
|  group || a set of cfe's that make up an anonymous group || ''value'' is a table of grouped cfe's (can be used to pass several items to a view) (the table should be name-indexed)
|-
|  structure || a Lua table with no further type info ||
|-
|  password || a password which should not be readable by a user ||
|-
|  hidden || a hidden field typically containing information used by ACF and not visible to a user ||
|}


= The Model defines the object set =
= The Model defines the object set =


The model is responsible for writing and reading from the running system. The model also does not need to know which part of a specific acf module it is running under. It is not mandatory that the model be lua "oop" as the rest of the system is. (the model may not have any need to know "self")
The model is responsible for writing and reading from the running system. The model typically does not need to know which part of a specific acf module it is running under. It is not mandatory that the model be lua "oop" as the rest of the system is. (the model may not have any need to know "self")


Since the model can choose how much or how little of the system to expose, the basic data set should be defined in the model.


Since the model can choose how much or how little of the system to expose, the basic data set should be defined in the model (perhaps as a constructor function)
[[Category:ACF]]

Latest revision as of 12:30, 7 March 2016

While the mvc.lua code provides a generic framework for any lua "mvc"-based application, "acf" is the component that makes the mvc.lua framework into a web configuration Application. Some ideas and rationales for application-wide settings are discussed here.

Use of cfe

A cfe (Configuration Framework Entity) is a way to pass data between a model, controller and view in a common way. There are many ways to do this (e.g. closures, AKClass); use of cfe is an arbitrary decision just to keep development moving forward.

A cfe is a table with some fields guaranteed to exist. It is also a way to abstract user-modifiable data from view-centric HTML input types. ACF isn't necessarily web-only. With a different controller and views, it could be cli (or gui?!). The acf-cli application is an example of this.

Fields in all cfes

cfe's are constructed from a function in mvc.lua that returns an anonymous table with the following fields

Field Default Description
value "" The value of the cfe (e.g. the IP address, hostname, password, etc.)
type "text" The type of entity (see below)
label "" User-readable label for the value

The reason for having these fields pre-defined is to allow models, controllers and views to use the indexes without having to first check if they exist. For example the entity will always have a value and type.

cfe's can have other fields. Some common fields that may, or may not, be present:

Field Description
errtxt Text explaining why validation failed
option A list of options for this value
descr User-readable description for the value
seq Numeric sequence suggesting display order for cfe's in a group or form
default Default value (can be displayed to user)
readonly If present, indicates that the information is to be displayed, but not editable, typically used in forms

To set fields or overwrite field defaults, specify a table in the argument list to the cfe constructor:

mycfe = cfe({label="User", value="asdf", errtxt="Invalid User"})

is equivalent to

mycfe = {label="User", value="asdf", type="text", errtxt="Invalid User"}

cfe types

The type field of a cfe can be one of the following:

type Description Modifiers
text a text field, typically one line of text
longtext a multi-line text field, like a textarea
select a select list value is the currently selected item
option is an array of select options
multi a multi-select list value is an array of selected items
option is an array of select options
list a list value is an array of strings
boolean true or false
raw raw binary data
form a set of cfe's that make up a form value is a table of cfe's that make up a form (the table should be name-indexed)
option is the command name to save changes (button name for HTML)
descr or errtxt may contain the result of a save attempt
group a set of cfe's that make up an anonymous group value is a table of grouped cfe's (can be used to pass several items to a view) (the table should be name-indexed)
structure a Lua table with no further type info
password a password which should not be readable by a user
hidden a hidden field typically containing information used by ACF and not visible to a user

The Model defines the object set

The model is responsible for writing and reading from the running system. The model typically does not need to know which part of a specific acf module it is running under. It is not mandatory that the model be lua "oop" as the rest of the system is. (the model may not have any need to know "self")

Since the model can choose how much or how little of the system to expose, the basic data set should be defined in the model.