line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoMojo::Schema; |
2
|
40
|
|
|
40
|
|
1972990
|
use Moose; |
|
40
|
|
|
|
|
4117337
|
|
|
40
|
|
|
|
|
327
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has 'attachment_dir' => ( is => 'rw', isa => 'Str' ); |
7
|
|
|
|
|
|
|
|
8
|
40
|
|
|
40
|
|
257342
|
use parent 'DBIx::Class::Schema'; |
|
40
|
|
|
|
|
100
|
|
|
40
|
|
|
|
|
302
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->load_namespaces( default_resultset_class => '+MojoMojo::Schema::Base::ResultSet' ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
MojoMojo::Schema - DBIC Schema |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 METHODS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head2 create_initial_data |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Creates initial set of data in the database which is necessary to run MojoMojo. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub create_initial_data { |
25
|
6
|
|
|
6
|
1
|
4161706
|
my ($schema, $config, $custom_values) = @_; |
26
|
|
|
|
|
|
|
|
27
|
6
|
|
|
|
|
27
|
my $file = __PACKAGE__ . ".pm"; |
28
|
6
|
|
|
|
|
40
|
$file =~ s{::}{/}g; |
29
|
6
|
|
|
|
|
31
|
my $path = $INC{$file}; |
30
|
6
|
|
|
|
|
39
|
$path =~ s{Schema\.pm$}{I18N}; |
31
|
|
|
|
|
|
|
|
32
|
6
|
|
|
|
|
3934
|
require Locale::Maketext::Simple; |
33
|
6
|
|
|
|
|
8276
|
Locale::Maketext::Simple->import( |
34
|
|
|
|
|
|
|
Decode => 1, |
35
|
|
|
|
|
|
|
Class => 'MojoMojo', |
36
|
|
|
|
|
|
|
Path => $path, |
37
|
|
|
|
|
|
|
); |
38
|
6
|
|
50
|
|
|
362069
|
my $lang = $config->{'default_lang'} || 'en'; |
39
|
6
|
|
|
|
|
24
|
$lang =~ s/\..*$//; |
40
|
6
|
|
|
|
|
25
|
loc_lang($lang); |
41
|
|
|
|
|
|
|
|
42
|
6
|
|
50
|
|
|
1673
|
my $default_user = $ENV{USER} || 'admin'; |
43
|
|
|
|
|
|
|
|
44
|
6
|
|
50
|
|
|
95
|
$custom_values ||= { |
45
|
|
|
|
|
|
|
wiki_name => 'MojoMojo', |
46
|
|
|
|
|
|
|
admin_username => 'admin', |
47
|
|
|
|
|
|
|
admin_password => 'admin', |
48
|
|
|
|
|
|
|
admin_fullname => $default_user, |
49
|
|
|
|
|
|
|
admin_email => "$default_user\@localhost", |
50
|
|
|
|
|
|
|
anonymous_email => 'anonymous.coward@localhost', |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
6
|
|
|
|
|
2069
|
print "Creating initial data\n"; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my @people = $schema->populate( |
56
|
|
|
|
|
|
|
'Person', |
57
|
|
|
|
|
|
|
[ |
58
|
|
|
|
|
|
|
[ |
59
|
|
|
|
|
|
|
qw/ active views photo login name email pass timezone born gender occupation industry interests movies music / |
60
|
|
|
|
|
|
|
], |
61
|
|
|
|
|
|
|
[ |
62
|
|
|
|
|
|
|
1, 0, 0, loc('anonymouscoward'), loc('Anonymous Coward'), $custom_values->{anonymous_email}, |
63
|
|
|
|
|
|
|
'', '', undef, '', '', '', '', '', '' |
64
|
|
|
|
|
|
|
], |
65
|
|
|
|
|
|
|
[ |
66
|
|
|
|
|
|
|
1, 0, 0, $custom_values->{admin_username}, $custom_values->{admin_fullname}, $custom_values->{admin_email}, |
67
|
6
|
|
|
|
|
85
|
$custom_values->{admin_password}, '', undef, '', '', '', '', '', '' |
68
|
|
|
|
|
|
|
], |
69
|
|
|
|
|
|
|
] |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
6
|
|
|
|
|
89890
|
my @roles = $schema->populate( |
73
|
|
|
|
|
|
|
'Role', |
74
|
|
|
|
|
|
|
[ |
75
|
|
|
|
|
|
|
[ qw/ name active / ], |
76
|
|
|
|
|
|
|
[ loc('Admins'), 1 ], |
77
|
|
|
|
|
|
|
[ loc('Users'), 1 ], |
78
|
|
|
|
|
|
|
[ loc('Anonymous'), 1 ] |
79
|
|
|
|
|
|
|
] |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
6
|
|
|
|
|
36695
|
my @role_members = $schema->populate( |
83
|
|
|
|
|
|
|
'RoleMember', |
84
|
|
|
|
|
|
|
[ |
85
|
|
|
|
|
|
|
[ qw/role person admin/ ], |
86
|
|
|
|
|
|
|
[ $roles[0]->id, $people[1]->id, 1 ], |
87
|
|
|
|
|
|
|
[ $roles[2]->id, $people[0]->id, 0 ] |
88
|
|
|
|
|
|
|
] |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
6
|
|
|
|
|
27242
|
my @path_permissions = $schema->populate( |
92
|
|
|
|
|
|
|
'PathPermissions', |
93
|
|
|
|
|
|
|
[ |
94
|
|
|
|
|
|
|
[ qw/path role apply_to_subpages create_allowed delete_allowed edit_allowed view_allowed attachment_allowed / ], |
95
|
|
|
|
|
|
|
[ '/', $roles[0]->id, qw/ no yes yes yes yes yes / ], |
96
|
|
|
|
|
|
|
[ '/', $roles[0]->id, qw/yes yes yes yes yes yes / ], |
97
|
|
|
|
|
|
|
[ '/', $roles[1]->id, qw/ no yes no yes yes yes / ], |
98
|
|
|
|
|
|
|
[ '/', $roles[1]->id, qw/yes yes no yes yes yes / ], |
99
|
|
|
|
|
|
|
[ '/', $roles[2]->id, qw/ no yes no yes yes no / ], |
100
|
|
|
|
|
|
|
[ '/', $roles[2]->id, qw/yes yes no yes yes no / ] |
101
|
|
|
|
|
|
|
] |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my @prefs = $schema->populate( |
106
|
|
|
|
|
|
|
'Preference', |
107
|
|
|
|
|
|
|
[ |
108
|
|
|
|
|
|
|
[qw/ prefkey prefvalue /], |
109
|
|
|
|
|
|
|
[ 'name', $custom_values->{wiki_name} ], |
110
|
|
|
|
|
|
|
[ 'admins', $custom_values->{admin_username} ], |
111
|
|
|
|
|
|
|
[ 'theme', $config->{'theme'} || 'default' ], |
112
|
6
|
|
50
|
|
|
72226
|
[ 'open_registration', $config->{'open_registration'} || 1 ], |
|
|
|
50
|
|
|
|
|
113
|
|
|
|
|
|
|
[ 'anonymous_user', 'anonymouscoward' ], |
114
|
|
|
|
|
|
|
] |
115
|
|
|
|
|
|
|
); |
116
|
|
|
|
|
|
|
|
117
|
6
|
|
|
|
|
37459
|
my @pages = $schema->populate( |
118
|
|
|
|
|
|
|
'Page', |
119
|
|
|
|
|
|
|
[ |
120
|
|
|
|
|
|
|
[qw/ version parent name name_orig depth lft rgt content_version /], |
121
|
|
|
|
|
|
|
[ undef, undef, '/', '/', 0, 1, 5, undef ], |
122
|
|
|
|
|
|
|
[ undef, 1, 'help', loc('Help'), 1, 2, 3, undef ], |
123
|
|
|
|
|
|
|
[ undef, 1, 'admin', 'Admin', 1, 4, 5, undef ], |
124
|
|
|
|
|
|
|
] |
125
|
|
|
|
|
|
|
); |
126
|
|
|
|
|
|
|
|
127
|
6
|
|
|
|
|
47953
|
my @pageversions = $schema->populate( |
128
|
|
|
|
|
|
|
'PageVersion', |
129
|
|
|
|
|
|
|
[ |
130
|
|
|
|
|
|
|
[ |
131
|
|
|
|
|
|
|
qw/page version parent parent_version name name_orig depth |
132
|
|
|
|
|
|
|
content_version_first content_version_last creator status created |
133
|
|
|
|
|
|
|
release_date remove_date comments/ |
134
|
|
|
|
|
|
|
], |
135
|
|
|
|
|
|
|
[ |
136
|
|
|
|
|
|
|
1, 1, undef, undef, '/', '/', 0, undef, undef, $people[1]->id, '', 0, '', '', '' |
137
|
|
|
|
|
|
|
], |
138
|
|
|
|
|
|
|
[ |
139
|
|
|
|
|
|
|
2, 1, 1, undef, 'help', 'Help', 0, undef, undef, $people[1]->id, '', 0, '', '', |
140
|
|
|
|
|
|
|
'' |
141
|
|
|
|
|
|
|
], |
142
|
|
|
|
|
|
|
[ |
143
|
|
|
|
|
|
|
3, 1, 1, undef, 'admin', 'Admin', 0, undef, undef, $people[1]->id, '', 0, '', |
144
|
|
|
|
|
|
|
'', '' |
145
|
|
|
|
|
|
|
], |
146
|
|
|
|
|
|
|
] |
147
|
|
|
|
|
|
|
); |
148
|
|
|
|
|
|
|
|
149
|
6
|
|
|
|
|
58938
|
my @content = $schema->populate( |
150
|
|
|
|
|
|
|
'Content', |
151
|
|
|
|
|
|
|
[ |
152
|
|
|
|
|
|
|
[ |
153
|
|
|
|
|
|
|
qw/ page version creator created body status release_date remove_date type abstract comments |
154
|
|
|
|
|
|
|
precompiled / |
155
|
|
|
|
|
|
|
], |
156
|
|
|
|
|
|
|
[ |
157
|
|
|
|
|
|
|
1, 1, $people[1]->id, 0, loc('welcome message', "test"), |
158
|
|
|
|
|
|
|
'released', 1, 1, '', '', '', '' |
159
|
|
|
|
|
|
|
], |
160
|
|
|
|
|
|
|
[ |
161
|
|
|
|
|
|
|
2, 1, $people[1]->id, 0, loc('help message'), |
162
|
|
|
|
|
|
|
'released', 1, 1, '', '', '', '' |
163
|
|
|
|
|
|
|
], |
164
|
|
|
|
|
|
|
[ |
165
|
|
|
|
|
|
|
3, 1, $people[1]->id, 0, loc('admin home page'), |
166
|
|
|
|
|
|
|
'released', 1, 1, '', '', '' |
167
|
|
|
|
|
|
|
], |
168
|
|
|
|
|
|
|
] |
169
|
|
|
|
|
|
|
); |
170
|
|
|
|
|
|
|
|
171
|
6
|
|
|
|
|
57119
|
$schema->resultset('Page')->update( { version => 1 } ); |
172
|
6
|
|
|
|
|
32336
|
$schema->resultset('Page')->update( { content_version => 1 } ); |
173
|
6
|
|
|
|
|
11254
|
$schema->resultset('PageVersion')->update( { content_version_first => 1 } ); |
174
|
6
|
|
|
|
|
11583
|
$schema->resultset('PageVersion')->update( { content_version_last => 1 } ); |
175
|
|
|
|
|
|
|
|
176
|
6
|
|
|
|
|
11485
|
print "Success!\n"; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 AUTHOR |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Marcus Ramberg <mramberg@cpan.org> |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 LICENSE |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify |
186
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
1; |