RoutesAuthDBI/Install.pm

filter: Statementstmt 100% 13 / 13 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 89.4% 17 / 19 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
manual
1.0
CRAP 1.0
« RoutesAuthDBI/Model/Base.pm ↑ Summary
1 package Mojolicious::Plugin::RoutesAuthDBI::Install;
2 2 ▶use Mojo::Base 'Mojolicious::Controller';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use DBIx::Mojo::Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 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<https://github.com/mche/Mojolicious-Plugin-RoutesAuthDBI/blob/master/Diagram.svg>
22  
23 =head1 Manual
24  
25 $ read -d '' CODE <<PERL; perl -Ilib -e "$CODE" get /man
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 <<PERL; perl -Ilib -e "$CODE" get /schema/<name>[?...] # /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 <<PERL; perl -Ilib -e "$CODE" get /schema/<name>[?...] 2>/dev/null | psql -d <dbname> # /schema/<name>?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 <<PERL; perl -Ilib -e "$CODE" get /app 2>/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 /<pluginconf->{admin}{prefix}>/<pluginconf->{admin}{trust}>/user/new/<new admin login>/<admin pass> 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/<new admin login>/<admin pass>
89  
90 =head1 Administration of system ready!
91  
92 =cut
93  
94 1 ▶sub manual {
Subroutine manual: called CC=1 SCAR=0.0
Pod undocumented
95 1 my $c = shift;
96
97 1 $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 <dbname> # 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 /<pluginconf->{admin}{prefix}>/<pluginconf->{admin}{trust}>/admin/new/<new admin login>/<admin pass>
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/<new admin login>/<admin pass>
132 ------------
133  
134  
135 Administration of system ready!
136  
137 TXT
138 }
139  
140  
141 1 ▶sub sampl_app {
Subroutine sampl_app: called CC=1 SCAR=0.0
Pod undocumented
142 1 my $c = shift;
143 1 my $code = $sql->{'sample.app'}->render;
144 1 $c->render(format=>'txt', text => <<TXT);
145 $code
146 TXT
147 }
148  
149  
150 2 1;
151  
152 __DATA__
« RoutesAuthDBI/Model/Base.pm ↑ Summary