4 use lib
"$ENV{LJHOME}/cgi-bin";
10 foreach (@LJ::LANGS
, @LJ::LANGS_IN_PROGRESS
) {
11 BML
::register_isocode
(substr($_, 0, 2), $_);
12 BML
::register_language
($_);
15 # set default path/domain for cookies
16 BML
::set_config
("CookieDomain" => $LJ::COOKIE_DOMAIN
);
17 BML
::set_config
("CookiePath" => $LJ::COOKIE_PATH
);
19 BML
::register_hook
("startup", sub {
20 my $uri = "bml" . LJ
::Request
->uri;
21 unless ($uri =~ s/\.bml$//) {
25 LJ
::Request
->notes("codepath" => $uri);
28 BML
::register_hook
("codeerror", sub {
31 my $err = LJ
::errobj
($msg) or return;
36 $msg .= " \@ $LJ::SERVER_NAME" if $LJ::SERVER_NAME
;
39 my $remote = LJ
::get_remote
();
40 if (($remote && $remote->show_raw_errors) || $LJ::IS_DEV_SERVER
) {
41 return "<pre>" . LJ
::ehtml
("[Error: $msg]") . "</pre>";
43 return $LJ::MSG_ERROR
|| "Sorry, there was a problem.";
48 BML
::set_config
("DefaultContentType", "text/html; charset=utf-8");
51 # register BML multi-language hook
52 BML
::register_hook
("ml_getter", \
&LJ
::Lang
::get_text
);
54 # include file handling
55 BML
::register_hook
('include_getter', sub {
56 # simply call LJ::load_include, as it does all the work of hitting up
57 # memcache/db for us and falling back to disk if necessary...
58 my ($file, $source) = @_;
59 $$source = LJ
::load_include
($file);
63 # Allow scheme override to be defined as a code ref or an explicit string value
64 BML
::register_hook
('default_scheme_override', sub {
65 my $current_scheme = shift;
67 my $override = $LJ::BML_SCHEME_OVERRIDE
{$current_scheme};
68 return LJ
::conf_test
($override) if defined $override;
70 return LJ
::conf_test
($LJ::SCHEME_OVERRIDE
);
73 # extra perl to insert at the beginning of a code block
75 BML
::register_hook
("codeblock_init_perl", sub {
77 *errors = *BMLCodeBlock::errors;
78 *warnings = *BMLCodeBlock::warnings;
82 # now apply any local behaviors which may be defined
83 eval { require "lj-bml-init-local.pl" };
84 die $@
if $@
&& $! != ENOENT
;