Skip to content
This repository
Newer
Older
100644 221 lines (169 sloc) 7.221 kb
5fca2bc7 »
2008-04-27 This README is not very technical.
1
2
54e2d9a4 »
2008-05-08 ASCII art in the README
3 -+m
4 .%- ..
5 [ Squatting ] . m*#-+
6cff920e »
2008-05-16 s/a/A/
6 A Camping-inspired Web Microframework for Perl m+*##+m.
54e2d9a4 »
2008-05-08 ASCII art in the README
7 ...- m#*#%-..
8 --.. +mm###-+-.
9 ..- m..*#####*m++
10 .--+.-m#m+.%+-m###+
11 .-m..###+...% m#m-##% .
12 +%+.. -++.+ m--#-+
13 .. --..%*-%- --+#.m
14 - - -.--+# .. +#m+
15 ..#-+%. +.#..
16 . . . .%#-... .-+.-
17 . -.+m+-. .. .-.++#.*-... . .
18 ..- .+. ..+..+---+%---.--.--#m#+.. +
19 .-. m .. -.m++m####%###-##%.++*%++ m .
20 . +. m-- *##*#+###..-m+m.++.#-####-%-m. ..
21 -m#--%###-m+- --+%m..--. - .-*%####% ..-. -.
22 -...-*##%m+.+-+.++-m#+-. .. . +.+%%-#m..m#%m+..-.
23 -..*#**m.-.+..-.m+-##+.- +m-+*%- %-- %##-
24 ...++*++.. . . +m##*-. -.%m+ + -.-++%+-
25 . ++###.%.-- . . *m+##%%. .-%-#- . ...#...
26 ..%*+m . + m+####%.. .-+%#+- .-#--
27 -.#mm.. --.- +%#-m#%% ...%+##%+ .+..\-
28 .+mm%+ .. ..m-m.+%%+m**+.. --.##%m--. + #-.
29 .--%%. . m .#++ %-- +mm-. ...m##m-.+ -+*--
30 +-#+- . .##+.. +..m .m-#%#%-- -.##-.
31 .%.**+. ...m#%..- .. ...# m . +-%#.%+ . %#%..+
32 -+##%.+.. #-. -. .m+..m -#%mm .--**++
33 .-%.*m+-...mm+ . .+ +- -m-+. ..*#.. .
34 .-+*m#%m**++-+ .. -##.%%.- - ..##+-.
35 - +-*%##%+mm--+ . .#m-m- - -+.m.##-+.
36 .. m*##*#*%-m+- - . . .m.+.m .. m%+.*-% -
37 ...+##m%####m-+m- -. .. ..- ++.. . +.. +%-###m-%.
38 ..%#-%#++%####.+.m-+. . +m#+#+%.. . -#*###m.--
39 . %-mm ++-mm+**##%mm. - .+mm#+*.+--.#/##-+-+m .
40 ..+.# - +-. m%m#m#*+.-..+##*###%m#%#% .--- - . .
41 .-m#m. . . ..m+...#%m--+-*#+######.%+.. .+
42 ..m-#%. . ..- .+-- - .---.-**-+--...
43 .+.#m#m- .. . . - -..- ..*
44 . +-##-+. . -- . ..
45 .+##m%+
46 .%.---
47 .. .
48 ...
5fca2bc7 »
2008-04-27 This README is not very technical.
49
54e2d9a4 »
2008-05-08 ASCII art in the README
50 http://en.wikipedia.org/wiki/Squatting
eef08d4e »
2011-06-15 redid the README
51 https://github.com/beppu/squatting
52
53
54 The API (should fit comfortably in your head with plenty of room to spare).
55 ---------------------------------------------------------------------------
56
57 ## [0] BEGINNING AN APP
58
59 package App;
60 use Squatting; # <-- This use statement is where the magic happens.
61 #
62 # %App::CONFIG
63 # &App::D
64 # &App::Controllers::R
65 # @App::Controllers::C
66 # %App::Controllers::C
67 # &App::Controllers::C
68 # &App::Views::R
69 # @App::Views::V
70 # %App::Views::V
71 #
72 # @App::ISA = qw(Squatting);
73 # # ...and Squatting->isa('Class::C3::Componentised')
74
75 ## [1] CUSTOMIZING AN APP
76
77 our %CONFIG = (
78 # App configuration goes in a hash.
79 );
80
81 # Code that needs to run when the app starts goes in init().
82 sub init {
83 my ($class) = @_;
84 $class->next::method();
85 }
5fca2bc7 »
2008-04-27 This README is not very technical.
86
eef08d4e »
2011-06-15 redid the README
87 # Code that needs to run on every request goes in service().
88 sub service {
89 my ($class, $controller, @args) = @_;
90
91 # before controller
5fca2bc7 »
2008-04-27 This README is not very technical.
92
eef08d4e »
2011-06-15 redid the README
93 my $content = $class->next::method($controller, @args);
5fca2bc7 »
2008-04-27 This README is not very technical.
94
eef08d4e »
2011-06-15 redid the README
95 # after controller
7ade3e78 »
2008-05-08 s/Bavl/Example/g
96
eef08d4e »
2011-06-15 redid the README
97 return $content;
98 }
5fca2bc7 »
2008-04-27 This README is not very technical.
99
eef08d4e »
2011-06-15 redid the README
100 1;
5fca2bc7 »
2008-04-27 This README is not very technical.
101
eef08d4e »
2011-06-15 redid the README
102 ## [2] DEFINE CONTROLLERS
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
103
eef08d4e »
2011-06-15 redid the README
104 package App::Controllers;
105 our @C = (
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
106
eef08d4e »
2011-06-15 redid the README
107 C(
108 'Home' => [ '/' ],
109 get => sub {
110 }
111 ),
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
112
eef08d4e »
2011-06-15 redid the README
113 C(
114 'Post' => [ '/(\d+)/(\d+)/(\w+)' ],
115 get => sub {
116 my ($self, $year, $month, $slug) = @_;
117 },
118 post => sub {
119 my ($self, $year, $month, $slug) = @_;
120 }
121 )
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
122
eef08d4e »
2011-06-15 redid the README
123 C(
124 'Comment' => [ '/comment' ],
125 post => sub {
126 }
127 )
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
128
eef08d4e »
2011-06-15 redid the README
129 );
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
130
eef08d4e »
2011-06-15 redid the README
131 1;
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
132
eef08d4e »
2011-06-15 redid the README
133 ## [3] DEFINE VIEWS
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
134
eef08d4e »
2011-06-15 redid the README
135 package App::Views;
136 our @V = (
137 V(
138 'Default',
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
139
eef08d4e »
2011-06-15 redid the README
140 layout => sub {
141 my ($self, $v, $content) = @_;
142 # This optional method allows you to wrap the content
143 # that your template methods return.
144 return "HEADER $content FOOTER";
145 },
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
146
eef08d4e »
2011-06-15 redid the README
147 _partial => sub {
148 my ($self, $v) = @_;
149 # If you want a view to not be wrapped by the layout,
150 # its name should begin with "_".
151 return "exactly what you want";
152 },
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
153
eef08d4e »
2011-06-15 redid the README
154 wrapped => sub {
155 my ($self, $v) = @_;
156 # This template's name does not begin with "_" so it
157 # WILL be wrapped by the layout.
158 return "wrapped content";
159 }
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
160
eef08d4e »
2011-06-15 redid the README
161 _ => sub {
162 my ($self, $v) = @_;
163 # If a named template method is not found, this method
164 # will be run. Think of it as AUTOLOAD for views.
165 return "something";
166 },
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
167
eef08d4e »
2011-06-15 redid the README
168 ),
169 );
170
171 1;
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
172
173
eef08d4e »
2011-06-15 redid the README
174 SUMMARY OF THE SQUATTING API
175 ----------------------------
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
176
eef08d4e »
2011-06-15 redid the README
177 %App::CONFIG Where your app configuration is expected to be
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
178
eef08d4e »
2011-06-15 redid the README
179 &App::init Code that runs on applicationn initialization
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
180
eef08d4e »
2011-06-15 redid the README
181 &App::service Code that runs on every HTTP request
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
182
eef08d4e »
2011-06-15 redid the README
183 App::Controllers Package where controllers are expected to be
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
184
eef08d4e »
2011-06-15 redid the README
185 @App::Controllers::C Array where controllers are expected to be
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
186
eef08d4e »
2011-06-15 redid the README
187 &App::Controllers::C Helper function for creating Squatting::Controller
188 objects
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
189
eef08d4e »
2011-06-15 redid the README
190 &App::Controllers::R Helper function for generating URL paths;
191 Think "R" for "route".
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
192
eef08d4e »
2011-06-15 redid the README
193 App::Views Package where views are expected to be
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
194
eef08d4e »
2011-06-15 redid the README
195 @App::Views::V Array where views are expected to be
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
196
eef08d4e »
2011-06-15 redid the README
197 &App::Views::V Helper function for creating Squatting::View objects
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
198
eef08d4e »
2011-06-15 redid the README
199 &App::Views::R Helper function for generating URL paths;
200 It's the exact same function as &App::Controllers::R.
201 &App::Controllers::R == &App::Views::R
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
202
203
eef08d4e »
2011-06-15 redid the README
204 You should be able to memorize this quite easily, and I hope you
205 never have to use a search engine to figure out how any of this works.
206 The entire API should fit comfortably inside your mind with plenty of
207 room to spare.
15d782e4 »
2008-05-08 the README that evolved from Bavl was more appropriate for Squatting
208
209
eef08d4e »
2011-06-15 redid the README
210 For more information:
211 `perldoc Squatting`
212 `perldoc Squatting::Controller`
213 `perldoc Squatting::View`
214
215
216 For practical examples, see:
217 Rhetoric (a simple blogging system)
218 Pod::Server (a POD browser)
219 Stardust (a COMET server)
5fca2bc7 »
2008-04-27 This README is not very technical.
220
Something went wrong with that request. Please try again.