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 |
|
|
17 |
|
=over 20 |
18 |
|
|
19 |
|
=item as_markup |
20 |
|
|
21 |
|
HTML content |
22 |
|
|
23 |
|
=item as_sponge |
24 |
|
|
25 |
|
Tabular output |
26 |
|
|
27 |
|
FIXME link to description |
28 |
|
|
29 |
|
=item as_data |
30 |
|
|
31 |
|
Any perl hash structure |
32 |
|
|
33 |
|
=back |
34 |
|
|
35 |
|
|
36 |
|
=head2 No html templates |
37 |
|
|
38 |
|
Frey doesn't have html templates. Since your methods are part of REST URIs, |
39 |
|
it doesn't make sense to separate html from object itself, which represent |
40 |
|
web page. L<Frey::Web> provides role which has a bunch of helpful things |
41 |
|
when creating html. |
42 |
|
|
43 |
|
Basically, if html you are generating in readable code semantically correct |
44 |
|
to you, it the right track. |
45 |
|
|
46 |
|
You don't even have to create initial entry form as L<Frey::Run>, |
47 |
|
which will start your L<Moose> classes, will call L<Frey::Action> |
48 |
|
for help and generate initial form for you. |
49 |
|
|
50 |
|
Creating files is mess, so L<Frey::ClassCreator/create_class_source> will |
51 |
|
create class and test skeleton for you. |
52 |
|
|
53 |
|
If I did it right, it should read similar to human language, like SmallTalk. |
54 |
|
|
55 |
|
To make things simple, there are few convertions (with nod to Ruby on Rails) |
56 |
|
which will help you get started: |
57 |
|
|
58 |
|
|
59 |
|
=head2 default parametars |
60 |
|
|
61 |
|
Default values for |
62 |
|
|
63 |
|
|
64 |
|
=head2 html markup |
65 |
|
|
66 |
|
HTML markup should be enclosed in C< qq| > and C< | > quotes. There is also |
67 |
|
funny but very readable convention of multi line html when you have to |
68 |
|
intermix confitions: |
69 |
|
|
70 |
|
my $html |
71 |
|
= qq|<h1>First</h1>| |
72 |
|
. ( $is_second ? qq|<h2>Second</h2>| : '' ) |
73 |
|
. qq|<h3>Third</h3>| |
74 |
|
; |
75 |
|
|
76 |
|
This will be checked and reported at some point. Ideally, I would like to |
77 |
|
write just |
78 |
|
|
79 |
|
my $html |
80 |
|
= qq|<h1>First</h1>| |
81 |
|
. $is_second ? qq|<h2>Second</h2>| : '' |
82 |
|
. qq|<h3>Third</h3>| |
83 |
|
; |
84 |
|
|
85 |
|
which is valid perl syntax but doesn't work as expected. |
86 |
|
|
87 |
|
|
88 |
|
=head2 SmallTalk like refactoring |
89 |
|
|
90 |
|
Frey is heavily influcenced by SmallTalks, up to the point of syntax. Coding |
91 |
|
Frey code should be like playing with L<Frey>. And you might end up with |
92 |
|
result which might surprise you. |
93 |
|
|
94 |
|
Refactoring tools are not new in perl. However, |
95 |
|
|
96 |
|
|
97 |
|
=head2 examples |
98 |
|
|
99 |
|
To help you get started, here are few implemented flows in Frey: |
100 |
|
|
101 |
|
=over 20 |
102 |
|
|
103 |
|
=item L<Frey::Shell::Grep> |
104 |
|
|
105 |
|
Simple interaction with C<grep> |
106 |
|
|
107 |
|
=item L<Frey::SVK> |
108 |
|
|
109 |
|
Gather data, display selection form with checkboxes |
110 |
|
|
111 |
|
=item L<Frey::IconBrowser> |
112 |
|
|
113 |
|
Display a huge amount of icons with single HTTP request |
114 |
|
|
115 |
|
=back |
116 |
|
|
117 |
|
|
118 |
=head1 Command-line integration |
=head1 Command-line integration |
119 |
|
|
120 |
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 |