[dw-free] move cgi-bin/lj*.pl files into proper modules (in cgi-bin/LJ)
[commit: http://hg.dwscoalition.org/dw-free/rev/b9043502017a]
http://bugs.dwscoalition.org/show_bug.cgi?id=1726
lj-bml-init.pl => LJ/GLobal/BMLInit.pm
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=1726
lj-bml-init.pl => LJ/GLobal/BMLInit.pm
Patch by
Files modified:
- cgi-bin/LJ/Global/BMLInit.pm
- cgi-bin/lj-bml-init.pl
- htdocs/_config.bml
- t/00-compile.t
--------------------------------------------------------------------------------
diff -r 1dc28b858eb4 -r b9043502017a cgi-bin/LJ/Global/BMLInit.pm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/LJ/Global/BMLInit.pm Mon Nov 07 18:28:01 2011 +0800
@@ -0,0 +1,101 @@
+#!/usr/bin/perl
+#
+# This code was forked from the LiveJournal project owned and operated
+# by Live Journal, Inc. The code has been modified and expanded by
+# Dreamwidth Studios, LLC. These files were originally licensed under
+# the terms of the license supplied by Live Journal, Inc, which can
+# currently be found at:
+#
+# http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
+#
+# In accordance with the original license, this code and all its
+# modifications are provided under the GNU General Public License.
+# A copy of that license can be found in the LICENSE file included as
+# part of this distribution.
+
+use strict;
+use lib "$LJ::HOME/cgi-bin";
+use Errno qw(ENOENT);
+use LJ::Config;
+LJ::Config->load;
+use Apache::BML;
+
+foreach (@LJ::LANGS, @LJ::LANGS_IN_PROGRESS) {
+ BML::register_isocode(substr($_, 0, 2), $_);
+ BML::register_language($_);
+}
+
+# set default path/domain for cookies
+BML::set_config( "CookieDomain" => $LJ::COOKIE_DOMAIN );
+BML::set_config( "CookiePath" => "/" );
+
+BML::register_hook("startup", sub {
+ my $r = BML::get_request();
+ my $uri = "bml" . $r->uri;
+ unless ($uri =~ s/\.bml$//) {
+ $uri .= ".index";
+ }
+ $uri =~ s!/!.!g;
+ $r->notes->{"codepath"} = $uri;
+});
+
+BML::register_hook("codeerror", sub {
+ my $msg = shift;
+
+ my $err = LJ::errobj($msg) or return;
+ $err->log;
+ $msg = $err->as_html;
+
+ chomp $msg;
+ $msg .= " \@ $LJ::SERVER_NAME" if $LJ::SERVER_NAME;
+ warn "$msg\n";
+
+ my $remote = LJ::get_remote();
+ if (($remote && $remote->show_raw_errors) || $LJ::IS_DEV_SERVER) {
+ return "<b>[Error: $msg]</b>";
+ } else {
+ return $LJ::MSG_ERROR || "Sorry, there was a problem.";
+ }
+});
+
+if ($LJ::UNICODE) {
+ BML::set_config("DefaultContentType", "text/html; charset=utf-8");
+}
+
+# register BML multi-language hook
+BML::register_hook("ml_getter", \&LJ::Lang::get_text);
+
+# include file handling
+BML::register_hook('include_getter', sub {
+ # simply call LJ::load_include, as it does all the work of hitting up
+ # memcache/db for us and falling back to disk if necessary...
+ my ($file, $source) = @_;
+ $$source = LJ::load_include($file);
+ return 1;
+});
+
+# Allow scheme override to be defined as a code ref or an explicit string value
+BML::register_hook('default_scheme_override', sub {
+ my $current_scheme = shift;
+
+ my $override = $LJ::BML_SCHEME_OVERRIDE{$current_scheme};
+ return LJ::conf_test($override) if defined $override;
+
+ return LJ::conf_test($LJ::SCHEME_OVERRIDE);
+});
+
+# extra perl to insert at the beginning of a code block
+# compilation
+BML::register_hook("codeblock_init_perl", sub {
+ return q{*errors = *BMLCodeBlock::errors;};
+});
+
+# now apply any local behaviors which may be defined
+eval "use LJ::Local::BMLInit;";
+die $@ if $@ && $! != ENOENT;
+
+# if the old local filename is in use, log an error.
+warn "NOTE: Found lj-bml-init-local.pl, please rename to cgi-bin/LJ/Local/BMLInit.pm"
+ if -e "$LJ::HOME/cgi-bin/lj-bml-init-local.pl";
+
+1;
diff -r 1dc28b858eb4 -r b9043502017a cgi-bin/lj-bml-init.pl
--- a/cgi-bin/lj-bml-init.pl Mon Nov 07 17:46:20 2011 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-#!/usr/bin/perl
-#
-# This code was forked from the LiveJournal project owned and operated
-# by Live Journal, Inc. The code has been modified and expanded by
-# Dreamwidth Studios, LLC. These files were originally licensed under
-# the terms of the license supplied by Live Journal, Inc, which can
-# currently be found at:
-#
-# http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
-#
-# In accordance with the original license, this code and all its
-# modifications are provided under the GNU General Public License.
-# A copy of that license can be found in the LICENSE file included as
-# part of this distribution.
-
-use strict;
-use lib "$LJ::HOME/cgi-bin";
-use Errno qw(ENOENT);
-use LJ::Config;
-LJ::Config->load;
-use Apache::BML;
-
-foreach (@LJ::LANGS, @LJ::LANGS_IN_PROGRESS) {
- BML::register_isocode(substr($_, 0, 2), $_);
- BML::register_language($_);
-}
-
-# set default path/domain for cookies
-BML::set_config( "CookieDomain" => $LJ::COOKIE_DOMAIN );
-BML::set_config( "CookiePath" => "/" );
-
-BML::register_hook("startup", sub {
- my $r = BML::get_request();
- my $uri = "bml" . $r->uri;
- unless ($uri =~ s/\.bml$//) {
- $uri .= ".index";
- }
- $uri =~ s!/!.!g;
- $r->notes->{"codepath"} = $uri;
-});
-
-BML::register_hook("codeerror", sub {
- my $msg = shift;
-
- my $err = LJ::errobj($msg) or return;
- $err->log;
- $msg = $err->as_html;
-
- chomp $msg;
- $msg .= " \@ $LJ::SERVER_NAME" if $LJ::SERVER_NAME;
- warn "$msg\n";
-
- my $remote = LJ::get_remote();
- if (($remote && $remote->show_raw_errors) || $LJ::IS_DEV_SERVER) {
- return "<b>[Error: $msg]</b>";
- } else {
- return $LJ::MSG_ERROR || "Sorry, there was a problem.";
- }
-});
-
-if ($LJ::UNICODE) {
- BML::set_config("DefaultContentType", "text/html; charset=utf-8");
-}
-
-# register BML multi-language hook
-BML::register_hook("ml_getter", \&LJ::Lang::get_text);
-
-# include file handling
-BML::register_hook('include_getter', sub {
- # simply call LJ::load_include, as it does all the work of hitting up
- # memcache/db for us and falling back to disk if necessary...
- my ($file, $source) = @_;
- $$source = LJ::load_include($file);
- return 1;
-});
-
-# Allow scheme override to be defined as a code ref or an explicit string value
-BML::register_hook('default_scheme_override', sub {
- my $current_scheme = shift;
-
- my $override = $LJ::BML_SCHEME_OVERRIDE{$current_scheme};
- return LJ::conf_test($override) if defined $override;
-
- return LJ::conf_test($LJ::SCHEME_OVERRIDE);
-});
-
-# extra perl to insert at the beginning of a code block
-# compilation
-BML::register_hook("codeblock_init_perl", sub {
- return q{*errors = *BMLCodeBlock::errors;};
-});
-
-# now apply any local behaviors which may be defined
-eval { require "lj-bml-init-local.pl" };
-die $@ if $@ && $! != ENOENT;
-
-1;
diff -r 1dc28b858eb4 -r b9043502017a htdocs/_config.bml
--- a/htdocs/_config.bml Mon Nov 07 17:46:20 2011 +0800
+++ b/htdocs/_config.bml Mon Nov 07 18:28:01 2011 +0800
@@ -4,7 +4,7 @@
IncludePath inc/
AllowOldSyntax 0
-ExtraConfig _config-local.bml, $LJHOME/cgi-bin/lj-bml-init.pl
+ExtraConfig _config-local.bml, $LJHOME/cgi-bin/LJ/Global/BMLInit.pm
AllowCode 1
AllowTemplateCode 1
MildXSSProtection 1
diff -r 1dc28b858eb4 -r b9043502017a t/00-compile.t
--- a/t/00-compile.t Mon Nov 07 17:46:20 2011 +0800
+++ b/t/00-compile.t Mon Nov 07 18:28:01 2011 +0800
@@ -16,7 +16,7 @@
'Data/ObjectDriver/Driver/DBD/SQLite.pm' => 'Bareword "DBI::SQL_BLOB"',
'Data/ObjectDriver/Driver/DBD/Oracle.pm' => 'no Oracle',
- 'cgi-bin/lj-bml-init.pl' => 'BML::register_isocode called from non-conffile context',
+ 'LJ/Global/BMLInit.pm' => 'BML::register_isocode called from non-conffile context',
'cgi-bin/lj-bml-blocks.pl' => 'BML::register_block called from non-lookfile context',
);
@@ -66,7 +66,7 @@
}
# Bail out if any of the tests failed
-BAIL_OUT("Aborting test suite") if scalar
+BAIL_OUT("Aborting test suite") if scalar
grep { not $_->{ok} } Test::More->builder->details;
--------------------------------------------------------------------------------

no subject
no subject
no subject