Типа я (zilogic) wrote in changelog,
Типа я
zilogic
changelog

[livejournal] r19564: LJSUP-9366: Change Interstitial dialog f...

Committer: amyshkin
LJSUP-9366: Change Interstitial dialog for Singapore
U   trunk/bin/upgrading/proplists.dat
U   trunk/cgi-bin/LJ/Setting.pm
U   trunk/cgi-bin/LJ/Widget.pm
U   trunk/htdocs/editjournal.bml
U   trunk/htdocs/manage/settings/index.bml
U   trunk/htdocs/tools/endpoints/widget.bml
U   trunk/htdocs/update.bml
U   trunk/htdocs/userinfo.bml
Modified: trunk/bin/upgrading/proplists.dat
===================================================================
--- trunk/bin/upgrading/proplists.dat	2011-08-02 08:48:18 UTC (rev 19563)
+++ trunk/bin/upgrading/proplists.dat	2011-08-02 08:59:14 UTC (rev 19564)
@@ -1694,3 +1694,11 @@
   indexed: 0
   multihomed: 1
   cldversion: 8
+
+userproplist.singapore_invitations:
+  datatype: char
+  prettyname: Singapore invitations status
+  des: Singapore invitations status
+  indexed: 0
+  multihomed: 0
+  cldversion: 8

Modified: trunk/cgi-bin/LJ/Setting.pm
===================================================================
--- trunk/cgi-bin/LJ/Setting.pm	2011-08-02 08:48:18 UTC (rev 19563)
+++ trunk/cgi-bin/LJ/Setting.pm	2011-08-02 08:59:14 UTC (rev 19564)
@@ -23,12 +23,41 @@
 sub htmlcontrol_label { "" }
 sub raw_html          { "" }
 
+sub handle_post {
+    my ( $class, $params, $widget ) = @_;
+    delete @$params{qw/lj_form_auth _widget_id _widget_ippu _widget_class/};
+
+    my %res;
+
+    eval {
+        %res = $widget->save(LJ::get_remote(), $params);
+    };
+
+    return %res;
+}
+
+sub form_start {
+    my $self = shift;
+
+    return '<form action="javascript: return false" id="settingwindow_form">'
+      . '<input type="hidden" name="_widget_class" value="'
+      . (  ref($self) || $self )
+      . '">'
+      # hidden for posting submit button (form can have several submit buttons)
+      . '<input type="hidden" id="form_submit" name="submit" value="">' ;
+}
+
+sub form_end {
+    return '</form>';
+}
+
+sub form_auth {
+    return LJ::form_auth();
+}
+
 sub error_check {
     my ($class, $u, $args) = @_;
     my $val = $class->get_arg($args, "foo");
-    #unless ($val =~ /blah/) {
-    #   $class->errors("foo" => "Invalid foo");
-    #}
 
     die "No 'error_check' configured for settings module '$class'\n";
 }

Modified: trunk/cgi-bin/LJ/Widget.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget.pm	2011-08-02 08:48:18 UTC (rev 19563)
+++ trunk/cgi-bin/LJ/Widget.pm	2011-08-02 08:59:14 UTC (rev 19564)
@@ -1,7 +1,7 @@
 package LJ::Widget;
 
 use strict;
-use Carp;
+use Carp qw/croak cluck/;
 use LJ::ModuleLoader;
 use LJ::Auth;
 
@@ -36,6 +36,7 @@
 
     my $eopts = "";
     my $ehtml = $opts{noescape} ? 0 : 1;
+
     foreach my $attr (grep { ! /^(noescape)$/ && ! /^(authas)$/ } keys %opts) {
         $eopts .= " $attr=\"" . ($ehtml ? LJ::ehtml($opts{$attr}) : $opts{$_}) . "\"";
     }
@@ -121,7 +122,6 @@
             }
         }
         LJ::need_res($opt_hash{stylesheet}) if $opt_hash{stylesheet};
-
         return $widget->render_body(@opts);
     } or $class->handle_error($@);
 
