[dw-free] crossposter: mood themes don't display icons on external sites
[commit: http://hg.dwscoalition.org/dw-free/rev/752317d07dc7]
http://bugs.dwscoalition.org/show_bug.cgi?id=1132
Fix mood icons not showing up on crossposted entries.
Patch by
janinedog.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=1132
Fix mood icons not showing up on crossposted entries.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- bin/upgrading/moods-external.dat
- bin/upgrading/update-db-general.pl
- bin/upgrading/update-db.pl
- cgi-bin/DW/External/Account.pm
- cgi-bin/DW/External/XPostProtocol/LJXMLRPC.pm
- cgi-bin/ljmood.pl
-------------------------------------------------------------------------------- diff -r 030b40fba2bf -r 752317d07dc7 bin/upgrading/moods-external.dat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/upgrading/moods-external.dat Mon Jul 20 12:21:13 2009 -0500 @@ -0,0 +1,684 @@ +# siteid moodid mood + +# LiveJournal +2 1 aggravated +2 2 angry +2 3 annoyed +2 4 anxious +2 5 bored +2 6 confused +2 7 crappy +2 8 cranky +2 9 depressed +2 10 discontent +2 11 energetic +2 12 enraged +2 13 enthralled +2 14 exhausted +2 15 happy +2 16 high +2 17 horny +2 18 hungry +2 19 infuriated +2 20 irate +2 21 jubilant +2 22 lonely +2 23 moody +2 24 pissed off +2 25 sad +2 26 satisfied +2 27 sore +2 28 stressed +2 29 thirsty +2 30 thoughtful +2 31 tired +2 32 touched +2 33 lazy +2 34 drunk +2 35 ditzy +2 36 mischievous +2 37 morose +2 38 gloomy +2 39 melancholy +2 40 drained +2 41 excited +2 42 relieved +2 43 hopeful +2 44 amused +2 45 determined +2 46 scared +2 47 frustrated +2 48 indescribable +2 49 sleepy +2 51 groggy +2 52 hyper +2 53 relaxed +2 54 restless +2 55 disappointed +2 56 curious +2 57 mellow +2 58 peaceful +2 59 bouncy +2 60 nostalgic +2 61 okay +2 62 rejuvenated +2 63 complacent +2 64 content +2 65 indifferent +2 66 silly +2 67 flirty +2 68 calm +2 69 refreshed +2 70 optimistic +2 71 pessimistic +2 72 giggly +2 73 pensive +2 74 uncomfortable +2 75 lethargic +2 76 listless +2 77 recumbent +2 78 exanimate +2 79 embarrassed +2 80 envious +2 81 sympathetic +2 82 sick +2 83 hot +2 84 cold +2 85 worried +2 86 loved +2 87 awake +2 88 working +2 89 productive +2 90 accomplished +2 91 busy +2 92 blah +2 93 full +2 95 grumpy +2 96 weird +2 97 nauseated +2 98 ecstatic +2 99 chipper +2 100 rushed +2 101 contemplative +2 102 nerdy +2 103 geeky +2 104 cynical +2 105 quixotic +2 106 crazy +2 107 creative +2 108 artistic +2 109 pleased +2 110 bitchy +2 111 guilty +2 112 irritated +2 113 blank +2 114 apathetic +2 115 dorky +2 116 impressed +2 117 naughty +2 118 predatory +2 119 dirty +2 120 giddy +2 121 surprised +2 122 shocked +2 123 rejected +2 124 numb +2 125 cheerful +2 126 good +2 127 distressed +2 128 intimidated +2 129 crushed +2 130 devious +2 131 thankful +2 132 grateful +2 133 jealous +2 134 nervous + +# InsaneJournal +3 1 aggravated +3 2 angry +3 3 annoyed +3 4 anxious +3 5 bored +3 6 confused +3 7 crappy +3 8 cranky +3 9 depressed +3 10 discontent +3 11 energetic +3 12 enraged +3 13 enthralled +3 14 exhausted +3 15 happy +3 16 high +3 17 horny +3 18 hungry +3 19 infuriated +3 20 irate +3 21 jubilant +3 22 lonely +3 23 moody +3 24 pissed off +3 25 sad +3 26 satisfied +3 27 sore +3 28 stressed +3 29 thirsty +3 30 thoughtful +3 31 tired +3 32 touched +3 33 lazy +3 34 drunk +3 35 ditzy +3 36 mischievous +3 37 morose +3 38 gloomy +3 39 melancholy +3 40 drained +3 41 excited +3 42 relieved +3 43 hopeful +3 44 amused +3 45 determined +3 46 scared +3 47 frustrated +3 48 indescribable +3 49 sleepy +3 51 groggy +3 52 hyper +3 53 relaxed +3 54 restless +3 55 disappointed +3 56 curious +3 57 mellow +3 58 peaceful +3 59 bouncy +3 60 nostalgic +3 61 okay +3 62 rejuvenated +3 63 complacent +3 64 content +3 65 indifferent +3 66 silly +3 67 flirty +3 68 calm +3 69 refreshed +3 70 optimistic +3 71 pessimistic +3 72 giggly +3 73 pensive +3 74 uncomfortable +3 75 lethargic +3 76 listless +3 77 recumbent +3 78 exanimate +3 79 embarrassed +3 80 envious +3 81 sympathetic +3 82 sick +3 83 hot +3 84 cold +3 85 worried +3 86 loved +3 87 awake +3 88 working +3 89 productive +3 90 accomplished +3 91 busy +3 92 blah +3 93 full +3 95 grumpy +3 96 weird +3 97 nauseated +3 98 ecstatic +3 99 chipper +3 100 rushed +3 101 contemplative +3 102 nerdy +3 103 geeky +3 104 cynical +3 105 quixotic +3 106 crazy +3 107 creative +3 108 artistic +3 109 pleased +3 110 bitchy +3 111 guilty +3 112 irritated +3 113 blank +3 114 apathetic +3 115 dorky +3 116 impressed +3 117 naughty +3 118 predatory +3 119 dirty +3 120 giddy +3 121 surprised +3 122 shocked +3 123 rejected +3 124 numb +3 125 cheerful +3 126 good +3 127 distressed +3 128 intimidated +3 129 crushed +3 130 devious +3 131 thankful +3 132 grateful +3 133 jealous + +# DeadJournal +4 1 aggravated +4 2 angry +4 3 annoyed +4 4 anxious +4 5 bored +4 6 confused +4 7 crappy +4 8 cranky +4 9 depressed +4 10 discontent +4 11 energetic +4 12 enraged +4 13 enthralled +4 14 exhausted +4 15 happy +4 16 high +4 17 horny +4 18 hungry +4 19 infuriated +4 20 irate +4 21 jubilant +4 22 lonely +4 23 moody +4 24 pissed off +4 25 sad +4 26 satisfied +4 27 sore +4 28 stressed +4 29 thirsty +4 30 thoughtful +4 31 tired +4 32 touched +4 33 lazy +4 34 drunk +4 35 ditzy +4 36 mischievous +4 37 morose +4 38 gloomy +4 39 melancholy +4 40 drained +4 41 excited +4 42 relieved +4 43 hopeful +4 44 amused +4 45 determined +4 46 scared +4 47 frustrated +4 48 indescribable +4 49 sleepy +4 51 groggy +4 52 hyper +4 53 relaxed +4 54 restless +4 55 disappointed +4 56 curious +4 57 mellow +4 58 peaceful +4 59 bouncy +4 60 nostalgic +4 61 okay +4 62 rejuvenated +4 63 complacent +4 64 content +4 65 indifferent +4 66 silly +4 67 flirty +4 68 calm +4 69 refreshed +4 70 optimistic +4 71 pessimistic +4 72 giggly +4 73 pensive +4 74 uncomfortable +4 75 lethargic +4 76 listless +4 77 recumbent +4 78 exanimate +4 79 embarrassed +4 80 envious +4 81 sympathetic +4 82 sick +4 83 hot +4 84 cold +4 85 worried +4 86 loved +4 87 awake +4 88 working +4 89 productive +4 90 accomplished +4 91 busy +4 92 blah +4 93 full +4 95 grumpy +4 96 weird +4 97 nauseated +4 98 ecstatic +4 99 chipper +4 100 rushed +4 101 contemplative +4 102 nerdy +4 103 geeky +4 104 cynical +4 105 quixotic +4 106 crazy +4 107 creative +4 108 artistic +4 109 pleased +4 110 bitchy +4 111 guilty +4 112 irritated +4 113 blank +4 114 apathetic +4 115 dorky +4 116 impressed +4 117 naughty +4 118 predatory +4 119 dirty +4 120 giddy +4 121 surprised +4 122 shocked +4 123 rejected +4 124 numb +4 125 cheerful +4 126 good +4 127 distressed +4 128 intimidated +4 129 crushed +4 130 devious +4 131 thankful +4 132 grateful +4 133 jealous +4 134 nervous + +# Inksome +5 1 aggravated +5 2 angry +5 3 annoyed +5 4 anxious +5 5 bored +5 6 confused +5 7 crappy +5 8 cranky +5 9 depressed +5 10 discontent +5 11 energetic +5 12 enraged +5 14 exhausted +5 15 happy +5 16 high +5 18 hungry +5 19 infuriated +5 20 irate +5 21 jubilant +5 22 lonely +5 23 moody +5 25 sad +5 26 satisfied +5 28 stressed +5 30 thoughtful +5 31 tired +5 32 touched +5 33 lazy +5 34 drunk +5 41 excited +5 42 relieved +5 43 hopeful +5 44 amused +5 46 scared +5 47 frustrated +5 49 sleepy +5 51 groggy +5 52 hyper +5 53 relaxed +5 54 restless +5 55 disappointed +5 56 curious +5 61 okay +5 68 calm +5 70 optimistic +5 74 uncomfortable +5 79 embarrassed +5 80 envious +5 81 sympathetic +5 82 sick +5 83 hot +5 84 cold +5 85 worried +5 86 loved +5 87 awake +5 88 working +5 89 productive +5 90 accomplished +5 91 busy +5 93 full +5 95 grumpy +5 98 ecstatic +5 101 contemplative +5 102 nerdy +5 103 geeky +5 104 cynical +5 107 creative +5 109 pleased +5 112 irritated +5 115 dorky +5 116 impressed +5 119 dirty +5 121 surprised +5 122 shocked +5 123 rejected +5 124 numb +5 125 cheerful +5 126 good +5 127 distressed +5 128 intimidated +5 130 devious +5 131 thankful +5 132 grateful +5 133 jealous +5 134 nervous + +# JournalFen +6 1 aggravated +6 2 angry +6 3 annoyed +6 4 anxious +6 5 bored +6 6 confused +6 7 crappy +6 8 cranky +6 9 depressed +6 10 discontent +6 11 energetic +6 12 enraged +6 14 exhausted +6 15 happy +6 16 high +6 18 hungry +6 19 infuriated +6 20 irate +6 21 jubilant +6 22 lonely +6 23 moody +6 24 Determined +6 25 sad +6 26 satisfied +6 28 stressed +6 29 E-V-O-L +6 30 thoughtful +6 31 tired +6 32 touched +6 33 lazy +6 34 drunk +6 35 Slashy +6 36 Obsessed +6 37 Obscene +6 38 Fan-Tabulous +6 39 Fantastico +6 40 Fan-Fucking-tastic +6 41 excited +6 42 relieved +6 43 hopeful +6 44 amused +6 45 Flattened +6 46 scared +6 47 frustrated +6 48 Freakish +6 49 sleepy +6 50 Toppy +6 51 groggy +6 52 hyper +6 53 relaxed +6 54 restless +6 55 disappointed +6 56 curious +6 58 Guilty +6 60 Grouchy +6 61 okay +6 62 Happy-Dance +6 63 Snoopy-Dancing +6 65 Holier-than-thou +6 66 Vindicated +6 67 Validated +6 68 calm +6 70 optimistic +6 71 pessimistic +6 72 Impish +6 73 Indignant +6 74 uncomfortable +6 75 Important +6 78 Invincible +6 79 embarrassed +6 80 envious +6 81 sympathetic +6 82 sick +6 83 hot +6 84 cold +6 85 worried +6 86 loved +6 87 awake +6 88 working +6 89 productive +6 90 accomplished +6 91 busy +6 92 Overwhelmed +6 93 full +6 94 Peeved +6 95 grumpy +6 96 weird +6 98 ecstatic +6 99 Pimping +6 100 Pissed +6 101 contemplative +6 102 nerdy +6 103 geeky +6 104 cynical +6 106 crazy +6 107 creative +6 108 Righteous +6 109 pleased +6 110 Rushed +6 112 irritated +6 113 blank +6 114 apathetic +6 115 dorky +6 116 impressed +6 117 naughty +6 118 Squeeing +6 119 dirty +6 120 giddy +6 121 surprised +6 122 shocked +6 123 rejected +6 124 numb +6 125 cheerful +6 126 good +6 127 distressed +6 128 intimidated +6 129 Unhappy +6 130 devious +6 131 thankful +6 132 grateful +6 133 jealous +6 134 nervous +6 135 Wiped +6 137 Zany +6 138 Lustful +6 139 *Snarl* +6 140 GRRRRRR +6 141 Sex-ay +6 142 Sexy +6 143 Prettiful +6 144 Petty +6 145 Petulant +6 146 Used +6 147 Shiny +6 148 OMGWTF +6 150 Navel-Gazing +6 151 Useless +6 152 Useful +6 154 Spiffy +6 155 Smart +6 156 Goofy +6 157 *drool* +6 158 *thud* +6 159 Caffeinated +6 161 Homicidal +6 162 Murderous +6 163 Stoked +6 164 Dramatic +6 165 *sporfle!* +6 166 Schwa +6 167 Suicidal +6 168 Needy-like +6 169 Interested +6 170 Mildly Amused +6 171 Amped +6 172 Piqued +6 173 Hormonal +6 174 Mystified +6 175 Gobsmacked +6 176 Fixin' for a fight +6 177 Amazed +6 178 Forlorn +6 179 Poetic +6 180 Cliquish +6 181 Blessed +6 182 Tantalized +6 183 Presumptious +6 184 Bitter +6 185 Sparkly +6 186 Candy-Coated +6 187 In Denial +6 188 Brash +6 189 On Top of the World +6 190 Dumped on +6 191 Gruesome +6 192 Hawkish +6 193 Nosy +6 194 Morose +6 195 Dovish +6 196 Focused +6 197 Musing +6 198 Catty +6 199 Flippant +6 200 Frivolous +6 201 Dangerous +6 202 Meek +6 203 Irredeemable +6 204 Peckish +6 205 Starving +6 207 Unrepentant +6 208 Horny +6 209 Bitch Slapped +6 210 Mundane diff -r 030b40fba2bf -r 752317d07dc7 bin/upgrading/update-db-general.pl --- a/bin/upgrading/update-db-general.pl Mon Jul 20 17:10:25 2009 +0000 +++ b/bin/upgrading/update-db-general.pl Mon Jul 20 12:21:13 2009 -0500 @@ -3261,6 +3261,16 @@ CREATE TABLE pp_trans ( ) EOC +register_tablecreate('external_site_moods', <<'EOC'); +CREATE TABLE external_site_moods ( + siteid int unsigned not null, + mood varchar(40) not null, + moodid int(10) unsigned not null default '0', + + PRIMARY KEY (siteid, mood) +) +EOC + # NOTE: new table declarations go ABOVE here ;) diff -r 030b40fba2bf -r 752317d07dc7 bin/upgrading/update-db.pl --- a/bin/upgrading/update-db.pl Mon Jul 20 17:10:25 2009 +0000 +++ b/bin/upgrading/update-db.pl Mon Jul 20 12:21:13 2009 -0500 @@ -229,6 +229,7 @@ sub populate_database { ($su, $made_system) = vivify_system_user(); populate_moods(); + populate_external_moods(); # we have a flag to disable population of s1/s2 if the user requests unless ($opt_nostyles) { populate_s2(); @@ -568,6 +569,34 @@ sub populate_proplist_file { } $insert->(); close($fh); +} + +sub populate_external_moods { + my $moodfile = "$ENV{'LJHOME'}/bin/upgrading/moods-external.dat"; + + if ( open MOODFILE, "<$moodfile" ) { + print "Populating mood data for external sites.\n"; + + # $siteid => { $mood => { siteid => $siteid, mood => $mood, moodid => $moodid } } + my $moods = $dbh->selectall_hashref( "SELECT siteid, mood, moodid FROM external_site_moods", [ 'siteid', 'mood' ] ); + + foreach my $line ( <MOODFILE> ) { + chomp $line; + + if ( $line =~ /^(\d+)\s+(\d+)\s+(.+)$/ ) { + my ( $siteid, $moodid, $mood ) = ( $1, $2, $3 ); + + unless ( $moods->{$siteid} && $moods->{$siteid}->{$mood} && $moods->{$siteid}->{$mood}->{moodid} eq $moodid ) { + $dbh->do( + "REPLACE INTO external_site_moods ( siteid, mood, moodid ) VALUES ( ?, ?, ? )", + undef, $siteid, $mood, $moodid + ); + } + } + } + + close MOODFILE; + } } sub populate_moods { diff -r 030b40fba2bf -r 752317d07dc7 cgi-bin/DW/External/Account.pm --- a/cgi-bin/DW/External/Account.pm Mon Jul 20 17:10:25 2009 +0000 +++ b/cgi-bin/DW/External/Account.pm Mon Jul 20 12:21:13 2009 -0500 @@ -341,6 +341,11 @@ sub supports_challenge { } #accessors + +sub siteid { + return $_[0]->{siteid}; +} + sub acctid { return $_[0]->{acctid}; } diff -r 030b40fba2bf -r 752317d07dc7 cgi-bin/DW/External/XPostProtocol/LJXMLRPC.pm --- a/cgi-bin/DW/External/XPostProtocol/LJXMLRPC.pm Mon Jul 20 17:10:25 2009 +0000 +++ b/cgi-bin/DW/External/XPostProtocol/LJXMLRPC.pm Mon Jul 20 12:21:13 2009 -0500 @@ -315,15 +315,43 @@ sub entry_to_req { my $entryprops = $entry->props; $req->{props} = {}; # only bring over these properties - for my $entrykey (qw ( adult_content current_coords current_location current_mood current_music opt_backdated opt_nocomments opt_noemail opt_preformatted opt_screening picture_keyword qotdid taglist used_rte pingback )) { + for my $entrykey (qw ( adult_content current_coords current_location current_music opt_backdated opt_nocomments opt_noemail opt_preformatted opt_screening picture_keyword qotdid taglist used_rte pingback )) { $req->{props}->{$entrykey} = $entryprops->{$entrykey} if defined $entryprops->{$entrykey}; } - # the current_mood above handles custom moods; for standard moods we - # use current_moodid - if ($entryprops->{current_moodid}) { - my $mood = LJ::mood_name($entryprops->{current_moodid}); - $req->{props}->{current_mood} = $mood if $mood; + + # figure out what current_moodid and current_mood to pass to the crossposted entry + my ( $siteid, $moodid, $mood ) = ( $extacct->siteid, $entryprops->{current_moodid}, $entryprops->{current_mood} ); + my $external_moodid; + if ( $moodid && $mood ) { + # use the mood text that was given + $req->{props}->{current_mood} = $mood; + + # try these in order: + # 1. use the mood icon that matches the given mood id + # 2. use the mood icon that matches the given mood text + # 3. don't use an icon + $external_moodid = LJ::get_external_site_moodid( siteid => $siteid, moodid => $moodid ); + unless ( $external_moodid ) { + $external_moodid = LJ::get_external_site_moodid( siteid => $siteid, mood => $mood ); + } + } elsif ( $moodid ) { + # try these in order: + # 1. use the mood icon that matches the given mood id + # 2. use the mood text that matches the given mood id (no icon) + $external_moodid = LJ::get_external_site_moodid( siteid => $siteid, moodid => $moodid ); + unless ( $external_moodid ) { + $req->{props}->{current_mood} = LJ::mood_name( $moodid ); + } + } elsif ( $mood ) { + # try these in order: + # 1. use the mood icon that matches the given mood text + # 2. use the mood text that was given (no icon) + $external_moodid = LJ::get_external_site_moodid( siteid => $siteid, mood => $mood ); + unless ( $external_moodid ) { + $req->{props}->{current_mood} = $mood; + } } + $req->{props}->{current_moodid} = $external_moodid if $external_moodid; # and set the useragent - FIXME put this somewhere else? $req->{props}->{useragent} = "Dreamwidth Crossposter"; diff -r 030b40fba2bf -r 752317d07dc7 cgi-bin/ljmood.pl --- a/cgi-bin/ljmood.pl Mon Jul 20 17:10:25 2009 +0000 +++ b/cgi-bin/ljmood.pl Mon Jul 20 12:21:13 2009 -0500 @@ -142,4 +142,24 @@ sub get_moods return \%LJ::CACHE_MOODS; } +# given a local moodid or mood and an external siteid, return that mood's id on that site +sub get_external_site_moodid { + my %opts = @_; + + my $siteid = $opts{siteid}; + my $moodid = $opts{moodid}; + my $mood = $opts{mood}; + + return 0 unless $siteid; + return 0 unless $moodid || $mood; + + my $mood_text = $mood ? $mood : LJ::mood_name( $moodid ); + + # determine which moodid on the external site corresponds to the given $mood_text + my $dbr = LJ::get_db_reader(); + my ( $external_moodid ) = $dbr->selectrow_array( "SELECT moodid FROM external_site_moods WHERE siteid = ? AND LOWER( mood ) = ?", undef, $siteid, lc $mood_text ); + + return $external_moodid ? $external_moodid : 0; +} + 1; --------------------------------------------------------------------------------
no subject
no subject
no subject
no subject
no subject