line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::RoutesAuthDBI::Install; |
2
|
2
|
|
|
2
|
|
89588
|
use Mojo::Base 'Mojolicious::Controller'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
14
|
|
3
|
2
|
|
|
2
|
|
1535
|
use DBIx::Mojo::Template; |
|
2
|
|
|
|
|
22961
|
|
|
2
|
|
|
|
|
24
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
my $sql = DBIx::Mojo::Template->new(__PACKAGE__); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=pod |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=encoding utf8 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 Mojolicious::Plugin::RoutesAuthDBI::Install |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
¡ ¡ ¡ ALL GLORY TO GLORIA ! ! ! |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Mojolicious::Plugin::RoutesAuthDBI::Install - is a Mojolicious::Controller for installation instructions. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DB DESIGN DIAGRAM |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
See L |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 Manual |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$ read -d '' CODE <
|
26
|
|
|
|
|
|
|
use Mojo::Base 'Mojolicious'; |
27
|
|
|
|
|
|
|
sub startup { |
28
|
|
|
|
|
|
|
shift->routes->route('/man') |
29
|
|
|
|
|
|
|
->to('install#manual', namespace=>'Mojolicious::Plugin::RoutesAuthDBI'); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
__PACKAGE__->new->start; |
32
|
|
|
|
|
|
|
PERL |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 View schema (define the postgresql schema name and alternative tables names) |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$ read -d '' CODE <[?...] # /schema/public?profiles=профили |
38
|
|
|
|
|
|
|
use Mojo::Base 'Mojolicious'; |
39
|
|
|
|
|
|
|
sub startup { |
40
|
|
|
|
|
|
|
shift->routes->route('/schema/:schema') |
41
|
|
|
|
|
|
|
->to('Schema#schema', namespace=>'Mojolicious::Plugin::RoutesAuthDBI'); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
__PACKAGE__->new->start; |
44
|
|
|
|
|
|
|
PERL |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 Apply schema (define the postgresql schema name and tables names) |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$ read -d '' CODE <[?...] 2>/dev/null | psql -d # /schema/?roles=groups |
50
|
|
|
|
|
|
|
use Mojo::Base 'Mojolicious'; |
51
|
|
|
|
|
|
|
sub startup { |
52
|
|
|
|
|
|
|
shift->routes->route('/schema/:schema') |
53
|
|
|
|
|
|
|
->to('Schema#schema', namespace=>'Mojolicious::Plugin::RoutesAuthDBI'); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
__PACKAGE__->new->start; |
56
|
|
|
|
|
|
|
PERL |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 Sample app |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$ read -d '' CODE </dev/null > test-app.pl |
62
|
|
|
|
|
|
|
use Mojo::Base 'Mojolicious'; |
63
|
|
|
|
|
|
|
sub startup { |
64
|
|
|
|
|
|
|
shift->routes->route('/app') |
65
|
|
|
|
|
|
|
->to('install#sampl_app', namespace=>'Mojolicious::Plugin::RoutesAuthDBI'); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
__PACKAGE__->new->start; |
68
|
|
|
|
|
|
|
PERL |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 Define DBI->connect(...) and some plugin options in test-app.pl |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 Check list of admin routes: |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$ perl test-app.pl routes |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 Start app |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$ perl test-app.pl daemon |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 Trust url for admin-user creation: |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$ perl test-app.pl get /{admin}{prefix}>/{admin}{trust}>/user/new// 2>/dev/null |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
User will be created and assigned to role 'Admin' . Role 'Admin' assigned to namespace 'Mojolicious::Plugin::RoutesAuthDBI' that has access to all admin controller routes! |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 Sign in on browser |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
http://127.0.0.1:3000/sign/in// |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 Administration of system ready! |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub manual { |
95
|
1
|
|
|
1
|
0
|
266
|
my $c = shift; |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
11
|
$c->render(format=>'txt', text=><<'TXT'); |
98
|
|
|
|
|
|
|
Welcome Mojolicious::Plugin::RoutesAuthDBI ! |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1. Apply db schema by command (define the postgresql schema name): |
101
|
|
|
|
|
|
|
------------ |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$ perl -e "use Mojo::Base 'Mojolicious'; __PACKAGE__->new()->start(); sub startup {shift->routes->route('/schema/:schema')->to('DB#schema', namespace=>'Mojolicious::Plugin::RoutesAuthDBI');}" get /schema/public 2>/dev/null | psql -d # here set public pg schema! |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
2. Create test-app.pl and then define in them DBI->connect(...) and some plugin options: |
107
|
|
|
|
|
|
|
------------ |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
$ perl -e "use Mojo::Base 'Mojolicious'; __PACKAGE__->new()->start(); sub startup {shift->routes->route('/')->to('install#sampl_app', namespace=>'Mojolicious::Plugin::RoutesAuthDBI');}" get / 2>/dev/null > test-app.pl |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
3. View admin routes: |
112
|
|
|
|
|
|
|
------------ |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
$ perl test-app.pl routes |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
4. Start app: |
118
|
|
|
|
|
|
|
------------ |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
$ perl test-app.pl daemon |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
5. Go to trust url for admin-user creation : |
124
|
|
|
|
|
|
|
------------ |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
$ perl test-app.pl get /{admin}{prefix}>/{admin}{trust}>/admin/new// |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
User will be created and assigned to role 'Admin' . Role 'Admin' assigned to namespace 'Mojolicious::Plugin::RoutesAuthDBI' that has access to all admin controller routes! |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
6. Go to http://127.0.0.1:3000/sign/in// |
132
|
|
|
|
|
|
|
------------ |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Administration of system ready! |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
TXT |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub sampl_app { |
142
|
1
|
|
|
1
|
0
|
250
|
my $c = shift; |
143
|
1
|
|
|
|
|
7
|
my $code = $sql->{'sample.app'}->render; |
144
|
1
|
|
|
|
|
2217
|
$c->render(format=>'txt', text => <
|
145
|
|
|
|
|
|
|
$code |
146
|
|
|
|
|
|
|
TXT |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
1; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
__DATA__ |