Igor Gariev (gariev) wrote in changelog,
Igor Gariev
gariev
changelog

[ljcom] r10732: LJSUP-9232: Refactor resources inclusion...

Committer: gariev
LJSUP-9232: Refactor resources inclusion in the integration (kommersant) project

U   trunk/cgi-bin/LJ/PartnerSite.pm
U   trunk/htdocs/gadgets/loginstatus.bml
Modified: trunk/cgi-bin/LJ/PartnerSite.pm
===================================================================
--- trunk/cgi-bin/LJ/PartnerSite.pm	2011-07-05 07:26:03 UTC (rev 10731)
+++ trunk/cgi-bin/LJ/PartnerSite.pm	2011-07-05 07:46:57 UTC (rev 10732)
@@ -87,7 +87,7 @@
      'code' => 'alert("everything's ok");',
  });
  
- $partner->request_logcom_resources;
+ my $resources_html = $partner->resources_html;
  
  my $info = $partner->get_comments_info($docid, {
      'thread' => 12345 || undef,
@@ -150,11 +150,6 @@
 
 =item *
 
-custom_css_url: the URL of the partner-provided CSS file to load in the iframe
-on the partner's site, if necessary
-
-=item *
-
 xdreceiver_path: the path, relative to the domain, of a page on the
 partner's site, to provide a cross-domain communication channel
 
@@ -194,11 +189,11 @@
 =cut
 
 __PACKAGE__->mk_accessors qw( id name journal_username journalid journal
-                              api_key domain link_pattern custom_css_url
+                              api_key domain link_pattern 
                               xdreceiver_path rate_limits encoding
                               mapping_locked disabled dochash_salt
                               sync_comments_count_url_pattern
-                              lj_resources partner_resources identities
+                              lj_resources raw_resources identities
                               widget_version );
 
 ### CLASS METHODS ###
@@ -588,22 +583,28 @@
 
 =item *
 
-$partner->request_logcom_resources: call need_res and include_raw necessary
-for the page of logcom.bml
+$partner->resources_html: calls LJ::need_res() with list of nessesary resources
+Returns the HTML code  - result of LJ::res_includes() call.
 
 =cut
 
-sub request_logcom_resources {
-    my ($self) = @_;
+sub resources_html {
+    my $self = shift;
+    my $opts = shift;
 
+    LJ::need_res( { 'clean_list' => 1 } );
+
     LJ::need_res(qw( js/partners/placeholder.js
                      js/jquery.js
                      stc/lj_base.css ),
                      'stc/partners/login/v' . $self->widget_version . '.css' );
 
-    LJ::include_raw( 'css_link' => $self->custom_css_url )
-        if $self->custom_css_url;
+    my $additional_lj_resources = $self->lj_resources;
+    LJ::need_res(@$additional_lj_resources) if $additional_lj_resources;
 
+    return 
+        LJ::res_includes( {'only_needed' => $opts->{'only_needed'}} ) . 
+        $self->raw_resources;
 }
 
 # note that this function returns a list, not a scalar
@@ -988,21 +989,6 @@
 
 =cut
 
-sub resources {
-    my $self = shift;
-
-    my $resources = $self->partner_resources;
-
-    if ($self->lj_resources) {
-        LJ::need_res( { clean_list => 1 } );
-        LJ::need_res( @{ $self->lj_resources } );
-    }
-
-    $resources .= LJ::res_includes();
-
-    return $resources;
-}
-
 sub identity_type_enabled {
     my ( $self, $idtype ) = @_;
 

Modified: trunk/htdocs/gadgets/loginstatus.bml
===================================================================
--- trunk/htdocs/gadgets/loginstatus.bml	2011-07-05 07:26:03 UTC (rev 10731)
+++ trunk/htdocs/gadgets/loginstatus.bml	2011-07-05 07:46:57 UTC (rev 10732)
@@ -17,8 +17,6 @@
         return 'this domain doesn\'t belong to this partner';
     }
 
-    $partner->request_logcom_resources;
-
     my $journal = $partner->journal;
 
     my $js_check_domain = $partner->domain_check_js(
@@ -33,8 +31,6 @@
 
     my ( $partner_remote_ljuser, $logout_url );
 
-    LJ::need_res( 'stc/partners/login/v' . $partner->widget_version . '.css' );
-
     if ( $remote ) {
         my $remote_sessid = $remote->session->id;
 
@@ -60,7 +56,7 @@
         'js_check_domain'       => $js_check_domain,
         'partner_remote_ljuser' => $partner_remote_ljuser,
         'logout_url'            => $logout_url,
-        'resources_html'        => $partner->resources,
+        'resources_html'        => $partner->resources_html,
         'logged_in'             => $remote ? 1 : 0,
     );
 

Tags: bml, gariev, ljcom, pm
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