Permalink
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...
1 parent d5b0ddb commit 1784c1e09070540a95fb905c55ddc86b355d9ffd @jamiemccarthy jamiemccarthy committed Jan 14, 2003
View
@@ -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
@@ -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
@@ -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});
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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';
}
@@ -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">
@@ -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
@@ -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%";
Oops, something went wrong.

0 comments on commit 1784c1e

Please sign in to comment.