2 |
|
|
3 |
This page describes how to use and develop with L<Frey> |
This page describes how to use and develop with L<Frey> |
4 |
|
|
5 |
|
=head1 Designing user interaction flows |
6 |
|
|
7 |
|
Frey is all about creating Moose classes as your interaction with pages. |
8 |
|
Each page is instance of class with some parametars received with post or |
9 |
|
get request. |
10 |
|
|
11 |
|
If you want to access those parameters in your object, you have to define |
12 |
|
attributes for it using L<Moose/has> |
13 |
|
|
14 |
|
You can also generate result in three different forms: |
15 |
|
|
16 |
|
=over 20 |
17 |
|
|
18 |
|
=item as_markup |
19 |
|
|
20 |
|
HTML content |
21 |
|
|
22 |
|
=item as_sponge |
23 |
|
|
24 |
|
Tabular output |
25 |
|
|
26 |
|
FIXME link to description |
27 |
|
|
28 |
|
=item as_data |
29 |
|
|
30 |
|
Any perl hash structure |
31 |
|
|
32 |
|
=back |
33 |
|
|
34 |
|
Frey doesn't have html templates. Since your methods are part of REST URIs, |
35 |
|
it doesn't make sense to separate html from object itself, which represent |
36 |
|
web page. L<Frey::Web> provides role which has a bunch of helpful things |
37 |
|
when creating html. |
38 |
|
|
39 |
|
Basically, if html you are generating in readable code semantically correct |
40 |
|
to you, it the right track. |
41 |
|
|
42 |
|
You don't even have to create initial entry form as L<Frey::Run>, |
43 |
|
which will start your L<Moose> classes, will call L<Frey::Action> |
44 |
|
for help and generate initial form for you. |
45 |
|
|
46 |
|
Creating files is mess, so L<Frey::ClassCreator/create_class_source> will |
47 |
|
create class and test skeleton for you. |
48 |
|
|
49 |
|
If I did it right, it should read similar to human language, like SmallTalk. |
50 |
|
|
51 |
|
To make things simple, there are few convertions (with nod to Ruby on Rails) |
52 |
|
which will help you get started: |
53 |
|
|
54 |
|
=head2 default parametars |
55 |
|
|
56 |
|
=head2 html markup |
57 |
|
|
58 |
|
HTML markup should be enclosed in C< qq| > and C< | > quotes. There is also |
59 |
|
funny but very readable convention of multi line html when you have to |
60 |
|
intermix confitions: |
61 |
|
|
62 |
|
my $html |
63 |
|
= qq|<h1>First</h1>| |
64 |
|
. ( $is_second ? qq|<h2>Second</h2>| : '' ) |
65 |
|
. qq|<h3>Third</h3>| |
66 |
|
; |
67 |
|
|
68 |
|
This will be checked and reported at some point. Ideally, I would like to |
69 |
|
write just |
70 |
|
|
71 |
|
my $html |
72 |
|
= qq|<h1>First</h1>| |
73 |
|
. $is_second ? qq|<h2>Second</h2>| : '' |
74 |
|
. qq|<h3>Third</h3>| |
75 |
|
; |
76 |
|
|
77 |
|
which is valid perl syntax but doesn't work as expected. |
78 |
|
|
79 |
|
=head2 examples |
80 |
|
|
81 |
|
To help you get started, here are few implemented flows in Frey: |
82 |
|
|
83 |
|
=over 20 |
84 |
|
|
85 |
|
=item L<Frey::Shell::Grep> |
86 |
|
|
87 |
|
Simple interaction with C<grep> |
88 |
|
|
89 |
|
=item L<Frey::SVK> |
90 |
|
|
91 |
|
Gather data, display selection form with checkboxes |
92 |
|
|
93 |
|
=item L<Frey::IconBrowser> |
94 |
|
|
95 |
|
Display a huge amount of icons with single HTTP request |
96 |
|
|
97 |
|
=back |
98 |
|
|
99 |
=head1 Command-line integration |
=head1 Command-line integration |
100 |
|
|
101 |
One of key points is that L<Frey> runs under your user. This means it has |
One of key points is that L<Frey> runs under your user. This means it has |