afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] changelog2009-08-27 04:31 pm

[dw-free] Deal with "lj" in opt_ljcut_disable_* options

[commit: http://hg.dwscoalition.org/dw-free/rev/c264a63ae857]

http://bugs.dwscoalition.org/show_bug.cgi?id=724

Rename options; expose them via the display tab in /manage/settings (Cut Tag
Options)

Patch by [personal profile] kareila.

Files modified:
  • bin/upgrading/en.dat
  • bin/upgrading/proplists.dat
  • bin/upgrading/update-db-general.pl
  • cgi-bin/DW/Setting/CutDisable.pm
  • cgi-bin/LJ/S2/DayPage.pm
  • cgi-bin/LJ/S2/FriendsPage.pm
  • cgi-bin/LJ/S2/RecentPage.pm
  • cgi-bin/ljhooks.pl
  • htdocs/manage/settings/index.bml
--------------------------------------------------------------------------------
diff -r 0fab2892cfcc -r c264a63ae857 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Thu Aug 27 05:22:30 2009 +0000
+++ b/bin/upgrading/en.dat	Thu Aug 27 16:30:55 2009 +0000
@@ -2505,6 +2505,18 @@ setting.ctxpopup.label=Hover Menu
 
 setting.ctxpopup.option=Show menu when I hover over userhead images or userpics
 
+setting.cutdisable.label=Cut Tag Behavior
+
+setting.cutdisable.option=Display full content of cut entries?
+
+setting.cutdisable.sel.both=Yes, in both contexts
+
+setting.cutdisable.sel.journal=Yes, when viewing journals
+
+setting.cutdisable.sel.none=No, honor cut tags (default behavior)
+
+setting.cutdisable.sel.reading=Yes, when viewing reading pages
+
 setting.display.accountstatus.actionlink.contactabuse=Contact Abuse
 
 setting.display.accountstatus.actionlink.delete=Delete
diff -r 0fab2892cfcc -r c264a63ae857 bin/upgrading/proplists.dat
--- a/bin/upgrading/proplists.dat	Thu Aug 27 05:22:30 2009 +0000
+++ b/bin/upgrading/proplists.dat	Thu Aug 27 16:30:55 2009 +0000
@@ -638,7 +638,7 @@ userproplist.opt_imageundef:
   multihomed: 0
   prettyname: Use Placeholders for Undefined-Size Images
 
-userproplist.opt_ljcut_disable_friends:
+userproplist.opt_cut_disable_reading:
   cldversion: 4
   datatype: bool
   des: LJCUT disabled in friends view
@@ -646,7 +646,7 @@ userproplist.opt_ljcut_disable_friends:
   multihomed: 0
   prettyname: LJCUT disabled in friends view
 
-userproplist.opt_ljcut_disable_lastn:
+userproplist.opt_cut_disable_journal:
   cldversion: 4
   datatype: bool
   des: LJCUT disabled in lastn and day views
diff -r 0fab2892cfcc -r c264a63ae857 bin/upgrading/update-db-general.pl
--- a/bin/upgrading/update-db-general.pl	Thu Aug 27 05:22:30 2009 +0000
+++ b/bin/upgrading/update-db-general.pl	Thu Aug 27 16:30:55 2009 +0000
@@ -3968,6 +3968,13 @@ register_alter(sub {
                   q{ALTER TABLE acctcode ADD COLUMN email VARCHAR(255) AFTER timesent} );
     }
 
+    # convert 'ljcut' userprops
+    if ( table_relevant( "userproplist" ) && ! check_dbnote( "userprop_ljcut_to_cut" ) ) {
+        do_sql( "UPDATE userproplist SET name='opt_cut_disable_reading' WHERE name='opt_ljcut_disable_friends'" );
+        do_sql( "UPDATE userproplist SET name='opt_cut_disable_journal' WHERE name='opt_ljcut_disable_lastn'" );
+        set_dbnote( "userprop_ljcut_to_cut", 1 );
+    }
+
 });
 
 
diff -r 0fab2892cfcc -r c264a63ae857 cgi-bin/DW/Setting/CutDisable.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/Setting/CutDisable.pm	Thu Aug 27 16:30:55 2009 +0000
@@ -0,0 +1,80 @@
+#!/usr/bin/perl
+#
+# DW::Setting::CutDisable
+#
+# LJ::Setting module for choosing whether or not to disable the
+# display of entry cut text on a user's journal or reading page,
+# as governed by the userprops "opt_cut_disable_journal" and
+# "opt_cut_disable_reading"
+#
+# Authors:
+#      Jen Griffin <kareila@livejournal.com>
+#
+# Copyright (c) 2009 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::Setting::CutDisable;
+use base 'LJ::Setting';
+use strict;
+use warnings;
+
+sub should_render {
+    my ( $class, $u ) = @_;
+    return $u && ! $u->is_syndicated;
+    # identity users will only be shown opt_cut_disable_reading
+}
+
+sub label {
+    my $class = shift;
+    return $class->ml( 'setting.cutdisable.label' );
+}
+
+sub option {
+    my ( $class, $u, $errs, $args ) = @_;
+    my $key = $class->pkgkey;
+
+    my $opt_reading = $u->prop( "opt_cut_disable_reading" ) || 0;
+    my $opt_journal = $u->prop( "opt_cut_disable_journal" ) || 0;
+    my $cutdisable = $class->get_arg( $args, "cutdisable" ) ||
+        ( $opt_reading << 0 | $opt_journal << 1 );
+
+    my @opts = (
+        0 => $class->ml( "setting.cutdisable.sel.none" ),
+        1 => $class->ml( "setting.cutdisable.sel.reading" ),
+        2 => $class->ml( "setting.cutdisable.sel.journal" ),
+        3 => $class->ml( "setting.cutdisable.sel.both" ),
+    );
+    @opts = @opts[0..3] if $u->is_identity;
+
+    my $ret;
+    $ret .= "<label for='${key}cutdisable'>";
+    $ret .= $class->ml( 'setting.cutdisable.option' );
+    $ret .= "</label> ";
+
+    $ret .= LJ::html_select( { name => "${key}cutdisable",
+                               id   => "${key}cutdisable",
+                               selected => $cutdisable },
+                             @opts );
+
+    my $errdiv = $class->errdiv( $errs, "cutdisable" );
+    $ret .= "<br />$errdiv" if $errdiv;
+
+    return $ret;
+}
+
+sub save {
+    my ( $class, $u, $args ) = @_;
+
+    my $val = $class->get_arg( $args, "cutdisable" ) || 0;
+    $u->set_prop( "opt_cut_disable_reading" => ( $val & 1 ) > 0 );
+    $u->set_prop( "opt_cut_disable_journal" => ( $val & 2 ) > 0 )
+         unless $u->is_identity;
+
+    return 1;
+}
+
+1;
diff -r 0fab2892cfcc -r c264a63ae857 cgi-bin/LJ/S2/DayPage.pm
--- a/cgi-bin/LJ/S2/DayPage.pm	Thu Aug 27 05:22:30 2009 +0000
+++ b/cgi-bin/LJ/S2/DayPage.pm	Thu Aug 27 16:30:55 2009 +0000
@@ -95,8 +95,7 @@ sub DayPage
     push @items, $_ while $_ = $sth->fetchrow_hashref;
     my @itemids = map { $_->{'itemid'} } @items;
 
-    # load 'opt_ljcut_disable_lastn' prop for $remote.
-    LJ::load_user_props($remote, "opt_ljcut_disable_lastn");
+    $remote->preload_props( "opt_cut_disable_journal" ) if $remote;
 
     ### load the log properties
     my %logprops = ();
@@ -150,7 +149,7 @@ sub DayPage
         my $suspend_msg = $entry_obj && $entry_obj->should_show_suspend_msg_to($remote) ? 1 : 0;
         LJ::CleanHTML::clean_event(\$text, { 'preformatted' => $logprops{$itemid}->{'opt_preformatted'},
                                              'cuturl' => LJ::item_link($u, $itemid, $anum),
-                                             'ljcut_disable' => $remote ? $remote->{'opt_ljcut_disable_lastn'} : undef,
+                                             'ljcut_disable' => $remote ? $remote->{'opt_cut_disable_journal'} : undef,
                                              'suspend_msg' => $suspend_msg,
                                              'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0, });
         LJ::expand_embedded($u, $ditemid, $remote, \$text);
diff -r 0fab2892cfcc -r c264a63ae857 cgi-bin/LJ/S2/FriendsPage.pm
--- a/cgi-bin/LJ/S2/FriendsPage.pm	Thu Aug 27 05:22:30 2009 +0000
+++ b/cgi-bin/LJ/S2/FriendsPage.pm	Thu Aug 27 16:30:55 2009 +0000
@@ -60,7 +60,7 @@ sub FriendsPage
 
     my $ret;
 
-    LJ::load_user_props( $remote, "opt_nctalklinks", "opt_stylemine", "opt_imagelinks", "opt_imageundef", "opt_ljcut_disable_friends" );
+    $remote->preload_props( "opt_nctalklinks", "opt_stylemine", "opt_imagelinks", "opt_imageundef", "opt_cut_disable_reading" ) if $remote;
 
     # load options for image links
     my ($maximgwidth, $maximgheight) = (undef, undef);
@@ -231,7 +231,7 @@ sub FriendsPage
                                              'maximgwidth' => $maximgwidth,
                                              'maximgheight' => $maximgheight,
                                              'imageplaceundef' => $remote->{'opt_imageundef'},
-                                             'ljcut_disable' => $remote ? $remote->{'opt_ljcut_disable_friends'} : undef,
+                                             'ljcut_disable' => $remote ? $remote->{'opt_cut_disable_reading'} : undef,
                                              'suspend_msg' => $suspend_msg,
                                              'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0, });
         LJ::expand_embedded($friends{$friendid}, $ditemid, $remote, \$text);
diff -r 0fab2892cfcc -r c264a63ae857 cgi-bin/LJ/S2/RecentPage.pm
--- a/cgi-bin/LJ/S2/RecentPage.pm	Thu Aug 27 05:22:30 2009 +0000
+++ b/cgi-bin/LJ/S2/RecentPage.pm	Thu Aug 27 16:30:55 2009 +0000
@@ -44,7 +44,7 @@ sub RecentPage
     };
     $p->{'data_links_order'} = [ qw(rss atom) ];
 
-    LJ::load_user_props($remote, "opt_nctalklinks", "opt_ljcut_disable_lastn");
+    $remote->preload_props( "opt_nctalklinks", "opt_cut_disable_journal") if $remote;
 
     my $get = $opts->{'getargs'};
 
@@ -172,7 +172,7 @@ sub RecentPage
         my $suspend_msg = $entry_obj && $entry_obj->should_show_suspend_msg_to($remote) ? 1 : 0;
         LJ::CleanHTML::clean_event(\$text, { 'preformatted' => $logprops{$itemid}->{'opt_preformatted'},
                                               'cuturl' => LJ::item_link($u, $itemid, $item->{'anum'}),
-                                              'ljcut_disable' => $remote ? $remote->prop("opt_ljcut_disable_lastn") : undef,
+                                              'ljcut_disable' => $remote ? $remote->prop("opt_cut_disable_journal") : undef,
                                               'suspend_msg' => $suspend_msg,
                                               'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0, });
         LJ::expand_embedded($u, $ditemid, $remote, \$text);
diff -r 0fab2892cfcc -r c264a63ae857 cgi-bin/ljhooks.pl
--- a/cgi-bin/ljhooks.pl	Thu Aug 27 05:22:30 2009 +0000
+++ b/cgi-bin/ljhooks.pl	Thu Aug 27 16:30:55 2009 +0000
@@ -147,23 +147,23 @@ register_setter("maximagesize", sub {
     return 1;
 });
 
-register_setter("opt_ljcut_disable_lastn", sub {
+register_setter("opt_cut_disable_journal", sub {
     my ($u, $key, $value, $err) = @_;
     unless ($value =~ /^(0|1)$/) {
         $$err = "Illegal value. Must be '0' or '1'";
         return 0;
     }
-    $u->set_prop("opt_ljcut_disable_lastn", $value);
+    $u->set_prop( "opt_cut_disable_journal", $value );
     return 1;
 });
 
-register_setter("opt_ljcut_disable_friends", sub {
+register_setter("opt_cut_disable_reading", sub {
     my ($u, $key, $value, $err) = @_;
     unless ($value =~ /^(0|1)$/) {
         $$err = "Illegal value. Must be '0' or '1'";
         return 0;
     }
-    $u->set_prop("opt_ljcut_disable_friends", $value);
+    $u->set_prop( "opt_cut_disable_reading", $value );
     return 1;
 });
 
diff -r 0fab2892cfcc -r c264a63ae857 htdocs/manage/settings/index.bml
--- a/htdocs/manage/settings/index.bml	Thu Aug 27 05:22:30 2009 +0000
+++ b/htdocs/manage/settings/index.bml	Thu Aug 27 16:30:55 2009 +0000
@@ -57,6 +57,7 @@ body<=
                 LJ::Setting::TimeZone
                 LJ::Setting::ImagePlaceholders
                 LJ::Setting::EmbedPlaceholders
+                DW::Setting::CutDisable
                 LJ::Setting::EmailFormat
                 LJ::Setting::EntryEditor
                 LJ::Setting::NCTalkLinks
--------------------------------------------------------------------------------