@@ -139,11 +139,11 @@
 
 sub post_fields_by_widget {
     my $class = shift;
-    my %opts = @_;
+    my %opts  = @_;
 
-    my $post = $opts{post};
+    my $post    = $opts{post};
     my $widgets = $opts{widgets};
-    my $errors = $opts{errors};
+    my $errors  = $opts{errors};
 
     my %per_widget = map { /^(?:LJ::Widget::)?(.+)$/; $1 => {} } @$widgets;
     my $eff_submit = undef;
@@ -233,18 +233,23 @@
 # returns hash returned from the last processed widget
 # pushes any errors onto @BMLCodeBlock::errors
 sub handle_post {
-    my $class   = shift;
-    my $post    = shift;
+    my $class = shift;
+    my $post  = shift;
     my @widgets;
+
     # support for per-widget handle_post() options
     my %widget_opts = ();
-    while (@_) {
+
+    while ( @_ ) {
         my $w = shift;
-        if (@_ && ref $_[0]) {
+
+        if ( @_ && ref $_[0] ) {
             $widget_opts{$w} = shift(@_);
         }
+
         push @widgets, $w;
     }
+
     # no errors, return empty list
     return () unless LJ::did_post() && @widgets;
 
@@ -254,15 +259,19 @@
     # require form auth for widget submissions
     my $errorsref = \@BMLCodeBlock::errors;
 
-    unless (LJ::check_form_auth($post->{lj_form_auth}) || $LJ::WIDGET_NO_AUTH_CHECK) {
+    unless ( LJ::check_form_auth($post->{lj_form_auth}) || $LJ::WIDGET_NO_AUTH_CHECK ) {
         push @$errorsref, BML::ml('error.invalidform');
     }
 
-    my $per_widget = $class->post_fields_by_widget( post => $post, widgets => \@widgets, errors => $errorsref );
+    my $per_widget = $class->post_fields_by_widget(
+        post    => $post,
+        widgets => \@widgets,
+        errors  => $errorsref,
+    );
 
     my %res;
 
-    while (my ($class, $fields) = each %$per_widget) {
+    while ( my ($class, $fields) = each %$per_widget ) {
         eval { %res = "LJ::Widget::$class"->handle_post($fields, %{$widget_opts{$class} or {}}) } or
             "LJ::Widget::$class"->handle_error($@ => $errorsref);
     }

Modified: trunk/htdocs/editjournal.bml
===================================================================
--- trunk/htdocs/editjournal.bml	2011-08-02 08:48:18 UTC (rev 19563)
+++ trunk/htdocs/editjournal.bml	2011-08-02 08:59:14 UTC (rev 19564)
@@ -429,7 +429,7 @@
     </script>
 };
 
-            $ret .= LJ::Widget::SettingProdDisplay->render;
+            $ret .= LJ::Widget::SettingWindow->render;
 
             return $ret;
         }
@@ -589,7 +589,7 @@
 
         $ret .= "</td></tr></table>";
 
-        $ret .= LJ::Widget::SettingProdDisplay->render;
+        $ret .= LJ::Widget::SettingWindow->render;
 
         return $ret;
     }

Modified: trunk/htdocs/manage/settings/index.bml
===================================================================
--- trunk/htdocs/manage/settings/index.bml	2011-08-02 08:48:18 UTC (rev 19563)
+++ trunk/htdocs/manage/settings/index.bml	2011-08-02 08:59:14 UTC (rev 19564)
@@ -497,7 +497,7 @@
 
     $ret .= "</div>";
 
-    $ret .= LJ::Widget::SettingProdDisplay->render;
+    $ret .= LJ::Widget::SettingWindow->render;
     
     return $ret;
 }

Modified: trunk/htdocs/tools/endpoints/widget.bml
===================================================================
--- trunk/htdocs/tools/endpoints/widget.bml	2011-08-02 08:48:18 UTC (rev 19563)
+++ trunk/htdocs/tools/endpoints/widget.bml	2011-08-02 08:59:14 UTC (rev 19564)
@@ -25,9 +25,11 @@
     my $remote = LJ::get_remote();
 
     my $widget_class = $POST{_widget_class} || $GET{_widget_class};
-    return $err->("Invalid widget class $widget_class") unless $widget_class =~ /^(IPPU::)?\w+$/gm;
-    $widget_class = "LJ::Widget::$widget_class";
+    return $err->("Invalid widget class $widget_class") unless $widget_class =~ /^(IPPU::|LJ::Setting::)?\w+$/gm;
 
+    # hack: enable LJ::Setting class
+    $widget_class = "LJ::Widget::$widget_class" unless $widget_class =~ /^LJ::Setting::/;
+
     return $err->("Cannot do AJAX request to $widget_class")
         unless $widget_class->ajax;
 
@@ -39,21 +41,24 @@
         $POST{$_} = $GET{$_} foreach keys %GET;
     }
 
-    my $widget_id    = $POST{_widget_id};
-    my $widget_ippu  = $POST{_widget_ippu};
-    my $doing_post   = delete $POST{_widget_post};
+    my $widget_id   = $POST{_widget_id};
 
+    my $doing_post  = delete $POST{_widget_post};
+
     my %ret = (
-               _widget_id    => $widget_id,
-               _widget_class => $widget_class,
-               );
+        _widget_id    => $widget_id,
+        _widget_class => ref $widget_class || $widget_class,
+    );
 
     # make sure that we're working with the right user
+    # TODO: check auth validity
     if ($POST{authas}) {
         if ($widget_class->authas) {
+        # TODO: check if it is really needed
             my $u = LJ::get_authas_user($POST{authas});
             return $err->("Invalid user.") unless $u;
-        } else {
+        }
+        else {
             return $err->("Widget does not support authas authentication.");
         }
     }
@@ -66,10 +71,18 @@
 
         my %res;
 
-        eval {
-            %res = LJ::Widget->handle_post(\%POST, $widget_class);
-        };
+        if( $widget_class =~ /^LJ::Setting::/ ) {
+            eval {
+                %res = LJ::Setting->handle_post(\%POST, $widget_class);
+            };
+        }
+        else {
+            eval {
+                %res = LJ::Widget->handle_post(\%POST, $widget_class);
+            };
+        }
 
+
         $ret{res} = \%res;
 
         $ret{errors} = $@ ? [$@] : \@errors;

Modified: trunk/htdocs/update.bml
===================================================================
--- trunk/htdocs/update.bml	2011-08-02 08:48:18 UTC (rev 19563)
+++ trunk/htdocs/update.bml	2011-08-02 08:59:14 UTC (rev 19564)
@@ -352,7 +352,7 @@
         $$body .= LJ::entry_form($entry, \$$head, $onload, $errors);
         $$body .= "</form><!-- end #updateForm -->\n";
 
-        $$body .= LJ::Widget::SettingProdDisplay->render;
+        $$body .= LJ::Widget::SettingWindow->render;
 
         return;
     };

Modified: trunk/htdocs/userinfo.bml
===================================================================
--- trunk/htdocs/userinfo.bml	2011-08-02 08:48:18 UTC (rev 19563)
+++ trunk/htdocs/userinfo.bml	2011-08-02 08:59:14 UTC (rev 19564)
@@ -1623,7 +1623,7 @@
 
     $body .= "</div>";
 
-    $body .= LJ::Widget::SettingProdDisplay->render;
+    $body .= LJ::Widget::SettingWindow->render;
 
     $bml_okay = 0;
     return;

Tags: bml, dat, livejournal, pm, zilogic
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