/[Frey]/trunk/lib/Frey/Manual.pod
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Frey/Manual.pod

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1014 - (show annotations)
Sun Jan 25 12:57:28 2009 UTC (15 years, 3 months ago) by dpavlin
File size: 6489 byte(s)
DBIC refactor of Reblog into sponge
1 =head1 Frey Manual
2
3 This page describes how to use and develop with L<Frey>
4
5 =head1 Developer parts
6
7 =head2 Moose classes
8
9 All Moose classes have simple introspection API which use
10 L<Frey::Introspect> to show class and it's pod (using L<Frey::Pod>).
11
12 Example of valid REST URL is
13
14 http://localhost:16001/Frey
15
16 which will show L<Frey> class introspection.
17
18 You can also add method invocation and optional parameters to C<new>
19 constructor like this:
20
21 http://localhost:16001/Frey::Pod/as_markup?class=Frey
22
23 this is same using L<Frey::Pod> from perl as
24
25 Frey::Pod->new( class => 'Frey' )->as_markup;
26
27 Forms to enter required parameters will be generated automatically,
28 allowing you to explore your data while you are making interface for it.
29
30 =head2 Database
31
32 FIXME broken if not noted in C<TODO>
33
34 For database objects we support L<DBIx::Class> to introspect existing
35 database and implement user interface for it.
36
37 =over 5
38
39 Steps to create classes for your existing L<Reblog> database:
40
41 =item 1
42
43
44
45 =back
46
47 =head1 User parts
48
49 =head2 Pipes
50
51 See L<Frey::Pipe> for now.
52
53 =head1 Designing user interaction flows
54
55 Frey is all about creating Moose classes as your interaction with pages.
56 Each page is instance of class with some parameters received with post or
57 get request.
58
59 If you want to access those parameters in your object, you have to define
60 attributes for it using L<Moose/has>
61
62 You can also generate result in three different forms:
63
64
65 =over 20
66
67 =item as_markup
68
69 HTML content
70
71 =item as_sponge
72
73 Tabular output
74
75 FIXME link to description
76
77 =item as_data
78
79 Any perl hash structure
80
81 =back
82
83
84 =head2 No html templates
85
86 Frey doesn't have html templates. Since your methods are part of REST URIs,
87 it doesn't make sense to separate html from object itself, which represent
88 web page. L<Frey::Web> provides role which has a bunch of helpful things
89 when creating html.
90
91 Basically, if html you are generating in readable code semantically correct
92 to you, it the right track.
93
94 You don't even have to create initial entry form as L<Frey::Run>,
95 which will start your L<Moose> classes, will call L<Frey::Action>
96 for help and generate initial form for you. If this magic is wrong,
97 just define C<< sub render_pipe { 'radio' } >> to force rending of
98 C<pipe> attribute as radio buttons.
99
100 =head2 Easy skeletons
101
102 Creating files is mess, so L<Frey::Class::Create/create_class_source> will
103 create class and test skeleton for you.
104
105 If I did it right, it should read similar to human language, like Smalltalk.
106
107 L<Frey> is careful to provide enough magic to build skeletons just of files
108 which contain some specific logic to your aplication, so it's not massive code
109 generation as in Java...
110
111 To make things simple, there are few conventions (with nod to Ruby on Rails)
112 which will help you get started:
113
114
115 =head2 HTML markup convetion
116
117 HTML markup should be enclosed in C< qq| > and C< | > quotes. There is also
118 funny but very readable convention of multi line html when you have to
119 intermix conditions:
120
121 my $html
122 = qq|<h1>First</h1>|
123 . ( $is_second ? qq|<h2>Second</h2>| : '' )
124 . qq|<h3>Third</h3>|
125 ;
126
127 This will be checked and reported at some point. Ideally, I would like to
128 write just
129
130 my $html
131 = qq|<h1>First</h1>|
132 . $is_second ? qq|<h2>Second</h2>| : ''
133 . qq|<h3>Third</h3>|
134 ;
135
136 which is valid perl syntax but doesn't work as expected.
137
138
139 =head2 Smalltalk like refactoring
140
141 Frey is heavily influenced by Smalltalk, up to the point of syntax. Coding
142 Frey code should be like playing with L<Frey>. And you might end up with
143 result which might surprise you.
144
145 Refactoring tools are not new in perl. We have L<PPI>, L<App::Ack> and C<vim>
146 so what more do we want?
147
148 If you look closely into Smalltalk development work-flow, you really need
149 ability to rename class or method without any additional effort. For that,
150 we use L<Frey::Class::Refactor> which allows code modifications at source
151 level with just few clicks.
152
153 =head2 Default values
154
155 When L<Frey::Run> tries to create instance of class (usually because of web
156 request) it tried to read default values from C<yaml> files in C<etc/> and
157 if it doesn't find all of required values it will invoke L<Frey::Action> to
158 create end-user html form with missing fields.
159
160
161 =head1 Examples
162
163 To help you get started, here are few implemented flows in Frey:
164
165 =over 20
166
167 =item L<Frey::Shell::Grep>
168
169 Simple interaction with C<grep>
170
171 =item L<Frey::SVK>
172
173 Gather data, display selection form with checkboxes
174
175 =item L<Frey::IconBrowser>
176
177 Display a huge amount of icons with single HTTP request
178
179 =back
180
181
182 =head1 Command-line integration
183
184 One of key points is that L<Frey> runs under your user. This means it has
185 access to your terminal, and ssh keys, so beware!
186
187 =head1 Install
188
189 =head2 Firefox
190
191 Frey is designed to provide close integration between your day-to-day data
192 mungling work in console and Firefox.
193
194 You might want to open separate Firefox and terminal for Frey sessions.
195
196 It's also useful to have Firebug extension installed in Firefox to provide
197 quick introspection on html, network traffic and request parameters.
198
199 If nothing else, L<Frey::Bookmarklet> provides Firebug lite bookmarklet.
200
201 It's all Text! Firefox extension at
202 L<https://addons.mozilla.org/en-US/firefox/addon/4125> provides integration
203 between form textarea and your editor, so it's also handy.
204
205 =head2 vim
206
207 Content on page will be linked to vim using L<Frey::Web/html_links>
208
209 You might want to install vim plugin C<prel_synwrite.vim> from
210 L<http://www.vim.org/scripts/script.php?script_id=896>
211 to check syntax on every C<:Write>
212
213
214 =head2 xdotool
215
216 Used for switching focus between browser and terminal
217
218 =head1 Command-line helpers
219
220 =head2 bin/dev.sh
221
222 Recommended way to start development L<Frey> server since it will restart it
223 automatically and kill running instance if existing.
224
225 =head2 bin/check-syntax.sh
226
227 Check syntax of modified files.
228
229 =head2 bin/grep-iselect.sh
230
231 Helper using C<iselect> to quickly grep, select result and jump to C<vim>.
232
233 You can also pass grep params for context etc, like this:
234
235 ./bin/grep-iselect.sh something -C 3
236 ./bin/grep-iselect.sh something -A 10 -B 3
237
238 =head2 bin/log.sh
239
240 Open last 3 logs in vim
241
242 =head2 bin/checkout-js.sh
243
244 Checkout bunch of JavaScript code from all over the net, some of which is
245 used in Frey and rest is kind of TODO list...
246
247 =head2 bin/clean-var.sh
248
249 Cleanup C<var/> directory which gets a lot of dumps. Most of useful data
250 is held forever because I believe that trends are most interesting way to
251 look at data.
252
253 =cut

  ViewVC Help
Powered by ViewVC 1.1.26