forked from interchange/wellwell
-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
421 lines (295 loc) · 10.2 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
=== <WARNING> ===
We don't pay any heed to backward compatibility for Wellwell until
it is announced as stable and mature enough.
=== </WARNING> ===
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
WellWell is the new Interchange Shop Starter Kit.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
It's main difference from previous IC demo catalogs that it doesn't tend to be a demo, but rather a frame for building new catalogs.
It's main building blocks are components, assembled together with [compose] called from within pages.
Flaws in Standard / Interchange
*******************************
* two shopping carts components to maintain
* components need to specified on every page instead of globally
* incomplete ITL doesn't crash whole page
Goals
*****
* No stone will be left unturned.
* KISS instead of convoluted ITL code in standard and predecessors.
* Death of [process] (almost done).
* Supersede Interchange's routes and profiles with form framework.
* Keep core of WellWell small, use plugins for extended functionality.
In consequence this deprecates the following tags in this scope:
[button], [image].
Prerequisites
*************
Interchange 5.7.1 and at least:
Dispatch.pm 1.103
Order.pm 2.104
Composition
***********
[compose] basically just evaluates the components passed inside the [compose]
tag and fits them into the containers inside the template.
Templates
=========
Templates are HTML files with placeholders for the containers.
The placeholders are uppercase words inside curly braces.
A very simple template would look like:
<html>
<head>
{HTMLHEAD}
</head>
<body>
{BODY}
</body>
</html>
Components
==========
Components are evaluated as ITL and put into the placeholders.
[compose
component.body="hello_world"
]
To automatically create a wrapping div for each component,
set COMPOSE_CONTAINER to 1.
Automatic components/attributes
===============================
Usually certain components appear on every page and you don't
want to specify them inside the [compose] tag.
[compose] examines the following variables which set
components and attributes globally:
MV_COMPONENT_AUTO
MV_ATTRIBUTE_AUTO
Example:
Variable MV_COMPONENT_AUTO htmlhead:htmlhead left:menu,categorynav body:infobox
Variable MV_ATTRIBUTE_AUTO menu.name=main
Users, Roles and Permissions
****************************
Users
-----
Users are stored in the "users" table. The primary key is "uid", quite like
an Unix user id, which is used to identify the user through the system.
Other settings, like username and email, can be changed by the user.
Roles
-----
Roles allow to group users and grant them permissions. Users are allowed
to be in multiple roles.
Roles are stored in the "roles" table. The primary key is "rid", quite like
an Unix group id, which the exception of the two default roles (anonymous
and authenticated).
The default user roles are:
* Anonymous user: this role is used for users that don't have a user account or that are not authenticated.
* Authenticated user: this role is automatically granted to all logged in users.
The anonymous user has always the rid of 1 and the authenticated user has
always the rid of 2.
This matches the following records in the permissions table:
rid | uid | perm
-----+-----+---------------
1 | 0 | anonymous
2 | 0 | authenticated
The relationship between users and roles is kept in the "user_roles" table,
e.g.
uid | rid
-----+-----
1 | 3
1 | 4
Permissions
-----------
Permissions can be assigned to a role or to an user. If you want
to restrict some content, you can use the [acl] tag for checking
for proper permissions.
The following example produces a link only if the current user
has the "create_content" permission.
[acl check create_content]
<a href="[area new_content]">Create content</a>
[/acl]
[acl] returns its body on success or the permission if body is
empty.
Please note that [acl check] without a permission is always
successful.
Acl parameter in [compose]
..........................
Permissions can be checked for a complete page like that:
[compose
acl.check="view_titles"
acl.bounce="index"
components.body="title_info"
]
Please note that submitted [form] forms bypass this permission
check because they are evaluated during autoload.
Menus
.....
Only menu entries with sufficient permission will be displayed
(permission field in menus table).
Forms
*****
The recommended way to call [form] forms is within the compose tag:
[compose
components.body="product_info wishlist_add"
forms.wishlist_add.name="wishlist_add"
/]
Parts
-----
Each form consists of one or multiple subforms, called parts.
The parts are stored in the "form_series" table:
name Form name
part Part name
label Label displayed on top of the form (optional)
template Template (optional)
profile Profile to check input in this part (optional)
position Position of part (1,2,3,...)
Template
--------
Forms are build from templates as well. The default template is located at:
templates/form
Alternative templates can be specified in table form_series, field
template.
The default template looks as follows:
{PREPEND}
{TOP}
<fieldset>
<legend>{TITLE}</legend>
{FIELDS}
{SUBMIT}
</fieldset>
{BOTTOM}
{PREPEND} is a placeholder which can be used for form components.
{TOP} starts the HTML form.
{TITLE} shows the label field from form_series table.
{FIELDS} contains the regular form elements.
{SUBMIT} contains the button form elements (as specified in form_elements
table or default submit button)
{BOTTOM} ends the HTML form.
Elements
--------
The elements of a form (part) are stored in the "form_elements" table:
code Serial number
name Name of form element
label Label for form element
component Part name
priority Sort order in form (descending)
widget Widget
The widget is passed by the form_element_field theme function to the
[display] tag.
One exception to that is the "legend" widget, which just displays the
label of the form_element.
Attributes
----------
Every form element can have a set of attributes, stored in the form_attributes
table. They are working pretty much the same as in the metadata table for the
Interchange UI.
Attributes can be applied for every form element with a certain name:
wellwell=> select * from form_attributes where name = 'country';
code | name | component | attribute | value
------+---------+-----------+--------------+------------------------------------------------------------
32 | country | | lookup_query | SELECT code,name FROM country ORDER BY priority DESC, name
Or only for a certain from:
wellwell=> select * from form_attributes where component = 'content_edit';
code | name | component | attribute | value
------+------+--------------+-----------+-------
30 | uri | content_edit | width | 200
31 | body | content_edit | height | 400
Hooks
-----
There are two hooks for forms:
form_NAME_load (e.g. form_checkout_load)
form_NAME_save (e.g. form_checkout_save)
The first parameter for the hook sub is the part name.
Load
....
The load hook is called for the setup of a form part. It is not
called if the profile check for the form part has been failed.
The return value of the load hook is either a false value or
a hash reference which can contain the following members:
page triggers a bounce to that page instead of displaying
the form
attributes hash reference providing defaults for form attributes
Save
....
The save hook is called if the form part has been successfully
submitted (e.g. profile check successful).
Theming
-------
Most aspects of a form can be 'themed':
* title
* elements (complete, label and field)
* submit button
Currently, you can modify one of the existing theme functions:
theme_form_title
theme_form_element
theme_form_element_label
theme_form_element_field
theme_form_submit
Components
----------
Regular components can also included in forms. Examples are
dynamic form parts and supplementary content.
Form components are stored in the "form_components" table.
name - form name
part - form part (empty if component applies to all parts of the form)
component - component name
location - placeholder used to place the component, e.g prepend for
{PREPEND} placeholder
priority - sort order in placeholder (descending)
Plugins
*******
Plugins are living in the plugins subdirectory of wellwell.
Plugins are activated by adding them to PLUGINS variable
(comma separated list of plugins).
Please read the README for the plugin first and follow the
instructions before activating the plugin.
Authoring plugins
=================
Plugins are basically a small WellWell catalog on its own.
Configuration
-------------
The configuration file is called plugin.cfg. The basic configuration
is as follows:
Message Loading helloworld plugin.
Variable CURPLUGIN helloworld
include plugins/default.cfg
Info file
---------
The info file NAME.info contains basic information about the plugin:
name
version
author
E.g.
name = Hello world!
version = 0.1
author = Stefan Hornburg (Racke) <[email protected]>
Directory structure
-------------------
NAME.info - info file (see Info file)
plugin.cfg - configuration file (see Configuration)
code - directory for custom code (tags, functions, ...)
pages/NAME - directory for pages
components - directory for components
Images
******
Originals for (product) images are recorded in images table.
Paging
******
Paging can be controlled by passing parameters to [searchcontainer].
paging_startlinks => always show # links at the beginning
paging_endlinks => always show # links at the end
paging_slidelength => length of sliding window
Example:
96 pages, startlinks 3, endlinks 1, slidelength 5
page 1 shows: 1,2,3,4,5,..,96
page 8 shows: 1,2,3,..,6,7,8,9,10,..,96
Processing
**********
1. Autoload
Autoload checks for form submissions so we can reroute the request based on
certain conditions.
Routes
******
More flexible routes needs modifications to Interchange itself, but here we go:
- complementing record files with record macros
Modules for Composition Framework
*********************************
Vend::Compose::Address => addresses, [address]
Vend::Compose::Taxonomy
Features
********
- deal gracefully with discontinued items (through order_missing SpecialSub)