-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
306 lines (240 loc) · 7.79 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
NAME
Tags::HTML::Login::Access - Tags helper for login access.
SYNOPSIS
use Tags::HTML::Login::Access;
my $obj = Tags::HTML::Login::Access->new(%params);
$obj->process($message_ar);
$obj->process_css($message_types_hr);
METHODS
"new"
my $obj = Tags::HTML::Login::Access->new(%params);
Constructor.
Returns instance of object.
* "css"
CSS::Struct::Output object for process_css processing.
Default value is undef.
* "css_access"
CSS class for access box.
Default value is 'form-login'.
* "form_method"
Form method.
Possible values are 'post' and 'get'.
Default value is 'post'.
* "lang"
Language in ISO 639-2 code.
Default value is 'eng'.
* "logo_image_url"
URL to logo image.
Default value is undef.
* "register_url"
URL to registration page.
Default value is undef.
* "tags"
Tags::Output object.
Default value is undef.
* "tags_after"
Reference to array with Tags code which will be placed after
form.
Default value is [].
* "text"
Hash reference with keys defined language in ISO 639-2 code and
value with hash reference with texts.
Required keys are 'login', 'password_label', 'username_label'
and 'submit'.
Default value is:
{
'eng' => {
'login' => 'Login',
'password_label' => 'Password',
'username_label' => 'User name',
'submit' => 'Login',
},
}
"process"
$obj->process($message_ar);
Process Tags structure for login box.
Reference to array with message objects $message_ar must be a instance
of Data::Message::Simple object.
Returns undef.
"process_css"
$obj->process_css($message_types_hr);
Process CSS::Struct structure for login box.
Variable $message_type_hr is reference to hash with keys for message
type and value for color in CSS style. Possible message types are info
and error now. Types are defined in Data::Message::Simple.
Returns undef.
ERRORS
new():
From Class::Utils::set_params():
Unknown parameter '%s'.
From Mo::utils::check_array():
Parameter 'tags_after' must be a array.
Value: %s
Reference: %s
From Mo::utils::CSS::check_css_unit():
Parameter 'width' doesn't contain unit number.
Value: %s
Parameter 'width' doesn't contain unit name.
Value: %s
Parameter 'width' contain bad unit.
Unit: %s
Value: %s
From Mo::utils::Language::check_language_639_2():
Parameter 'lang' doesn't contain valid ISO 639-2 code.
Codeset: %s
Value: %s
From Tags::HTML::new():
Parameter 'css' must be a 'CSS::Struct::Output::*' class.
Parameter 'tags' must be a 'Tags::Output::*' class.
process():
From Tags::HTML::process():
Parameter 'tags' isn't defined.
process_css():
From Tags::HTML::process_css():
Parameter 'css' isn't defined.
EXAMPLE1
use strict;
use warnings;
use CSS::Struct::Output::Indent;
use Tags::HTML::Login::Access;
use Tags::Output::Indent;
# Object.
my $css = CSS::Struct::Output::Indent->new;
my $tags = Tags::Output::Indent->new;
my $obj = Tags::HTML::Login::Access->new(
'css' => $css,
'tags' => $tags,
);
# Process login button.
$obj->process_css;
$obj->process;
# Print out.
print "CSS\n";
print $css->flush."\n\n";
print "HTML\n";
print $tags->flush."\n";
# Output:
# CSS
# .form-login {
# width: 300px;
# background-color: #f2f2f2;
# padding: 20px;
# border-radius: 5px;
# box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
# }
# .form-login fieldset {
# border: none;
# padding: 0;
# margin-bottom: 20px;
# }
# .form-login legend {
# font-weight: bold;
# margin-bottom: 10px;
# }
# .form-login p {
# margin: 0;
# padding: 10px 0;
# }
# .form-login label {
# display: block;
# font-weight: bold;
# margin-bottom: 5px;
# }
# .form-login input[type="text"], .form-login input[type="password"] {
# width: 100%;
# padding: 8px;
# border: 1px solid #ccc;
# border-radius: 3px;
# }
# .form-login button[type="submit"] {
# width: 100%;
# padding: 10px;
# background-color: #4CAF50;
# color: #fff;
# border: none;
# border-radius: 3px;
# cursor: pointer;
# }
# .form-login button[type="submit"]:hover {
# background-color: #45a049;
# }
#
# HTML
# <form class="form-login" method="post">
# <fieldset>
# <legend>
# Login
# </legend>
# <p>
# <label for="username">
# User name
# </label>
# <input type="text" name="username" id="username" autofocus="autofocus">
# </input>
# </p>
# <p>
# <label for="password">
# Password
# </label>
# <input type="password" name="password" id="password">
# </input>
# </p>
# <p>
# <button type="submit" name="login" value="login">
# Login
# </button>
# </p>
# </fieldset>
# </form>
EXAMPLE2
use strict;
use warnings;
use CSS::Struct::Output::Indent;
use Plack::App::Tags::HTML;
use Plack::Runner;
use Tags::HTML::Login::Access;
use Tags::Output::Indent;
use Unicode::UTF8 qw(decode_utf8);
my $css = CSS::Struct::Output::Indent->new;
my $tags = Tags::Output::Indent->new(
'xml' => 1,
'preserved' => ['style'],
);
my $login = Tags::HTML::Login::Access->new(
'css' => $css,
'tags' => $tags,
'register_url' => '/register',
);
my $app = Plack::App::Tags::HTML->new(
'component' => 'Tags::HTML::Container',
'data' => [sub {
$login->process_css;
$login->process;
}],
'data_prepare' => [sub {
$login->process_css;
}],
'css' => $css,
'tags' => $tags,
'title' => 'Login and password',
)->to_app;
Plack::Runner->new->run($app);
# Output screenshot is in images/ directory.
DEPENDENCIES
Class::Utils, Error::Pure, List::Util, Mo::utils, Mo::utils::CSS,
Mo::utils::Language, Readonly, Tags::HTML, Tags::HTML::Messages.
SEE ALSO
Tags::HTML::Login::Button
Tags helper for login button.
Tags::HTML::Login::Register
Tags helper for login register.
REPOSITORY
<https://github.com/michal-josef-spacek/Tags-HTML-Login-Access>
AUTHOR
Michal Josef Špaček <mailto:skim@cpan.org>
<http://skim.cz>
LICENSE AND COPYRIGHT
© 2021-2024 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.14