| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
16
|
|
|
16
|
|
1237028
|
use strict; |
|
|
16
|
|
|
|
|
40
|
|
|
|
16
|
|
|
|
|
580
|
|
|
2
|
16
|
|
|
16
|
|
85
|
use warnings; |
|
|
16
|
|
|
|
|
32
|
|
|
|
16
|
|
|
|
|
930
|
|
|
3
|
|
|
|
|
|
|
package Rubric::Config; |
|
4
|
|
|
|
|
|
|
# ABSTRACT: the configuration data for a Rubric |
|
5
|
|
|
|
|
|
|
$Rubric::Config::VERSION = '0.155'; |
|
6
|
16
|
|
|
16
|
|
12343
|
use parent qw(Class::Accessor); |
|
|
16
|
|
|
|
|
4426
|
|
|
|
16
|
|
|
|
|
86
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# =head1 DESCRIPTION |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# Rubric::Config provides access to the configuration data for a Rubric. The |
|
11
|
|
|
|
|
|
|
# basic implementation stores its configuration in YAML in a text file in the |
|
12
|
|
|
|
|
|
|
# current working directory. By default, Rubric::Config looks for C, |
|
13
|
|
|
|
|
|
|
# but an alternate filename may be passed when using the module: |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# use Rubric::Config ".rubric_yml"; |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
# =cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
16
|
|
|
16
|
|
67633
|
use YAML::XS (); |
|
|
16
|
|
|
|
|
68267
|
|
|
|
16
|
|
|
|
|
5233
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $config_filename = $ENV{RUBRIC_CONFIG_FILE} || 'rubric.yml'; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub import { |
|
24
|
70
|
|
|
70
|
|
732
|
my ($class) = shift; |
|
25
|
70
|
100
|
|
|
|
10798
|
$config_filename = shift if @_; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# =head1 SETTINGS |
|
29
|
|
|
|
|
|
|
# |
|
30
|
|
|
|
|
|
|
# These configuration settings can all be retrieved by methods of the same name. |
|
31
|
|
|
|
|
|
|
# |
|
32
|
|
|
|
|
|
|
# =over 4 |
|
33
|
|
|
|
|
|
|
# |
|
34
|
|
|
|
|
|
|
# =item * dsn |
|
35
|
|
|
|
|
|
|
# |
|
36
|
|
|
|
|
|
|
# the DSN to be used by Rubric::DBI to connect to the Rubric's database |
|
37
|
|
|
|
|
|
|
# |
|
38
|
|
|
|
|
|
|
# =item * db_user |
|
39
|
|
|
|
|
|
|
# |
|
40
|
|
|
|
|
|
|
# the username to be used by Rubric::DBI to connect to the Rubric's database |
|
41
|
|
|
|
|
|
|
# |
|
42
|
|
|
|
|
|
|
# =item * db_pass |
|
43
|
|
|
|
|
|
|
# |
|
44
|
|
|
|
|
|
|
# the password to be used by Rubric::DBI to connect to the Rubric's database |
|
45
|
|
|
|
|
|
|
# |
|
46
|
|
|
|
|
|
|
# =item * dbi_trace_level |
|
47
|
|
|
|
|
|
|
# |
|
48
|
|
|
|
|
|
|
# level of debug output for DBI |
|
49
|
|
|
|
|
|
|
# |
|
50
|
|
|
|
|
|
|
# =item * dbi_trace_file |
|
51
|
|
|
|
|
|
|
# |
|
52
|
|
|
|
|
|
|
# Where to send DBI debug output if dbi_trace_level |
|
53
|
|
|
|
|
|
|
# |
|
54
|
|
|
|
|
|
|
# =item * session_cipher_key |
|
55
|
|
|
|
|
|
|
# |
|
56
|
|
|
|
|
|
|
# The key to use to encrypt sessions, which are stored in user cookies. This |
|
57
|
|
|
|
|
|
|
# must be set. |
|
58
|
|
|
|
|
|
|
# |
|
59
|
|
|
|
|
|
|
# =item * uri_root |
|
60
|
|
|
|
|
|
|
# |
|
61
|
|
|
|
|
|
|
# the absolute URI for the root of the Rubric::WebApp install |
|
62
|
|
|
|
|
|
|
# |
|
63
|
|
|
|
|
|
|
# =item * css_href |
|
64
|
|
|
|
|
|
|
# |
|
65
|
|
|
|
|
|
|
# the absolute URI for the stylesheet to be used by Rubric::WebApp pages |
|
66
|
|
|
|
|
|
|
# |
|
67
|
|
|
|
|
|
|
# =item * basename |
|
68
|
|
|
|
|
|
|
# |
|
69
|
|
|
|
|
|
|
# This is the text to display as the name of this Rubric instance. It defaults |
|
70
|
|
|
|
|
|
|
# to "Rubric". |
|
71
|
|
|
|
|
|
|
# |
|
72
|
|
|
|
|
|
|
# =item * template_path |
|
73
|
|
|
|
|
|
|
# |
|
74
|
|
|
|
|
|
|
# the INCLUDE_PATH passed to Template when creating the template renderers |
|
75
|
|
|
|
|
|
|
# |
|
76
|
|
|
|
|
|
|
# =item * email_from |
|
77
|
|
|
|
|
|
|
# |
|
78
|
|
|
|
|
|
|
# the email address from which Rubric will send email |
|
79
|
|
|
|
|
|
|
# |
|
80
|
|
|
|
|
|
|
# =item * smtp_server |
|
81
|
|
|
|
|
|
|
# |
|
82
|
|
|
|
|
|
|
# the SMTP server used to send email |
|
83
|
|
|
|
|
|
|
# |
|
84
|
|
|
|
|
|
|
# =item * entries_query_class |
|
85
|
|
|
|
|
|
|
# |
|
86
|
|
|
|
|
|
|
# This is the class used to process the C run method. It defaults to |
|
87
|
|
|
|
|
|
|
# C. |
|
88
|
|
|
|
|
|
|
# |
|
89
|
|
|
|
|
|
|
# =item * login_class |
|
90
|
|
|
|
|
|
|
# |
|
91
|
|
|
|
|
|
|
# This is the class used to check for logins; it should subclass |
|
92
|
|
|
|
|
|
|
# Rubric::WebApp::Login. If not supplied, the default is |
|
93
|
|
|
|
|
|
|
# Rubric::WebApp::Login::Post. |
|
94
|
|
|
|
|
|
|
# |
|
95
|
|
|
|
|
|
|
# =item * skip_newuser_verification |
|
96
|
|
|
|
|
|
|
# |
|
97
|
|
|
|
|
|
|
# If true, users will be created without verification codes, and won't get |
|
98
|
|
|
|
|
|
|
# verification emails. |
|
99
|
|
|
|
|
|
|
# |
|
100
|
|
|
|
|
|
|
# =item * registration_closed |
|
101
|
|
|
|
|
|
|
# |
|
102
|
|
|
|
|
|
|
# true if registration new users can't register for accounts via the web |
|
103
|
|
|
|
|
|
|
# |
|
104
|
|
|
|
|
|
|
# =item * private_system |
|
105
|
|
|
|
|
|
|
# |
|
106
|
|
|
|
|
|
|
# true value if users must have an account to view entries |
|
107
|
|
|
|
|
|
|
# |
|
108
|
|
|
|
|
|
|
# =item * private_tag |
|
109
|
|
|
|
|
|
|
# |
|
110
|
|
|
|
|
|
|
# A tag which, if attached to an entry, makes it private. The default value is |
|
111
|
|
|
|
|
|
|
# C<@private>, and I strongly advise against changing it, since I may change the |
|
112
|
|
|
|
|
|
|
# way these "system tags" work in the future. |
|
113
|
|
|
|
|
|
|
# |
|
114
|
|
|
|
|
|
|
# =item * markup_formatter |
|
115
|
|
|
|
|
|
|
# |
|
116
|
|
|
|
|
|
|
# This entry, if given, should be a mapping of markup names to formatter plugins. |
|
117
|
|
|
|
|
|
|
# For example: |
|
118
|
|
|
|
|
|
|
# |
|
119
|
|
|
|
|
|
|
# markup_formatter: |
|
120
|
|
|
|
|
|
|
# kwid: Rubric::Entry::Formatter::Kwid |
|
121
|
|
|
|
|
|
|
# tex: Rubric::Entry::Formatter::TeX |
|
122
|
|
|
|
|
|
|
# |
|
123
|
|
|
|
|
|
|
# (No. Neither of those exist.) |
|
124
|
|
|
|
|
|
|
# |
|
125
|
|
|
|
|
|
|
# If it is not specified in the config file, an entry for C<_default> is set to |
|
126
|
|
|
|
|
|
|
# the built-in, extremely simple entry formatter. |
|
127
|
|
|
|
|
|
|
# |
|
128
|
|
|
|
|
|
|
# =item * one_entry_per_link |
|
129
|
|
|
|
|
|
|
# |
|
130
|
|
|
|
|
|
|
# if true, each user can have only one entry per link (default: true) |
|
131
|
|
|
|
|
|
|
# |
|
132
|
|
|
|
|
|
|
# =item * allowed_schemes |
|
133
|
|
|
|
|
|
|
# |
|
134
|
|
|
|
|
|
|
# If undef, all URI schemes are allowed in entries. If it's an array reference, |
|
135
|
|
|
|
|
|
|
# it's the list of allowed schemes. |
|
136
|
|
|
|
|
|
|
# |
|
137
|
|
|
|
|
|
|
# =item * display_localtime |
|
138
|
|
|
|
|
|
|
# |
|
139
|
|
|
|
|
|
|
# If true, the local time (of the server) will be displayed for entry |
|
140
|
|
|
|
|
|
|
# create/modify times. Otherwise, all times will be UTC. (This option is |
|
141
|
|
|
|
|
|
|
# probably temporary, until per-user timezones are implemented.) |
|
142
|
|
|
|
|
|
|
# |
|
143
|
|
|
|
|
|
|
# =item * default_page_size |
|
144
|
|
|
|
|
|
|
# |
|
145
|
|
|
|
|
|
|
# The number of entries that are displayed on a page of entries, by default. |
|
146
|
|
|
|
|
|
|
# |
|
147
|
|
|
|
|
|
|
# =item * max_page_size |
|
148
|
|
|
|
|
|
|
# |
|
149
|
|
|
|
|
|
|
# The maximum number of entries that will be displayed on a page of entries. If |
|
150
|
|
|
|
|
|
|
# more are requested, this many will be displayed. |
|
151
|
|
|
|
|
|
|
# |
|
152
|
|
|
|
|
|
|
# =back |
|
153
|
|
|
|
|
|
|
# |
|
154
|
|
|
|
|
|
|
# =head1 METHODS |
|
155
|
|
|
|
|
|
|
# |
|
156
|
|
|
|
|
|
|
# These methods are used by the setting accessors, internally: |
|
157
|
|
|
|
|
|
|
# |
|
158
|
|
|
|
|
|
|
# =head2 _read_config |
|
159
|
|
|
|
|
|
|
# |
|
160
|
|
|
|
|
|
|
# This method returns the config data, if loaded. If it hasn't already been |
|
161
|
|
|
|
|
|
|
# loaded, it finds and parses the configuration file, then returns the data. |
|
162
|
|
|
|
|
|
|
# |
|
163
|
|
|
|
|
|
|
# =cut |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
my $config; |
|
166
|
|
|
|
|
|
|
sub _read_config { |
|
167
|
2474
|
100
|
|
2474
|
|
15675
|
return $config if $config; |
|
168
|
|
|
|
|
|
|
|
|
169
|
16
|
|
|
|
|
41
|
my $config_file = $config_filename; |
|
170
|
16
|
|
|
|
|
94
|
$config = YAML::XS::LoadFile($config_file); |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
# =head2 _default |
|
174
|
|
|
|
|
|
|
# |
|
175
|
|
|
|
|
|
|
# This method returns the default configuration has a hashref. |
|
176
|
|
|
|
|
|
|
# |
|
177
|
|
|
|
|
|
|
# =cut |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
my $default = { |
|
180
|
|
|
|
|
|
|
basename => 'Rubric', |
|
181
|
|
|
|
|
|
|
css_href => undef, |
|
182
|
|
|
|
|
|
|
db_user => undef, |
|
183
|
|
|
|
|
|
|
db_pass => undef, |
|
184
|
|
|
|
|
|
|
dsn => undef, |
|
185
|
|
|
|
|
|
|
dbi_trace_level => 0, |
|
186
|
|
|
|
|
|
|
dbi_trace_file => undef, |
|
187
|
|
|
|
|
|
|
email_from => undef, |
|
188
|
|
|
|
|
|
|
login_class => 'Rubric::WebApp::Login::Post', |
|
189
|
|
|
|
|
|
|
smtp_server => undef, |
|
190
|
|
|
|
|
|
|
uri_root => '', |
|
191
|
|
|
|
|
|
|
private_tag => '@private', |
|
192
|
|
|
|
|
|
|
private_system => undef, |
|
193
|
|
|
|
|
|
|
template_path => undef, |
|
194
|
|
|
|
|
|
|
allowed_schemes => undef, |
|
195
|
|
|
|
|
|
|
default_page_size => 25, |
|
196
|
|
|
|
|
|
|
display_localtime => 0, |
|
197
|
|
|
|
|
|
|
entries_query_class => 'Rubric::WebApp::Entries', |
|
198
|
|
|
|
|
|
|
max_page_size => 100, |
|
199
|
|
|
|
|
|
|
markup_formatter => {}, |
|
200
|
|
|
|
|
|
|
one_entry_per_link => 1, |
|
201
|
|
|
|
|
|
|
registration_closed => undef, |
|
202
|
|
|
|
|
|
|
session_cipher_key => undef, |
|
203
|
|
|
|
|
|
|
skip_newuser_verification => undef, |
|
204
|
|
|
|
|
|
|
}; |
|
205
|
565
|
|
|
565
|
|
22959
|
sub _default { $default } |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# =head2 make_ro_accessor |
|
208
|
|
|
|
|
|
|
# |
|
209
|
|
|
|
|
|
|
# Rubric::Config isa Class::Accessor, and uses this sub to build its setting |
|
210
|
|
|
|
|
|
|
# accessors. For a given field, it returns the value of that field in the |
|
211
|
|
|
|
|
|
|
# configuration, if it exists. Otherwise, it returns the default for that field. |
|
212
|
|
|
|
|
|
|
# |
|
213
|
|
|
|
|
|
|
# =cut |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub make_ro_accessor { |
|
216
|
384
|
|
|
384
|
1
|
16537
|
my ($class, $field) = @_; |
|
217
|
|
|
|
|
|
|
sub { |
|
218
|
1498
|
100
|
|
1498
|
|
15322
|
exists $class->_read_config->{$field} |
|
219
|
|
|
|
|
|
|
? $class->_read_config->{$field} |
|
220
|
|
|
|
|
|
|
: $class->_default->{$field} |
|
221
|
|
|
|
|
|
|
} |
|
222
|
384
|
|
|
|
|
1949
|
} |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(keys %$default); |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
1; |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
__END__ |