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/Handler | |
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/Handler')
-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 |
6 files changed, 30 insertions, 32 deletions
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'; }, |