Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

New userboxes for article and users.pl display. New lastlooktime param

for users and lastlookmemory var to make "otheruser" tab temporary.
Also added function to the API, "ellipsify".
  • Loading branch information...
commit 1784c1e09070540a95fb905c55ddc86b355d9ffd 1 parent d5b0ddb
@jamiemccarthy jamiemccarthy authored
View
11 Slash/Slash.pm
@@ -813,16 +813,7 @@ EOT
}
# we need a display-friendly fakeemail string
- $comment->{fakeemail_vis} = $comment->{fakeemail};
- my $mel = $constants->{comments_max_email_len};
- if (length($comment->{fakeemail}) > $mel) {
- my $mel2 = int(($mel-5)/2);
- $comment->{fakeemail_vis} =
- substr($comment->{fakeemail}, 0, $mel2)
- . " ... "
- . substr($comment->{fakeemail}, -$mel2, $mel2)
- if $mel2 > 3;
- }
+ $comment->{fakeemail_vis} = ellipsify($comment->{fakeemail});
return _hard_dispComment(
$comment, $constants, $user, $form, $comment_shrunk,
View
55 Slash/Utility/Data/Data.pm
@@ -53,6 +53,7 @@ use vars qw($VERSION @EXPORT);
chopEntity
countWords
decode_entities
+ ellipsify
encryptPassword
findWords
fixHref
@@ -2425,6 +2426,60 @@ sub vislenify {
#========================================================================
+=head2 ellipsify (TEXT [, LEN])
+
+Given any text, makes sure it's not too long by shrinking its
+length to at most LEN, putting an ellipse in the middle. If the
+LEN is too short to allow an ellipse in the middle, it just does
+an ellipse at the end, or in the worst case, a substr.
+
+=over 4
+
+=item Parameters
+
+=over 4
+
+=item TEXT
+
+Any text.
+
+=item LEN
+
+Usually not necessary; if present, overrides the var
+comments_max_email_len (email is what this function was designed to
+work on).
+
+=back
+
+=item Return value
+
+New value.
+
+=back
+
+=cut
+
+sub ellipsify {
+ my($text, $len) = @_;
+ $len ||= getCurrentStatic('comments_max_email_len') || 40;
+ if (length($text) > $len) {
+ my $len2 = int(($len-7)/2);
+ if ($len2 >= 4) {
+ $text = substr($text, 0, $len2)
+ . " ... "
+ . substr($text, -$len2);
+ } elsif ($len >= 8) {
+ $text = substr($text, 0, $len-4)
+ . " ...";
+ } else {
+ $text = substr($text, 0, $len);
+ }
+ }
+ return $text;
+}
+
+#========================================================================
+
=head2 getArmoredEmail (UID)
Returns a Spam Armored email address for the user associated with the
View
4 Slash/Utility/Display/Display.pm
@@ -1018,7 +1018,9 @@ sub createMenu {
if ($menu eq 'users'
&& $user->{lastlookuid}
&& $user->{lastlookuid} =~ /^\d+$/
- && $user->{lastlookuid} != $user->{uid}) {
+ && $user->{lastlookuid} != $user->{uid}
+ && ($user->{lastlooktime} || 0) >= time - ($constants->{lastlookmemory} || 3600)
+ ) {
my $lastlook_user = $slashdb->getUser($user->{lastlookuid});
my $nick_fix = fixparam($lastlook_user->{nickname});
my $nick_attribute = strip_attribute($lastlook_user->{nickname});
View
2  plugins/Journal/journal.pl
@@ -347,7 +347,9 @@ sub displayArticle {
# Store the fact that this user last looked at that user.
# For maximal convenience in stalking.
$user_change->{lastlookuid} = $uid;
+ $user_change->{lastlooktime} = time;
$user->{lastlookuid} = $uid;
+ $user->{lastlooktime} = time;
}
} else {
$nickname = $user->{nickname};
View
16 plugins/Zoo/zoo.pl
@@ -152,7 +152,9 @@ sub friends {
# Store the fact that this user last looked at that user.
# For maximal convenience in stalking.
$user_change->{lastlookuid} = $uid;
+ $user_change->{lastlooktime} = time;
$user->{lastlookuid} = $uid;
+ $user->{lastlooktime} = time;
}
my $editable = ($uid == $user->{uid} ? 1 : 0);
@@ -219,7 +221,9 @@ sub fof {
# Store the fact that this user last looked at that user.
# For maximal convenience in stalking.
$user_change->{lastlookuid} = $uid;
+ $user_change->{lastlooktime} = time;
$user->{lastlookuid} = $uid;
+ $user->{lastlooktime} = time;
}
my $editable = ($uid == $user->{uid} ? 1 : 0);
@@ -286,7 +290,9 @@ sub enof {
# Store the fact that this user last looked at that user.
# For maximal convenience in stalking.
$user_change->{lastlookuid} = $uid;
+ $user_change->{lastlooktime} = time;
$user->{lastlookuid} = $uid;
+ $user->{lastlooktime} = time;
}
my $editable = ($uid == $user->{uid} ? 1 : 0);
@@ -348,7 +354,9 @@ sub foes {
# Store the fact that this user last looked at that user.
# For maximal convenience in stalking.
$user_change->{lastlookuid} = $uid;
+ $user_change->{lastlooktime} = time;
$user->{lastlookuid} = $uid;
+ $user->{lastlooktime} = time;
}
my $editable = ($uid == $user->{uid} ? 1 : 0);
@@ -410,7 +418,9 @@ sub fans {
# Store the fact that this user last looked at that user.
# For maximal convenience in stalking.
$user_change->{lastlookuid} = $uid;
+ $user_change->{lastlooktime} = time;
$user->{lastlookuid} = $uid;
+ $user->{lastlooktime} = time;
}
my $editable = ($uid == $user->{uid} ? 1 : 0);
@@ -470,7 +480,9 @@ sub freaks {
# Store the fact that this user last looked at that user.
# For maximal convenience in stalking.
$user_change->{lastlookuid} = $uid;
+ $user_change->{lastlooktime} = time;
$user->{lastlookuid} = $uid;
+ $user->{lastlooktime} = time;
}
my $editable = ($uid == $user->{uid} ? 1 : 0);
@@ -532,7 +544,9 @@ sub all {
# Store the fact that this user last looked at that user.
# For maximal convenience in stalking.
$user_change->{lastlookuid} = $uid;
+ $user_change->{lastlooktime} = time;
$user->{lastlookuid} = $uid;
+ $user->{lastlooktime} = time;
}
my $editable = ($uid == $user->{uid} ? 1 : 0);
@@ -627,7 +641,9 @@ sub check {
# Store the fact that this user last looked at that user.
# For maximal convenience in stalking.
$user_change->{lastlookuid} = $uid;
+ $user_change->{lastlooktime} = time;
$user->{lastlookuid} = $uid;
+ $user->{lastlooktime} = time;
}
_printHead("confirm", {
nickname => $nickname,
View
1  sql/mysql/defaults.sql
@@ -715,6 +715,7 @@ INSERT INTO vars (name, value, description) VALUES ('istroll_uid_hours','72','Ho
INSERT INTO vars (name, value, description) VALUES ('karma_adj','-10=Terrible|-1=Bad|0=Neutral|12=Positive|25=Good|99999=Excellent','Adjectives that describe karma, used if karma_obfuscate is set (best to keep aligned with badkarma, m2_maxbonus_karma, and goodkarma)');
INSERT INTO vars (name, value, description) VALUES ('karma_obfuscate','0','Should users see, not their numeric karma score, but instead an adjective describing their approximate karma?');
INSERT INTO vars (name, value, description) VALUES ('label_ui','0','Whether to label some things in the admin ui');
+INSERT INTO vars (name, value, description) VALUES ('lastlookmemory','3600','Amount of time the uid last looked-at will be remembered/displayed');
INSERT INTO vars (name, value, description) VALUES ('lastComments','0','Last time we checked comments for moderation points');
INSERT INTO vars (name, value, description) VALUES ('lastsrandsec','awards','Last Block used in the semi-random block');
INSERT INTO vars (name, value, description) VALUES ('lenient_formkeys','0','0 - only ipid, 1 - ipid OR subnetid, in formkey validation check');
View
8 sql/mysql/upgrades
@@ -1152,3 +1152,11 @@ INSERT INTO vars (name, value, description) VALUES ('m2_modlogid_max_old','0','A
INSERT INTO vars (name, value, description) VALUES ('m2_modlogid_min_new','0','Approximate min moderatorlog id that counts as new');
INSERT INTO vars (name, value, description) VALUES ('m2_modlogid_max_new','0','Approximate max moderatorlog id');
+INSERT INTO vars (name, value, description) VALUES ('lastlookmemory','3600','Amount of time the uid last looked-at will be remembered/displayed');
+
+# Not really necessary to do this, it will only make a difference for a
+# short time anyway and may add many rows to users_param... but for any
+# sites that want to, feel free.
+# SELECT CONCAT("INSERT INTO users_param (uid, name, value) VALUES (", uid, ", 'lastlooktime', ", UNIX_TIMESTAMP(NOW()), ")") INTO OUTFILE '/tmp/lastlooktime' FROM users_param WHERE name='lastlookuid' ORDER BY uid;
+# SOURCE '/tmp/lastlooktime';
+
View
2  themes/slashcode/THEME
@@ -147,6 +147,7 @@ template=templates/index;index;default
template=templates/index;index;light
template=templates/info;menu;default
template=templates/isEligible;metamod;default
+template=templates/karma;misc;default
template=templates/linkComment;misc;default
template=templates/linkCommentPages;misc;default
template=templates/linkStory;misc;default
@@ -212,6 +213,7 @@ template=templates/topTopics;topics;default
template=templates/topics;menu;default
template=templates/udiscuss_list;comments;default
template=templates/undo_mod;comments;default
+template=templates/userboxes;misc;default
template=templates/userCom;users;default
template=templates/userInfo;users;default
template=templates/userSub;users;default
View
2  themes/slashcode/htdocs/users.pl
@@ -905,7 +905,9 @@ sub showInfo {
# Store the fact that this user last looked at that user.
# For maximal convenience in stalking.
$user_change->{lastlookuid} = $uid;
+ $user_change->{lastlooktime} = time;
$user->{lastlookuid} = $uid;
+ $user->{lastlooktime} = time;
$hr->{tab_selected_1} = 'otheruser';
}
View
70 themes/slashcode/templates/display;article;default
@@ -20,13 +20,12 @@ en_US
__name__
display
__template__
-[% USE Slash %]
+[% USE Slash;
-[% data = Slash.displayStory(story.sid, 'Full'); data.0 %]
+data = Slash.displayStory(story.sid, 'Full'); data.0;
-[% IF form.refresh %]
+IF form.refresh %]
<FONT COLOR="white" SIZE="1">How Refreshing! ([% form.sid %]) </FONT>
-
[% END %]
<P>
@@ -36,66 +35,21 @@ __template__
[% IF n %] [% IF p %] | [% END %][% n %] &nbsp;&gt; [% END %]
<P>&nbsp;</TD><TD>&nbsp;</TD><TD WIDTH="210" ALIGN="RIGHT" VALIGN="TOP">
-[% # -- User's Article Box. %]
-[% IF user.is_anon;
- # User is anonymous
- contents = BLOCK;
- PROCESS userlogin
- return_url = "${constants.rootdir}/article.pl?sid=${form.sid}";
- END;
- PROCESS fancybox
- title = "${constants.sitename} Login"
- contents = contents
- center = 1;
-ELSE;
- # User is logged in.
- M = BLOCK %][ <A HREF="[% constants.rootdir %]/my/homepage/">Preferences</A>[% END %]
- [% IF user.seclev > 99 && user.uid;
- M = BLOCK %]
-[% M %] | <A HREF="[% constants.rootdir %]/admin.pl">Admin</A> |
- <A HREF="[% constants.rootdir %]/admin.pl?op=edit&amp;sid=[% story.sid %]">Editor</A>
- [% END;
- END;
- M = "$M ]<P>\n";
- IF user.points || user.seclev > 99;
- M = BLOCK %]
-[% M %]<A HREF="[% constants.rootdir %]/~[% user.nickname | fixparam %]/">You</A> have moderator access and
-<B>[% user.points %]</B> point[% user.points == 1 ? '' : 's' %].
-Welcome to those of you just joining: <B>please</B>
-read the <A HREF="[% constants.rootdir %]/moderation.shtml">moderator guidelines</A>
-for instructions. (<B>updated 9.9!</B>)
-
-<P>
-
-&middot; You can't post & moderate the same discussion.
-<BR>&middot; Concentrate on Promoting more than Demoting.
-<BR>&middot; Browse at -1 to keep an eye out for abuses.
-<BR>&middot; <A HREF="mailto:[% constants.adminmail %]">Mail the admin</A> URLs showing abuse
-(the cid link please!).
- [% END;
- END;
- M = "$M<P> $user.mylinks ";
- # User can be logged in as both a regular user and author. This box should probably
- # show both names to make the user aware.
- name = user.nickname;
- IF user.uid; name = "$name &nbsp;($user.uid)"; END;
- PROCESS fancybox
- title = name
- contents = M
- center = 1;
-END %]
+[% PROCESS userboxes;
-[% IF show_poll;
+IF show_poll;
PROCESS fancybox
title = 'Article Poll'
contents = poll
center = 1;
END;
-PROCESS fancybox
- title = 'Related Links'
- contents = story.relatedtext
- center = 1;
+IF story.relatedtext;
+ PROCESS fancybox
+ title = 'Related Links'
+ contents = story.relatedtext
+ center = 1;
+END;
IF authortext;
PROCESS fancybox
@@ -109,7 +63,7 @@ IF section_block.block;
title = section.title
contents = section_block.block
center = 1;
-END; %]
+END %]
</TD></TR><TR><TD COLSPAN="4">
View
35 themes/slashcode/templates/karma;misc;default
@@ -0,0 +1,35 @@
+__section__
+default
+__description__
+Displays a karma score or adjective.
+
+* karma = the karma to display
+* admin_flag = is the displaying user qualified to see the number?
+
+__title__
+
+__page__
+misc
+__lang__
+en_US
+__name__
+karma
+__template__
+[% USE Slash %]
+
+[% IF constants.karma_obfuscate;
+ FOREACH score = constants.karma_adj.keys.nsort;
+ IF useredit.karma <= score;
+ constants.karma_adj.$score;
+ IF admin_flag;
+ " ("; useredit.karma; ")";
+ END;
+ LAST;
+ END;
+ END;
+ELSE;
+ useredit.karma;
+END; %]
+
+__seclev__
+1000
View
2  themes/slashcode/templates/prefs_titlebar;misc;default
@@ -13,8 +13,6 @@ en_US
__name__
prefs_titlebar
__template__
-[%# <!-- prefs_titlebar tab_selected=tab_selected uid=user.uid --> %]
-
[% title = title || "$user.nickname (This is you!)";
PROCESS titlebar title=title width="100%";
View
39 themes/slashcode/templates/userInfo;users;default
@@ -9,6 +9,7 @@ Display user's info
* commentstruct = arrayref of comments
* nickmatch_flag = current user is same as viewed user
* mod_flag = is moderator
+ (no need for this anymore)
* karma_flag = boolean for display karma
* admin_block = admin stuff
* admin_flag = boolean for whether to display admin stuff
@@ -36,13 +37,6 @@ and probably would be more interested in the Preferences links you see
up top there, where you can customize [% constants.sitename %],
change your password, or just click pretty widgets to kill time.
-[% IF mod_flag %]
-<P>You're a moderator with [% points %] point[% points == 1 ? '' : 's' %]
-[%- IF points && useredit.points_expire %] (expire on [% useredit.points_expire %])[% END %].
-Please read the
-<A HREF="[% constants.rootdir %]/moderation.shtml">Moderator Guidelines</A>
-before you do any moderation.<BR><P>
-[% END %]
[% IF ! useredit.registered %]
<P>This account is currently expired. Please <A HREF="[% constants.rootdir %]/users.pl?op=validateuser">re-register</A> at your earliest opportunity.<BR><P>
[% END %]
@@ -67,21 +61,8 @@ Last Journal Entry was [% Slash.timeCalc(useredit.journal_last_entry_date) %]</A
<BR>
[% END %]
[% IF karma_flag && (admin_flag || nickmatch_flag) %]
- <B>Karma:</B>
- [% IF constants.karma_obfuscate;
- FOREACH score = constants.karma_adj.keys.nsort;
- IF useredit.karma <= score;
- constants.karma_adj.$score;
- IF admin_flag;
- " ("; useredit.karma; ") ";
- END;
- " (mostly affected by moderation done to your comments)";
- LAST;
- END;
- END;
- ELSE;
- useredit.karma; " (mostly the sum of moderation done to your comments)";
- END; %]<BR>
+ <B>Karma:</B> [% PROCESS karma karma=useredit.karma admin_flag=admin_flag %]
+ (mostly affected by moderation done to your comments)<BR>
[% END %]
<P>
@@ -116,12 +97,22 @@ Last Journal Entry was [% Slash.timeCalc(useredit.journal_last_entry_date) %]</A
<BR>[% Slash.parseDomainTags(useredit.bio, useredit.fakeemail) | strip_html %]<BR>
[% END %]
-<BR>
+</TD>
+
+<TD VALIGN="TOP">[% PROCESS userboxes %]</TD>
+</TR>
+
+<TR><TD>&nbsp;</TD>
+
+<TD COLSPAN="2">
+
[% IF commentcount > 0 %]
[% commenttitle =
((min_comment == 0) ? "" : "$commentstruct.size of ")
_ "$useredit.nickname's "
- _ ((commentstruct.size == commentcount || min_comment > 0) ? "" : "Latest $commentstruct.size of $commentcount ")
+ _ ((commentstruct.size == commentcount || min_comment > 0)
+ ? ""
+ : "Latest $commentstruct.size of $commentcount ")
_ "Comment"
_ (commentcount == 1 ? "" : "s") %]
[% PROCESS titlebar width="100%" title = commenttitle %]
View
2  themes/slashcode/templates/user_titlebar;misc;default
@@ -17,8 +17,6 @@ user_titlebar
__template__
[% uid = uid || user.uid %]
-[%# <!-- user_titlebar tab_selected=tab_selected uid=uid --> %]
-
[% IF user.uid == uid && !user.is_anon;
title = title || "$user.nickname (This is you!)";
url_nick = user.nickname | fixparam;
View
135 themes/slashcode/templates/userboxes;misc;default
@@ -0,0 +1,135 @@
+__section__
+default
+__description__
+Displays the three user boxes (fancybox's).
+
+* useredit = user being viewed ("edit" is for historical reasons)
+ (if not given, the standard "user" will be used)
+
+__title__
+
+__page__
+misc
+__lang__
+en_US
+__name__
+userboxes
+__template__
+[% USE Slash;
+
+IF !useredit; useredit = user; END;
+
+IF user.is_anon;
+
+ # The user we're displaying this page for is not logged in.
+ # Show the login block.
+
+ title = "$constants.sitename Login";
+ IF form.sid;
+ contents = BLOCK %]
+ [% PROCESS userlogin
+ return_url = "$constants.rootdir/article.pl?sid=$form.sid" %]
+ [% END;
+ ELSE;
+ contents = BLOCK %]
+ [% PROCESS userlogin %]
+ [% END;
+ END;
+ PROCESS fancybox
+ title = title
+ contents = contents
+ center = 1;
+
+END;
+
+IF !useredit.is_anon;
+
+ # First box: general user info
+
+ title = FILTER strip_literal; useredit.nickname; END;
+ title = title _ " ($useredit.uid)";
+ contents = BLOCK;
+ '<A HREF="'; constants.rootdir; '/~';
+ FILTER fixparam; useredit.nickname; END; '/">';
+ useredit.nickname; '</A> ';
+ IF user.uid != useredit.uid;
+ PROCESS zoo_icons person=useredit.uid implied="";
+ END;
+ IF user.uid == useredit.uid OR user.is_admin;
+ # Looking at ourselves; show our real email info.
+ '<BR><A HREF="mailto:';
+ FILTER fixparam; useredit.realemail; END; '">';
+ Slash.ellipsify(useredit.realemail); '</A>';
+ '<BR>&nbsp;&nbsp;';
+ IF useredit.fakeemail;
+ 'shown as <A HREF="mailto:';
+ FILTER fixparam; useredit.fakeemail; END; '">';
+ Slash.ellipsify(useredit.fakeemail); '</A>';
+ ELSE;
+ '(email not shown publicly)';
+ END;
+ ELSE;
+ # Looking at someone else; show fake email info.
+ '<BR><A HREF="mailto:';
+ FILTER fixparam; useredit.fakeemail; END; '">';
+ Slash.ellipsify(useredit.fakeemail); '</A>';
+ END;
+ IF useredit.homepage;
+ '<BR><A HREF="';
+ FILTER fixparam; useredit.homepage; END; '">';
+ Slash.ellipsify(useredit.homepage); '</A>';
+ END;
+ IF user.uid == useredit.uid OR user.is_admin;
+ '<BR>Karma: ';
+ PROCESS karma karma=useredit.karma is_admin=useredit.is_admin;
+ END;
+ IF useredit.bio;
+ '<BR>'; useredit.bio;
+ END;
+ END;
+ PROCESS fancybox
+ title = title
+ contents = contents
+ center = 1;
+
+ # Second box: info about moderation, if applicable
+ # Note this applies to the current user, not the user
+ # being examined.
+
+ IF user.points || user.is_admin;
+ title = "Moderation";
+ contents = BLOCK %]
+<A HREF="[% constants.rootdir %]/~[% FILTER fixparam; user.nickname; END %]/">You</A>
+have moderator access
+[% IF user.is_admin %](because you're an admin)[% END %]
+and <B>[% user.points %]</B> point[% user.points == 1 ? '' : 's' %].
+Welcome to those of you just joining: <B>please</B>
+read the <A HREF="[% constants.rootdir %]/moderation.shtml">moderator guidelines</A>
+for instructions.
+<P>&middot; You can't post &amp; moderate the same discussion.
+<BR>&middot; Concentrate on promoting more than demoting.
+<BR>&middot; Browse at -1 to keep an eye out for abuses.
+<BR>&middot; <A HREF="mailto:[% constants.adminmail %]">Mail the admin</A>
+URLs showing abuse (the cid link please!).
+ [% END;
+ PROCESS fancybox
+ title = title
+ contents = contents
+ center = 1;
+ END;
+
+ # Third box: user space, if applicable
+ # Again, this is for the current user, not the edited user.
+
+ IF user.mylinks;
+ title = "User Space";
+ contents = user.mylinks;
+ PROCESS fancybox
+ title = title
+ contents = contents
+ center = 1;
+ END;
+END %]
+
+__seclev__
+1000
Please sign in to comment.
Something went wrong with that request. Please try again.