Allow to explicitly set ordering for groups of stylesheets. This lets
us make sure that the sitescheme-level stylesheets will always come before the
page-level styleseheets.
Patch by fu.
diffs (186 lines):
diff -r cbd13899d227 -r 64de350ea481 cgi-bin/bml/scheme/blueshift.look
--- a/cgi-bin/bml/scheme/blueshift.look Fri Jun 11 13:49:06 2010 +0800
+++ b/cgi-bin/bml/scheme/blueshift.look Fri Jun 11 13:52:12 2010 +0800
@@ -40,8 +40,8 @@ head<=
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?_code
- LJ::need_res( "stc/lj_base-app.css" );
- LJ::need_res( "stc/blueshift/blueshift.css" );
+ LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/lj_base-app.css" );
+ LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/blueshift/blueshift.css" );
_code?>
<?_code LJ::res_includes(); _code?>
diff -r cbd13899d227 -r 64de350ea481 cgi-bin/bml/scheme/celerity.look
--- a/cgi-bin/bml/scheme/celerity.look Fri Jun 11 13:49:06 2010 +0800
+++ b/cgi-bin/bml/scheme/celerity.look Fri Jun 11 13:52:12 2010 +0800
@@ -40,8 +40,8 @@ head<=
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?_code
- LJ::need_res( "stc/lj_base-app.css" );
- LJ::need_res( "stc/celerity/celerity.css" );
+ LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/lj_base-app.css" );
+ LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/celerity/celerity.css" );
_code?>
<?_code LJ::res_includes(); _code?>
diff -r cbd13899d227 -r 64de350ea481
cgi-bin/bml/scheme/gradation-horizontal.look
--- a/cgi-bin/bml/scheme/gradation-horizontal.look Fri Jun 11 13:49:06
2010 +0800
+++ b/cgi-bin/bml/scheme/gradation-horizontal.look Fri Jun 11 13:52:12
2010 +0800
@@ -40,11 +40,11 @@ head<=
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?_code
- LJ::need_res( "stc/lj_base-app.css" );
- LJ::need_res( "stc/gradation/gradation.css" );
+ LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/lj_base-app.css" );
+ LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/gradation/gradation.css" );
- LJ::need_res( {group=>'jquery'}, "js/nav-jquery.js" );
- LJ::need_res( {group=>'default'}, "js/nav.js" );
+ LJ::need_res( { group => 'jquery', priority =>
$LJ::SCHEME_RES_PRIORITY }, "js/nav-jquery.js" );
+ LJ::need_res( { group => 'default', priority =>
$LJ::SCHEME_RES_PRIORITY }, "js/nav.js" );
_code?>
<?_code LJ::res_includes(); _code?>
diff -r cbd13899d227 -r 64de350ea481 cgi-bin/bml/scheme/gradation-vertical.look
--- a/cgi-bin/bml/scheme/gradation-vertical.look Fri Jun 11 13:49:06
2010 +0800
+++ b/cgi-bin/bml/scheme/gradation-vertical.look Fri Jun 11 13:52:12
2010 +0800
@@ -40,8 +40,8 @@ head<=
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?_code
- LJ::need_res( "stc/lj_base-app.css" );
- LJ::need_res( "stc/gradation/gradation.css" );
+ LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/lj_base-app.css" );
+ LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/gradation/gradation.css" );
_code?>
<?_code LJ::res_includes(); _code?>
diff -r cbd13899d227 -r 64de350ea481 cgi-bin/bml/scheme/lynx.look
--- a/cgi-bin/bml/scheme/lynx.look Fri Jun 11 13:49:06 2010 +0800
+++ b/cgi-bin/bml/scheme/lynx.look Fri Jun 11 13:52:12 2010 +0800
@@ -32,7 +32,7 @@ page<=
<link rel="help" title="<?_ml lynx.nav.help _ml?>"
href="<?siteroot?>/support/" />
<?_code
use strict;
- LJ::need_res("stc/lj_base-app.css");
+ LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/lj_base-app.css" );
my $crumb_up;
if (LJ::get_active_crumb() ne '') {
diff -r cbd13899d227 -r 64de350ea481 cgi-bin/ljdefaults.pl
--- a/cgi-bin/ljdefaults.pl Fri Jun 11 13:49:06 2010 +0800
+++ b/cgi-bin/ljdefaults.pl Fri Jun 11 13:52:12 2010 +0800
@@ -327,6 +327,11 @@
# default to limit to 50,000 watch or trust edges to load
$LJ::MAX_WT_EDGES_LOAD ||= 50_000;
+
+ # the default priority for resources in a sitescheme,
+ # so that they come before any stylesheets declared by the page itself
+ # not really expected to change
+ $LJ::SCHEME_RES_PRIORITY = 2;
}
return 1;
diff -r cbd13899d227 -r 64de350ea481 cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl Fri Jun 11 13:49:06 2010 +0800
+++ b/cgi-bin/weblib.pl Fri Jun 11 13:52:12 2010 +0800
@@ -2399,6 +2399,9 @@ sub need_res {
my $group = $opts{group};
+ # higher priority means it comes first in the ordering
+ my $priority = $opts{priority} || 0;
+
foreach my $reskey (@_) {
die "Bogus reskey $reskey" unless $reskey =~ m!^(js|stc)/!;
@@ -2406,7 +2409,9 @@ sub need_res {
# since we need CSS everywhere and we are switching JS groups
my $lgroup = $group || ( $reskey =~ /^js/ ? 'default' : 'all' );
unless ($LJ::NEEDED_RES{$lgroup}->{$reskey}++) {
- push @LJ::NEEDED_RES, [ $lgroup, $reskey ];
+ $LJ::NEEDED_RES[$priority] ||= [];
+
+ push @{$LJ::NEEDED_RES[$priority]}, [ $lgroup, $reskey ];
}
}
}
@@ -2515,39 +2520,42 @@ sub res_includes {
$oldest{$type} = $modtime if $modtime > $oldest{$type};
};
- foreach my $resrow (@LJ::NEEDED_RES) {
+ foreach my $by_priority ( reverse @LJ::NEEDED_RES ) {
+ next unless $by_priority;
- # determine if this resource is part of the resource group that is
active;
- # or 'default' if no group explicitly active
- my ( $group, $key ) = @$resrow;
- next if
- $group ne 'all' &&
- ( ( defined $LJ::ACTIVE_RES_GROUP && $group ne
$LJ::ACTIVE_RES_GROUP ) ||
- ( ! defined $LJ::ACTIVE_RES_GROUP && $group ne 'default' ) );
-
- my $path;
- my $mtime = _file_modtime($key, $now);
- if ($key =~ m!^stc/fck/! || $LJ::FORCE_WSTAT{$key}) {
- $path = "w$key"; # wstc/ instead of stc/
- } else {
- $path = $key;
- }
-
- # if we want to also include a local version of this file, include
that too
- if (@LJ::USE_LOCAL_RES) {
- if (grep { lc $_ eq lc $key } @LJ::USE_LOCAL_RES) {
- my $inc = $key;
- $inc =~ s/(\w+)\.(\w+)$/$1-local.$2/;
- LJ::need_res($inc);
+ foreach my $resrow ( @$by_priority ) {
+ # determine if this resource is part of the resource group that is
active;
+ # or 'default' if no group explicitly active
+ my ( $group, $key ) = @$resrow;
+ next if
+ $group ne 'all' &&
+ ( ( defined $LJ::ACTIVE_RES_GROUP && $group ne
$LJ::ACTIVE_RES_GROUP ) ||
+ ( ! defined $LJ::ACTIVE_RES_GROUP && $group ne 'default' ) );
+
+ my $path;
+ my $mtime = _file_modtime($key, $now);
+ if ($key =~ m!^stc/fck/! || $LJ::FORCE_WSTAT{$key}) {
+ $path = "w$key"; # wstc/ instead of stc/
+ } else {
+ $path = $key;
}
- }
-
- if ($path =~ m!^js/(.+)!) {
- $add->('js', $1, $mtime);
- } elsif ($path =~ /\.css$/ && $path =~ m!^(w?)stc/(.+)!) {
- $add->("${1}stccss", $2, $mtime);
- } elsif ($path =~ /\.js$/ && $path =~ m!^(w?)stc/(.+)!) {
- $add->("${1}stcjs", $2, $mtime);
+
+ # if we want to also include a local version of this file, include
that too
+ if (@LJ::USE_LOCAL_RES) {
+ if (grep { lc $_ eq lc $key } @LJ::USE_LOCAL_RES) {
+ my $inc = $key;
+ $inc =~ s/(\w+)\.(\w+)$/$1-local.$2/;
+ LJ::need_res($inc);
+ }
+ }
+
+ if ($path =~ m!^js/(.+)!) {
+ $add->('js', $1, $mtime);
+ } elsif ($path =~ /\.css$/ && $path =~ m!^(w?)stc/(.+)!) {
+ $add->("${1}stccss", $2, $mtime);
+ } elsif ($path =~ /\.js$/ && $path =~ m!^(w?)stc/(.+)!) {
+ $add->("${1}stcjs", $2, $mtime);
+ }
}
}
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog