Extra option when importing: redo icon mapping when importing entries.
This lets you reimport the icon keywords if your example: you'd previously
imported your entries importing your icons (making everything fall back onto
the default), weren't able to import your icons previously because you ran into
the icon quota (and have since upgraded to a paid account or imported select
icons by hand), something went wrong during the icon import, etc.
Patch by fu.
diffs (246 lines):
diff -r 07113fa2962c -r 26d7bb11b894 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat Tue May 25 18:08:10 2010 +0800
+++ b/bin/upgrading/en.dat Tue May 25 18:20:37 2010 +0800
@@ -4256,6 +4256,8 @@ widget.importchoosedata.item.lj_comments
widget.importchoosedata.item.lj_entries.desc=Imports <em>all</em> your journal
entries, whether they're friends-only, private or public. This will
automatically import your tags and custom security groups.
+widget.importchoosedata.item.lj_entries_remap_icon.desc=Updates icons on
previously imported entries. Has no effect for new imports. Reimports your
journal entries, your tags, and your custom security groups.
+
widget.importchoosedata.item.lj_friendgroups.desc=Imports your friend groups
as [[sitename]] access filters.
widget.importchoosedata.item.lj_friends.desc=Imports your friends as OpenID
accounts and puts them in your imported access filters. This will automatically
import your custom security groups.
@@ -4313,6 +4315,8 @@ widget.importstatus.item.lj_comments=Jou
widget.importstatus.item.lj_comments=Journal comments
widget.importstatus.item.lj_entries=Journal entries
+
+widget.importstatus.item.lj_entries_remap_icon=Update icon keywords
widget.importstatus.item.lj_friendgroups=Custom security groups
diff -r 07113fa2962c -r 26d7bb11b894 bin/upgrading/update-db-general.pl
--- a/bin/upgrading/update-db-general.pl Tue May 25 18:08:10 2010 +0800
+++ b/bin/upgrading/update-db-general.pl Tue May 25 18:20:37 2010 +0800
@@ -2743,6 +2743,7 @@ CREATE TABLE import_data (
usejournal VARCHAR(255),
password_md5 VARCHAR(255),
groupmap BLOB,
+ options BLOB,
PRIMARY KEY (userid, import_data_id),
INDEX (import_data_id)
@@ -3889,6 +3890,11 @@ EOF
"ALTER TABLE externalaccount ADD COLUMN recordlink
enum('1','0') NOT NULL default '0'");
}
+ unless ( column_type( 'import_data', 'options' ) ) {
+ do_alter( 'import_data',
+ q{ALTER TABLE import_data ADD COLUMN options BLOB} );
+ }
+
});
diff -r 07113fa2962c -r 26d7bb11b894 cgi-bin/DW/Logic/Importer.pm
--- a/cgi-bin/DW/Logic/Importer.pm Tue May 25 18:08:10 2010 +0800
+++ b/cgi-bin/DW/Logic/Importer.pm Tue May 25 18:20:37 2010 +0800
@@ -19,6 +19,7 @@ use strict;
use strict;
use Digest::MD5 qw/ md5_hex /;
use DW::Pay;
+use Storable;
sub get_import_data_for_user {
my ( $class, $u ) = @_;
@@ -29,10 +30,13 @@ sub get_import_data_for_user {
# load up their most recent (active) import
# FIXME: memcache this
my $imports = $dbh->selectall_arrayref(
- 'SELECT import_data_id, hostname, username, usejournal, password_md5
FROM import_data WHERE userid = ? ' .
+ 'SELECT import_data_id, hostname, username, usejournal, password_md5,
options FROM import_data WHERE userid = ? ' .
'ORDER BY import_data_id DESC LIMIT 1',
undef, $u->id
);
+
+ $imports->[0]->[5] = Storable::thaw( $imports->[0]->[5] ) || {}
+ if $imports && $imports->[0] && $imports->[0]->[5];
return $imports;
}
@@ -96,7 +100,28 @@ sub set_import_data_for_user {
undef, $u->id
);
- return "";
+ return undef;
+}
+
+sub set_import_data_options_for_user {
+ my ( $class, $u, %opts ) = @_;
+
+ my $id = delete $opts{import_data_id};
+ return unless %opts;
+
+ my $data = Storable::nfreeze( \%opts );
+
+ my $dbh = LJ::get_db_writer()
+ or return "Unable to connect to database.";
+
+ $dbh->do(
+ "UPDATE import_data SET options = ? WHERE import_data_id = ?",
+ undef, $data, $id
+ );
+
+ return $dbh->errstr if $dbh->err;
+
+ return undef;
}
sub set_import_items_for_user {
diff -r 07113fa2962c -r 26d7bb11b894 cgi-bin/DW/Worker/ContentImporter.pm
--- a/cgi-bin/DW/Worker/ContentImporter.pm Tue May 25 18:08:10 2010 +0800
+++ b/cgi-bin/DW/Worker/ContentImporter.pm Tue May 25 18:20:37 2010 +0800
@@ -26,7 +26,7 @@ use Time::HiRes qw/ sleep time /;
use Time::HiRes qw/ sleep time /;
use Carp qw/ croak confess /;
use Encode qw/ encode_utf8 /;
-use Storable qw/ freeze /;
+use Storable;
use LWP::UserAgent;
use XMLRPC::Lite;
use Digest::MD5 qw/ md5_hex /;
@@ -98,9 +98,12 @@ sub import_data {
my $dbh = LJ::get_db_writer()
or croak 'unable to get global database master';
- my $hr = $dbh->selectrow_hashref( 'SELECT userid, hostname, username,
usejournal, password_md5, import_data_id ' .
+ my $hr = $dbh->selectrow_hashref( 'SELECT userid, hostname, username,
usejournal, password_md5, import_data_id, options ' .
'FROM import_data WHERE userid = ? AND
import_data_id = ?', undef, $userid, $impid );
croak $dbh->errstr if $dbh->err;
+
+ $hr->{options} = Storable::thaw( $hr->{options} ) || {}
+ if $hr && $hr->{options};
return $hr;
}
diff -r 07113fa2962c -r 26d7bb11b894
cgi-bin/DW/Worker/ContentImporter/LiveJournal/Entries.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Entries.pm Tue May 25
18:08:10 2010 +0800
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Entries.pm Tue May 25
18:20:37 2010 +0800
@@ -158,10 +158,10 @@ sub try_work {
next;
}
- # FIXME: this is the key moment to "skip". if we want a paid user or
someone
- # to get their picture keyword updated, we should skip them here.
- # FIXME: this is a fixme because we should implement some way of making
- # this available to users.
+ # if we want a paid user or someone to get their picture keyword
updated,
+ # skip them here.
+ next if $data->{options}->{lj_entries_remap_icon};
+
delete $sync{$1 >> 8};
}
$log->( 'Syncitems now has %d items post-prune (first pass).', scalar(
keys %sync ) );
diff -r 07113fa2962c -r 26d7bb11b894 cgi-bin/LJ/Widget/ImportChooseData.pm
--- a/cgi-bin/LJ/Widget/ImportChooseData.pm Tue May 25 18:08:10 2010 +0800
+++ b/cgi-bin/LJ/Widget/ImportChooseData.pm Tue May 25 18:20:37 2010 +0800
@@ -40,6 +40,15 @@ sub render_body {
display_name => $class->ml( 'widget.importstatus.item.lj_entries'
),
desc => $class->ml( 'widget.importchoosedata.item.lj_entries.desc'
),
selected => 0,
+
+ suboptions => [
+ {
+ name => 'lj_entries_remap_icon',
+ display_name => $class->ml(
'widget.importstatus.item.lj_entries_remap_icon' ),
+ desc => $class->ml(
'widget.importchoosedata.item.lj_entries_remap_icon.desc' ),
+ selected => 0,
+ }
+ ]
},
{
name => 'lj_friends',
@@ -90,6 +99,24 @@ sub render_body {
);
$ret .= " <label
for='$option->{name}'>$option->{display_name}</label>";
$ret .= "<?p $option->{desc} p?>";
+
+ if ( my @suboptions = @{ $option->{suboptions} || [] } ) {
+ $ret .= "<ul class='importsuboptions'>";
+ foreach my $suboption ( @suboptions ) {
+ $ret .= "<li>";
+ $ret .= $class->html_check(
+ name => $suboption->{name},
+ id => $suboption->{name},
+ value => 1,
+ selected => $suboption->{selected},
+ );
+ $ret .= " <label
for='$suboption->{name}'>$suboption->{display_name}</label>";
+ $ret .= "<?p $suboption->{desc} p?>";
+ $ret .= "</li>";
+ }
+ $ret .= "</ul>";
+ }
+
$ret .= "</div>";
}
@@ -117,6 +144,10 @@ sub handle_post {
return ( ret => $class->ml(
'widget.importchoosedata.error.noitemsselected' ) )
unless $has_items;
+ # if we're doing the suboption, turn on the parent option
+ $post->{lj_entries} = 1
+ if $post->{lj_entries_remap_icon};
+
# if comments are on, turn entries on
$post->{lj_entries} = 1
if $post->{lj_comments};
diff -r 07113fa2962c -r 26d7bb11b894 cgi-bin/LJ/Widget/ImportConfirm.pm
--- a/cgi-bin/LJ/Widget/ImportConfirm.pm Tue May 25 18:08:10 2010 +0800
+++ b/cgi-bin/LJ/Widget/ImportConfirm.pm Tue May 25 18:20:37 2010 +0800
@@ -80,6 +80,10 @@ sub handle_post {
['lj_comments', 'init'],
);
+ my %suboptions = (
+ lj_entries => [ 'lj_entries_remap_icon' ],
+ );
+
# get import_data_id for the user
my $imports = DW::Logic::Importer->get_import_data_for_user( $u );
my $id = $imports->[0]->[0];
@@ -87,7 +91,18 @@ sub handle_post {
# schedule userpic, bio, and tag imports
foreach my $item ( @jobs ) {
next unless $post->{$item->[0]};
+
+ my $suboption = $suboptions{$item->[0]} || [];
+ my %opts;
+ foreach ( @$suboption ) {
+ $opts{$_} = 1 if $post->{$_};
+ }
+
if ( my $error = DW::Logic::Importer->set_import_items_for_user( $u,
item => $item, id => $id ) ) {
+ return ( ret => $error );
+ }
+
+ if ( my $error =
DW::Logic::Importer->set_import_data_options_for_user( $u, import_data_id =>
$id, %opts ) ) {
return ( ret => $error );
}
}
diff -r 07113fa2962c -r 26d7bb11b894 htdocs/stc/importer.css
--- a/htdocs/stc/importer.css Tue May 25 18:08:10 2010 +0800
+++ b/htdocs/stc/importer.css Tue May 25 18:20:37 2010 +0800
@@ -53,6 +53,10 @@ p.intro {
padding: 0 0 0 22px !important; margin: 0 !important;
font-size: 0.9em;
color: #666;
+}
+
+.importer .importsuboptions {
+ margin-left: 2.5em;
}
.importer .sites {
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog