Add beta-testing mode for jquerified journals (features only partially 
implemented for now)

        Patch by fu. 

diffs (149 lines):

diff -r 3cd5dbffdd1b -r 1c0749606568 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat      Tue Mar 15 21:06:44 2011 +0800
+++ b/bin/upgrading/en.dat      Mon Mar 28 14:40:04 2011 +0800
@@ -4373,6 +4373,24 @@ widget.betafeature.btn.off=Turn OFF beta
 
 widget.betafeature.btn.on=Turn ON beta testing
 
+widget.betafeature.journaljquery.on<<
+Currently beta-testing the new JS behavior on journals.
+<h3>Implemented</h3>
+[[implemented]]
+
+<h3>Todo</h3>
+[[notimplemented]]
+.
+
+widget.betafeature.journaljquery.off<<
+Switch to the new JS behavior on journals.
+<h3>Implemented</h3>
+[[implemented]]
+
+<h3>Todo</h3>
+[[notimplemented]]
+.
+
 widget.communitymanagement.nopending=No communities require action.
 
 widget.communitymanagement.pending=Pending:
diff -r 3cd5dbffdd1b -r 1c0749606568 cgi-bin/DW/BetaFeatures/journaljquery.pm
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/BetaFeatures/journaljquery.pm  Mon Mar 28 14:40:04 2011 +0800
@@ -0,0 +1,42 @@
+#!/usr/bin/perl
+#
+# DW::BetaFeatures::journaljquery - Allow users to beta test the updated 
jquery-ified journals
+#
+# Authors:
+#      Afuna <[email protected]>
+#
+# Copyright (c) 2011 by Dreamwidth Studios, LLC.
+#
+# This program is free software; you may redistribute it and/or modify it under
+# the same terms as Perl itself. For a copy of the license, please reference
+# 'perldoc perlartistic' or 'perldoc perlgpl'.
+
+package DW::BetaFeatures::journaljquery;
+
+use strict;
+use base "LJ::BetaFeatures::default";
+
+sub args_list {
+    my @implemented = (
+        "Logging in",
+    );
+
+    my @notimplemented = (
+        "Contextual hover",
+        "Screen/freeze/delete",
+        "Quick reply",
+        "Cut expand and collapse",
+        "Media embed placeholder expansion",
+        "Control strip injection for non-supporting journals",
+        "Same-page poll submission",
+        "Thread expander",
+        "Icon browser",
+    );
+
+    return (
+        implemented => "<ul>" . join( "\n", map { "<li>$_</li>" } @implemented 
) . "</ul>",
+        notimplemented => "<ul>" . join( "\n", map { "<li>$_</li>" } 
@notimplemented ) . "</ul>",
+    );
+}
+
+1;
diff -r 3cd5dbffdd1b -r 1c0749606568 cgi-bin/LJ/BetaFeatures.pm
--- a/cgi-bin/LJ/BetaFeatures.pm        Tue Mar 15 21:06:44 2011 +0800
+++ b/cgi-bin/LJ/BetaFeatures.pm        Mon Mar 28 14:40:04 2011 +0800
@@ -20,7 +20,9 @@ use LJ::ModuleLoader;
 
 my %HANDLER_OF_KEY = (); # key -> handler object
 my @HANDLER_LIST   = LJ::ModuleLoader->module_subclasses(__PACKAGE__);
-foreach my $handler (@HANDLER_LIST) {
+my @DW_HANDLER_LIST = LJ::ModuleLoader->module_subclasses( "DW::BetaFeatures" 
);
+
+foreach my $handler (@HANDLER_LIST, @DW_HANDLER_LIST) {
     eval "use $handler";
     die "Error loading handler '$handler': $@" if $@;
 }
@@ -33,7 +35,7 @@ sub get_handler {
     return $handler if $handler;
 
     my $use_key = 'default';
-    foreach my $cl (@HANDLER_LIST) {
+    foreach my $cl (@HANDLER_LIST, @DW_HANDLER_LIST) {
         my $subcl = (split("::", $cl))[-1];
         next if $subcl eq 'default';
         next unless $subcl eq $key;
diff -r 3cd5dbffdd1b -r 1c0749606568 cgi-bin/LJ/BetaFeatures/default.pm
--- a/cgi-bin/LJ/BetaFeatures/default.pm        Tue Mar 15 21:06:44 2011 +0800
+++ b/cgi-bin/LJ/BetaFeatures/default.pm        Mon Mar 28 14:40:04 2011 +0800
@@ -98,4 +98,9 @@ sub is_expired {
     return 1;
 }
 
+# any arguments to pass to the translation string to describe this feature?
+sub args_list {
+    return ();
+}
+
 1;
diff -r 3cd5dbffdd1b -r 1c0749606568 cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm  Tue Mar 15 21:06:44 2011 +0800
+++ b/cgi-bin/LJ/S2.pm  Mon Mar 28 14:40:04 2011 +0800
@@ -169,6 +169,10 @@ sub make_journal
     # like print_stylesheet() won't run, which don't have an method invocant
     return $page if $page && ref $page ne 'HASH';
 
+    my $beta_jquery = LJ::BetaFeatures->user_in_beta( $remote => 
"journaljquery" );
+    LJ::set_active_resource_group( 'jquery' )
+        if $beta_jquery;
+
     # Control strip
     my $show_control_strip = LJ::Hooks::run_hook( 'show_control_strip' );
     if ($show_control_strip) {
@@ -204,7 +208,7 @@ sub make_journal
 
     # 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 );
+        if $show_control_strip && ! $beta_jquery;
 
     s2_run($r, $ctx, $opts, $entry, $page);
 
diff -r 3cd5dbffdd1b -r 1c0749606568 cgi-bin/LJ/Widget/BetaFeature.pm
--- a/cgi-bin/LJ/Widget/BetaFeature.pm  Tue Mar 15 21:06:44 2011 +0800
+++ b/cgi-bin/LJ/Widget/BetaFeature.pm  Mon Mar 28 14:40:04 2011 +0800
@@ -39,10 +39,10 @@ sub render_body {
     if ($handler->is_active && $handler->user_can_add($u)) {
         $ret .= $class->start_form;
         if ($u->is_in_beta($feature)) {
-            $ret .= "<?p " . $class->ml("widget.betafeature.$feature.on") . " 
p?>";
+            $ret .= "<?p " . $class->ml("widget.betafeature.$feature.on", { 
$handler->args_list } ) . " p?>";
             $ret .= $class->html_submit("off", 
$class->ml('widget.betafeature.btn.off'));
         } else {
-            $ret .= "<?p " . $class->ml("widget.betafeature.$feature.off") . " 
p?>";
+            $ret .= "<?p " . $class->ml("widget.betafeature.$feature.off", { 
$handler->args_list } ) . " p?>";
             $ret .= $class->html_submit("on", 
$class->ml('widget.betafeature.btn.on'));
         }
         $ret .= $class->html_hidden( feature => $feature, user => $u->user );
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to