Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 221 lines (169 sloc) 7.221 kB
5fca2bc This README is not very technical.
John Beppu authored
1
2
54e2d9a ASCII art in the README
John Beppu authored
3 -+m
4 .%- ..
5 [ Squatting ] . m*#-+
6cff920 s/a/A/
John Beppu authored
6 A Camping-inspired Web Microframework for Perl m+*##+m.
54e2d9a ASCII art in the README
John Beppu authored
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 ...
5fca2bc This README is not very technical.
John Beppu authored
49
54e2d9a ASCII art in the README
John Beppu authored
50 http://en.wikipedia.org/wiki/Squatting
eef08d4 @beppu redid the README
authored
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 }
5fca2bc This README is not very technical.
John Beppu authored
86
eef08d4 @beppu redid the README
authored
87 # Code that needs to run on every request goes in service().
88 sub service {
89 my ($class, $controller, @args) = @_;
90
91 # before controller
5fca2bc This README is not very technical.
John Beppu authored
92
eef08d4 @beppu redid the README
authored
93 my $content = $class->next::method($controller, @args);
5fca2bc This README is not very technical.
John Beppu authored
94
eef08d4 @beppu redid the README
authored
95 # after controller
7ade3e7 s/Bavl/Example/g
John Beppu authored
96
eef08d4 @beppu redid the README
authored
97 return $content;
98 }
5fca2bc This README is not very technical.
John Beppu authored
99
eef08d4 @beppu redid the README
authored
100 1;
5fca2bc This README is not very technical.
John Beppu authored
101
eef08d4 @beppu redid the README
authored
102 ## [2] DEFINE CONTROLLERS
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
103
eef08d4 @beppu redid the README
authored
104 package App::Controllers;
105 our @C = (
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
106
eef08d4 @beppu redid the README
authored
107 C(
108 'Home' => [ '/' ],
109 get => sub {
110 }
111 ),
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
112
eef08d4 @beppu redid the README
authored
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 )
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
122
eef08d4 @beppu redid the README
authored
123 C(
124 'Comment' => [ '/comment' ],
125 post => sub {
126 }
127 )
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
128
eef08d4 @beppu redid the README
authored
129 );
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
130
eef08d4 @beppu redid the README
authored
131 1;
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
132
eef08d4 @beppu redid the README
authored
133 ## [3] DEFINE VIEWS
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
134
eef08d4 @beppu redid the README
authored
135 package App::Views;
136 our @V = (
137 V(
138 'Default',
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
139
eef08d4 @beppu redid the README
authored
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 },
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
146
eef08d4 @beppu redid the README
authored
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 },
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
153
eef08d4 @beppu redid the README
authored
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 }
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
160
eef08d4 @beppu redid the README
authored
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 },
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
167
eef08d4 @beppu redid the README
authored
168 ),
169 );
170
171 1;
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
172
173
eef08d4 @beppu redid the README
authored
174 SUMMARY OF THE SQUATTING API
175 ----------------------------
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
176
eef08d4 @beppu redid the README
authored
177 %App::CONFIG Where your app configuration is expected to be
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
178
eef08d4 @beppu redid the README
authored
179 &App::init Code that runs on applicationn initialization
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
180
eef08d4 @beppu redid the README
authored
181 &App::service Code that runs on every HTTP request
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
182
eef08d4 @beppu redid the README
authored
183 App::Controllers Package where controllers are expected to be
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
184
eef08d4 @beppu redid the README
authored
185 @App::Controllers::C Array where controllers are expected to be
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
186
eef08d4 @beppu redid the README
authored
187 &App::Controllers::C Helper function for creating Squatting::Controller
188 objects
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
189
eef08d4 @beppu redid the README
authored
190 &App::Controllers::R Helper function for generating URL paths;
191 Think "R" for "route".
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
192
eef08d4 @beppu redid the README
authored
193 App::Views Package where views are expected to be
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
194
eef08d4 @beppu redid the README
authored
195 @App::Views::V Array where views are expected to be
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
196
eef08d4 @beppu redid the README
authored
197 &App::Views::V Helper function for creating Squatting::View objects
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
198
eef08d4 @beppu redid the README
authored
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
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
202
203
eef08d4 @beppu redid the README
authored
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.
15d782e the README that evolved from Bavl was more appropriate for Squatting
John Beppu authored
208
209
eef08d4 @beppu redid the README
authored
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)
5fca2bc This README is not very technical.
John Beppu authored
220
Something went wrong with that request. Please try again.