svnno****@sourc*****
svnno****@sourc*****
2008年 12月 16日 (火) 12:30:11 JST
Revision: 884 http://svn.sourceforge.jp/view?root=slashdotjp&view=rev&rev=884 Author: tach Date: 2008-12-16 12:30:11 +0900 (Tue, 16 Dec 2008) Log Message: ----------- merged from upstream T_2_5_0_235 tag Modified Paths: -------------- slashjp/branches/upstream/current/Slash/Apache/User/User.pm slashjp/branches/upstream/current/Slash/Tools/Tools.pm slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/common.js slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/jquery/jquery.autocomplete.css slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/tag-ui.css slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/tag-ui.js slashjp/branches/upstream/current/plugins/Ajax/templates/tag_ui_widget;misc;default slashjp/branches/upstream/current/plugins/FireHose/FireHose.pm slashjp/branches/upstream/current/plugins/FireHose/firehose.pl slashjp/branches/upstream/current/plugins/FireHose/mysql_dump.sql slashjp/branches/upstream/current/plugins/FireHose/mysql_schema.sql slashjp/branches/upstream/current/plugins/FireHose/templates/formatHoseTitle;misc;default slashjp/branches/upstream/current/plugins/FireHose/templates/list;firehose;default slashjp/branches/upstream/current/plugins/FireHose/templates/tag_widget;firehose;default slashjp/branches/upstream/current/plugins/Submit/submit.pl slashjp/branches/upstream/current/plugins/Tags/Tags.pm slashjp/branches/upstream/current/plugins/Tags/archive_globjs_viewed.pl slashjp/branches/upstream/current/plugins/Tags/tagbox.pl slashjp/branches/upstream/current/plugins/Tags/tags_udc.pl slashjp/branches/upstream/current/plugins/Tags/templates/usertagnames;users;default slashjp/branches/upstream/current/plugins/Tags/templates/usertags;users;default slashjp/branches/upstream/current/plugins/Tags/templates/usertagsforname;users;default slashjp/branches/upstream/current/plugins/Users2/Users2.pm slashjp/branches/upstream/current/plugins/Zoo/templates/plainlist;zoo;default slashjp/branches/upstream/current/sql/mysql/defaults.sql slashjp/branches/upstream/current/sql/mysql/upgrades slashjp/branches/upstream/current/tagboxes/CommentScoreReason/CommentScoreReason.pm slashjp/branches/upstream/current/themes/slashcode/THEME slashjp/branches/upstream/current/themes/slashcode/htdocs/users2.pl slashjp/branches/upstream/current/themes/slashcode/templates/u2AdminListComments;users;default slashjp/branches/upstream/current/themes/slashcode/templates/u2ListComments;users;default slashjp/branches/upstream/current/themes/slashcode/templates/u2MainView;users;default slashjp/branches/upstream/current/themes/slashcode/templates/u2Menu;users;default slashjp/branches/upstream/current/themes/slashcode/templates/u2UserBoxes;users;default slashjp/branches/upstream/current/themes/slashcode/templates/user_titlebar;misc;default Added Paths: ----------- slashjp/branches/upstream/current/themes/slashcode/templates/u2_rsslink;users;default slashjp/branches/upstream/current/utils/import_comments_firehose -------------- next part -------------- Modified: slashjp/branches/upstream/current/Slash/Apache/User/User.pm =================================================================== --- slashjp/branches/upstream/current/Slash/Apache/User/User.pm 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/Slash/Apache/User/User.pm 2008-12-16 03:30:11 UTC (rev 884) @@ -444,8 +444,8 @@ } } if ($redirect_to_nonssl) { - # User is not authorized to connect to the SSL webserver. - # Redirect them to the non-SSL URL. + # User is not authorized to connect to the SSL webserver, + # so redirect them to the non-SSL URL. my $newloc = $uri; $newloc .= "?" . $r->args if $r->args; $r->err_header_out(Location => @@ -540,6 +540,74 @@ } } + +{ +my %ops_my = ( + inbox => { args => 'op=list', uri => 'messages.pl' }, + # XXX change messages to be same as /inbox, move this to /my/preferences/messages + messages => { args => 'op=display_prefs', uri => 'messages.pl' }, + comments => { args => 'op=editcomm' }, + homepage => { args => 'op=edithome' }, + password => { args => 'op=changeprefs', uri => 'login.pl' }, + logout => { args => 'op=userclose', uri => 'login.pl' }, + misc => { args => 'op=editmiscopts' }, + amigos => { args => 'op=friendview', uri => 'journal.pl' }, + bookmarks => { args => 'op=showbookmarks' }, + firehose => { args => 'op=userfirehose' }, + preferences => { args => 'op=displayprefs', uri => 'preferences.pl' }, + tags => { args => 'op=showtags' }, + journal => { args => 'op=list', uri => 'journal.pl' }, + + friends => { args => 'op=friends', uri => 'zoo.pl' }, + fans => { args => 'op=fans', uri => 'zoo.pl' }, + freaks => { args => 'op=freaks', uri => 'zoo.pl' }, + foes => { args => 'op=foes', uri => 'zoo.pl' }, + zoo => { args => 'op=all', uri => 'zoo.pl' }, + + default => { args => 'op=edituser' } +); +$ops_my{$_}{uri} ||= 'users.pl' for (keys %ops_my); + +my %ops_u = ( + pubkey => { args => 'nick=__NICK__&uid=__UID__', uri => 'pubkey.pl' }, + submissions => { args => 'nick=__NICK__&uid=__UID__&op=usersubmissions' }, + comments => { args => 'nick=__NICK__&uid=__UID__&op=usercomments' }, + amigos => { args => 'nick=__NICK__&uid=__UID__&op=friendview', uri => 'journal.pl' }, + bookmarks => { args => 'nick=__NICK__&uid=__UID__&op=showbookmarks' }, + firehose => { args => 'uid=__UID__&op=userfirehose' }, + journal => { args => 'nick=__NICK__&uid=__UID__&op=display', uri => 'journal.pl' }, + tags => { args => 'nick=__NICK__&uid=__UID__&op=showtags' }, + + friends => { args => 'nick=__NICK__&uid=__UID__&op=friends', uri => 'zoo.pl' }, + fans => { args => 'nick=__NICK__&uid=__UID__&op=fans', uri => 'zoo.pl' }, + freaks => { args => 'nick=__NICK__&uid=__UID__&op=freaks', uri => 'zoo.pl' }, + foes => { args => 'nick=__NICK__&uid=__UID__&op=foes', uri => 'zoo.pl' }, + zoo => { args => 'nick=__NICK__&uid=__UID__&op=all', uri => 'zoo.pl' }, + + default => { args => 'nick=__NICK__&uid=__UID__' }, +); +$ops_u{$_}{uri} ||= 'users.pl' for (keys %ops_u); + +my %ops_u2 = ( + submissions => { args => 'nick=__NICK__&uid=__UID__&dp=submissions' }, + comments => { args => 'nick=__NICK__&uid=__UID__&dp=comments' }, + amigos => { args => 'nick=__NICK__&uid=__UID__&dp=journalfriends' }, + bookmarks => { args => 'nick=__NICK__&uid=__UID__&dp=bookmarks' }, + firehose => { args => 'uid=__UID__&dp=firehose' }, + admin => { args => 'nick=__NICK__&uid=__UID__&dp=admin' }, + journal => { args => 'nick=__NICK__&uid=__UID__&dp=journal' }, + tags => { args => 'nick=__NICK__&uid=__UID__&dp=tags&op=userinfo' }, + + friends => { args => 'nick=__NICK__&uid=__UID__&dp=friends' }, + fans => { args => 'nick=__NICK__&uid=__UID__&dp=fans' }, + freaks => { args => 'nick=__NICK__&uid=__UID__&dp=freaks' }, + foes => { args => 'nick=__NICK__&uid=__UID__&dp=foes' }, + zoo => { args => 'nick=__NICK__&uid=__UID__&dp=all' }, + + default => { args => 'nick=__NICK__&uid=__UID__' } +); +$ops_u2{$_}{uri} ||= 'users2.pl' for (keys %ops_u2); + ######################################################## # XXX May want to rename this, since it's being used for a user's # prefs/info pages (/my/foo) and for the global handlers too (/foo). @@ -616,129 +684,54 @@ my $logged_in = $r->header_in('Cookie') =~ $USER_MATCH; my $try_login = !$logged_in && $logtoken; - my $found_the_op = 0; + my($r_args, $r_uri); + if ($logged_in || $try_login) { + my $r_op = $ops_my{$op}; + $r_op ||= $ops_my{default}; + ($r_args, $r_uri) = @{$r_op}{qw(args uri)}; + if ($op eq 'inbox') { - $found_the_op = 1; - my $args = 'op=list'; if ($extra =~ m{^ (rss|atom) /? $}x) { - $args .= '_rss'; - $args .= "&logtoken=$logtoken" if $try_login; - $args .= "&content_type=$1"; + $r_args .= '_rss'; + $r_args .= "&logtoken=$logtoken" if $try_login; + $r_args .= "&content_type=$1"; } - $r->args($args); - $r->uri('/messages.pl'); - $r->filename($constants->{basedir} . '/messages.pl'); } elsif ($logged_in) { - $found_the_op = 1; if ($op eq 'journal') { - my $args; - if ($extra =~ /^\d+$/) { - $args = "id=$extra&op=edit"; - } elsif ($extra eq 'friends') { - $args = "op=friendview"; - } else { - $args = "op=list"; + $extra .= '/'; + if ($extra =~ /^(\d+)\/$/) { + $r_args = "id=$1&op=edit"; + } elsif ($extra =~ s/^friends\///) { + $r_args = "op=friendview"; } - $r->args($args); - $r->uri('/journal.pl'); - $r->filename($constants->{basedir} . '/journal.pl'); - } elsif ($op eq 'discussions') { - $r->args("op=personal_index"); - $r->uri('/comments.pl'); - $r->filename($constants->{basedir} . '/comments.pl'); - - - } elsif ($op eq 'messages') { # XXX change to be same as /inbox, move this to /my/preferences/messages - $r->args("op=display_prefs"); - $r->uri('/messages.pl'); - $r->filename($constants->{basedir} . '/messages.pl'); - } elsif ($op =~ /^(?:friends|fans|freaks|foes|zoo)$/) { - my $args = "op=$op"; $extra .= '/'; - - if ($op eq 'friends' && $extra =~ s/^friends\///) { - $args =~ s/friends/fof/; - } elsif ($op eq 'friends' && $extra =~ s/^foes\///) { - $args =~ s/friends/eof/; - } elsif ($op eq 'zoo') { - $args =~ s/zoo/all/; + if ($op eq 'friends') { + if ($extra =~ s/^friends\///) { + $r_args =~ s/friends/fof/; + } elsif ($extra =~ s/^foes\///) { + $r_args =~ s/friends/eof/; + } } - $r->args($args); - $r->uri('/zoo.pl'); - $r->filename($constants->{basedir} . '/zoo.pl'); - - } elsif ($op eq 'comments') { - $r->args("op=editcomm"); - $r->uri('/users.pl'); - $r->filename($constants->{basedir} . '/users.pl'); - - } elsif ($op eq 'homepage') { - $r->args("op=edithome"); - $r->uri('/users.pl'); - $r->filename($constants->{basedir} . '/users.pl'); - - } elsif ($op eq 'password') { - $r->args("op=changeprefs"); - $r->uri('/login.pl'); - $r->filename($constants->{basedir} . '/login.pl'); - - } elsif ($op eq 'logout') { - $r->args("op=userclose"); - $r->uri('/login.pl'); - $r->filename($constants->{basedir} . '/login.pl'); - - } elsif ($op eq 'misc') { - $r->args("op=editmiscopts"); - $r->uri('/users.pl'); - $r->filename($constants->{basedir} . '/users.pl'); - - } elsif ($op eq 'amigos') { - $r->args("op=friendview"); - $r->uri('/journal.pl'); - $r->filename($constants->{basedir} . '/journal.pl'); - } elsif ($op eq 'tags') { - my $args = 'op=showtags'; # XXX "!" is a 'reserved' char in URI, escape it here? - $args .= "&tagname=$extra" if $extra; - $r->args($args); - $r->uri('/users.pl'); - $r->filename($constants->{basedir} . '/users.pl'); - - } elsif ($op eq 'bookmarks') { - $r->args("op=showbookmarks"); - $r->uri('/users.pl'); - $r->filename($constants->{basedir} . '/users.pl'); - - } elsif ($op eq 'firehose') { - my $filter = fixparam("user:"); - $r->args("op=userfirehose"); - $r->uri('users.pl'); - $r->filename($constants->{basedir} . '/users.pl'); - - } elsif ($op eq 'preferences') { - $r->args("op=displayprefs"); - $r->uri('/preferences.pl'); - $r->filename($constants->{basedir} . '/preferences.pl'); - - } else { - $r->args("op=edituser"); - $r->uri('/users.pl'); - $r->filename($constants->{basedir} . '/users.pl'); + $r_args .= "&tagname=$extra" if $extra; } } + } else { + undef $r_args; + $r_uri = 'login.pl'; } - if (!$found_the_op) { - $r->uri('/login.pl'); - $r->filename($constants->{basedir} . '/login.pl'); - } + $r->args($r_args) if defined($r_args); + $r->uri('/' . $r_uri); + $r->filename($constants->{basedir} . '/' . $r_uri); + return OK; } elsif ($uri =~ m[^/bookmarks (?: /(.*) | /? ) $]x) { @@ -770,207 +763,84 @@ my $nick_orig = $nick; $nick = fixparam($nick); # make safe to pass back to script - # maybe we should refactor this code a bit ... - # have a hash that points op to args and script name -- pudge - # e.g.: - # my %ops = ( journal => ['/journal.pl', 'op=display'], ... ); - # $r->args($ops{$op}[1] . "&nick=$nick"); - # $r->uri($ops{$op}[0]); - # $r->filename($constants->{basedir} . $ops{$op}[0]); + my($r_args, $r_uri); if (!$uid) { - $r->args("op=no_user"); - $r->uri('/users.pl'); - $r->filename($constants->{basedir} . '/users.pl'); + $r_args = 'op=no_user'; + $r_uri = 'users.pl'; - } elsif ($op eq 'journal') { - $extra .= '/' . $more; + } else { + my $r_op = $ops_u{$op}; + my $u2 = 0; + if ($constants->{u2} || $saveuri =~ m[^/(?:%5[eE]|\^)(.+)]) { + $r_op = $ops_u2{$op} if $ops_u2{$op}; + $u2 = 1; + } + $r_op ||= $u2 ? $ops_u2{default} : $ops_u{default}; + ($r_args, $r_uri) = @{$r_op}{qw(args uri)}; - if ( - ($saveuri =~ m[^/(?:%5[eE]|\^)(.+)] || $constants->{u2}) - && - !($extra =~ m{^ (rss|atom) /?$}x || $extra =~ /^(\d+)\/$/) - ) { - my $args = "nick=$nick&uid=$uid&dp=journal"; + # special cases for handling $extra + if ($op eq 'journal') { + $extra .= '/' . $more; + if ($u2 && !($extra =~ m{ (?:rss|atom) /?$}x || $extra =~ /^(\d+)\/$/)) { + # show hose in friend view (op=journalfriends) + $r_args .= 'friends' if $extra =~ /^friends\//; + } else { + # override u2 for rss|atom and \d + ($r_args, $r_uri) = @{ $ops_u{journal} }{ qw(args uri) }; - if ($extra =~ s/^friends\///) { # show hose in friend view - $args .= 'friends'; - } + if ($extra =~ /^(\d+)\/$/) { + $r_args .= "&id=$1"; + } elsif ($extra =~ s/^friends\///) { + $r_args =~ s/display/friendview/; + } + if ($extra =~ m{^ (rss|atom) / ? $}x) { + $r_args .= "&logtoken=$logtoken" if $logtoken; + $r_args .= "&content_type=$1"; + } - $r->args($args); - $r->uri('/users2.pl'); - $r->filename($constants->{basedir} . '/users2.pl'); - - } else { - my $args = "op=display&nick=$nick&uid=$uid"; - if ($extra =~ /^(\d+)\/$/) { - $args .= "&id=$1"; - } elsif ($extra =~ s/^friends\///) { - $args =~ s/display/friendview/; + $r_args .= "&$query"; } - if ($extra =~ m{^ (rss|atom) / ? $}x) { - $args .= "&logtoken=$logtoken" if $logtoken; - $args .= "&content_type=$1"; - } - $args .= "&$query"; - $r->args($args); - $r->uri('/journal.pl'); - $r->filename($constants->{basedir} . '/journal.pl'); - } - } elsif ($op eq 'discussions') { - $r->args("op=creator_index&nick=$nick&uid=$uid"); - $r->uri('/comments.pl'); - $r->filename($constants->{basedir} . '/comments.pl'); - - } elsif ($op eq 'pubkey') { - $r->args("nick=$nick&uid=$uid"); - $r->uri('/pubkey.pl'); - $r->filename($constants->{basedir} . '/pubkey.pl'); - - } elsif ($op eq 'submissions') { - if ($saveuri =~ m[^/(?:%5[eE]|\^)(.+)] || $constants->{u2}) { - $r->args("nick=$nick&dp=submissions&uid=$uid"); - $r->uri('/users2.pl'); - $r->filename($constants->{basedir} . '/users2.pl'); - } else { - $r->args("nick=$nick&op=usersubmissions&uid=$uid"); - $r->uri('/users.pl'); - $r->filename($constants->{basedir} . '/users.pl'); - } - } elsif ($op eq 'comments') { - if ($saveuri =~ m[^/(?:%5[eE]|\^)(.+)] || $constants->{u2}) { - $r->args("nick=$nick&dp=comments&uid=$uid"); - $r->uri('/users2.pl'); - $r->filename($constants->{basedir} . '/users2.pl'); - } else { - $r->args("nick=$nick&op=usercomments&uid=$uid"); - $r->uri('/users.pl'); - $r->filename($constants->{basedir} . '/users.pl'); - } - } elsif ($op =~ /^(?:friends|fans|freaks|foes|zoo)$/) { - if ($saveuri =~ m[^/(?:%5[eE]|\^)(.+)] || $constants->{u2}) { - my $args = "nick=$nick&uid=$uid&dp="; + } elsif ($op =~ /^(?:friends|fans|freaks|foes|zoo)$/) { $extra .= '/' . $more; - - if ($op eq 'friends' && $extra =~ s/^friends\///) { - $op =~ s/friends/fof/; - } elsif ($op eq 'friends' && $extra =~ s/^foes\///) { - $op =~ s/friends/eof/; - } elsif ($op eq 'zoo') { - $op =~ s/zoo/all/; + if ($u2 && $extra =~ m{ (?:rss|atom) /?$}x) { + # override u2 for rss|atom and \d + ($r_args, $r_uri) = @{ $ops_u{journal} }{ qw(args uri) }; } - if ($extra =~ m{^ (rss|atom) /?$}x) { - my $args = "nick=$nick&uid=$uid&op=$op"; - $args .= "&content_type=$1"; - - $r->args($args); - $r->uri('/zoo.pl'); - $r->filename($constants->{basedir} . '/zoo.pl'); - } else { - $r->args($args . $op); - $r->uri('/users2.pl'); - $r->filename($constants->{basedir} . '/users2.pl'); + if ($op eq 'friends') { + if ($extra =~ s/^friends\///) { + $r_args =~ s/friends/fof/; + } elsif ($extra =~ s/^foes\///) { + $r_args =~ s/friends/eof/; + } } - } else { - my $args = "op=$op&nick=$nick&uid=$uid"; - $extra .= '/' . $more; - if ($op eq 'friends' && $extra =~ s/^friends\///) { - $args =~ s/friends/fof/; - } elsif ($op eq 'friends' && $extra =~ s/^foes\///) { - $args =~ s/friends/eof/; - } elsif ($op eq 'zoo') { - $args =~ s/zoo/all/; - } - if ($extra =~ m{^ (rss|atom) /?$}x) { - $args .= "&content_type=$1"; + $r_args .= "&content_type=$1"; } - $r->args($args); - $r->uri('/zoo.pl'); - $r->filename($constants->{basedir} . '/zoo.pl'); - } - } elsif ($op eq 'amigos') { - if ($saveuri =~ m[^/(?:%5[eE]|\^)(.+)] || $constants->{u2}) { - $r->args("nick=$nick&uid=$uid&dp=journalfriends"); - $r->uri('/users2.pl'); - $r->filename($constants->{basedir} . '/users2.pl'); - } else { - $r->args("op=friendview&nick=$nick&uid=$uid"); - $r->uri('/journal.pl'); - $r->filename($constants->{basedir} . '/journal.pl'); - } - - } elsif ($op eq 'tags') { - if ($saveuri =~ m[^/(?:%5[eE]|\^)(.+)] || $constants->{u2}) { - $r->uri('/users2.pl'); - $r->filename($constants->{basedir} . '/users2.pl'); - my $args; - if ($extra) { - $args = "op=userinfo&nick=$nick&dp=usertag&uid=$uid"; - $args .= "&tagname=$extra" if $extra; - } else { - $args = "op=userinfo&uid=$uid&nick=$nick&dp=tags"; - } - $r->args($args); - } else { - my $args = "op=showtags&nick=$nick&uid=$uid"; + } elsif ($op eq 'tags') { + $r_args =~ s/dp=tags/dp=usertag/ if $u2 && $extra; # XXX "!" is a 'reserved' char in URI, escape it here? - $args .= "&tagname=$extra" if $extra; - $r->args($args); - $r->uri('/users.pl'); - $r->filename($constants->{basedir} . '/users.pl'); + $r_args .= "&tagname=$extra" if $extra; } + } - } elsif ($op eq 'bookmarks') { - if ($saveuri =~ m[^/(?:%5[eE]|\^)(.+)] || $constants->{u2}) { - $r->args("nick=$nick&dp=bookmarks&uid=$uid"); - $r->uri('/users2.pl'); - $r->filename($constants->{basedir} . '/users2.pl'); - } else { - $r->args("op=showbookmarks&nick=$nick&uid=$uid"); - $r->uri('/users.pl'); - $r->filename($constants->{basedir} . '/users.pl'); - } - } elsif ($op eq 'firehose') { - if ($saveuri =~ m[^/(?:%5[eE]|\^)(.+)] || $constants->{u2}) { - my $filter = fixparam("\"user:$nick_orig\""); - $r->args("dp=firehose&uid=$uid"); - $r->uri('/users2.pl'); - $r->filename($constants->{basedir} . '/users2.pl'); - } else { - my $filter = fixparam("\"user:$nick_orig\""); - $r->args("op=userfirehose&uid=$uid"); - $r->uri('/users.pl'); - $r->filename($constants->{basedir} . '/users.pl'); - } - } elsif (($op eq 'admin' && $constants->{u2}) || - ($op eq 'admin' && $saveuri =~ m[^/(?:%5[eE]|\^)(.+)])) { - $r->args("nick=$nick&dp=admin&uid=$uid"); - $r->uri('/users2.pl'); - $r->filename($constants->{basedir} . '/users2.pl'); + $r_args =~ s/__NICK__/$nick/; + $r_args =~ s/__UID__/$uid/; - } else { - if ($saveuri =~ m[^/(?:%5[eE]|\^)(.+)] || $constants->{u2}) { - $r->args("nick=$nick&uid=$uid"); - $r->uri('/users2.pl'); - $r->filename($constants->{basedir} . '/users2.pl'); - } else { - $r->args("nick=$nick&uid=$uid"); - $r->uri('/users.pl'); - $r->filename($constants->{basedir} . '/users.pl'); - } - } + $r->args($r_args) if defined($r_args); + $r->uri('/' . $r_uri); + $r->filename($constants->{basedir} . '/' . $r_uri); return OK; } return DECLINED; -} +} } Modified: slashjp/branches/upstream/current/Slash/Tools/Tools.pm =================================================================== --- slashjp/branches/upstream/current/Slash/Tools/Tools.pm 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/Slash/Tools/Tools.pm 2008-12-16 03:30:11 UTC (rev 884) @@ -20,7 +20,7 @@ our @EXPORT = qw( pmpath pathpm pmpathsrc counterpart srcfile installfile basefile basefile basename dirname - syntax_check %CONFIG + syntax_check %CONFIG $MAIN_REPO @BIN_EXT $BIN_EXT $BIN_RE myprint myexit mysystem myask ); @@ -28,6 +28,7 @@ our @BIN_EXT = qw(gz tgz bz2 gif jpg png ico); our $BIN_EXT = join '|', @BIN_EXT; our $BIN_RE = qr/\.(?:$BIN_EXT)$/; +our $MAIN_REPO = 'master'; my(%cache); # if cache gets stale, you can use force => 0, or heck, just Modified: slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/common.js =================================================================== --- slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/common.js 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/common.js 2008-12-16 03:30:11 UTC (rev 884) @@ -40,6 +40,7 @@ firehose_settings.section = 0; firehose_settings.more_num = 0; firehose_settings.metamod = 0; + firehose_settings.admin_filters = 0; // Settings to port out of settings object firehose_item_count = 0; @@ -447,6 +448,10 @@ } } + if (name == "view" || name == "tab") { + $('#firehoselist').html("<h1 class='loading_msg'>Loading New Items</h1>"); + } + if (name == "color" || name == "tab" || name == "pause" || name == "startdate" || name == "duration" || name == "issue" || name == "pagesize") { params[name] = value; if (name == "startdate") { @@ -952,6 +957,9 @@ var saved_selection = new $.TextSelection(gFocusedText); var $menu = $('.ac_results:visible'); + var add_behind_scenes = $("#firehoselist .loading_msg").length; + if (add_behind_scenes) { $('.busy').show(); } + if (firehose_updates.length > 0) { var el = firehose_updates.pop(); var fh = 'firehose-' + el[1]; @@ -968,7 +976,14 @@ need_animate = 0; } } else if (firehose_after[el[1]] && $('#firehose-' + firehose_after[el[1]]).size()) { - $('#firehose-' + firehose_after[el[1]]).before(el[2]); + + // don't insert a new article between the floating slashbox ad and its article + var $landmark = $('#firehose-' + firehose_after[el[1]]), $prev = $landmark.prev(); + if ( $prev.is('#floating-slashbox-ad') ) { + $landmark = $prev; + } + + $landmark.before(el[2]); if (!isInWindow($dom('title-'+ firehose_after[el[1]]))) { need_animate = 0; } @@ -981,6 +996,10 @@ $('#firehoselist').prepend(el[2]); } + if (add_behind_scenes) { + need_animate = 0; + } + var toheight = 50; if (fh_view_mode == "full") { toheight = 200; @@ -1055,7 +1074,7 @@ need_animate = 0; } - if ((firehose_removals < 10 ) || !need_animate) { + if ((firehose_removals < 10 ) && !add_behind_scenes ) { myAnim.onComplete.subscribe(function() { var elem = this.getEl(); if (elem && elem.parentNode) { @@ -1073,12 +1092,23 @@ } } } - if(!need_animate) { - wait_interval = 10; + if(!need_animate || add_behind_scenes) { + wait_interval = 0; } + + //console.log("Wait: " + wait_interval); setTimeout(firehose_handle_update, wait_interval); } else { firehose_reorder(); + if (add_behind_scenes) { + $('#firehoselist .loading_msg').each(function() { if(this && this.parentNode) { this.parentNode.removeChild(this);} }); + if (elem && elem.parentNode) { + elem.parentNode.removeChild(elem); + } + $('#firehoselist').show('slow'); + $('.busy').hide(); + + } firehose_get_next_updates(); } @@ -1189,6 +1219,10 @@ firehose_updates_size = firehose_updates.length; firehose_removed_first = 0; processed = processed + 1; + if ($('#firehoselist .loading_msg').length) { + $('#firehoselist').hide(); + $('#firehoselist .loading_msg').show(); + } firehose_handle_update(); } } @@ -1885,7 +1919,7 @@ return 0; if ($article) - $article = Slash.Firehose.at_or_below_ad_space($article); + $article = Slash.Firehose.ready_ad_space($article); else $article = Slash.Firehose.choose_article_for_next_ad(); @@ -1931,171 +1965,149 @@ // -var AD_HEIGHT = 300, AD_WIDTH = 300, FOOTER_PADDING = 5, +var AD_HEIGHT = 300, AD_WIDTH = 300, - current_mode = { has_content: false }, $ad_position, // 300x300 div that holds the current (if any) ad - $current_article, // the article to which that ad is attached - $slashboxes, // the container in which the ad floats - $footer; + ad_target_article, // the article to which that ad is attached + $ad_offset_parent, // the container in which the ad _position_ floats (between articles) + $slashboxes, // the container (sort of) in which the ad content actually appears (though not as a child) + $footer, + is_ad_locked; // ad must be shown for at least 30 seconds + $(function(){ + is_ad_locked = false; + $ad_position = $([]); + ad_target_article = null; + $footer = $('#ft'); - $slashboxes = $('#slashboxes, #userboxes'). - eq(0). - append('<div id="floating-slashbox-ad" />'); - $ad_position = $slashboxes.find('#floating-slashbox-ad'); + $slashboxes = $('#slashboxes, #userboxes').eq(0); - $(window).scroll(fix_ad_position); $('#firehoselist'). bind('articlesMoved', fix_ad_position). bind('beforeArticleRemoved', notice_article_removed); - - $ad_position. - bind('adArticleRemoved', function(){ - set_current_ad($current_article.next(':visible')); - }); }); function notice_article_removed( event, removed_article ){ - if ( current_mode.has_content && $current_article[0]===removed_article ) { - $ad_position.trigger('adArticleRemoved'); + if ( ad_target_article === removed_article ) { + remove_ad(); } } -function if_same_mode( a, b ){ - return (!a.has_content && !b.has_content) || - ( - (a.has_content == b.has_content) && - (a.is_in_window == b.is_in_window) && - (a.pinned == b.pinned) - ); -} +function remove_ad(){ + ad_target_article = null; -function set_mode( next ){ - var cur = current_mode; + if ( is_ad_locked ) { + return false; + } - // if it's actually a change... - if ( ! if_same_mode(cur, next) ) { - if ( ! next.has_content ) { - $ad_position.hide(); - } else if ( cur.pinned != next.pinned ) { - $ad_position.hide(); + $ad_position.remove(); + $ad_position = $([]); + return true; +} - var next_class = next.pinned || ''; - if ( next.pinned == 'Article' ) { - $current_article. - prepend($ad_position). - css('overflow', 'visible'); - } else if ( next.pinned == 'Bottom' ) { - $slashboxes.after($ad_position); - next_class += ' yui_b'; - } else { - $slashboxes.append($ad_position); - } +function insert_ad( $article, ad ){ + if ( !ad || !$article || $article.length != 1 || !remove_ad() ) { + return; + } - $ad_position.setClass(next_class); + ad_target_article = $article[0]; + $ad_position = $article. + before('<div id="floating-slashbox-ad" class="No" />'). + prev(). + append(ad); - if ( !cur.has_content ) { - $ad_position.fadeIn('fast'); - } else { - $ad_position.show(); - } + setTimeout(function(){ + is_ad_locked = false; + if ( ! ad_target_article ) { + remove_ad(); } + }, 30000); + is_ad_locked = true; - var event_name; - if ( cur.has_content != next.has_content ) { - event_name = next.has_content ? 'adInserted' : 'adRemoved'; - } else if ( cur.pinned != next.pinned ) { - event_name = 'adPinnedTo' + next.pinned; - } else if ( cur.is_in_window != next.is_in_window ) { - event_name = next.is_in_window ? 'adMovedIntoWindow' : 'adMovedOutOfWindow'; - } else if ( cur.top != next.top ) { - event_name = 'adMoved'; - } + if ( ! $ad_offset_parent ) { + $ad_offset_parent = $article.offsetParent(); + } - current_mode = next; - - if ( event_name ) { - $ad_position.trigger(event_name); - } - } + fix_ad_position(); + $ad_position.fadeIn('fast'); } -function set_current_ad( $new_article, new_ad ){ - var have_new_article = $new_article && $new_article.length, - clear_all = !have_new_article && !new_ad; +function nearest_article_edge(){ + // Why not just ask for the offset of $ad_position? + // ...because $ad_position may be absolutely positioned already - if ( !current_mode.has_content && !new_ad ) { - return; + var $article = $ad_position.next(); + var pos = $article.offset(); + if ( pos !== undefined ) { + return pos.top; } - if ( clear_all || new_ad ) { - set_mode({ has_content: false }); - $ad_position.empty(); + $article = $ad_position.prev(); + pos = $other.offset(); + if ( pos !== undefined ) { + return pos.top + $article.height(); } - if ( !clear_all ) { - if ( new_ad ) { - current_mode.will_have_content = true; - $ad_position.append(new_ad); - } - if ( have_new_article ) { - $current_article = $new_article.eq(0); - } - fix_ad_position(); - } else { - $current_article = null; - } + return 0; } +function pin( lo, n, hi ){ + // return n', the nearest value to n such that lo<=n'<=hi + + if ( hi < lo ) return { value: undefined, description: 'Empty' }; // pin-range is empty, there is no n' such that lo<=n'<=hi + if ( n <= lo ) return { value: lo, description: 'Min' }; + if ( n <= hi ) return { value: n, description: 'No' }; + return { value: hi, description: 'Max' }; +} + function fix_ad_position(){ - if ( current_mode.has_content || current_mode.will_have_content ) { + if ( $ad_position.length ) { var footer = $footer.offset(), - slashboxes = $slashboxes.offset(), - article = $current_article.offset(); + slashboxes = $slashboxes.offset(); - if ( ! footer || ! slashboxes || ! article ) { + if ( ! footer || ! slashboxes ) { return; } - var space_top = slashboxes.top + $slashboxes.height(), - space_bottom = footer.top - FOOTER_PADDING, - window_top = window.pageYOffset, - window_bottom = window_top + window.innerHeight, - ad_top = Math.max(space_top, Math.min(article.top, space_bottom-AD_HEIGHT)), - next_mode = { has_content: true, - is_in_window: !( ad_top > window_bottom || ad_top + AD_HEIGHT < window_top ), - top: ad_top - slashboxes.top - }; + var min_top = slashboxes.top + $slashboxes.height(), + max_top = footer.top - AD_HEIGHT, + pinned_top = pin(min_top, nearest_article_edge(), max_top), - if ( space_bottom - space_top < AD_HEIGHT ) { - next_mode.pinned = 'SqueezedOut'; - } else if ( ad_top == article.top ) { - next_mode.pinned = 'Article'; - } else if ( ad_top < article.top ) { - next_mode.pinned = 'Bottom'; - } else if ( ad_top > (article.top + $current_article.height()) ) { - next_mode.pinned = 'TopDisconnected'; - } else { - next_mode.pinned = 'Top'; + prev_top = $ad_position.offset().top, + prev_class = $ad_position.attr('className'), + prev_pinned = prev_class !== 'No', + + next_top = pinned_top.value, + next_class = pinned_top.description, + next_pinned = next_class !== 'No', + next_css = {}; + + if ( prev_pinned > next_pinned ) { + // if we're un-pinning the ad, clear our explicit 'top' setting + next_css.top = ''; + } else if ( next_pinned && (!prev_pinned || prev_top!=next_top) ) { + // else if we're becoming pinned or are already pinned, but need a different top + next_css.top = '' + (next_top - $ad_offset_parent.offset().top) + 'px'; } - set_mode(next_mode); + if ( next_css.top !== undefined ) { + $ad_position.css(next_css); + } + + if ( prev_class != next_class ) { + $ad_position.setClass(next_class); + } } } Slash.Util.Package({ named: 'Slash.Firehose.floating_slashbox_ad', api: { - is_visible: function(){ return current_mode.has_content && current_mode.is_in_window; }, - remove: function(){ set_current_ad() }, - current_article: function(){ return $current_article; }, - is_pinned_to: function(){ return current_mode.pinned; }, - bind: function(){ return $ad_position.bind.apply($ad_position, arguments); }, - unbind: function(){ return $ad_position.unbind.apply($ad_position, arguments); } + is_visible: function(){ return isInWindow($ad_position.children().get(0)); }, + remove: function(){ remove_ad() }, }, - stem_function: set_current_ad + stem_function: insert_ad }); Slash.Firehose.articles_on_screen = function(){ @@ -2146,21 +2158,26 @@ } } -Slash.Firehose.at_or_below_ad_space = function( $articles ){ +// filter $articles to only those adjacent to available space for an ad +// return empty list if none, or if not enough time has yet passed to place a new ad +Slash.Firehose.ready_ad_space = function( $articles ){ + var $result = $([]); try { - var min_top = Math.max(window.pageYOffset, $slashboxes.offset().top + $slashboxes.height()); - return $articles.filter(function(){ - return $(this).offset().top >= min_top; - }); + if ( !is_ad_locked ) { + var min_top = Math.max(window.pageYOffset, $slashboxes.offset().top + $slashboxes.height()); + $result = $articles.filter(function(){ + return $(this).offset().top >= min_top; + }); + } } catch ( e ) { // don't throw } // just tell the caller no articles supplied are at or below ad-space - return $([]); + return $result; } Slash.Firehose.choose_article_for_next_ad = function(){ - var Fh=Slash.Firehose, $articles=Fh.at_or_below_ad_space(Fh.articles_on_screen()); + var Fh=Slash.Firehose, $articles=Fh.ready_ad_space(Fh.articles_on_screen()); return $articles.eq( Math.floor(Math.random()*$articles.length) ); } Modified: slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/jquery/jquery.autocomplete.css =================================================================== --- slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/jquery/jquery.autocomplete.css 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/jquery/jquery.autocomplete.css 2008-12-16 03:30:11 UTC (rev 884) @@ -31,6 +31,7 @@ in relative units scroll will be broken in firefox */ line-height: 16px; + text-align: left; overflow: hidden; } Modified: slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/tag-ui.css =================================================================== --- slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/tag-ui.css 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/tag-ui.css 2008-12-16 03:30:11 UTC (rev 884) @@ -138,11 +138,12 @@ /* no mouse over highlight for datatypes */ .tag-display li.d:hover span.tag { color: inherit; - background-color: inherit; + background-color: inherit !important; } div.tag-display, -div.tag-display > h1.legend { +div.tag-display > h1.legend, +div.tag-display > ul { width: auto !important; } @@ -314,9 +315,10 @@ div.tag-display-stub, div.tag-display { - display: inline !important; + display: inline; position: relative; margin-left: 0 !important; + overflow: hidden; /* border:1px dotted #000; *//* troubleshooting safari */ } @@ -539,3 +541,14 @@ /* div.tag-display ul, div.tag-display li {display: inline-block;} */ + + +/*Opera tag bugs*/ +div.tag-widget.opera div.tag-display li {/*ensures the damn pop up things stay with its parents and don't "run away"*/ +display: inline-block +} + +div.tag-widget.opera {/*fixing spacing between this widget and article*/ +padding-top:18px; +margin-top:-16px; +} Modified: slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/tag-ui.js =================================================================== --- slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/tag-ui.js 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/Ajax/htdocs/images/tag-ui.js 2008-12-16 03:30:11 UTC (rev 884) @@ -571,68 +571,8 @@ } -function $position_context_display( $display ){ - if ( ! $related_trigger || ! $related_trigger.length ) { - return $display; - } - - var RIGHT_PADDING = 18; - - var $entry = $display.nearest_parent('[tag-server]'); - var left_edge = $entry.offset().left; - var right_edge = left_edge + $entry.width() - RIGHT_PADDING; - - var global_align = $related_trigger.offset().left; - global_align = Math.max(left_edge, global_align); - - var need_minimal_fix = true; - if ( $display.is(':visible') ) { - try { - var display_width = $display.children('ul:first').width(); - $display.css({ - right: '' - }); - - global_align = Math.max( - left_edge, - Math.min(right_edge-display_width, global_align) ); - var distance = global_align - $display.offset().left; - if ( distance ) { - $display.animate({left: '+='+distance}); - } - - need_minimal_fix = false; - } catch (e0) { - } - } - - if ( need_minimal_fix ) { - try { - var BROKEN_NEGATIVE_MARGIN_CALCULATION = -10; - - // we may not be visible, so can't trust offsetParent() on ourself - // better get it from our parent - var x_adjust = -$display.parent().offsetParent().offset().left; - $display.css({ - left: global_align + x_adjust + BROKEN_NEGATIVE_MARGIN_CALCULATION, - right: right_edge + x_adjust - }); - } catch (e1) { - } - } - - return $display; -} - -function $queue_reposition( $display, if_only_width ){ - return $display.queue(function(){ - $position_context_display($display, if_only_width); - $(this).dequeue(); - }); -} - var gFocusedText; -var $previous_context_trigger = $().filter(); +var $previous_context_trigger = $([]); var tag_widget_fns = { @@ -684,11 +624,13 @@ set_context: function( context, force ){ var widget = this; + var new_trigger = !$previous_context_trigger.length || ($previous_context_trigger[0] !== $related_trigger[0]); + var new_context = context != this._current_context; + if ( context ) { - if ( context == this._current_context && - (!$previous_context_trigger.length || - $related_trigger[0] === $previous_context_trigger[0]) && !force ) { + if ( !new_context && !new_trigger && !force ) { context = ''; + new_context = true; } else { if ( !(context in suggestions_for_context) && context in context_triggers ) { context = (this._current_context != 'default') ? 'default' : ''; @@ -703,52 +645,65 @@ this._context_timeout = null; } - // only have to set_tags on the display if the context really is changing - if ( context != this._current_context ) { + // only have to set_tags on the display if the something really changed + if ( new_context || new_trigger ) { var context_tags = []; if ( context && context in suggestions_for_context ) { context_tags = list_as_array(suggestions_for_context[context]); } - var has_tags = context_tags.length !== 0; - $('.ready[context=related]', this) .each(function(){ var display = this; var $display = $(display); - var had_tags = $display.find('span.tag').length !== 0; - - // animations are automatically queued... - if ( had_tags < has_tags ) { - $display.css('display', 'none'); - } else if ( had_tags > has_tags ) { + if ( $display.find('span.tag').length ) { $display.slideUp(400); } - // ...when regular code needs to synchronize with animation - $display.queue(function(){ - // I have to queue that code up myself - display.set_tags(context_tags, { classes: 'suggestion' }); - if ( has_tags && widget.modify_context ) { - widget.modify_context(display, context); - } - $display.dequeue(); - }); - if ( has_tags ) { - $queue_reposition($display); - if ( !had_tags ) { - $queue_reposition($display.slideDown(400)); - } + + + + if ( context_tags.length ) { + var $parent = $display.parent(), + global_left = $related_trigger.offset().left, + parent_left = $parent.offset().left, + best_left = global_left - parent_left; + + $display.queue(function(){ + // ...when regular code needs to synchronize with animation + // I have to queue that code up myself + + // if display had no tags before, $display.hide() would silently fail, because it's already hidden + // so hide the widget itself while we make the changes + $parent.hide(); + display.set_tags(context_tags, { classes: 'suggestion' }); + if ( widget.modify_context ) { + widget.modify_context(display, context); + } + + // now hide() will work, so hide the display (child) instead of the widget (parent) + // but we can't _really_ hide it, because we need to ask its width + $display.show().css('height', '0'); + $parent.show(); + try { + var max_left = $parent.width() - $display.find('ul').width(); + best_left = Math.min(best_left, max_left); + } catch ( e0 ) { + } + + $display.hide(); + $display.css({ + height: '', + left: best_left + }); + + $display.slideDown(400); + $display.dequeue(); + }); } }); this._current_context = context; - } else if ( context && - $related_trigger.length && - $previous_context_trigger.length && - $previous_context_trigger[0] !== $related_trigger[0] ) { - - $position_context_display($('.ready[context=related]', this)); } $previous_context_trigger = $related_trigger; @@ -1076,10 +1031,14 @@ update_class_map(well_known_tags, 't2', YAHOO.slashdot.topicTags); update_class_map(well_known_tags, 'y p', ['nod', 'metanod']); update_class_map(well_known_tags, 'x p', ['nix', 'metanix']); + update_class_map(well_known_tags, 'p', ['mainpage']); // Rob requests 'mainpage' never show its face update_class_map(well_known_tags, 'd', data_types); if ( fh_is_admin ) { update_class_map(well_known_tags, 'w p', ['signed', 'unsigned', 'signoff']); + update_class_map(well_known_tags, 'd', ['unknown']); // Tags.pm debugging + } else { + update_class_map(well_known_tags, 'd p', ['unknown']); // Tags.pm debugging, non-admins don't get to see } }); Modified: slashjp/branches/upstream/current/plugins/Ajax/templates/tag_ui_widget;misc;default =================================================================== --- slashjp/branches/upstream/current/plugins/Ajax/templates/tag_ui_widget;misc;default 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/Ajax/templates/tag_ui_widget;misc;default 2008-12-16 03:30:11 UTC (rev 884) @@ -17,9 +17,17 @@ __seclev__ 10000 __template__ -[% IF user.tags_canread_stories %] -[% tags_reader = Slash.getObject('Slash::Tags'); tags = tags_reader.setGetCombinedTags(key, key_type); %] -[%# the tag-widget itself %] +[% IF user.tags_canread_stories -%] +[% tags_reader = Slash.getObject('Slash::Tags'); tag_info = tags_reader.setGetCombinedTags(key, key_type); -%] +[% IF tag_info.datatype == 'story' -%] +[% IF key_type == 'stoid' -%] +[% tag_info.stoid = key -%] +[% ELSE -%] +[% tag_info.stoid = item.srcid -%] +[% END -%] +[% END -%] + +[%# the tag-widget itself -%] <div class="tag-widget-stub body-widget" init="context_timeout:15000"> [%# the disclosure triangle %] @@ -31,31 +39,31 @@ <span class="button collapse"></span> </a> - [% IF user.tags_canwrite_stories %] - [%# the tag input field %] + [% IF user.tags_canwrite_stories -%] + [%# the tag input field -%] <form class="tag-editor" onsubmit="form_submit_tags(this, {fade_remove: 400, order: 'prepend', classes:'not-saved'}); return false"> <input class="tag-entry" type="text" size="10"> <span class="tag-server-busy"><img src="[% constants.imagedir %]/spinner[% IF !featured %]2[% END %].gif"></span> </form> - [% END %] + [% END -%] - [%# the tag 'bars' %] - [% IF user.tags_canwrite_stories %] + [%# the tag 'bars' -%] + [% IF user.tags_canwrite_stories -%] <div class="tag-display-stub" context="user" init="legend:'my tags'"></div> [% END %] - <div class="tag-display-stub" context="top" init="legend:'top tags'">[% tags.top %]</div> - <div class="tag-display-stub" context="system" init="legend:'system tags'">[% tags.system %]</div> - [%- IF item.type == "story" && + <div class="tag-display-stub" context="top" init="legend:'top tags'">[% tag_info.top %]</div> + <div class="tag-display-stub" context="system"">[% tag_info.system %]</div> + [% IF tag_info.datatype == "story" && constants.signoff_use && ((user.is_admin && !user.firehose_usermode) || user.acl.signoff_allowed) && - ! Slash.db.hasUserSignedStory(item.srcid, user.uid) -%] - <div class="tag-display-stub" context="signoff" init="legend:'signoff', menu:false">unsigned</div> + ! Slash.db.hasUserSignedStory(tag_info.stoid, user.uid) -%] + <div class="tag-display-stub" context="signoff" init="menu:false">unsigned</div> [%- END -%] - <div class="tag-display-stub" context="datatype" init="legend:'type tag'">[% tags.datatype %]</div> - [% IF user.tags_canwrite_stories %] - [%# the suggestions bar %] + <div class="tag-display-stub" context="datatype" init="menu:false">[% tag_info.datatype %]</div> + [% IF user.tags_canwrite_stories -%] + [%# the suggestions bar -%] <div class="related"> - <div class="tag-display-stub" context="related" init="legend:'suggestions', menu:false"></div> + <div class="tag-display-stub" context="related" init="menu:false"></div> </div> [% END %] </div> Modified: slashjp/branches/upstream/current/plugins/FireHose/FireHose.pm =================================================================== --- slashjp/branches/upstream/current/plugins/FireHose/FireHose.pm 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/FireHose/FireHose.pm 2008-12-16 03:30:11 UTC (rev 884) @@ -266,6 +266,13 @@ } } +sub getUserBookmarkForUrl { + my($self, $uid, $url_id) = @_; + my $uid_q = $self->sqlQuote($uid); + my $url_id_q = $self->sqlQuote($url_id); + return $self->sqlSelectHashref("*", "bookmarks", "uid=$uid_q and url_id=$url_id_q"); +} + sub createUpdateItemFromBookmark { my($self, $id, $options) = @_; $options ||= {}; @@ -297,7 +304,8 @@ activity => $activity, public => "yes", type => $type, - srcid => $id + srcid => $id, + createtime => $bookmark->{createdtime}, }; $data->{introtext} = $options->{introtext} if $options->{introtext}; if ($type eq "feed") { @@ -838,7 +846,7 @@ push @where, 'rejected = ' . $self->sqlQuote($options->{rejected}); } - if (defined $options->{category} || $user->{is_admin}) { + if (defined $options->{category} || ($user->{is_admin} && $options->{admin_filters})) { $options->{category} ||= ''; push @where, 'category = ' . $self->sqlQuote($options->{category}); } @@ -882,8 +890,13 @@ } my $rows = $self->sqlSelectAllHashrefArray("count(*)", $tables, $where, $count_other); - my $count = @$rows; + my $row_num = @$rows; + my $count = $row_num; + if ($row_num == 1 && !$count_other) { + $count = $rows->[0]->{"count(*)"}; + } + my $page_size = $ps || 1; $results->{records_pages} ||= ceil($count / $page_size); $results->{records_page} ||= (int(($options->{offset} || 0) / $options->{limit}) + 1) || 1; @@ -942,8 +955,13 @@ my $where = join ' AND ', @$where_ar, "createtime $it_cmp $i_time_q", "createtime $bt_cmp $border_time_q"; - my $rows = $self->sqlSelectAllHashrefArray("count(*)", $tables, $where, $other); - my $day_count = @$rows; + my $rows = $self->sqlSelectAllHashrefArray("firehose.id", $tables, $where, $other); + my $row_num = @$rows; + my $day_count = $row_num; + + if ($row_num == 1 && !$other) { + $day_count = $rows->[0]->{'count(*)'}; + } my $day_labels = getOlderDaysFromDay($item_day, 0, 0, { skip_add_today => 1, show_future_days => 1, force => 1 }); @@ -1489,7 +1507,14 @@ if (!$item->{day}) { my $url = $slashdb->getUrl($item->{url_id}); my $the_user = $slashdb->getUser($item->{uid}); - $html->{"title-$_->{id}"} = slashDisplay("formatHoseTitle", { adminmode => $adminmode, item => $item, showtitle => 1, url => $url, the_user => $the_user, options => $opts }, { Return => 1 }); + $item->{atstorytime} = '__TIME_TAG__'; + my $title = slashDisplay("formatHoseTitle", { adminmode => $adminmode, item => $item, showtitle => 1, url => $url, the_user => $the_user, options => $opts }, { Return => 1 }); + + my $atstorytime; + $atstorytime = $user->{aton} . ' ' . timeCalc($item->{'createtime'}); + $title =~ s/\Q__TIME_TAG__\E/$atstorytime/; + $html->{"title-$_->{id}"} = $title; + my $introtext = $item->{introtext}; slashDisplay("formatHoseIntro", { introtext => $introtext, url => $url, $item => $item }, { Return => 1 }); $html->{"text-$_->{id}"} = $introtext; @@ -1831,7 +1856,7 @@ } if (!exists($data->{last_update}) && !exists($data->{-last_update})) { - my @non_trivial = grep {!/^(activity|toptags)$/} keys %$data; + my @non_trivial = grep {!/^activity$/} keys %$data; if (@non_trivial > 0) { $data->{-last_update} = 'NOW()'; } else { @@ -1910,12 +1935,14 @@ return '' if $gSkin->{skid} != $constants->{mainpage_skid}; return '' if !$constants->{firehose_mcd_disp}; + my $index = $form->{index} ? 1 : 0; + if ($mcd && !$options->{nodates} && !$options->{nobylines} && !$options->{nocolors} && !$options->{nothumbs} && !$options->{vote} - && !$form->{skippop} && !$form->{index} + && !$form->{skippop} && !$user->{is_admin}) { - $mcdkey = "$self->{_mcd_keyprefix}:dispfirehose-$options->{mode}:$id"; + $mcdkey = "$self->{_mcd_keyprefix}:dispfirehose-$options->{mode}:$id:$index"; } return $mcdkey; } @@ -1926,9 +1953,12 @@ return [ ] if !$constants->{firehose_mcd_disp}; my $keys = [ ]; my $mcd = $self->getMCD(); + if ($mcd) { foreach my $mode (qw(full fulltitle)) { - push @$keys, "$self->{_mcd_keyprefix}:dispfirehose-$mode:$id"; + foreach my $index (qw(0 1)) { + push @$keys, "$self->{_mcd_keyprefix}:dispfirehose-$mode:$id:$index"; + } } } return $keys; @@ -1937,38 +1967,48 @@ sub dispFireHose { my($self, $item, $options) = @_; my $constants = getCurrentStatic(); + my $user = getCurrentUser(); $options ||= {}; my $mcd = $self->getMCD(); my $mcdkey; + my $retval; + if ($mcd) { $mcdkey = $self->genFireHoseMCDKey($item->{id}, $options); - my $cached; if ($mcdkey) { - $cached = $mcd->get("$mcdkey"); + $retval = $mcd->get("$mcdkey"); } - return $cached if $cached; } - my $retval = slashDisplay('dispFireHose', { - item => $item, - mode => $options->{mode}, - tags_top => $options->{tags_top}, # old-style - top_tags => $options->{top_tags}, # new-style - system_tags => $options->{system_tags}, # new-style - options => $options->{options}, - vote => $options->{vote}, - bodycontent_include => $options->{bodycontent_include}, - nostorylinkwrapper => $options->{nostorylinkwrapper}, - view_mode => $options->{view_mode} - }, { Page => "firehose", Return => 1 }); + $item->{atstorytime} = "__TIME_TAG__"; - if ($mcd) { - $mcdkey = $self->genFireHoseMCDKey($item->{id}, $options); - if ($mcdkey) { - my $exptime = $constants->{firehose_memcached_disp_exptime} || 180; - $mcd->set($mcdkey, $retval, $exptime); + if (!$retval) { # No cache hit + $retval = slashDisplay('dispFireHose', { + item => $item, + mode => $options->{mode}, + tags_top => $options->{tags_top}, # old-style + top_tags => $options->{top_tags}, # new-style + system_tags => $options->{system_tags}, # new-style + options => $options->{options}, + vote => $options->{vote}, + bodycontent_include => $options->{bodycontent_include}, + nostorylinkwrapper => $options->{nostorylinkwrapper}, + view_mode => $options->{view_mode} + }, { Page => "firehose", Return => 1 }); + + if ($mcd) { + $mcdkey = $self->genFireHoseMCDKey($item->{id}, $options); + if ($mcdkey) { + my $exptime = $constants->{firehose_memcached_disp_exptime} || 180; + $mcd->set($mcdkey, $retval, $exptime); + } } } + + my $atstorytime; + $atstorytime = $user->{aton} . ' ' . timeCalc($item->{'createtime'}); + $retval =~ s/\Q__TIME_TAG__\E/$atstorytime/; + return $retval; } @@ -2248,6 +2288,8 @@ my $form = getCurrentForm(); my $gSkin = getCurrentSkin(); + my $mainpage = 0; + my ($f_change, $v_change, $t_change); if (!$opts->{initial}) { @@ -2530,6 +2572,9 @@ } elsif ($user->{is_admin} && $validator->{categories}{$_} && !defined $fh_options->{category}) { $fh_options->{category} = $_; } elsif ($skin_nexus{$_}) { + if (!$not && $skin_nexus{$_} == $constants->{mainpage_nexus_tid}) { + $mainpage = 1; + } push @{$fh_options->{$not."nexus"}}, $skin_nexus{$_}; } elsif ($user->{is_admin} && $_ eq "rejected") { $fh_options->{rejected} = "yes"; @@ -2586,8 +2631,7 @@ } # push all necessary nexuses on if we want stories show as brief - if ($constants->{brief_sectional_mainpage} && $the_skin->{nexus} == $constants->{mainpage_nexus_tid} && - $options->{fhfilter} eq "$the_skin->{name} story") { + if ($constants->{brief_sectional_mainpage} && $the_skin->{nexus} == $constants->{mainpage_nexus_tid} && $mainpage) { my $nexus_children = $self->getMainpageDisplayableNexuses(); push @{$fh_options->{nexus}}, @$nexus_children; @@ -2629,19 +2673,23 @@ } $options->{public} = "yes"; + + if ($options->{view} eq "daddypants" || $form->{admin_filters}) { + $options->{admin_filters} = 1; + } + if ($adminmode) { # $options->{attention_needed} = "yes"; - if ($firehose_page ne "user") { + if ($options->{admin_filters}) { $options->{accepted} = "no" if !$options->{accepted}; $options->{rejected} = "no" if !$options->{rejected}; } $options->{duration} ||= -1; } else { if ($firehose_page ne "user") { - $options->{accepted} = "no" if !$options->{accepted}; + # $options->{accepted} = "no" if !$options->{accepted}; } - $options->{duration} ||= 1; if ($user->{is_subscriber} && (!$no_saved || $form->{index})) { $options->{createtime_subscriber_future} = 1; } else { @@ -2918,7 +2966,7 @@ my $featured; if ($gSkin->{name} eq "idle" && !$user->{firehose_nomarquee}) { - my $featured_ops ={ primaryskid => $gSkin->{skid}, type => "story", limit => 1, orderby => 'createtime', orderdir => 'DESC'}; + my $featured_ops = { primaryskid => $gSkin->{skid}, type => "story", limit => 1, orderby => 'createtime', orderdir => 'DESC'}; if ($user->{is_subscriber}) { $featured_ops->{createtime_subscriber_future} = 1; Modified: slashjp/branches/upstream/current/plugins/FireHose/firehose.pl =================================================================== --- slashjp/branches/upstream/current/plugins/FireHose/firehose.pl 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/FireHose/firehose.pl 2008-12-16 03:30:11 UTC (rev 884) @@ -244,7 +244,7 @@ } xmlDisplay($form->{content_type} => { channel => { - title => "$constants->{sitename} Firehose", + title => "$constants->{sitename} Firehose - Filtered to '$options->{fhfilter}'", 'link' => "$gSkin->{absolutedir}/firehose.pl", descriptions => "$constants->{sitename} Firehose" }, Modified: slashjp/branches/upstream/current/plugins/FireHose/mysql_dump.sql =================================================================== --- slashjp/branches/upstream/current/plugins/FireHose/mysql_dump.sql 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/FireHose/mysql_dump.sql 2008-12-16 03:30:11 UTC (rev 884) @@ -52,7 +52,7 @@ INSERT INTO firehose_view (id, uid, viewname, useparentfilter, filter, orderby, orderdir, color, duration, mode, mixedmode, tab_display, options_edit, admin_maxitems, maxitems, seclev, pause) VALUES (NULL, 0, "usersubmission", "no", '"author:{nickname}" submission', "createtime", "DESC", "black", "-1", "full", "0", "no", "no", 20, 20, 0,"1"); -INSERT INTO firehose_view (id, uid, viewname, useparentfilter, filter, orderby, orderdir, color, duration, mode, mixedmode, tab_display, options_edit, admin_maxitems, maxitems, seclev, pause) VALUES (NULL, 0, "userbookmark", "no", '"author:{nickname}" bookmark', "createtime", "DESC", "black", "-1", "full", "0", "no", "no", 20, 20, 0,"1"); +INSERT INTO firehose_view (id, uid, viewname, useparentfilter, filter, orderby, orderdir, color, duration, mode, mixedmode, tab_display, options_edit, admin_maxitems, maxitems, seclev, pause) VALUES (NULL, 0, "userbookmark", "no", '"user:{nickname}" bookmark', "createtime", "DESC", "black", "-1", "full", "0", "no", "no", 20, 20, 0,"1"); INSERT INTO firehose_view (id, uid, viewname, useparentfilter, filter, orderby, orderdir, color, duration, mode, mixedmode, tab_display, options_edit, admin_maxitems, maxitems, seclev, pause) VALUES (NULL, 0, "userfirehose", "no", '"user:{nickname}"', "createtime", "DESC", "black", "-1", "full", "0", "no", "no", 20, 20, 0,"1"); Modified: slashjp/branches/upstream/current/plugins/FireHose/mysql_schema.sql =================================================================== --- slashjp/branches/upstream/current/plugins/FireHose/mysql_schema.sql 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/FireHose/mysql_schema.sql 2008-12-16 03:30:11 UTC (rev 884) @@ -46,7 +46,8 @@ KEY popularity (popularity), KEY neediness (neediness), KEY url_id (url_id), - KEY uid (uid) + KEY uid (uid), + KEY last_update (last_update) ) TYPE=InnoDB; # The table giving an Object's Generally Accepted Story Publication Time Modified: slashjp/branches/upstream/current/plugins/FireHose/templates/formatHoseTitle;misc;default =================================================================== --- slashjp/branches/upstream/current/plugins/FireHose/templates/formatHoseTitle;misc;default 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/FireHose/templates/formatHoseTitle;misc;default 2008-12-16 03:30:11 UTC (rev 884) @@ -26,6 +26,14 @@ fh_page = fh_page || "firehose.pl"; title = item.title; +IF item.type == "bookmark" && options.view == "userbookmark"; + fh = Slash.getObject("Slash::FireHose"); + ub = fh.getUserBookmarkForUrl(options.user_view_uid, item.url_id); + IF ub && ub.title; + title = ub.title; + END; +END; + IF item.primaryskid && item.primaryskid != form.primaryskid && item.primaryskid != constants.mainpage_skid && item.type == "story"; the_skin = Slash.db.getSkin(item.primaryskid); IF user.is_anon; @@ -86,7 +94,7 @@ IF options.nodates; title = title _ " hide"; END; -title = title _ '">' _ Slash.timeCalc(item.createtime, "%Y-%m-%d %H:%M") _ "</span> <span class=\"nickname"; +title = title _ '">' _ item.atstorytime _ "</span> <span class=\"nickname"; IF options.nobylines; title = title _ " hide"; END; Modified: slashjp/branches/upstream/current/plugins/FireHose/templates/list;firehose;default =================================================================== --- slashjp/branches/upstream/current/plugins/FireHose/templates/list;firehose;default 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/FireHose/templates/list;firehose;default 2008-12-16 03:30:11 UTC (rev 884) @@ -30,7 +30,7 @@ submission_hash.${submission.subid} = submission; END; submission_accept = submission_count - (submission_reject + submission_pend) %] -<div id="message"><div class="content"><p>Submission Summary: +<div id="message"><div class="content"><p class="submissions">Submission Summary: [% submission_pend %] pending, [% submission_reject %] rejected, [% submission_accept %] accepted ([% @@ -42,10 +42,13 @@ %]% accepted)</p></div></div> -[% ELSIF options.view == "userjournal" AND (user.uid == options.user_view_uid) %] +[% ELSIF options.view == "userjournal" %] <div id="message"><div class="content"> - <a href="[% gSkin.rootdir %]/journal.pl?op=list">Manage Journal Entries</a> | - <a href="[% gSkin.rootdir %]/journal.pl?op=editprefs">Edit Journal Preferences</a> + [% IF user.uid == options.user_view_uid -%] + <a href="[% constants.real_rootdir %]/journal.pl?op=list">Manage Journal Entries</a> | + <a href="[% constants.real_rootdir %]/journal.pl?op=editprefs">Edit Journal Preferences</a> | + [%- END %] + <a href="[% constants.real_rootdir %]/~[% user.nickname | strip_paramattr %]/journal/friends">[% user.nickname | strip_literal %]'s Friends' Journals</a> </div></div> [% END %] @@ -202,6 +205,9 @@ [% IF options.index %] firehose_settings.index = 1; [% END %] + [% IF options.admin_filters %] + firehose_settings.admin_filters = 1; + [% END %] var firehose_action_time = 0; var firehose_user_class = [% user.is_anon ? 0 : 1 %]; @@ -249,17 +255,6 @@ if ( gFocusedText === this ) { gFocusedText = null; } - }). - autocomplete('/ajax.pl', { - loadingClass: 'working', - multiple: true, - multipleSeparator: ' ', - minChars: 3, - autoFill: true, - max: 25, - extraParams: { - op: 'tags_list_tagnames' - } }); $('#firehoselist').click(firehose_click_tag); Modified: slashjp/branches/upstream/current/plugins/FireHose/templates/tag_widget;firehose;default =================================================================== --- slashjp/branches/upstream/current/plugins/FireHose/templates/tag_widget;firehose;default 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/FireHose/templates/tag_widget;firehose;default 2008-12-16 03:30:11 UTC (rev 884) @@ -57,7 +57,7 @@ [%# the tag 'bars' %] <div class="tag-display-stub" context="user" init="legend:'my tags'"></div> <div class="tag-display-stub" context="top" init="legend:'top tags'">[% tags.top %]</div> - <div class="tag-display-stub" context="system" init="legend:'system tags'">[% tags.system; + <div class="tag-display-stub" context="system">[% tags.system; IF options.view == "usersubmission"; this_submission = Slash.db.getSubmission(item.srcid); SWITCH this_submission.del; @@ -70,12 +70,12 @@ constants.signoff_use && ((user.is_admin && !user.firehose_usermode) || user.acl.signoff_allowed) && ! Slash.db.hasUserSignedStory(item.srcid, user.uid) -%] - <div class="tag-display-stub" context="signoff" stoid="[% item.srcid %]" init="legend:'signoff', menu:false">unsigned</div> + <div class="tag-display-stub" context="signoff" stoid="[% item.srcid %]" init="menu:false">unsigned</div> [%- END -%] - <div class="tag-display-stub" context="datatype" init="legend:'type tag'">[% tags.datatype %]</div> + <div class="tag-display-stub" context="datatype" init="menu:false">[% tags.datatype %]</div> [%# the suggestions bar %] <div class="related"> - <div class="tag-display-stub" context="related" init="legend:'suggestions', menu:false"></div> + <div class="tag-display-stub" context="related" init="menu:false"></div> </div> </div> [% ELSE %] @@ -88,7 +88,7 @@ [%- END %]><span class="button collapse"></span></a> [%# the tag 'bars' %] <div class="tag-display-stub" context="top" init="legend:'top tags'">[% tags.top %]</div> - <div class="tag-display-stub" context="system" init="legend:'system tags'">[% tags.system; + <div class="tag-display-stub" context="system">[% tags.system; IF options.view == "usersubmission"; this_submission = Slash.db.getSubmission(item.srcid); SWITCH this_submission.del; @@ -97,7 +97,7 @@ CASE 2; ' accepted'; END; END %]</div> - <div class="tag-display-stub" context="datatype" init="legend:'type tag'">[% tags.datatype %]</div> + <div class="tag-display-stub" context="datatype" init="menu:false">[% tags.datatype %]</div> </div> [% END %] [% END %] Modified: slashjp/branches/upstream/current/plugins/Submit/submit.pl =================================================================== --- slashjp/branches/upstream/current/plugins/Submit/submit.pl 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/Submit/submit.pl 2008-12-16 03:30:11 UTC (rev 884) @@ -699,54 +699,6 @@ yourPendingSubmissions($constants, $slashdb, $user, $form, { skip_submit_body => 1 }); print getData("submit_body_close"); - if (!$user->{is_anon}) { - my $events = $slashdb->sqlSelectAllHashref( - 'eid', 'eid, date', 'user_events', "uid = $uid and code = 3"); - - # Delete the oldest event for this user if they already have 5 events. - if ((scalar keys %$events) == 5) { - my $eid = [sort keys %$events]->[0]; - $slashdb->sqlDelete('user_events', "uid = $uid and code = 3 and eid = $eid"); - } - - my $submission_id = - $slashdb->sqlSelect("id", "firehose", "uid = $uid and srcid = " . $messagesub->{subid} . " and type = 'submission'"); - - # Insert event - $slashdb->sqlInsert('user_events', { - code => 3, - uid => $uid, - event => $submission_id, - -date => 'NOW()', - }); - - # Create/update event block - my $event_blocks = $slashdb->sqlSelectAllHashref( - 'uid', 'bid, uid, block', 'user_event_blocks', "uid = $uid and code = 3"); - - # New block - if (!%$event_blocks) { - $slashdb->sqlInsert('user_event_blocks', { - code => 3, - uid => $uid, - block => $submission_id, - }); - } else { - my @blocks = split(/,/, $event_blocks->{$uid}->{block}); - - # Remove oldest event from this block - if (scalar @blocks == 5) { - @blocks = @blocks[1 .. 4]; - } - - # Append new event - $blocks[$#blocks + 1] = $submission_id; - my $new_blocks = join(",", @blocks); - - $slashdb->sqlUpdate('user_event_blocks', { block => $new_blocks }, "uid = $uid and code = 3"); - } - } - return(1); } Modified: slashjp/branches/upstream/current/plugins/Tags/Tags.pm =================================================================== --- slashjp/branches/upstream/current/plugins/Tags/Tags.pm 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/Tags/Tags.pm 2008-12-16 03:30:11 UTC (rev 884) @@ -1137,7 +1137,7 @@ my $system_tags = $section_tag . ' ' . $topic_tags; - my $response = '<datatype>' . $datatype_tag . '<system>' . $system_tags . '<top>'. $top_tags; + my $response = '<datatype>' . ($datatype_tag || 'unknown') . '<system>' . $system_tags . '<top>'. $top_tags; $response .= '<user>' . $user_tags unless $form->{global_tags_only}; return $response; Modified: slashjp/branches/upstream/current/plugins/Tags/archive_globjs_viewed.pl =================================================================== --- slashjp/branches/upstream/current/plugins/Tags/archive_globjs_viewed.pl 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/Tags/archive_globjs_viewed.pl 2008-12-16 03:30:11 UTC (rev 884) @@ -19,7 +19,7 @@ my $min_gvid = $slashdb->sqlSelect('MIN(gvid)', 'globjs_viewed'); my $max_gvid = $min_gvid + 50_000; - my $where_clause = "gvid < $max_gvid AND viewed_at < DATE_SUB(NOW(), INTERVAL 6 MONTH)"; + my $where_clause = "gvid < $max_gvid AND viewed_at < DATE_SUB(NOW(), INTERVAL 3 MONTH)"; my $old_arch_size = $slashdb->sqlSelect('COUNT(*)', 'globjs_viewed_archived'); $slashdb->sqlDo("INSERT IGNORE INTO globjs_viewed_archived Modified: slashjp/branches/upstream/current/plugins/Tags/tagbox.pl =================================================================== --- slashjp/branches/upstream/current/plugins/Tags/tagbox.pl 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/Tags/tagbox.pl 2008-12-16 03:30:11 UTC (rev 884) @@ -74,6 +74,7 @@ } tagboxLog('tagbox.pl starting'); + my $sleeps_in_a_row = 0; my $exclude_behind = 1; my $max_activity_for_run = 10; my $feederlog_largerows = $constants->{tags_feederlog_largerows} || 50_000; @@ -134,6 +135,7 @@ # obsolete the results we'd get by calling run() right now. if ($activity_feeder > 10) { tagboxLog("tagbox.pl re-updating feederlog, activity $activity_feeder"); + $sleeps_in_a_row = 0; next; } @@ -149,8 +151,11 @@ # If nothing's going on, ease up some (not that it probably # matters much, since if nothing's going on both of the # above should be doing reasonably fast SELECTs). - if (!$activity_feeder && !$activity_run) { - tagboxLog('tagbox.pl sleeping 3'); + if ($activity_feeder || $activity_run) { + $sleeps_in_a_row = 0; + } else { + ++$sleeps_in_a_row; + tagboxLog('tagbox.pl sleeping 3') if $sleeps_in_a_row % 100 == 1; sleep 3; } last if $task_exit_flag; Modified: slashjp/branches/upstream/current/plugins/Tags/tags_udc.pl =================================================================== --- slashjp/branches/upstream/current/plugins/Tags/tags_udc.pl 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/Tags/tags_udc.pl 2008-12-16 03:30:11 UTC (rev 884) @@ -94,12 +94,14 @@ my $hour = $cur_hour - 3600*$hoursback; my $hour_next = $hour + 3600; my $tags_reader = getObject('Slash::Tags', { db_type => 'reader' }); + my $comments_gtid = $tags_reader->getGlobjTypes()->{comments} || 5; my $tags_ar = $tags_reader->sqlSelectAllHashrefArray( - '*', - 'tags', + 'tags.*', + 'tags NATURAL JOIN globjs', "created_at BETWEEN FROM_UNIXTIME($hour) AND DATE_ADD(FROM_UNIXTIME($hour), INTERVAL 3599 SECOND) AND tagnameid IN ($dnid, $upid) - AND inactivated IS NULL"); + AND inactivated IS NULL + AND gtid != $comments_gtid"); $tags_reader->addCloutsToTagArrayref($tags_ar, 'vote'); my $cloutsum = 0; Modified: slashjp/branches/upstream/current/plugins/Tags/templates/usertagnames;users;default =================================================================== --- slashjp/branches/upstream/current/plugins/Tags/templates/usertagnames;users;default 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/Tags/templates/usertagnames;users;default 2008-12-16 03:30:11 UTC (rev 884) @@ -24,7 +24,7 @@ UNLESS notitle; PROCESS user_titlebar tab_selected='tags'; END; %] [% IF user.tags_canread_stories && tagnames.size %] -<div><table border="0" cellpadding="0" cellspacing="0" width="100%" class="tagslist"> +<div><table class="tagslist"> [% FOREACH tagname = tagnames %] <tr><td class="tagname" valign="top"><a href="[% url_base %]tags/[% tagname | strip_paramattr %]">[% tagname | strip_html %]</a></td></tr> [% END %] Modified: slashjp/branches/upstream/current/plugins/Tags/templates/usertags;users;default =================================================================== --- slashjp/branches/upstream/current/plugins/Tags/templates/usertags;users;default 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/Tags/templates/usertags;users;default 2008-12-16 03:30:11 UTC (rev 884) @@ -24,7 +24,7 @@ PROCESS user_titlebar tab_selected='tags' %] [% IF user.tags_canread_stories && tags_grouped.keys.size %] -<div><table border="0" cellpadding="0" cellspacing="0" width="100%" class="tagslist"> +<div><table class="tagslist"> [% FOREACH tagname = tags_grouped.keys.sort; tagname_shown = 0; FOREACH tag = tags_grouped.$tagname %] Modified: slashjp/branches/upstream/current/plugins/Tags/templates/usertagsforname;users;default =================================================================== --- slashjp/branches/upstream/current/plugins/Tags/templates/usertagsforname;users;default 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/Tags/templates/usertagsforname;users;default 2008-12-16 03:30:11 UTC (rev 884) @@ -26,7 +26,7 @@ UNLESS notitle; PROCESS user_titlebar tab_selected='tags'; END; %] [% IF user.tags_canread_stories && tags.size %] -<div><table border="0" cellpadding="0" cellspacing="0" width="100%" class="tagslist"> +<div><table class="tagslist"> [% FOREACH tag = tags %] [% UNLESS tag.globj_type == "submissions" %] <tr> Modified: slashjp/branches/upstream/current/plugins/Users2/Users2.pm =================================================================== --- slashjp/branches/upstream/current/plugins/Users2/Users2.pm 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/Users2/Users2.pm 2008-12-16 03:30:11 UTC (rev 884) @@ -330,7 +330,7 @@ } sub truncateMarquee { - my($self, $marquee, $len) = @_; + my($self, $marquee) = @_; my $text; my $linebreak = qr{(?: @@ -340,22 +340,30 @@ div | (?:block)?quote | [oud]l )> )}x; - my $min_chars = 50; - my $max_chars = $len || 1000; + my $min_chars = 50; + my $max_chars = 1500; + my $orig_len = length($marquee->{body}); - if (length($marquee) < $min_chars) { - $text = $marquee; + if (length($marquee->{body}) < $min_chars) { + $text = $marquee->{body}; } else { - $text = $1 if $marquee =~ m/^(.{$min_chars,$max_chars})?$linebreak/s; + $text = $1 if $marquee->{body} =~ m/^(.{$min_chars,$max_chars})?$linebreak/s; } - $text ||= chopEntity($marquee, $max_chars); + $text ||= chopEntity($marquee->{body}, $max_chars); local $Slash::Utility::Data::approveTag::admin = 1; $text = strip_html($text); $text = balanceTags($text, { admin => 1 }); $text = addDomainTags($text); - return $text; + $marquee->{body} = $text; + + if ($orig_len > length($text)) { + $marquee->{truncated} = 1; + } + + return $marquee; + } sub DESTROY { Modified: slashjp/branches/upstream/current/plugins/Zoo/templates/plainlist;zoo;default =================================================================== --- slashjp/branches/upstream/current/plugins/Zoo/templates/plainlist;zoo;default 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/plugins/Zoo/templates/plainlist;zoo;default 2008-12-16 03:30:11 UTC (rev 884) @@ -13,7 +13,7 @@ __name__ plainlist __template__ -<table width="100%" border="0" cellpadding="2" cellspacing="0"> +<table class="zooList"> <tr><th align="left">User</th> <th align="left" colspan="2">User's...</th> <th align="left"> Last Journal</th></tr> Modified: slashjp/branches/upstream/current/sql/mysql/defaults.sql =================================================================== --- slashjp/branches/upstream/current/sql/mysql/defaults.sql 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/sql/mysql/defaults.sql 2008-12-16 03:30:11 UTC (rev 884) @@ -840,7 +840,7 @@ INSERT INTO vars (name, value, description) VALUES ('cur_performance_stats_lastid', '0', 'accesslogid to start searching at'); INSERT INTO vars (name, value, description) VALUES ('cur_performance_stats_weeks', '8', 'number of weeks back to compare current stats to'); INSERT INTO vars (name, value, description) VALUES ('currentqid',1,'The Current Question on the homepage pollbooth'); -INSERT INTO vars (name, value, description) VALUES ('cvs_tag_currentcode','T_2_5_0_233','The current cvs tag that the code was updated to - this does not affect site behavior but may be useful for your records'); +INSERT INTO vars (name, value, description) VALUES ('cvs_tag_currentcode','T_2_5_0_235','The current cvs tag that the code was updated to - this does not affect site behavior but may be useful for your records'); INSERT INTO vars (name, value, description) VALUES ('datadir','/usr/local/slash/www.example.com','What is the root of the install for Slash'); INSERT INTO vars (name, value, description) VALUES ('db_auto_increment_increment','1','If your master DB uses auto_increment_increment, i.e. multiple master replication, echo its value into this var'); INSERT INTO vars (name, value, description) VALUES ('dbsparklines_disp','0','Display dbsparklines in the currentAdminUsers box?'); Modified: slashjp/branches/upstream/current/sql/mysql/upgrades =================================================================== --- slashjp/branches/upstream/current/sql/mysql/upgrades 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/sql/mysql/upgrades 2008-12-16 03:30:11 UTC (rev 884) @@ -5686,8 +5686,6 @@ # 2008-11-20 UPDATE vars SET value = 'T_2_5_0_231' WHERE name = 'cvs_tag_currentcode'; -# SLASHCODE/USEPERL LAST UPDATED HERE - UPDATE firehose SET public="yes" WHERE type="journal"; create temporary table firehose_deletedjournal (id int unsigned not null primary key); @@ -5704,8 +5702,6 @@ # 2008-11-25 UPDATE vars SET value = 'T_2_5_0_232' WHERE name = 'cvs_tag_currentcode'; -# SLASHDOT LAST UPDATED HERE - # for plugins/FireHose ALTER TABLE firehose ADD INDEX uid (uid); @@ -5717,3 +5713,18 @@ # 2008-11-26 UPDATE vars SET value = 'T_2_5_0_233' WHERE name = 'cvs_tag_currentcode'; +UPDATE firehose_view SET filter='"user:{nickname}" bookmark' WHERE viewname="userbookmark"; + +# 2008-12-04 +UPDATE vars SET value = 'T_2_5_0_234' WHERE name = 'cvs_tag_currentcode'; + +# SLASHCODE/USEPERL LAST UPDATED HERE + +# SLASHDOT LAST UPDATED HERE + +# for plugins/FireHose +ALTER TABLE firehose ADD INDEX last_update (last_update); + +# 2008-12-11 +UPDATE vars SET value = 'T_2_5_0_235' WHERE name = 'cvs_tag_currentcode'; + Modified: slashjp/branches/upstream/current/tagboxes/CommentScoreReason/CommentScoreReason.pm =================================================================== --- slashjp/branches/upstream/current/tagboxes/CommentScoreReason/CommentScoreReason.pm 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/tagboxes/CommentScoreReason/CommentScoreReason.pm 2008-12-16 03:30:11 UTC (rev 884) @@ -110,7 +110,7 @@ } sub run_process { - my($self, $affected_id, $tags_ar) = @_; + my($self, $affected_id, $tags_ar, $options) = @_; my $constants = getCurrentStatic(); my $tagsdb = getObject('Slash::Tags'); my $tagboxdb = getObject('Slash::Tagbox'); @@ -206,6 +206,15 @@ my $new_score = $points_orig + $mod_score_sum; my $new_karma_bonus = ($karma_bonus eq 'yes' && $keep_karma_bonus) ? 1 : 0; + if ($options->{return_only}) { + return { + score => $new_score, + karma_bonus => $new_karma_bonus, + reason => $current_reason_mode, + neediness => $neediness, + }; + } + $self->info_log("cid %d to score: %d, %s kb %d->%d, neediness %.1f", $cid, $new_score, $reasons->{$current_reason_mode}{name}, ($karma_bonus eq 'yes' ? 1 : 0), $new_karma_bonus, $neediness); Modified: slashjp/branches/upstream/current/themes/slashcode/THEME =================================================================== --- slashjp/branches/upstream/current/themes/slashcode/THEME 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/themes/slashcode/THEME 2008-12-16 03:30:11 UTC (rev 884) @@ -347,6 +347,7 @@ template=templates/u2AdminListComments;users;default template=templates/u2UserBoxes;users;default template=templates/u2ListComments;users;default +template=templates/u2_rsslink;users;default misc=misc/spamarmors plugin=Admin Modified: slashjp/branches/upstream/current/themes/slashcode/htdocs/users2.pl =================================================================== --- slashjp/branches/upstream/current/themes/slashcode/htdocs/users2.pl 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/themes/slashcode/htdocs/users2.pl 2008-12-16 03:30:11 UTC (rev 884) @@ -68,20 +68,6 @@ tab_selected_1 => 'me', tab_selected_2 => 'firehose' }, - usersubmissions => { - function => \&showSubmissions, - #I made this change, not all sites are going to care. -Brian - seclev => $constants->{users_show_info_seclev}, - checks => [], - tab_selected_1 => 'me', - }, - usercomments => { - function => \&showComments, - #I made this change, not all sites are going to care. -Brian - seclev => $constants->{users_show_info_seclev}, - checks => [], - tab_selected_1 => 'me', - }, display => { function => \&showInfo, #I made this change, not all sites are going to care. -Brian @@ -91,16 +77,6 @@ tab_selected_1 => 'me', tab_selected_2 => 'info', }, -# savepasswd => { -# function => \&savePasswd, -# seclev => 1, -# post => 1, -# formname => $formname, -# checks => [ qw (max_post_check valid_check -# formkey_check regen_formkey) ], -# tab_selected_1 => 'preferences', -# tab_selected_2 => 'password', -# }, saveuseradmin => { function => \&saveUserAdmin, seclev => 10000, @@ -108,26 +84,6 @@ formname => $formname, checks => [], }, - savehome => { - function => \&saveHome, - seclev => 1, - post => 1, - formname => $formname, - checks => [ qw (valid_check - formkey_check regen_formkey) ], - tab_selected_1 => 'preferences', - tab_selected_2 => 'home', - }, - savecomm => { - function => \&saveComm, - seclev => 1, - post => 1, - formname => $formname, - checks => [ qw (valid_check - formkey_check regen_formkey) ], - tab_selected_1 => 'preferences', - tab_selected_2 => 'comments', - }, saveuser => { function => \&saveUser, seclev => 1, @@ -138,15 +94,6 @@ tab_selected_1 => 'preferences', tab_selected_2 => 'user', }, -# changepasswd => { -# function => \&changePasswd, -# seclev => 1, -# formname => $formname, -# checks => $savepass_flag ? [] : -# [ qw (generate_formkey) ], -# tab_selected_1 => 'preferences', -# tab_selected_2 => 'password', -# }, editmiscopts => { function => \&editMiscOpts, seclev => 1, @@ -177,29 +124,6 @@ formname => $formname, checks => [], }, - edithome => { - function => \&editHome, - seclev => 1, - formname => $formname, - checks => [ qw (generate_formkey) ], - tab_selected_1 => 'preferences', - tab_selected_2 => 'home', - }, - editcomm => { - function => \&editComm, - seclev => 1, - formname => $formname, - checks => [ qw (generate_formkey) ], - tab_selected_1 => 'preferences', - tab_selected_2 => 'comments', - }, -# newuser => { -# function => \&newUser, -# seclev => 0, -# formname => "${formname}/nu", -# checks => [ qw (max_post_check valid_check -# formkey_check regen_formkey) ], -# }, newuseradmin => { function => \&newUserForm, seclev => 10000, @@ -212,71 +136,12 @@ formname => $formname, checks => [], }, -# mailpasswd => { -# function => \&mailPasswd, -# seclev => 0, -# formname => "${formname}/mp", -# checks => [ qw (max_post_check valid_check -# interval_check formkey_check ) ], -# tab_selected_1 => 'preferences', -# tab_selected_2 => 'password', -# }, validateuser => { function => \&validateUser, seclev => 1, formname => $formname, checks => ['regen_formkey'], }, - showtags => { - function => \&showTags, - seclev => 1, - formname => $formname, - checks => [], - tab_selected => 'tags', - }, - showbookmarks => { - function => \&showBookmarks, - seclev => 0, - formname => $formname, - checks => [], - tab_selected => 'bookmarks', - }, - edittags => { - function => \&editTags, - seclev => 1, - formname => $formname, - checks => [], - tab_selected => 'tags', - }, - savetags => { - function => \&saveTags, - seclev => 1, - formname => $formname, - checks => [], - tab_selected => 'tags', - }, -# userclose => { -# function => \&displayForm, -# seclev => 0, -# formname => $formname, -# checks => [], -# }, -# newuserform => { -# function => \&displayForm, -# seclev => 0, -# formname => "${formname}/nu", -# checks => [ qw (max_post_check -# generate_formkey) ], -# }, -# mailpasswdform => { -# function => \&displayForm, -# seclev => 0, -# formname => "${formname}/mp", -# checks => [ qw (max_post_check -# generate_formkey) ], -# tab_selected_1 => 'preferences', -# tab_selected_2 => 'password', -# }, displayform => { function => \&displayForm, seclev => 0, @@ -761,119 +626,6 @@ ################################################################# -sub showSubmissions { - my($hr) = @_; - my $reader = getObject('Slash::DB', { db_type => 'reader' }); - my $form = getCurrentForm(); - my $constants = getCurrentStatic(); - my $user = getCurrentUser(); - my($uid, $nickname); - - print createMenu("users", { - style => 'tabbed', - justify => 'right', - color => 'colored', - tab_selected => $hr->{tab_selected_1} || "", - }); - - if ($form->{uid} or $form->{nick}) { - $uid = $form->{uid} || $reader->getUserUID($form->{nick}); - $nickname = $reader->getUser($uid, 'nickname'); - } else { - $nickname = $user->{nickname}; - $uid = $user->{uid}; - } - - my $storycount = $reader->countStoriesBySubmitter($uid); - my $stories = $reader->getStoriesBySubmitter( - $uid, - $constants->{user_submitter_display_default} - ) unless !$storycount; - - slashDisplay('userSub', { - nick => $nickname, - uid => $uid, - nickmatch_flag => ($user->{uid} == $uid ? 1 : 0), - stories => $stories, - storycount => $storycount, - }, { Page => 'users' }); -} - -################################################################# -sub showComments { - my($hr) = @_; - my $reader = getObject('Slash::DB', { db_type => 'reader' }); - my $form = getCurrentForm(); - my $constants = getCurrentStatic(); - my $user = getCurrentUser(); - my $commentstruct = []; - my($uid, $nickname); - - my $user_edit; - if ($form->{uid} || $form->{nick}) { - $uid = $form->{uid} || $reader->getUserUID($form->{nick}); - $user_edit = $reader->getUser($uid); - } else { - $uid = $user->{uid}; - $user_edit = $user; - } - $nickname = $user_edit->{nickname}; - - print createMenu("users", { - style => 'tabbed', - justify => 'right', - color => 'colored', - tab_selected => $user_edit->{uid} == $user->{uid} ? 'me' : 'otheruser', - }); - - my $min_comment = $form->{min_comment} || 0; - $min_comment = 0 unless $user->{seclev} > $constants->{comments_more_seclev} - || $constants->{comments_more_seclev} == 2 && $user->{is_subscriber}; - my $comments_wanted = $user->{show_comments_num} - || $constants->{user_comment_display_default}; - my $commentcount = $reader->countCommentsByUID($uid); - my $comments = $reader->getCommentsByUID( - $uid, $comments_wanted, $min_comment - ) if $commentcount; - - if (ref($comments) eq 'ARRAY') { - my $kinds = $reader->getDescriptions('discussion_kinds'); - for my $comment (@$comments) { - # This works since $sid is numeric. - $comment->{replies} = $reader->countCommentsBySidPid($comment->{sid}, $comment->{cid}); - - # This is ok, since with all luck we will not be hitting the DB - # ...however, the "sid" parameter here must be the string - # based SID from either the "stories" table or from - # pollquestions. - my $discussion = $reader->getDiscussion($comment->{sid}); - - if ($kinds->{ $discussion->{dkid} } =~ /^journal(?:-story)?$/) { - $comment->{type} = 'journal'; - } elsif ($kinds->{ $discussion->{dkid} } eq 'poll') { - $comment->{type} = 'poll'; - } else { - $comment->{type} = 'story'; - } - $comment->{disc_title} = $discussion->{title}; - $comment->{url} = $discussion->{url}; - } - } - - my $mod_reader = getObject("Slash::$constants->{m1_pluginname}", { db_type => 'reader' }); - slashDisplay('userCom', { - nick => $nickname, - useredit => $user_edit, - nickmatch_flag => ($user->{uid} == $uid ? 1 : 0), - commentstruct => $comments, - commentcount => $commentcount, - min_comment => $min_comment, - reasons => $mod_reader->getReasons(), - karma_flag => 0, - admin_flag => $user->{is_admin}, - }, { Page => 'users' }); -} - sub noUser { print getData("no_user"); } @@ -1432,6 +1184,7 @@ $form->{dp} = 'firehose'; # Marquee is the "latest thing" $marquee = $users2->getMarquee($latest_comments, $latest_journals, $latest_submissions); + #$marquee = $users2->truncateMarquee($marquee); $not_fhid = $users2->getMarqueeFireHoseId($marquee); } @@ -1645,137 +1398,6 @@ } ##################################################################### -sub editTags { - my($hr) = @_; - my $slashdb = getCurrentDB(); - my $user = getCurrentUser(); - my $constants = getCurrentStatic(); - my $note = $hr->{note} || ""; - - return if $user->{is_anon}; # shouldn't be, but can't hurt to check - - print createMenu("users", { - style => 'tabbed', - justify => 'right', - color => 'colored', - tab_selected => $hr->{tab_selected_1} || "", - }); - - my $user_edit = $slashdb->getUser($user->{uid}); - my $title = getTitle('editTags_title'); - - slashDisplay('editTags', { - user_edit => $user_edit, - title => $title, - note => $note, - }); -} - -sub saveTags { - my($hr) = @_; - my $slashdb = getCurrentDB(); - my $user = getCurrentUser(); - my $form = getCurrentForm(); - my $constants = getCurrentStatic(); - - return if $user->{is_anon}; # shouldn't be, but can't hurt to check - - $slashdb->setUser($user->{uid}, { - tags_turnedoff => $form->{showtags} ? '' : 1 }); - editTags({ note => getMessage('savetags_msg') }); -} - -##################################################################### -sub showTags { - my($hr) = @_; - my $user = getCurrentUser(); - my $form = getCurrentForm(); - my $slashdb = getCurrentDB(); - my $constants = getCurrentStatic(); - my $tags_reader = getObject('Slash::Tags', { db_type => 'reader' }); - - my $tagname = $form->{tagname} || ''; - $tagname = '' if !$tags_reader->tagnameSyntaxOK($tagname); - - my($uid, $user_edit); - if ($form->{uid} || $form->{nick}) { - $uid = $form->{uid} || $tags_reader->getUserUID($form->{nick}); - $user_edit = $tags_reader->getUser($uid); - } - if (!$user_edit || $user_edit->{is_anon}) { - $uid = $user->{uid}; - $user_edit = $user; - } - my $nickname = $user_edit->{nickname}; - - if (!$constants->{plugin}{Tags}) { - print getError('bad_op', { op => $form->{op}}); - return; - } - - my $tagnameid = $tags_reader->getTagnameidFromNameIfExists($tagname); - if ($tagnameid) { - # Show all user's tags for one particular tagname. - my $tags_hr = $tags_reader->getGroupedTagsFromUser($user_edit->{uid}, - { tagnameid => $tagnameid }); - my $tags_ar = $tags_hr->{$tagname} || [ ]; - return slashDisplay('usertagsforname', { - useredit => $user_edit, - tagname => $tagname, - tags => $tags_ar, - notitle => 1, - }, { Page => 'users', Return => 1 }); - } else { - my $tags_hr = $tags_reader->getGroupedTagsFromUser($user_edit->{uid}); - my $num_tags = 0; - for my $tn (keys %$tags_hr) { - $num_tags += scalar @{ $tags_hr->{$tn} }; - } - # Show all user's tagnames, with links to show all - # tags for each particular tagname. - my $tagname_ar = [ sort keys %$tags_hr ]; - return slashDisplay('usertagnames', { - useredit => $user_edit, - tagnames => $tagname_ar, - notitle => 1, - }, { Page => 'users', Return => 1 }); - } -} - -################################################################# -sub showBookmarks { - my($hr) = @_; - my $user = getCurrentUser(); - my $form = getCurrentForm(); - my $slashdb = getCurrentDB(); - my $constants = getCurrentStatic(); - my $tags_reader = getObject('Slash::Tags', { db_type => 'reader' }); - - my($uid, $user_edit); - if ($form->{uid} || $form->{nick}) { - $uid = $form->{uid} || $tags_reader->getUserUID($form->{nick}); - $user_edit = $tags_reader->getUser($uid); - } - if (!$user_edit || $user_edit->{is_anon}) { - $uid = $user->{uid}; - $user_edit = $user; - } - my $nickname = $user_edit->{nickname}; - - if (!$constants->{plugin}{Tags}) { - print getError('bad_op', { op => $form->{op}}); - return; - } - - my $tags_ar = $tags_reader->getGroupedTagsFromUser($user_edit->{uid}, { type => "urls", only_bookmarked => 1 }); - - slashDisplay('userbookmarks', { - useredit => $user_edit, - tags_grouped => $tags_ar, - }); -} - -################################################################# sub editKey { my($uid) = @_; @@ -1814,12 +1436,6 @@ if ($form->{edituser}) { editUser($hr); - } elsif ($form->{edithome}) { - editHome($hr); - - } elsif ($form->{editcomm}) { - editComm($hr); - } elsif ($form->{changepasswd}) { changePasswd($hr); } @@ -2011,78 +1627,6 @@ } ################################################################# -sub changePasswd { - my($hr) = @_; - my $form = getCurrentForm(); - my $slashdb = getCurrentDB(); - my $user = getCurrentUser(); - my $constants = getCurrentStatic(); - - print createMenu("users", { - style => 'tabbed', - justify => 'right', - color => 'colored', - tab_selected => $hr->{tab_selected_1} || "", - }); - - my $user_edit = {}; - my $title; - my $suadmin_flag = ($user->{seclev} >= 10000) ? 1 : 0; - - my $admin_flag = ($user->{is_admin}) ? 1 : 0; - my $admin_block = ''; - - my $id = ''; - if ($admin_flag) { - if ($form->{userfield}) { - $id ||= $form->{userfield}; - if ($id =~ /^\d+$/) { - $user_edit = $slashdb->getUser($id); - } else { - $user_edit = $slashdb->getUser($slashdb->getUserUID($id)); - } - } else { - $user_edit = $id eq '' ? $user : $slashdb->getUser($id); - $id = $user_edit->{uid}; - } - } else { - $id = $user->{uid}; - $user_edit = $user; - } - - $admin_block = getUserAdmin($id, 'uid', 1) if $admin_flag; - - # print getMessage('note', { note => $form->{note}}) if $form->{note}; - - $title = getTitle('changePasswd_title', { user_edit => $user_edit }); - - my $session = $slashdb->getDescriptions('session_login'); - my $session_select = createSelect('session_login', $session, $user_edit->{session_login}, 1); - - my $clocation = $slashdb->getDescriptions('cookie_location'); - my @clocation_order = grep { exists $clocation->{$_} } qw(none classbid subnetid ipid); - my $clocation_select = createSelect('cookie_location', $clocation, - $user_edit->{cookie_location}, 1, 0, \@clocation_order - ); - - my $got_oldpass = 0; - if ($form->{oldpass}) { - my $return_uid = $slashdb->getUserAuthenticate($id, $form->{oldpass}, 1); - $got_oldpass = 1 if $return_uid && $id == $return_uid; - } - - slashDisplay('changePasswd', { - useredit => $user_edit, - admin_flag => $suadmin_flag, - title => $title, - session => $session_select, - clocation => $clocation_select, - admin_block => $admin_block, - got_oldpass => $got_oldpass - }); -} - -################################################################# sub editUser { my($hr) = @_; my $id = $hr->{uid} || ''; @@ -2146,253 +1690,6 @@ } ################################################################# -sub editHome { - my($hr) = @_; - my $id = $hr->{uid} || ''; - my $note = $hr->{note} || ''; - - my $slashdb = getCurrentDB(); - my $form = getCurrentForm(); - my $user = getCurrentUser(); - my $constants = getCurrentStatic(); - - print createMenu("users", { - style => 'tabbed', - justify => 'right', - color => 'colored', - tab_selected => $hr->{tab_selected_1} || "", - }); - - my($formats, $title, $tzformat_select); - my $user_edit = {}; - my $fieldkey; - - my $admin_flag = ($user->{is_admin}) ? 1 : 0; - my $admin_block = ''; - - if ($admin_flag && $form->{userfield}) { - $id ||= $form->{userfield}; - if ($form->{userfield} =~ /^\d+$/) { - $user_edit = $slashdb->getUser($id); - $fieldkey = 'uid'; - } else { - $user_edit = $slashdb->getUser($slashdb->getUserUID($id)); - $fieldkey = 'nickname'; - } - } else { - $user_edit = $id eq '' ? $user : $slashdb->getUser($id); - $fieldkey = 'uid'; - } -#use Data::Dumper; $Data::Dumper::Sortkeys = 1; print STDERR scalar(localtime) . " user_edit: " . Dumper($user_edit); - - return if isAnon($user_edit->{uid}) && ! $admin_flag; - $admin_block = getUserAdmin($id, $fieldkey, 1) if $admin_flag; - - $title = getTitle('editHome_title'); - - return if $user->{seclev} < 100 && isAnon($user_edit->{uid}); - - $formats = $slashdb->getDescriptions('dateformats'); - $tzformat_select = createSelect('tzformat', $formats, $user_edit->{dfid}, 1); - - my $lb_check = $user_edit->{lowbandwidth} ? $constants->{markup_checked_attribute} : ''; - my $sd_check = $user_edit->{simpledesign} ? $constants->{markup_checked_attribute} : ''; - my $i_check = $user_edit->{noicons} ? $constants->{markup_checked_attribute} : ''; - my $w_check = $user_edit->{willing} ? $constants->{markup_checked_attribute} : ''; - - my $tilde_ed = tildeEd($user_edit); - - slashDisplay('editHome', { - title => $title, - admin_block => $admin_block, - user_edit => $user_edit, - tzformat_select => $tzformat_select, - i_check => $i_check, - w_check => $w_check, - lb_check => $lb_check, - sd_check => $sd_check, - tilde_ed => $tilde_ed, - note => $note, - }); -} - -################################################################# -sub editComm { - my($hr) = @_; - my $id = $hr->{uid} || ''; - my $note = $hr->{note} || ''; - - my $slashdb = getCurrentDB(); - my $form = getCurrentForm(); - my $user = getCurrentUser(); - my $constants = getCurrentStatic(); - my $user_edit = {}; - my($formats, $commentmodes_select, $commentsort_select, $title, - $uthreshold_select, $highlightthresh_select, $posttype_select, - $bytelimit_select); - - my $admin_block = ''; - my $fieldkey; - - print createMenu("users", { - style => 'tabbed', - justify => 'right', - color => 'colored', - tab_selected => $hr->{tab_selected_1} || "", - }); - - my $admin_flag = $user->{is_admin} ? 1 : 0; - - if ($admin_flag && $form->{userfield}) { - $id ||= $form->{userfield}; - if ($form->{userfield} =~ /^\d+$/) { - $user_edit = $slashdb->getUser($id); - $fieldkey = 'uid'; - } else { - $user_edit = $slashdb->getUser($slashdb->getUserUID($id)); - $fieldkey = 'nickname'; - } - } else { - $user_edit = $id eq '' ? $user : $slashdb->getUser($id); - $fieldkey = 'uid'; - } - - my $hi = $constants->{comment_maxscore} - $constants->{comment_minscore}; - my $lo = -$hi; - my @range = map { $_ > 0 ? "+$_" : $_ } ($lo .. $hi); - - my @reasons = ( ); - my %reason_select = ( ); - if ($constants->{m1}) { - my $mod_reader = getObject("Slash::$constants->{m1_pluginname}", { db_type => 'reader' }); - my $reasons = $mod_reader->getReasons(); - for my $id (sort { $a <=> $b } keys %$reasons) { - push @reasons, $reasons->{$id}{name}; - } - # Reason modifiers - for my $reason_name (@reasons) { - my $key = "reason_alter_$reason_name"; - $reason_select{$reason_name} = createSelect( - $key, \@range, - $user_edit->{$key} || 0, 1, 1 - ); - } - } - - # Zoo relation modifiers - my %people_select; - my @people = qw(friend foe anonymous fof eof freak fan); - for (@people) { - my $key = "people_bonus_$_"; - $people_select{$_} = createSelect($key, \@range, - $user_edit->{$key} || 0, 1, 1 - ); - } - - # New-user modifier - my $new_user_bonus_select = createSelect('new_user_bonus', \@range, - $user_edit->{new_user_bonus} || 0, 1, 1); - my $new_user_percent_select = createSelect('new_user_percent', - [( 1..15, 20, 25, 30, 35, 40, 45, 50, 55, - 60, 65, 70, 75, 80, 85, 90, 95 )], - $user_edit->{new_user_percent} || 100, 1, 1); - # Karma modifier - my $karma_bonus = createSelect('karma_bonus', \@range, - $user_edit->{karma_bonus} || 0, 1, 1); - # Subscriber modifier - my $subscriber_bonus = createSelect('subscriber_bonus', \@range, - $user_edit->{subscriber_bonus} || 0, 1, 1); - - # Length modifier - my $small_length_bonus_select = createSelect('clsmall_bonus', \@range, - $user_edit->{clsmall_bonus} || 0, 1, 1); - my $long_length_bonus_select = createSelect('clbig_bonus', \@range, - $user_edit->{clbig_bonus} || 0, 1, 1); - - return if isAnon($user_edit->{uid}) && ! $admin_flag; - $admin_block = getUserAdmin($id, $fieldkey, 1) if $admin_flag; - - $title = getTitle('editComm_title'); - - $formats = $slashdb->getDescriptions('commentmodes'); - $commentmodes_select=createSelect('umode', $formats, $user_edit->{mode}, 1); - - $formats = $slashdb->getDescriptions('sortcodes'); - $commentsort_select = createSelect( - 'commentsort', $formats, $user_edit->{commentsort}, 1 - ); - - $formats = $slashdb->getDescriptions('threshcodes'); - $uthreshold_select = createSelect( - 'uthreshold', $formats, $user_edit->{threshold}, 1 - ); - - $formats = $slashdb->getDescriptions('threshcodes'); - $highlightthresh_select = createSelect( - 'highlightthresh', $formats, $user_edit->{highlightthresh}, 1 - ); - - $user_edit->{bytelimit} = $constants->{defaultbytelimit} - if $user_edit->{bytelimit} < 0 || $user_edit->{bytelimit} > 7; - my $bytelimit_desc = $user_edit->{is_subscriber} ? 'bytelimit' : 'bytelimit_sub'; - $formats = $slashdb->getDescriptions($bytelimit_desc); - $bytelimit_select = createSelect( - 'bytelimit', $formats, $user_edit->{bytelimit}, 1 - ); - - my $h_check = $user_edit->{hardthresh} ? $constants->{markup_checked_attribute} : ''; - my $r_check = $user_edit->{reparent} ? $constants->{markup_checked_attribute} : ''; - my $n_check = $user_edit->{noscores} ? $constants->{markup_checked_attribute} : ''; - my $s_check = $user_edit->{nosigs} ? $constants->{markup_checked_attribute} : ''; - my $b_check = $user_edit->{nobonus} ? $constants->{markup_checked_attribute} : ''; - my $sb_check = $user_edit->{nosubscriberbonus} ? $constants->{markup_checked_attribute} : ''; - my $p_check = $user_edit->{postanon} ? $constants->{markup_checked_attribute} : ''; - my $nospell_check = $user_edit->{no_spell} ? $constants->{markup_checked_attribute} : ''; - my $s_mod_check = $user_edit->{mod_with_comm} ? $constants->{markup_checked_attribute} : ''; - my $s_m2_check = $user_edit->{m2_with_mod} ? $constants->{markup_checked_attribute} : ''; - my $s_m2c_check = $user_edit->{m2_with_comm_mod} ? $constants->{markup_checked_attribute} : ''; - - $formats = $slashdb->getDescriptions('postmodes'); - $posttype_select = createSelect( - 'posttype', $formats, $user_edit->{posttype}, 1 - ); - - slashDisplay('editComm', { - title => $title, - admin_block => $admin_block, - user_edit => $user_edit, - h_check => $h_check, - r_check => $r_check, - n_check => $n_check, - s_check => $s_check, - b_check => $b_check, - sb_check => $sb_check, - p_check => $p_check, - s_mod_check => $s_mod_check, - s_m2_check => $s_m2_check, - s_m2c_check => $s_m2c_check, - nospell_check => $nospell_check, - commentmodes_select => $commentmodes_select, - commentsort_select => $commentsort_select, - highlightthresh_select => $highlightthresh_select, - uthreshold_select => $uthreshold_select, - posttype_select => $posttype_select, - reasons => \@reasons, - reason_select => \%reason_select, - people => \@people, - people_select => \%people_select, - new_user_percent_select => $new_user_percent_select, - new_user_bonus_select => $new_user_bonus_select, - note => $note, - karma_bonus => $karma_bonus, - subscriber_bonus => $subscriber_bonus, - small_length_bonus_select => $small_length_bonus_select, - long_length_bonus_select => $long_length_bonus_select, - bytelimit_select => $bytelimit_select, - }); -} - -################################################################# sub saveUserAdmin { my($hr) = @_; my $slashdb = getCurrentDB(); @@ -2549,92 +1846,6 @@ } ################################################################# -sub savePasswd { - my($hr) = @_; - my $note = $hr->{noteref} || undef; - - my $slashdb = getCurrentDB(); - my $form = getCurrentForm(); - my $user = getCurrentUser(); - my $constants = getCurrentStatic(); - - my $error_flag = 0; - my $user_edit = {}; - my $uid; - - my $user_edits_table = {}; - - if ($user->{is_admin}) { - $uid = $form->{uid} || $user->{uid}; - } else { - $uid = ($user->{uid} == $form->{uid}) ? $form->{uid} : $user->{uid}; - } - - $user_edit = $slashdb->getUser($uid); - - if (!$user_edit->{nickname}) { - $$note .= getError('cookie_err', { titlebar => 0 }, 0, 1) - if $note; - $error_flag++; - } - - if ($form->{pass1} ne $form->{pass2}) { - $$note .= getError('saveuser_passnomatch_err', { titlebar => 0 }, 0, 1) - if $note; - $error_flag++; - } - - if (!$form->{pass1} || length $form->{pass1} < 6) { - $$note .= getError('saveuser_passtooshort_err', { titlebar => 0 }, 0, 1) - if $note; - $error_flag++; - } - - if (!$user->{is_admin}){ - # not an admin -- check old password before changing passwd - my $return_uid = $slashdb->getUserAuthenticate($uid, $form->{oldpass}, 1); - if (!$return_uid || $return_uid != $uid) { - $$note .= getError('saveuser_badoldpass_err', { titlebar => 0 }, 0, 1) - if $note; - $error_flag++; - - } - } - - if (! $error_flag) { - $user_edits_table->{passwd} = $form->{pass1} if $form->{pass1}; - $user_edits_table->{session_login} = $form->{session_login}; - $user_edits_table->{cookie_location} = $form->{cookie_location}; - - # changed pass, so delete all logtokens - $slashdb->deleteLogToken($form->{uid}, 1); - - if ($user->{admin_clearpass} - && !$user->{state}{admin_clearpass_thisclick}) { - # User is an admin who sent their password in the clear - # some time ago; now that it's been changed, we'll forget - # about that incident, unless this click was sent in the - # clear as well. - $user_edits_table->{admin_clearpass} = ''; - } - - getOtherUserParams($user_edits_table); - $slashdb->setUser($uid, $user_edits_table) ; - $$note .= getMessage('saveuser_passchanged_msg', - { nick => $user_edit->{nickname}, uid => $user_edit->{uid} }, - 0, 1) if $note; - - # only set cookie if user is current user - if ($form->{uid} eq $user->{uid}) { - $user->{logtoken} = bakeUserCookie($uid, $slashdb->getLogToken($form->{uid}, 1)); - setCookie('user', $user->{logtoken}, $user_edits_table->{session_login}); - } - } - - return $error_flag; -} - -################################################################# sub saveUser { my($hr) = @_; my $slashdb = getCurrentDB(); @@ -2794,409 +2005,6 @@ ################################################################# -sub saveComm { - my($hr) = @_; - my $slashdb = getCurrentDB(); - my $user = getCurrentUser(); - my $form = getCurrentForm(); - my $constants = getCurrentStatic(); - my($uid, $user_fakeemail); - - if ($user->{is_admin}) { - $uid = $form->{uid} || $user->{uid}; - } else { - $uid = ($user->{uid} == $form->{uid}) ? - $form->{uid} : $user->{uid}; - } - - # Do the right thing with respect to the chosen email display mode - # and the options that can be displayed. - my $user_edit = $slashdb->getUser($uid); - my $new_fakeemail = ''; # at emaildisplay 0, don't show any email address - if ($form->{emaildisplay}) { - $new_fakeemail = getArmoredEmail($uid) if $form->{emaildisplay} == 1; - $new_fakeemail = $user_edit->{realemail} if $form->{emaildisplay} == 2; - } - - my $name = $user->{seclev} && $form->{name} ? - $form->{name} : $user->{nickname}; - - my $note = getMessage('savenickname_msg', - { nickname => $name }); - - print getError('cookie_err') if isAnon($uid) || !$name; - - # Take care of the lists - # Enforce Ranges for variables that need it - $form->{commentlimit} = 0 if $form->{commentlimit} < 1; - my $cl_max = $constants->{comment_commentlimit} || 0; - $form->{commentlimit} = $cl_max if $cl_max > 0 && $form->{commentlimit} > $cl_max; - $form->{commentspill} = 0 if $form->{commentspill} < 1; - - # For some of these values, namely the ones that we happen to - # know get stored in users_param, we change them to 'undef' - # if they are the default value. This deletes them from the - # users_param table, which has the same effect as storing the - # default except it's faster all around. If we ever change - # the schema to promote these fields from params into a - # proper users_* table, then this will no longer be correct. - # See prepareUser(). - my $max = $constants->{comment_maxscore} - $constants->{comment_minscore}; - my $min = -$max; - my $karma_bonus = ($form->{karma_bonus} !~ /^[\-+]?\d+$/) ? "+1" : $form->{karma_bonus}; - my $subscriber_bonus = ($form->{subscriber_bonus} !~ /^[\-+]?\d+$/) ? "+1" : $form->{subscriber_bonus}; - my $new_user_bonus = ($form->{new_user_bonus} !~ /^[\-+]?\d+$/) ? 0 : $form->{new_user_bonus}; - my $new_user_percent = (($form->{new_user_percent} <= 100 && $form->{new_user_percent} >= 0) - ? $form->{new_user_percent} - : 100); - my $clsmall_bonus = ($form->{clsmall_bonus} !~ /^[\-+]?\d+$/) ? 0 : $form->{clsmall_bonus}; - my $clbig_bonus = ($form->{clbig_bonus} !~ /^[\-+]?\d+$/) ? 0 : $form->{clbig_bonus}; - - my $user_edits_table = { - discussion2 => $form->{discussion2} || undef, - d2_comment_q => $form->{d2_comment_q} || undef, - d2_comment_order => $form->{d2_comment_order} || undef, - clsmall => $form->{clsmall}, - clsmall_bonus => ($clsmall_bonus || undef), - clbig => $form->{clbig}, - clbig_bonus => ($clbig_bonus || undef), - commentlimit => $form->{commentlimit}, - bytelimit => $form->{bytelimit}, - commentsort => $form->{commentsort}, - commentspill => $form->{commentspill}, - domaintags => ($form->{domaintags} != 2 ? $form->{domaintags} : undef), - emaildisplay => $form->{emaildisplay} || undef, - fakeemail => $new_fakeemail, - highlightthresh => $form->{highlightthresh}, - maxcommentsize => $form->{maxcommentsize}, - mode => $form->{umode}, - posttype => $form->{posttype}, - threshold => $form->{uthreshold}, - nosigs => ($form->{nosigs} ? 1 : 0), - reparent => ($form->{reparent} ? 1 : 0), - noscores => ($form->{noscores} ? 1 : 0), - hardthresh => ($form->{hardthresh} ? 1 : 0), - no_spell => ($form->{no_spell} ? 1 : undef), - nobonus => ($form->{nobonus} ? 1 : undef), - nosubscriberbonus => ($form->{nosubscriberbonus} ? 1 : undef), - postanon => ($form->{postanon} ? 1 : undef), - new_user_percent => ($new_user_percent && $new_user_percent != 100 - ? $new_user_percent : undef), - new_user_bonus => ($new_user_bonus || undef), - karma_bonus => ($karma_bonus ne '+1' ? $karma_bonus : undef), - subscriber_bonus => ($subscriber_bonus || undef), - textarea_rows => ($form->{textarea_rows} != $constants->{textarea_rows} - ? $form->{textarea_rows} : undef), - textarea_cols => ($form->{textarea_cols} != $constants->{textarea_cols} - ? $form->{textarea_cols} : undef), - user_comment_sort_type => ($form->{user_comment_sort_type} != 2 - ? $form->{user_comment_sort_type} : undef ), - mod_with_comm => ($form->{mod_with_comm} ? 1 : undef), - m2_with_mod => ($form->{m2_with_mod} ? 1 : undef), - m2_with_comm_mod => ($form->{m2_with_mod_on_comm} ? 1 : undef), - - }; - - # set our default values for the items where an empty-string won't do - my $defaults = { - posttype => 2, - highlightthresh => 4, - maxcommentsize => 4096, - reparent => 1, - commentlimit => 100, - commentspill => 50, - mode => 'thread' - }; - - my $mod_reader = getObject("Slash::$constants->{m1_pluginname}", { db_type => 'reader' }); - my @reasons = ( ); - my $reasons = $mod_reader->getReasons(); - for my $id (sort { $a <=> $b } keys %$reasons) { - push @reasons, $reasons->{$id}{name}; - } - - for my $reason_name (@reasons) { - my $key = "reason_alter_$reason_name"; - my $answer = $form->{$key} || 0; - $answer = 0 if !$answer || $answer !~ /^[\-+]?\d+$/; - $user_edits_table->{$key} = ($answer == 0) ? '' : $answer; - } - - for (qw| friend foe anonymous fof eof freak fan |) { - my $answer = $form->{"people_bonus_$_"}; - $answer = 0 if $answer !~ /^[\-+]?\d+$/; - $user_edits_table->{"people_bonus_$_"} = ($answer == 0) ? '' : $answer; - } - getOtherUserParams($user_edits_table); - setToDefaults($user_edits_table, {}, $defaults) if $form->{restore_defaults}; - $slashdb->setUser($uid, $user_edits_table); - - editComm({ uid => $uid, note => $note }); -} - -################################################################# -sub saveHome { - my($hr) = @_; - my $slashdb = getCurrentDB(); - my $user = getCurrentUser(); - my $form = getCurrentForm(); - my $constants = getCurrentStatic(); - my($uid, $error); - - if ($user->{is_admin}) { - $uid = $form->{uid} || $user->{uid} ; - } else { - $uid = ($user->{uid} == $form->{uid}) ? - $form->{uid} : $user->{uid}; - } - my $edit_user = $slashdb->getUser($uid); - - my $name = $user->{seclev} && $form->{name} ? - $form->{name} : $user->{nickname}; - $name = substr($name, 0, 20); - - my $note = getMessage('savenickname_msg', - { nickname => $name }); - - if (isAnon($uid) || !$name) { - my $cookiemsg = getError('cookie_err'); - print $cookiemsg; - } - - # Using the existing list of slashboxes and the set of - # what's checked and not, build up the new list. - # (New arrivals go at the end.) - my $slashboxes = $edit_user->{slashboxes}; - # Only go through all this if the user clicked save, - # not "Restore Slashbox Defaults"! - my($boxes, $skinBoxes) = $slashdb->getPortalsCommon(); - my $default_slashboxes_textlist = join ",", - @{$skinBoxes->{$constants->{mainpage_skid}}}; - if (!$form->{restore_slashbox_defaults}) { - $slashboxes = $default_slashboxes_textlist if !$slashboxes; - my @slashboxes = split /,/, $slashboxes; - my %slashboxes = ( ); - for my $i (0..$#slashboxes) { - $slashboxes{$slashboxes[$i]} = $i; - } - # Add new boxes in. - for my $key (sort grep /^showbox_/, keys %$form) { - my($bid) = $key =~ /^showbox_(\w+)$/; - next if length($bid) < 1 || length($bid) > 30 || $bid !~ /^\w+$/; - if (! exists $slashboxes{$bid}) { - $slashboxes{$bid} = 999; # put it at the end - } - } - # Remove any boxes that weren't checked. - for my $bid (@slashboxes) { - delete $slashboxes{$bid} unless $form->{"showbox_$bid"}; - } - @slashboxes = sort { - $slashboxes{$a} <=> $slashboxes{$b} - || - $a cmp $b - } keys %slashboxes; - # This probably should be a var (and appear in tilded_customize_msg) - $#slashboxes = 19 if $#slashboxes > 19; - $slashboxes = join ",", @slashboxes; - } - # If we're right back to the default, that means the - # empty string. - if ($slashboxes eq $default_slashboxes_textlist) { - $slashboxes = ""; - } - - # Set the story_never and story_always fields. - my $author_hr = $slashdb->getDescriptions('authors'); - my $tree = $slashdb->getTopicTree(); - my(@story_never_topic, @story_never_author, @story_never_nexus); - my(@story_always_topic, @story_always_author); - my(@story_always_nexus, @story_full_brief_nexus, @story_brief_always_nexus, @story_full_best_nexus, @story_brief_best_nexus); - my($story_topic_all, $story_author_all, $story_nexus_all) = (0, 0, 0); - - # Topics are either present (value=2) or absent (value=0). If absent, - # push them onto the never list. Otherwise, do nothing. (There's no - # way to have an "always" topic, at the moment.) If the hidden - # field topictids_present is false, then there are no topic tids, - # skip this. - if ($form->{topictids_present}) { - for my $tid ( - sort { $a <=> $b } - grep { !$tree->{$_}{nexus} } - keys %$tree - ) { - my $key = "topictid$tid"; - $story_topic_all++; - if (!$form->{$key}) { push @story_never_topic, $tid } - } - } - # Authors are either present (value=2) or absent (value=0). If - # absent, push them onto the never list. Otherwise, do nothing. - # (There's no way to have an "always" author, at the moment.) - for my $aid (sort { $a <=> $b } keys %$author_hr) { - my $key = "aid$aid"; - $story_author_all++; - if (!$form->{$key}) { push @story_never_author, $aid } - } - # Nexuses can have value 0, 1, 2, 3, 4, 5. - # 0 means the never list, - # 1 means brief view of mainpage articles only - # 2 means full view of mainpage articles only - # 3 means brief view of all content - # 4 means full view of mainpage content, brief view of sectional - # 5 means full view of all content - for my $tid ( - sort { $a <=> $b } - map { /^nexustid(\d+)$/; $1 } - grep { /^nexustid\d+$/ } - keys %$form - ) { - my $key = "nexustid$tid"; - next unless $tid && $tree->{$tid} && $tree->{$tid}{nexus}; - $story_nexus_all++; - if (!$form->{$key}) { push @story_never_nexus, $tid } - elsif ($form->{$key} == 5 ) { push @story_always_nexus, $tid } - elsif ($form->{$key} == 4 ) { push @story_full_brief_nexus, $tid } - elsif ($form->{$key} == 3 ) { push @story_brief_always_nexus, $tid } - elsif ($form->{$key} == 2 ) { push @story_full_best_nexus, $tid } - elsif ($form->{$key} == 1 ) { push @story_brief_best_nexus, $tid } - - - } -#use Data::Dumper; $Data::Dumper::Sortkeys = 1; print STDERR scalar(localtime) . " s_n_t '@story_never_topic' s_n_a '@story_never_author' s_n_n '@story_never_nexus' s_a_n '@story_always_nexus' form: " . Dumper($form); - # Sanity check. - $#story_never_topic = 299 if $#story_never_topic > 299; - $#story_never_author = 299 if $#story_never_author > 299; - $#story_never_nexus = 299 if $#story_never_nexus > 299; - $#story_always_topic = 299 if $#story_always_topic > 299; - $#story_always_author = 299 if $#story_always_author > 299; - $#story_always_nexus = 299 if $#story_always_nexus > 299; - $#story_full_brief_nexus = 299 if $#story_full_brief_nexus > 299; - $#story_brief_always_nexus = 299 if $#story_brief_always_nexus > 299; - $#story_brief_best_nexus = 299 if $#story_brief_best_nexus > 299; - $#story_full_best_nexus = 299 if $#story_full_best_nexus > 299; - - my $story_never_topic = join ",", @story_never_topic; - $story_never_topic = ($constants->{subscribe} && $user->{is_subscriber}) - ? checkList($story_never_topic, 1024) - : checkList($story_never_topic); - my $story_never_author = checkList(join ",", @story_never_author); - my $story_never_nexus = checkList(join ",", @story_never_nexus); - my $story_always_topic = checkList(join ",", @story_always_topic); - $story_always_topic = ($constants->{subscribe} && $user->{is_subscriber}) - ? checkList($story_always_topic, 1024) - : checkList($story_always_topic); - my $story_always_author = checkList(join ",", @story_always_author); - - my $story_always_nexus = checkList(join ",", @story_always_nexus); - my $story_full_brief_nexus = checkList(join ",", @story_full_brief_nexus); - my $story_brief_always_nexus = checkList(join ",", @story_brief_always_nexus); - my $story_brief_best_nexus = checkList(join ",", @story_brief_best_nexus); - my $story_full_best_nexus = checkList(join ",", @story_full_best_nexus); - - - my $user_edits_table = { - story_never_topic => $story_never_topic, - story_never_author => $story_never_author, - story_never_nexus => $story_never_nexus, - story_always_topic => $story_always_topic, - story_always_author => $story_always_author, - story_always_nexus => $story_always_nexus, - story_brief_always_nexus => $story_brief_always_nexus, - story_full_brief_nexus => $story_full_brief_nexus, - story_full_best_nexus => $story_full_best_nexus, - story_brief_best_nexus => $story_brief_best_nexus, - - slashboxes => checkList($slashboxes, 1024), - - maxstories => 30, # XXXSKIN fix this later - noboxes => ($form->{useslashboxes} ? 0 : 1), - lowbandwidth => ($form->{lowbandwidth} ? 1 : 0), - simpledesign => ($form->{simpledesign} ? 1 : 0), - noicons => ($form->{noicons} ? 1 : 0), - willing => ($form->{willing} ? 1 : 0), - }; - - if (defined $form->{tzcode} && defined $form->{tzformat}) { - $user_edits_table->{tzcode} = $form->{tzcode}; - $user_edits_table->{dfid} = $form->{tzformat}; - $user_edits_table->{dst} = $form->{dst}; - } - - # Force the User Space area to contain only known-good HTML tags. - # Unfortunately the cookie login model makes it just too risky - # to allow scripts in here; CSS's steal passwords. There are - # no known vulnerabilities at this time, but a combination of the - # social engineering taking place (inviting users to put Javascript - # from websites in here, and making available script URLs for that - # purpose), plus the fact that this could be used to amplify the - # seriousness of any future vulnerabilities, means it's way past - # time to shut this feature down. - Jamie 2002/03/06 - - # it's a VARCHAR ... - my $mylinks_limit = 255; - $user_edits_table->{mylinks} = balanceTags(strip_html( - chopEntity($form->{mylinks} || '', $mylinks_limit) - ), { deep_nesting => 2, length => $mylinks_limit }); - - $user_edits_table->{mylinks} = '' unless defined $user_edits_table->{mylinks}; - - $error = 1; - # must select at least 1/4 of nexuses, topics, authors - if ( scalar(@story_never_author) > ($story_author_all * 3/4) ) { - $note = getError('editHome_too_many_disabled'); - } elsif ( scalar(@story_never_nexus) > ($story_nexus_all * 3/4) ) { - $note = getError('editHome_too_many_disabled'); - } elsif ( scalar(@story_never_topic) > ($story_topic_all * 3/4) ) { - $note = getError('editHome_too_many_disabled'); - } else { - $error = 0; - } - - unless ($error) { - # If a user is unwilling to moderate, we should cancel all points, lest - # they be preserved when they shouldn't be. - if (!isAnon($uid) && !$form->{willing}) { - $slashdb->setUser($uid, { points => 0 }); - } - - getOtherUserParams($user_edits_table); - if ($form->{restore_defaults}) { - setToDefaults($user_edits_table, {}, { - maxstories => 30, - tzcode => "EST", - # XXX shouldn't this reset ALL the defaults, - # not just these two? - }); - } - if ($form->{restore_slashbox_defaults}) { - setToDefaults($user_edits_table, { - 'story_never_topic' => 1, - 'story_never_author' => 1, - 'story_never_nexus' => 1, - 'story_always_topic' => 1, - 'story_always_author' => 1, - 'story_always_nexus' => 1, - 'story_full_brief_nexus' => 1, - 'story_brief_always_nexus' => 1, - 'story_full_best_nexus' => 1, - 'story_brief_best_nexus' => 1, - 'maxstories' => 1, - 'noboxes' => 1, - 'light' => 1, - 'noicons' => 1, - 'willing' => 1 - }, { slashboxes => "" }); - } - -#print scalar(localtime) . " uet: " . Dumper($user_edits_table); - $slashdb->setUser($uid, $user_edits_table); - } - - editHome({ uid => $uid, note => $note }); -} - -################################################################# # A generic way for a site to allow users to edit data about themselves. # Most useful when your plugin or theme wants to let the user change # minor settings but you don't want to write a whole new version Modified: slashjp/branches/upstream/current/themes/slashcode/templates/u2AdminListComments;users;default =================================================================== --- slashjp/branches/upstream/current/themes/slashcode/templates/u2AdminListComments;users;default 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/themes/slashcode/templates/u2AdminListComments;users;default 2008-12-16 03:30:11 UTC (rev 884) @@ -70,7 +70,7 @@ [% PROCESS titlebar width="100%" title = commenttitle max_min_button = extra -%] [% max_min_button = "" %] [% END %] - <table width="100%" border="0" cellpadding="3" cellspacing="0" class="data"> + <table width="98%" border="0" cellpadding="3" cellspacing="0" class="data listComments"> <tr class="data_head"> [% IF type=="netid"; total_cols = total_cols + 1; %]<th>User</th>[% END %] <th>Subject[% IF admin_flag %]<span class="admin_data_label"> / Moderator</span>[% END %]</th> Modified: slashjp/branches/upstream/current/themes/slashcode/templates/u2ListComments;users;default =================================================================== --- slashjp/branches/upstream/current/themes/slashcode/templates/u2ListComments;users;default 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/themes/slashcode/templates/u2ListComments;users;default 2008-12-16 03:30:11 UTC (rev 884) @@ -69,7 +69,7 @@ %] [% max_min_button = "" %] [% END %] - <table width="100%" border="0" cellpadding="3" cellspacing="0" class="data"> + <table class="data listComments"> <tr> [% IF type=="netid"; total_cols = total_cols + 1; %]<th>User</th>[% END %] <th>Subject[% IF admin_flag %]<span class="admin_data_label"> / Moderator</span>[% END %]</th> Modified: slashjp/branches/upstream/current/themes/slashcode/templates/u2MainView;users;default =================================================================== --- slashjp/branches/upstream/current/themes/slashcode/templates/u2MainView;users;default 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/themes/slashcode/templates/u2MainView;users;default 2008-12-16 03:30:11 UTC (rev 884) @@ -16,16 +16,35 @@ [% IF main_view %] <div class="head"> - <div class="yui-b"> - [% PROCESS u2UserBio useredit=useredit %] - </div> + <div class="yui-b"> + [% PROCESS u2UserBio useredit=useredit %] + </div> - <div class="article" id="marquee_content"> - <h3>[% marquee.subject %]</h3> - <div class="body"> - [% marquee.body %] - </div> - </div> + <div class="article" id="marquee_content"> + [% IF !marquee.body %] + <h3>[% useredit.nickname | strip_literal %] doesn't seem to be particularly active.</h3> + [% ELSE %] + <h3>[% marquee.subject %]</h3> + <div class="body"> + [% marquee.body %] + [% IF marquee.truncated %] ...<p>[% END %] + </div> + [% END %] + + [% + '<br><a href="'; + + IF marquee.type == 'journal'; + constants.real_rootdir; '/~'; useredit.nickname | strip_paramattr; '/journal/'; marquee.id; + ELSIF marquee.type == 'submission'; + gSkin.rootdir; '/firehose.pl?op=view&id='; marquee.id; + ELSIF marquee.type == 'comment'; + gSkin.rootdir; '/comments.pl?sid='; marquee.sid; '&cid='; marquee.id; + END; + + '">Read More</a>'; + %] + </div> </div> [% END %] Modified: slashjp/branches/upstream/current/themes/slashcode/templates/u2Menu;users;default =================================================================== --- slashjp/branches/upstream/current/themes/slashcode/templates/u2Menu;users;default 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/themes/slashcode/templates/u2Menu;users;default 2008-12-16 03:30:11 UTC (rev 884) @@ -15,14 +15,14 @@ [% tilde = '^'; IF constants.u2; tilde = '~'; END; %] <div class="nav"> <ul class="menu" id="tablist"> -<li[% IF main_view %] class="active"[% END %]><a href="[% gSkin.rootdir %]/[% tilde; nickname | strip_paramattr %]">[% nickname | strip_literal %]</a></li> -<li[% IF data_pane == 'firehose' && !main_view %] class="active"[% END %]><a href="[% gSkin.rootdir %]/[% tilde; nickname | strip_paramattr %]/firehose">Firehose</a></li> +<li[% IF main_view %] class="active"[% active = 1; ELSE; active = 0; END %]><a href="[% gSkin.rootdir %]/[% tilde; nickname | strip_paramattr %]">[% nickname | strip_literal %]</a>[% IF active; PROCESS u2_rsslink useredit=useredit name="firehose"; END %]</li> +<li[% IF data_pane == 'firehose' && !main_view %] class="active"[% active=1; ELSE; active = 0; END %]><a href="[% gSkin.rootdir %]/[% tilde; nickname | strip_paramattr %]/firehose">Firehose</a>[% IF active; PROCESS u2_rsslink useredit=useredit name="firehose"; END;%]</li> [% IF comments_size != 0 %]<li[% IF data_pane == 'comments' %] class="active"[% END %]><a href="[% gSkin.rootdir %]/[% tilde; nickname | strip_paramattr %]/comments">Comments</a></li>[% END %] -[% IF journals_size != 0 %]<li[% IF data_pane == 'journal' %] class="active"[% END %]><a href="[% gSkin.rootdir %]/[% tilde; nickname | strip_paramattr %]/journal">Journals</a></li>[% END %] -[% IF submissions_size != 0 %]<li[% IF data_pane == 'submissions' %] class="active"[% END %]><a href="[% gSkin.rootdir %]/[% tilde; nickname | strip_paramattr %]/submissions">Submissions</a></li>[% END %] -[% IF bookmarks_size != 0 %]<li[% IF data_pane == 'bookmarks' %] class="active"[% END %]><a href="[% gSkin.rootdir %]/[% tilde; nickname | strip_paramattr %]/bookmarks">Bookmarks</a></li>[% END %] +[% IF journals_size != 0 %]<li[% IF data_pane == 'journal' %] class="active"[% active = 1; ELSE; active=0; END %]><a href="[% gSkin.rootdir %]/[% tilde; nickname | strip_paramattr %]/journal">Journals</a> [% IF active; PROCESS u2_rsslink useredit=useredit name="journal"; END; %]</li>[% END %] +[% IF submissions_size != 0 %]<li[% IF data_pane == 'submissions' %] class="active"[% active = 1; ELSE; active=0; END %]><a href="[% gSkin.rootdir %]/[% tilde; nickname | strip_paramattr %]/submissions">Submissions</a>[% IF active; PROCESS u2_rsslink useredit=useredit name="submissions"; END %]</li>[% END %] +[% IF bookmarks_size != 0 %]<li[% IF data_pane == 'bookmarks' %] class="active"[% active = 1; ELSE; active=0; END %]><a href="[% gSkin.rootdir %]/[% tilde; nickname | strip_paramattr %]/bookmarks">Bookmarks</a>[% IF active; PROCESS u2_rsslink useredit=useredit name="bookmarks"; END %]</li>[% END %] <li[% IF data_pane == 'friends' %] class="active"[% END %]><a href="[% gSkin.rootdir %]/[% tilde; nickname | strip_paramattr %]/friends">Friends</a></li> -[% IF tagshist_size > 2 || data_pane == "usertag" %]<li[% IF data_pane == 'tags' || data_pane == 'usertag' %] class="active"[% END %]><a href="[% gSkin.rootdir %]/[% tilde; nickname | strip_paramattr %]/tags">Tags</a></li>[% END %] +[% IF tagshist_size > 2 || data_pane == "usertag" %]<li[% IF data_pane == 'tags' || data_pane == 'usertag' %] class="active"[% END %]><a href="[% gSkin.rootdir %]/[% tilde; nickname | strip_paramattr %]/tags">Tags</a>[% IF data_pane == 'usertag'; PROCESS u2_rsslink useredit=useredit name="usertag"; END; %]</li>[% END %] [% IF is_admin %]<li[% IF data_pane == 'admin' %] class="active"[% END %]><a href="[% gSkin.rootdir %]/[% tilde; nickname | strip_paramattr %]/admin">Admin</a></li>[% END %] </ul> </div> Modified: slashjp/branches/upstream/current/themes/slashcode/templates/u2UserBoxes;users;default =================================================================== --- slashjp/branches/upstream/current/themes/slashcode/templates/u2UserBoxes;users;default 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/themes/slashcode/templates/u2UserBoxes;users;default 2008-12-16 03:30:11 UTC (rev 884) @@ -21,7 +21,7 @@ <div class="content" id="latest_comments_content"> <ul> - [% FOREACH cid = latest_comments.keys.sort %] + [% FOREACH cid = latest_comments.keys.sort.reverse %] [% reason_num = ''; reason_text = ''; @@ -54,7 +54,7 @@ </div> <div class="content" id="latest_journals_content"> <ul> - [% FOREACH jid = latest_journals.keys.sort %] + [% FOREACH jid = latest_journals.keys.sort.reverse %] <li><a href="[% constants.real_rootdir %]/~[% useredit.nickname | strip_paramattr %]/journal/[% latest_journals.$jid.id %]">[% latest_journals.$jid.description %]</a><br></li> [% END %] </ul> @@ -70,7 +70,7 @@ <div class="content" id="latest_submissions_content"> <ul> - [% FOREACH sid = latest_submissions.keys.sort %] + [% FOREACH sid = latest_submissions.keys.sort.reverse %] <li><a href="[% gSkin.rootdir %]/firehose.pl?op=view&id=[% latest_submissions.$sid.id %]">[% latest_submissions.$sid.title %]</a></li> [% END %] </ul> Added: slashjp/branches/upstream/current/themes/slashcode/templates/u2_rsslink;users;default =================================================================== --- slashjp/branches/upstream/current/themes/slashcode/templates/u2_rsslink;users;default (rev 0) +++ slashjp/branches/upstream/current/themes/slashcode/templates/u2_rsslink;users;default 2008-12-16 03:30:11 UTC (rev 884) @@ -0,0 +1,39 @@ +__section__ +default +__description__ +You should describe stuff here. +__title__ +Useless title to template +__page__ +users +__lang__ +en_US +__name__ +u2_rsslink +__seclev__ +10000 +__template__ +[% IF !user.is_anon; + filter_str = ""; + IF name == "journal"; + filter = '"author: ' _ useredit.nickname _ '" journal'; + ELSIF name == "journalfriends"; + filter = '"authorfriend: ' _ useredit.nickname _ '" journal'; + ELSIF name == "submissions"; + filter = '"author: ' _ useredit.nickname _ '" submission'; + ELSIF name == "bookmarks"; + filter = '"user: ' _ useredit.nickname _ '" bookmark'; + ELSIF name == "firehose"; + filter = '"user: ' _ useredit.nickname _ '"'; + ELSIF name == "usertag"; + filter = '"user: ' _ useredit.nickname _ '" "tag:' _ form.tagname _ '"'; + END; + + filter_str = "fhfilter=" _ Slash.strip_paramattr(filter); + + rss_param_str = "&orderdir=DESC&orderby=createtime&color=black&duration=-1&startdate="; + rss_param_str = filter_str _ rss_param_str; + rss_link = Slash.root2abs() _ "/firehose.pl?op=rss&content_type=rss&" _ rss_param_str _ "&logtoken=" _ Slash.strip_paramattr(Slash.getPublicLogToken()); + %] + <a href="[% rss_link %]"><img src="[% constants.imagedir %]/feed.png" alt="RSS for [% alt %]"></a> +[% END %] Modified: slashjp/branches/upstream/current/themes/slashcode/templates/user_titlebar;misc;default =================================================================== --- slashjp/branches/upstream/current/themes/slashcode/templates/user_titlebar;misc;default 2008-12-15 09:15:10 UTC (rev 883) +++ slashjp/branches/upstream/current/themes/slashcode/templates/user_titlebar;misc;default 2008-12-16 03:30:11 UTC (rev 884) @@ -55,7 +55,7 @@ { link = "$constants.real_rootdir/my/freaks/", label = "Freaks", sel_label = "freaks" }, ); END; IF constants.plugin.Tags; tabs.push( - { link = "$constants.real_rootdir/my/tags/", label = "Tags", sel_label = "tags" }, + { link = "$constants.real_rootdir/~$url_nick/tags/", label = "Tags", sel_label = "tags" }, ); END; IF constants.plugin.Bookmark; tabs.push( { link = "$constants.real_rootdir/my/bookmarks/", label = "Bookmarks", sel_label = "bookmarks" }, Added: slashjp/branches/upstream/current/utils/import_comments_firehose =================================================================== --- slashjp/branches/upstream/current/utils/import_comments_firehose (rev 0) +++ slashjp/branches/upstream/current/utils/import_comments_firehose 2008-12-16 03:30:11 UTC (rev 884) @@ -0,0 +1,112 @@ +#!/usr/bin/perl +use warnings; +use strict; + +use Slash::Test shift || 'slash'; + +my $slashdb = getCurrentDB(); +my $firehose = getObject("Slash::FireHose"); +my $tags = getObject("Slash::Tags"); + +my $log_loc; # set to something to log inserts +my $sleep = 0; # time to pause between inserts +my $v = 0; # Switch to true for verbose output +my $calc_pause = 0; # Switch to true to recalculate sleep interval by tagbox backlog + +my $days_back = 30; # Number of days of history to import + + +my $cids = $slashdb->sqlSelectColArrayref("cid","comments","uid!=666 AND date >DATE_SUB(NOW(), INTERVAL $days_back DAY)", "ORDER BY DATE DESC"); + +print "Total cids left: " . scalar(@$cids) ."\n"; + +my ($lastlog, $comments_added) = (0,0); + + +foreach my $cid(@$cids) { + my ($added_tag, $added_comment); + my $comment = $slashdb->getComment($cid); + my $item = $firehose->getFireHoseByTypeSrcid("comment", $cid); + if($item && $item->{id}) { + my $up_id = $tags->getTagnameidFromNameIfExists("nod"); + my $has_nod = $slashdb->sqlCount("tags", "uid=$comment->{uid} AND tagnameid=$up_id AND globjid=$item->{globjid}"); + print "HAS NOD: $has_nod $comment->{date}\n" if $v; + if (!$has_nod) { + my $tagid = $tags->createTag({ + uid => $comment->{uid}, + name => "nod", + globjid => $item->{globjid}, + private => 1, + }); + print "ADDING NOD $item->{globjid} TAGID: $tagid\n" if $v; + $added_tag = 1; + } + } else { + print "ADDING COMMENT $comment->{date}\n" if $v; + $added_comment = 1; + $comments_added++; + $firehose->createUpdateItemFromComment($comment->{cid}); + if ($log_loc) { + open LOG, ">>$log_loc"; + print LOG "$comment->{cid} $comment->{date}\n"; + close LOG; + } + } + + if (time - $lastlog > 60) { + $lastlog = time; + my $new_sleep = $sleep; + my $secs_back = get_secs_back(); + my $feeder_back = get_feeder_back(); + $feeder_back = int($feeder_back / 1000); + print "SECS BACK: $secs_back\n" if $v; + print "FEEDER BACK: $feeder_back\n" if $v; + + if($calc_pause) { + if ($secs_back < 2) { + $new_sleep = 0 + } elsif($secs_back < 2 ) { + $new_sleep = 1 + } elsif($secs_back < 4 ) { + $new_sleep = 3 + } elsif($secs_back < 6 ) { + $new_sleep = 4 + } elsif($secs_back < 10 ) { + $new_sleep = 5 + } else { + if ($sleep <= 10) { + $new_sleep = 10 + } else { + $new_sleep = $sleep +1 if $sleep < 20; + } + } + + my $feeder_penalty = 0; + + if ($feeder_back > 25) { + $feeder_penalty = int(($feeder_back - 25) / 5); + print "FEEDER PENALTY: $feeder_penalty\n" if $v; + } + $new_sleep += $feeder_penalty; + } + + print "$comment->{date} ADDED $comments_added BEHIND = $secs_back FB= $feeder_back SLEEP $sleep -> $new_sleep\n"; + $sleep = $new_sleep; + } + + if($added_tag || $added_comment) { + print "SLEEPING $sleep\n" if $v; + sleep $sleep; + } + + + +} + +sub get_secs_back { + return $slashdb->sqlSelect("(select unix_timestamp(created_at) from tags where tagid=(select max(tagid) from tags)) - (select unix_timestamp(created_at) from tags where tagid=(select min(last_tagid_logged) from tagboxes))"); +} + +sub get_feeder_back { + return $slashdb->sqlCount("tagboxlog_feeder"); +}