diff options
author | Yorhel <git@yorhel.nl> | 2019-10-08 18:16:46 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-10-10 16:40:30 +0200 |
commit | b3a9130763879d60c0e413c724a759860bd396af (patch) | |
tree | 2de6f9d21d4ce9f00fc11595906570be43d8ae5c /lib/VNDB | |
parent | 4c1dfc8bb62171c4c21057c47f238c8747bac3f8 (diff) |
rewards: Apply supporters badge and unicode name (almost) everywhere
Only place where this isn't applied (yet?): Sorting user lists still
goes by the old username and board names don't use the new unicode
names.
I have to say, I quite like the sql_user() and user_() pattern. It's not
without problems when applied to everything, but it's good enough for
several use cases.
Diffstat (limited to 'lib/VNDB')
-rw-r--r-- | lib/VNDB/DB/Chars.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/DB/Discussions.pm | 10 | ||||
-rw-r--r-- | lib/VNDB/DB/Misc.pm | 4 | ||||
-rw-r--r-- | lib/VNDB/DB/Producers.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/DB/Releases.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/DB/Staff.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/DB/Tags.pm | 4 | ||||
-rw-r--r-- | lib/VNDB/DB/Traits.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/DB/ULists.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/DB/Users.pm | 16 | ||||
-rw-r--r-- | lib/VNDB/DB/VN.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/Func.pm | 8 | ||||
-rw-r--r-- | lib/VNDB/Handler/Discussions.pm | 17 | ||||
-rw-r--r-- | lib/VNDB/Handler/Misc.pm | 8 | ||||
-rw-r--r-- | lib/VNDB/Handler/Tags.pm | 12 | ||||
-rw-r--r-- | lib/VNDB/Handler/Traits.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/Handler/ULists.pm | 8 | ||||
-rw-r--r-- | lib/VNDB/Handler/Users.pm | 15 | ||||
-rw-r--r-- | lib/VNDB/Util/Auth.pm | 4 | ||||
-rw-r--r-- | lib/VNDB/Util/BrowseHTML.pm | 41 | ||||
-rw-r--r-- | lib/VNDB/Util/CommonHTML.pm | 4 |
21 files changed, 55 insertions, 112 deletions
diff --git a/lib/VNDB/DB/Chars.pm b/lib/VNDB/DB/Chars.pm index 23953028..e2581f87 100644 --- a/lib/VNDB/DB/Chars.pm +++ b/lib/VNDB/DB/Chars.pm @@ -90,7 +90,7 @@ sub dbCharGetRev { $o{rev} ||= $self->dbRow('SELECT MAX(rev) AS rev FROM changes WHERE type = \'c\' AND itemid = ?', $o{id})->{rev}; my $select = 'c.itemid AS id, ch.name, ch.original, ch.gender'; - $select .= ', extract(\'epoch\' from c.added) as added, c.requester, c.comments, u.username, c.rev, c.ihid, c.ilock'; + $select .= ', extract(\'epoch\' from c.added) as added, c.comments, c.rev, c.ihid, c.ilock, '.VNWeb::DB::sql_user(); $select .= ', c.id AS cid, NOT EXISTS(SELECT 1 FROM changes c2 WHERE c2.type = c.type AND c2.itemid = c.itemid AND c2.rev = c.rev+1) AS lastrev'; $select .= ', ch.alias, ch.desc, ch.image, ch.b_month, ch.b_day, ch.s_bust, ch.s_waist, ch.s_hip, ch.height, ch.weight, ch.bloodt, ch.main, ch.main_spoil, co.hidden, co.locked' if $o{what} =~ /extended/; diff --git a/lib/VNDB/DB/Discussions.pm b/lib/VNDB/DB/Discussions.pm index 6139b83b..75fb93e8 100644 --- a/lib/VNDB/DB/Discussions.pm +++ b/lib/VNDB/DB/Discussions.pm @@ -41,7 +41,7 @@ sub dbThreadGet { my @select = ( qw|t.id t.title t.count t.locked t.hidden t.private|, 't.poll_question IS NOT NULL AS haspoll', - $o{what} =~ /lastpost/ ? ('tpl.uid AS luid', q|EXTRACT('epoch' from tpl.date) AS ldate|, 'ul.username AS lusername') : (), + $o{what} =~ /lastpost/ ? (q|EXTRACT('epoch' from tpl.date) AS lastpost_date|, VNWeb::DB::sql_user('ul', 'lastpost_')) : (), $o{what} =~ /poll/ ? (qw|t.poll_question t.poll_max_options t.poll_preview t.poll_recast|) : (), ); @@ -94,12 +94,12 @@ sub dbThreadGet { } if($o{what} =~ /firstpost/) { - do { my $x = $r->[$r{$_->{tid}}]; $x->{fuid} = $_->{uid}; $x->{fdate} = $_->{date}; $x->{fusername} = $_->{username} } for (@{$self->dbAll(q| - SELECT tpf.tid, tpf.uid, EXTRACT('epoch' from tpf.date) AS date, uf.username + do { my $idx = $r{ delete $_->{tid} }; $r->[$idx] = { $r->[$idx]->%*, %$_ } } for (@{$self->dbAll(q| + SELECT tpf.tid, EXTRACT('epoch' from tpf.date) AS firstpost_date, !s FROM threads_posts tpf JOIN users uf ON tpf.uid = uf.id WHERE tpf.num = 1 AND tpf.tid IN(!l)|, - [ keys %r ] + VNWeb::DB::sql_user('uf', 'firstpost_'), [ keys %r ] )}); } @@ -237,7 +237,7 @@ sub dbPostGet { my @select = ( qw|tp.tid tp.num tp.hidden|, q|extract('epoch' from tp.date) as date|, q|extract('epoch' from tp.edited) as edited|, $o{search} ? () : 'tp.msg', - $o{what} =~ /user/ ? qw|tp.uid u.username| : (), + $o{what} =~ /user/ ? (VNWeb::DB::sql_user()) : (), $o{what} =~ /thread/ ? ('t.title', 't.hidden AS thread_hidden') : (), ); my @join = ( diff --git a/lib/VNDB/DB/Misc.pm b/lib/VNDB/DB/Misc.pm index e1a1103c..27494380 100644 --- a/lib/VNDB/DB/Misc.pm +++ b/lib/VNDB/DB/Misc.pm @@ -79,11 +79,11 @@ sub dbRevisionGet { ); my($r, $np) = $self->dbPage(\%o, q| - SELECT c.id, c.type, c.itemid, c.requester, c.comments, c.rev, extract('epoch' from c.added) as added, u.username + SELECT c.id, c.type, c.itemid, c.comments, c.rev, extract('epoch' from c.added) as added, !s FROM changes c JOIN users u ON c.requester = u.id !W - ORDER BY c.id DESC|, \%where + ORDER BY c.id DESC|, VNWeb::DB::sql_user(), \%where ); # I couldn't find a way to fetch the titles the main query above without slowing it down considerably, so let's just do it this way. diff --git a/lib/VNDB/DB/Producers.pm b/lib/VNDB/DB/Producers.pm index 548f70c5..0caf0ece 100644 --- a/lib/VNDB/DB/Producers.pm +++ b/lib/VNDB/DB/Producers.pm @@ -68,7 +68,7 @@ sub dbProducerGetRev { $o{rev} ||= $self->dbRow('SELECT MAX(rev) AS rev FROM changes WHERE type = \'p\' AND itemid = ?', $o{id})->{rev}; my $select = 'c.itemid AS id, p.type, p.name, p.original, p.lang, po.rgraph'; - $select .= ', extract(\'epoch\' from c.added) as added, c.requester, c.comments, u.username, c.rev, c.ihid, c.ilock'; + $select .= ', extract(\'epoch\' from c.added) as added, c.comments, c.rev, c.ihid, c.ilock, '.VNWeb::DB::sql_user(); $select .= ', c.id AS cid, NOT EXISTS(SELECT 1 FROM changes c2 WHERE c2.type = c.type AND c2.itemid = c.itemid AND c2.rev = c.rev+1) AS lastrev'; $select .= ', p.desc, p.alias, p.website, p.l_wp, p.l_wikidata, po.hidden, po.locked' if $o{what} =~ /extended/; diff --git a/lib/VNDB/DB/Releases.pm b/lib/VNDB/DB/Releases.pm index 940ff087..1c95a3c0 100644 --- a/lib/VNDB/DB/Releases.pm +++ b/lib/VNDB/DB/Releases.pm @@ -127,7 +127,7 @@ sub dbReleaseGetRev { my $select = 'c.itemid AS id, r.title, r.original, r.website, r.released, r.minage, r.type, r.patch'; $select .= ', r.notes, r.catalog, r.gtin, r.resolution, r.voiced, r.freeware, r.doujin, r.uncensored, r.ani_story, r.ani_ero, r.engine, ro.hidden, ro.locked' if $o{what} =~ /extended/; - $select .= ', extract(\'epoch\' from c.added) as added, c.requester, c.comments, u.username, c.rev, c.ihid, c.ilock'; + $select .= ', extract(\'epoch\' from c.added) as added, c.comments, c.rev, c.ihid, c.ilock, '.VNWeb::DB::sql_user(); $select .= ', c.id AS cid, NOT EXISTS(SELECT 1 FROM changes c2 WHERE c2.type = c.type AND c2.itemid = c.itemid AND c2.rev = c.rev+1) AS lastrev'; my $r = $self->dbAll(q| diff --git a/lib/VNDB/DB/Staff.pm b/lib/VNDB/DB/Staff.pm index e5f38705..b8995d04 100644 --- a/lib/VNDB/DB/Staff.pm +++ b/lib/VNDB/DB/Staff.pm @@ -85,7 +85,7 @@ sub dbStaffGetRev { $o{rev} ||= $self->dbRow('SELECT MAX(rev) AS rev FROM changes WHERE type = \'s\' AND itemid = ?', $o{id})->{rev}; my $select = 'c.itemid AS id, sa.aid, sa.name, sa.original, s.gender, s.lang'; - $select .= ', extract(\'epoch\' from c.added) as added, c.requester, c.comments, u.username, c.rev, c.ihid, c.ilock'; + $select .= ', extract(\'epoch\' from c.added) as added, c.comments, c.rev, c.ihid, c.ilock, '.VNWeb::DB::sql_user(); $select .= ', c.id AS cid, NOT EXISTS(SELECT 1 FROM changes c2 WHERE c2.type = c.type AND c2.itemid = c.itemid AND c2.rev = c.rev+1) AS lastrev'; $select .= ', s.desc, s.l_wp, s.l_site, s.l_twitter, s.l_anidb, s.l_wikidata, s.l_pixiv, so.hidden, so.locked' if $o{what} =~ /extended/; diff --git a/lib/VNDB/DB/Tags.pm b/lib/VNDB/DB/Tags.pm index 75be42d8..875ff6e9 100644 --- a/lib/VNDB/DB/Tags.pm +++ b/lib/VNDB/DB/Tags.pm @@ -41,7 +41,7 @@ sub dbTagGet { my @select = ( qw|t.id t.searchable t.applicable t.name t.description t.state t.cat t.c_items t.defaultspoil|, q|extract('epoch' from t.added) as added|, - $o{what} =~ /addedby/ ? ('t.addedby', 'u.username') : (), + $o{what} =~ /addedby/ ? (VNWeb::DB::sql_user()) : (), ); my @join = $o{what} =~ /addedby/ ? 'JOIN users u ON u.id = t.addedby' : (); @@ -187,7 +187,7 @@ sub dbTagLinks { my @select = ( qw|tv.tag tv.vid tv.uid tv.vote tv.spoiler tv.ignore|, "EXTRACT('epoch' from tv.date) AS date", - $o{what} =~ /details/ ? (qw|v.title u.username t.name|) : (), + $o{what} =~ /details/ ? (qw|v.title t.name|, VNWeb::DB::sql_user()) : (), ); my @join = $o{what} =~ /details/ ? ( diff --git a/lib/VNDB/DB/Traits.pm b/lib/VNDB/DB/Traits.pm index f1c55b24..019f512f 100644 --- a/lib/VNDB/DB/Traits.pm +++ b/lib/VNDB/DB/Traits.pm @@ -46,7 +46,7 @@ sub dbTraitGet { my @select = ( qw|t.id t.searchable t.applicable t.name t.description t.state t.alias t."group" t."order" t.sexual t.c_items t.defaultspoil|, 'tg.name AS groupname', 'tg."order" AS grouporder', q|extract('epoch' from t.added) as added|, - $o{what} =~ /addedby/ ? ('t.addedby', 'u.username') : (), + $o{what} =~ /addedby/ ? (VNWeb::DB::sql_user()) : (), ); my @join = $o{what} =~ /addedby/ ? 'JOIN users u ON u.id = t.addedby' : (); push @join, 'LEFT JOIN traits tg ON tg.id = t."group"'; diff --git a/lib/VNDB/DB/ULists.pm b/lib/VNDB/DB/ULists.pm index 6de6b25b..6f061e97 100644 --- a/lib/VNDB/DB/ULists.pm +++ b/lib/VNDB/DB/ULists.pm @@ -193,7 +193,7 @@ sub dbVoteGet { my @select = ( qw|n.vid n.vote n.uid|, q|extract('epoch' from n.date) as date|, - $o{what} =~ /user/ ? ('u.username') : (), + $o{what} =~ /user/ ? (VNWeb::DB::sql_user()) : (), $o{what} =~ /vn/ ? (qw|v.title v.original|) : (), $o{what} =~ /hide_list/ ? ('u.hide_list') : (), ); diff --git a/lib/VNDB/DB/Users.pm b/lib/VNDB/DB/Users.pm index cccac169..663184cb 100644 --- a/lib/VNDB/DB/Users.pm +++ b/lib/VNDB/DB/Users.pm @@ -13,7 +13,7 @@ our @EXPORT = qw| # %options->{ username session uid ip registered search results page what sort reverse notperm } -# what: notifycount stats scryptargs extended +# what: extended # sort: username registered votes changes tags sub dbUserGet { my $s = shift; @@ -54,19 +54,9 @@ sub dbUserGet { my @select = ( qw|id username c_votes c_changes c_tags hide_list|, + VNWeb::DB::sql_user(), # XXX: This duplicates id and username, but updating all the code isn't going to be easy q|extract('epoch' from registered) as registered|, $o{what} =~ /extended/ ? qw|perm ign_votes| : (), # mail - $o{what} =~ /scryptargs/ ? 'user_getscryptargs(id) AS scryptargs' : (), - $o{what} =~ /notifycount/ ? - '(SELECT COUNT(*) FROM notifications WHERE uid = u.id AND read IS NULL) AS notifycount' : (), - $o{what} =~ /stats/ ? ( - '(SELECT COUNT(*) FROM rlists WHERE uid = u.id) AS releasecount', - '(SELECT COUNT(*) FROM vnlists WHERE uid = u.id) AS vncount', - '(SELECT COUNT(*) FROM threads_posts WHERE uid = u.id) AS postcount', - '(SELECT COUNT(*) FROM threads_posts WHERE uid = u.id AND num = 1) AS threadcount', - '(SELECT COUNT(DISTINCT tag) FROM tags_vn WHERE uid = u.id) AS tagcount', - '(SELECT COUNT(DISTINCT vid) FROM tags_vn WHERE uid = u.id) AS tagvncount', - ) : (), $token ? qq|extract('epoch' from user_isloggedin(id, decode('$token', 'hex'))) as session_lastused| : (), ); @@ -122,7 +112,7 @@ sub dbNotifyGet { qw|n.id n.ntype n.ltype n.iid n.subid|, q|extract('epoch' from n.date) as date|, q|extract('epoch' from n.read) as read|, - $o{what} =~ /titles/ ? qw|u.username n.c_title| : (), + $o{what} =~ /titles/ ? ('n.c_title', VNWeb::DB::sql_user()) : (), ); my($r, $np) = $s->dbPage(\%o, q| diff --git a/lib/VNDB/DB/VN.pm b/lib/VNDB/DB/VN.pm index b29ee3c6..9f0e4b1e 100644 --- a/lib/VNDB/DB/VN.pm +++ b/lib/VNDB/DB/VN.pm @@ -161,7 +161,7 @@ sub dbVNGetRev { my $uid = $self->authInfo->{id}; my $select = 'c.itemid AS id, vo.c_released, vo.c_languages::text[], vo.c_platforms::text[], v.title, v.original, vo.rgraph'; - $select .= ', extract(\'epoch\' from c.added) as added, c.requester, c.comments, u.username, c.rev, c.ihid, c.ilock'; + $select .= ', extract(\'epoch\' from c.added) as added, c.comments, c.rev, c.ihid, c.ilock, '.VNWeb::DB::sql_user(); $select .= ', c.id AS cid, NOT EXISTS(SELECT 1 FROM changes c2 WHERE c2.type = c.type AND c2.itemid = c.itemid AND c2.rev = c.rev+1) AS lastrev'; $select .= ', v.alias, v.image, v.img_nsfw, v.length, v.desc, v.l_wp, v.l_encubed, v.l_renai, v.l_wikidata, vo.hidden, vo.locked' if $o{what} =~ /extended/; $select .= ', vo.c_popularity, vo.c_rating, vo.c_votecount' if $o{what} =~ /rating/; diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm index 11e3dfee..32830459 100644 --- a/lib/VNDB/Func.pm +++ b/lib/VNDB/Func.pm @@ -13,7 +13,7 @@ use VNDB::BBCode; our @EXPORT = (@VNDBUtil::EXPORT, 'bb2html', 'bb2text', qw| clearfloat cssicon tagscore minage fil_parse fil_serialize parenttags childtags charspoil imgpath imgurl - fmtvote fmtmedia fmtvnlen fmtage fmtdatestr fmtdate fmtuser fmtrating fmtspoil + fmtvote fmtmedia fmtvnlen fmtage fmtdatestr fmtdate fmtrating fmtspoil json_encode json_decode script_json form_compare |); @@ -253,12 +253,6 @@ sub fmtdate { return strftime '%Y-%m-%d at %R', gmtime $t; } -# Arguments: (uid, username), or a hashref containing that info -sub fmtuser { - my($id,$n) = ref($_[0]) eq 'HASH' ? ($_[0]{uid}||$_[0]{requester}, $_[0]{username}) : @_; - return !$id ? '[deleted]' : sprintf '<a href="/u%d">%s</a>', $id, xml_escape $n; -} - # Turn a (natural number) vote into a rating indication sub fmtrating { ['worst ever', diff --git a/lib/VNDB/Handler/Discussions.pm b/lib/VNDB/Handler/Discussions.pm index 30512cfa..c17ca3b7 100644 --- a/lib/VNDB/Handler/Discussions.pm +++ b/lib/VNDB/Handler/Discussions.pm @@ -26,7 +26,7 @@ TUWF::register( sub caneditpost { my($self, $post) = @_; return $self->authCan('boardmod') || - ($self->authInfo->{id} && $post->{uid} == $self->authInfo->{id} && !$post->{hidden} && time()-$post->{date} < $self->{board_edit_time}) + ($self->authInfo->{id} && $post->{user_id} == $self->authInfo->{id} && !$post->{hidden} && time()-$post->{date} < $self->{board_edit_time}) } @@ -75,7 +75,8 @@ sub thread { td class => 'tc1'; a href => "/t$tid.$_->{num}", name => $_->{num}, "#$_->{num}"; if(!$_->{hidden}) { - lit ' by '.fmtuser($_); + lit ' by '; + VNWeb::HTML::user_($_); br; txt fmtdate $_->{date}, 'full'; } @@ -312,7 +313,7 @@ sub edit { 'Edit post'; $self->htmlHeader(title => $title, noindex => 1); $self->htmlForm({ frm => $frm, action => $url }, 'postedit' => [$title, - [ static => label => 'Username', content => fmtuser($p ? ($p->{uid}, $p->{username}) : ($self->authInfo->{id}, $self->authInfo->{username})) ], + [ static => label => 'Username', content => sub { VNWeb::HTML::user_($p || VNWeb::Auth::auth->user); '' } ], !$tid || $num == 1 ? ( [ input => short => 'title', name => 'Thread title' ], [ input => short => 'boards', name => 'Board(s)' ], @@ -394,7 +395,7 @@ sub board { $type eq 'p' ? $self->dbProducerGet(id => $iid)->[0] : $self->dbVNGet(id => $iid)->[0]; return $self->resNotFound if $iid && !$obj; - my $ititle = $obj && ($obj->{title}||$obj->{name}||$obj->{username}); + my $ititle = $obj && ($obj->{title}||$obj->{name}||VNWeb::HTML::user_displayname($obj)); my $title = $obj ? "Related discussions for $ititle" : $type eq 'all' ? 'All boards' : $BOARD_TYPE{$type}{txt}; my($list, $np) = $self->dbThreadGet( @@ -576,7 +577,7 @@ sub search { td class => 'tc1_1'; a href => $link, 't'.$l->{tid}; end; td class => 'tc1_2'; a href => $link, '.'.$l->{num}; end; td class => 'tc2', fmtdate $l->{date}; - td class => 'tc3'; lit fmtuser $l->{uid}, $l->{username}; end; + td class => 'tc3'; VNWeb::HTML::user_($l); end; td class => 'tc4'; div class => 'title'; a href => $link, $l->{title}; @@ -634,12 +635,12 @@ sub _threadlist { end; td class => 'tc2', $o->{count}-1; td class => 'tc3'; - lit fmtuser $o->{fuid}, $o->{fusername}; + VNWeb::HTML::user_($o, 'firstpost_'); end; td class => 'tc4'; - lit fmtuser $o->{luid}, $o->{lusername}; + VNWeb::HTML::user_($o, 'lastpost_'); lit ' @ '; - a href => "/t$o->{id}.$o->{count}", fmtdate $o->{ldate}, 'full'; + a href => "/t$o->{id}.$o->{count}", fmtdate $o->{lastpost_date}, 'full'; end; end 'tr'; } diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm index 9b4073ce..76663601 100644 --- a/lib/VNDB/Handler/Misc.pm +++ b/lib/VNDB/Handler/Misc.pm @@ -85,7 +85,8 @@ sub homepage { li; txt "$_->{type}:"; a href => "/$_->{type}$_->{itemid}.$_->{rev}", title => $_->{ioriginal}||$_->{ititle}, shorten $_->{ititle}, 33; - lit " by ".fmtuser($_); + lit " by "; + VNWeb::HTML::user_($_); end; } end; @@ -120,9 +121,10 @@ sub homepage { for (@$posts) { my $boards = join ', ', map $BOARD_TYPE{$_->{type}}{txt}.($_->{iid}?' > '.$_->{title}:''), @{$_->{boards}}; li; - txt fmtage($_->{ldate}).' '; + txt fmtage($_->{lastpost_date}).' '; a href => "/t$_->{id}.$_->{count}", title => "Posted in $boards", shorten $_->{title}, 25; - lit ' by '.fmtuser($_->{luid}, $_->{lusername}); + lit ' by '; + VNWeb::HTML::user_($_, 'lastpost_'); end; } end; diff --git a/lib/VNDB/Handler/Tags.pm b/lib/VNDB/Handler/Tags.pm index d674498c..cbc7b293 100644 --- a/lib/VNDB/Handler/Tags.pm +++ b/lib/VNDB/Handler/Tags.pm @@ -255,7 +255,7 @@ sub tagedit { [ input => short => 'name', name => 'Primary name' ], $self->authCan('tagmod') ? ( $tag ? - [ static => label => 'Added by', content => fmtuser($t->{addedby}, $t->{username}) ] : (), + [ static => label => 'Added by', content => sub { VNWeb::HTML::user_($t); '' } ] : (), [ select => short => 'state', name => 'State', options => [ [0, 'Awaiting moderation'], [1, 'Deleted/hidden'], [2, 'Approved'] ] ], [ checkbox => short => 'searchable', name => 'Searchable (people can use this tag to filter VNs)' ], @@ -428,7 +428,7 @@ sub taglinks { li; txt '['; a href => $url->(u=>0), 'remove'; txt '] '; txt 'User: '; - a href => "/u$f->{u}", $o->{username}||'Unknown user'; + VNWeb::HTML::user_($o); end; } if($f->{t}) { @@ -472,12 +472,8 @@ sub taglinks { Tr; td class => 'tc1', fmtdate $l->{date}; td class => 'tc2'; - if($l->{uid}) { - a href => $url->(u=>$l->{uid}), class => 'setfil', '> ' if !$f->{u}; - a href => "/u$l->{uid}", $l->{username}; - } else { - txt '[deleted]'; - } + a href => $url->(u=>$l->{uid}), class => 'setfil', '> ' if $l->{user_id} && !$f->{u}; + VNWeb::HTML::user_($l); end; td class => 'tc3'.($l->{ignore}?' ignored':''); tagscore $l->{vote}; diff --git a/lib/VNDB/Handler/Traits.pm b/lib/VNDB/Handler/Traits.pm index 4bf9a33d..f9802cff 100644 --- a/lib/VNDB/Handler/Traits.pm +++ b/lib/VNDB/Handler/Traits.pm @@ -233,7 +233,7 @@ sub traitedit { [ input => short => 'name', name => 'Primary name' ], $self->authCan('tagmod') ? ( $t ? - [ static => label => 'Added by', content => fmtuser($t->{addedby}, $t->{username}) ] : (), + [ static => label => 'Added by', content => sub { VNWeb::HTML::user_($t); '' } ] : (), [ select => short => 'state', name => 'State', options => [ [0,'Awaiting moderation'], [1,'Deleted/hidden'], [2,'Approved'] ] ], [ checkbox => short => 'searchable', name => 'Searchable (people can use this trait to filter characters)' ], diff --git a/lib/VNDB/Handler/ULists.pm b/lib/VNDB/Handler/ULists.pm index b66d0419..49d31788 100644 --- a/lib/VNDB/Handler/ULists.pm +++ b/lib/VNDB/Handler/ULists.pm @@ -155,7 +155,7 @@ sub votelist { $type eq 'u' && $f->{c} ne 'all' ? (vn_char => $f->{c}) : (), ); - my $title = $type eq 'v' ? "Votes for $obj->{title}" : "Votes by $obj->{username}"; + my $title = $type eq 'v' ? "Votes for $obj->{title}" : 'Votes by '.VNWeb::HTML::user_displayname($obj); $self->htmlHeader(noindex => 1, title => $title); $self->htmlMainTabs($type => $obj, 'votes'); div class => 'mainbox'; @@ -201,7 +201,7 @@ sub votelist { } elsif($l->{hide_list}) { b class => 'grayedout', 'hidden'; } else { - a href => "/u$l->{uid}", $l->{username}; + VNWeb::HTML::user_($l); } end; end; @@ -265,7 +265,7 @@ sub wishlist { page => $f->{p}, ); - my $title = $own ? 'My wishlist' : "$u->{username}'s wishlist"; + my $title = $own ? 'My wishlist' : VNWeb::HTML::user_displayname($u)."'s wishlist"; $self->htmlHeader(title => $title, noindex => 1); $self->htmlMainTabs('u', $u, 'wish'); div class => 'mainbox'; @@ -382,7 +382,7 @@ sub vnlist { $f->{t} >= 0 ? (status => $f->{t}) : (), ); - my $title = $own ? 'My visual novel list' : "$u->{username}'s visual novel list"; + my $title = $own ? 'My visual novel list' : VNWeb::HTML::user_displayname($u)."'s visual novel list"; $self->htmlHeader(title => $title, noindex => 1); $self->htmlMainTabs('u', $u, 'list'); diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm index 32648ee4..e31dbd77 100644 --- a/lib/VNDB/Handler/Users.pm +++ b/lib/VNDB/Handler/Users.pm @@ -34,13 +34,13 @@ sub posts { my($posts, $np) = $self->dbPostGet(uid => $uid, hide => 1, what => 'thread', page => $f->{p}, sort => 'date', reverse => 1); - my $title = "Posts made by $u->{username}"; + my $title = 'Posts made by '.VNWeb::HTML::user_displayname($u); $self->htmlHeader(title => $title, noindex => 1); $self->htmlMainTabs(u => $u, 'posts'); div class => 'mainbox'; h1 $title; if(!@$posts) { - p "$u->{username} hasn't made any posts yet."; + p VNWeb::HTML::user_displayname($u)." hasn't made any posts yet."; } end; @@ -168,7 +168,7 @@ sub list { my($s, $n, $l) = @_; Tr; td class => 'tc1'; - a href => '/u'.$l->{id}, $l->{username}; + VNWeb::HTML::user_($l); end; td class => 'tc2', fmtdate $l->{registered}; td class => 'tc3'.($l->{hide_list} && $self->authCan('usermod') ? ' linethrough' : ''); @@ -283,11 +283,10 @@ sub notifies { a href => "/u$uid/notify/$l->{id}", "$l->{ltype}$l->{iid}".($l->{subid}?".$l->{subid}":''); end; td class => 'tc5 clickable', id => "notify_$l->{id}"; - lit sprintf - $l->{ltype} ne 't' ? 'Edit of %s by %s' : - $l->{subid} == 1 ? 'New thread %s by %s' : 'Reply to %s by %s', - sprintf('<i>%s</i>', xml_escape $l->{c_title}), - sprintf('<i>%s</i>', xml_escape $l->{username}); + txt $l->{ltype} eq 't' ? 'Edit of ' : $l->{subid} == 1 ? 'New thread ' : 'Reply to '; + i $l->{c_title}; + txt ' by '; + i VNWeb::HTML::user_displayname($l); end; end 'tr'; }, diff --git a/lib/VNDB/Util/Auth.pm b/lib/VNDB/Util/Auth.pm index 91453edf..4394149f 100644 --- a/lib/VNDB/Util/Auth.pm +++ b/lib/VNDB/Util/Auth.pm @@ -63,9 +63,9 @@ sub authAdminSetPass { sub authInfo { - # Used to return a lot more, but this was by far the most common use + # Used to return a lot more, but only the id is still used now. # (code using other fields has been migrated) - +{ id => auth->uid, username => auth->username } + +{ id => auth->uid } } diff --git a/lib/VNDB/Util/BrowseHTML.pm b/lib/VNDB/Util/BrowseHTML.pm index 09bf55b2..24e657ae 100644 --- a/lib/VNDB/Util/BrowseHTML.pm +++ b/lib/VNDB/Util/BrowseHTML.pm @@ -10,7 +10,7 @@ use VNDB::Types; use POSIX 'ceil'; -our @EXPORT = qw| htmlBrowse htmlBrowseNavigate htmlBrowseHist htmlBrowseVN |; +our @EXPORT = qw| htmlBrowse htmlBrowseNavigate htmlBrowseVN |; # generates a browse box, arguments: @@ -122,45 +122,6 @@ sub htmlBrowseNavigate { } -sub htmlBrowseHist { - my($self, $list, $f, $np, $url) = @_; - $self->htmlBrowse( - items => $list, - options => $f, - nextpage => $np, - pageurl => $url, - class => 'history', - header => [ - sub { td class => 'tc1_1', 'Rev.'; td class => 'tc1_2', ''; }, - [ 'Date' ], - [ 'User' ], - [ 'Page' ], - ], - row => sub { - my($s, $n, $i) = @_; - my $revurl = "/$i->{type}$i->{itemid}.$i->{rev}"; - - Tr; - td class => 'tc1_1'; - a href => $revurl, "$i->{type}$i->{itemid}"; - end; - td class => 'tc1_2'; - a href => $revurl, ".$i->{rev}"; - end; - td class => 'tc2', fmtdate $i->{added}, 'full'; - td class => 'tc3'; - lit fmtuser $i; - end; - td class => 'tc4'; - a href => $revurl, title => $i->{ioriginal}, shorten $i->{ititle}, 80; - b class => 'grayedout'; lit bb2html $i->{comments}, 150; end; - end; - end 'tr'; - }, - ); -} - - sub htmlBrowseVN { my($self, $list, $f, $np, $url, $tagscore) = @_; $self->htmlBrowse( diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm index d8e584ab..72febd63 100644 --- a/lib/VNDB/Util/CommonHTML.pm +++ b/lib/VNDB/Util/CommonHTML.pm @@ -214,7 +214,7 @@ sub revheader { # type, obj txt ')'; br; txt 'By '; - lit fmtuser $obj; + VNWeb::HTML::user_($obj); txt ' on '; txt fmtdate $obj->{added}, 'full'; } @@ -401,7 +401,7 @@ sub htmlVoteStats { } elsif($_->{hide_list}) { b class => 'grayedout', 'hidden'; } else { - a href => "/u$_->{uid}", $_->{username}; + VNWeb::HTML::user_($_); } end; td fmtvote $_->{vote}; |