[dw-free] Control strip causes JS files to be included multiple times
[commit: http://hg.dwscoalition.org/dw-free/rev/8b4914e597b4]
http://bugs.dwscoalition.org/show_bug.cgi?id=3184
Split up the files, and move the inline script to below the existing library
tags.
Patch by
fu.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=3184
Split up the files, and move the inline script to below the existing library
tags.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/LJ/S2.pm
- cgi-bin/weblib.pl
-------------------------------------------------------------------------------- diff -r 0a7dcc4d9f1f -r 8b4914e597b4 cgi-bin/LJ/S2.pm --- a/cgi-bin/LJ/S2.pm Fri Oct 29 19:03:05 2010 +0800 +++ b/cgi-bin/LJ/S2.pm Fri Oct 29 19:36:06 2010 +0800 @@ -160,10 +160,29 @@ sub make_journal # like print_stylesheet() won't run, which don't have an method invocant return $page if $page && ref $page ne 'HASH'; + # Control strip + my $show_control_strip = LJ::Hooks::run_hook( 'show_control_strip' ); + if ($show_control_strip) { + LJ::Hooks::run_hook( 'control_strip_stylesheet_link' ); + + LJ::need_res(qw( + js/core.js + js/dom.js + js/httpreq.js + js/livejournal.js + js/md5.js + js/login.js + )); + } + # Include any head stc or js head content LJ::Hooks::run_hooks("need_res_for_journals", $u); my $extra_js = LJ::statusvis_message_js($u); $page->{head_content} .= LJ::res_includes() . $extra_js; + + # inject the control strip JS, but only after any libraries have been injected + $page->{head_content} .= LJ::control_strip_js_inject( user => $u->user ) + if( $show_control_strip ); s2_run($r, $ctx, $opts, $entry, $page); @@ -2120,13 +2139,6 @@ sub Page # other useful link rels $p->{head_content} .= qq{<link rel="help" href="$LJ::SITEROOT/support/faq" />\n}; - # Control strip - my $show_control_strip = LJ::Hooks::run_hook( 'show_control_strip' ); - if ($show_control_strip) { - LJ::Hooks::run_hook( 'control_strip_stylesheet_link' ); - $p->{'head_content'} .= LJ::control_strip_js_inject( user => $u->{user} ); - } - # FOAF autodiscovery my $foafurl = $u->{external_foaf_url} ? LJ::eurl($u->{external_foaf_url}) : "$p->{base_url}/data/foaf"; $p->{head_content} .= qq{<link rel="meta" type="application/rdf+xml" title="FOAF" href="$foafurl" />\n}; diff -r 0a7dcc4d9f1f -r 8b4914e597b4 cgi-bin/weblib.pl --- a/cgi-bin/weblib.pl Fri Oct 29 19:03:05 2010 +0800 +++ b/cgi-bin/weblib.pl Fri Oct 29 19:36:06 2010 +0800 @@ -2887,16 +2887,6 @@ sub control_strip_js_inject my $ret; - $ret .= "<script src='$LJ::JSPREFIX/core.js' type='text/javascript'></script>\n"; - $ret .= "<script src='$LJ::JSPREFIX/dom.js' type='text/javascript'></script>\n"; - $ret .= "<script src='$LJ::JSPREFIX/httpreq.js' type='text/javascript'></script>\n"; - - LJ::need_res(qw( - js/livejournal.js - js/md5.js - js/login.js - )); - my $r = DW::Request->get; my $baseuri = $r->header_in( 'Host' ) . $r->uri; my $args = LJ::eurl( $r->query_string ) || ''; --------------------------------------------------------------------------------