vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[livejournal] r22066: LJSUP-11897: System to organize JS/CSS s...

Committer: vad
LJSUP-11897: System to organize JS/CSS sources into libraries
U   trunk/cgi-bin/weblib.pl
Modified: trunk/cgi-bin/weblib.pl
===================================================================
--- trunk/cgi-bin/weblib.pl	2012-05-25 12:47:22 UTC (rev 22065)
+++ trunk/cgi-bin/weblib.pl	2012-05-25 12:49:53 UTC (rev 22066)
@@ -1315,6 +1315,7 @@
 ## Support 'args' option. Example: LJ::need_res( { args => 'media="screen"' }, 'stc/ljtimes/iframe.css' );
 ## Results in: <link rel="stylesheet" type="text/css" href="http://stat.lj-3-32.bulyon.local/ljtimes/iframe.css?v=1285833891" media="screen"/>
 ## LJ::need_res( {clean_list => 1} ) will suppress ALL previous resources and do NOTHING more!
+## LJ::need_res( {insert_head => 1}, 'my.css' ) insert my.css to the head of the list of sources. 
 sub need_res {
     my $opts = (ref $_[0]) ? shift : {};
     my @keys = @_;
@@ -1325,7 +1326,13 @@
         @LJ::INCLUDE_TEMPLATE = ();
         return;
     }
-    
+
+    my $insert_head = 0;
+    if ($opts->{insert_head}){
+        $insert_head = 1;
+    }
+
+    my @reskeys = ();
     foreach my $key (@keys) {
         my $reskey  = $key;
         my $resopts = $opts;
@@ -1342,11 +1349,17 @@
         die "Bogus reskey $reskey" unless $reskey =~ m!^(js|stc)/!;
 
         unless (exists $LJ::NEEDED_RES{$reskey}) {
-            push @LJ::NEEDED_RES, $reskey;
+            push @reskeys => $reskey;
         }
-
         $LJ::NEEDED_RES{$reskey} = $resopts;
     }
+
+    if ($insert_head){
+        unshift @LJ::NEEDED_RES, @reskeys;
+    } else {
+        push @LJ::NEEDED_RES, @reskeys;
+    }
+
 }
 
 sub include_raw  {

Tags: livejournal, pl, vad, vadvs
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments