summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-01-08 10:13:20 +0100
committerYorhel <git@yorhel.nl>2020-01-08 10:14:29 +0100
commit63f5fc988b86e543fa4d161d10786ce8d9ddbaeb (patch)
tree9cc41839df7529f6456b7d12e6c10dd1d335b4fe
parent788ff22a82cd16c5bc31f70a25118a99372bcb5f (diff)
Slightly less ugly tagscore display
And get rid of the spoiler warning in the tag link browser. There are lots of pages that would need it if we applied it consistently.
-rw-r--r--data/style.css15
-rw-r--r--lib/VNDB/Func.pm30
-rw-r--r--lib/VNDB/Handler/Tags.pm2
-rw-r--r--lib/VNDB/Util/BrowseHTML.pm2
-rw-r--r--lib/VNWeb/Tags/Lib.pm16
-rw-r--r--lib/VNWeb/Tags/Links.pm47
6 files changed, 39 insertions, 73 deletions
diff --git a/data/style.css b/data/style.css
index ce7b1ac5..9f2c1d35 100644
--- a/data/style.css
+++ b/data/style.css
@@ -568,8 +568,7 @@ div.scr_uploader { visibility: hidden; overflow: hidden; width: 1px; height:
/****** VN browse ********/
-.vnbrowse thead .tc_s { padding-left: 30px }
-.vnbrowse .tc_s { width: 65px }
+.vnbrowse .tc_s { padding-left: 30px; width: 70px }
.vnbrowse .tc2 { text-align: right; padding: 0; }
.vnbrowse .tc3 { padding: 0; }
.vnbrowse .tc5 { text-align: right; padding-right: 10px }
@@ -930,11 +929,17 @@ div.uposts td.tc4 b { margin-left: 10px }
/***** Tag links *****/
.browse.taglinks .tc1 { width: 70px }
-.browse.taglinks .tc3 { width: 90px }
-.browse.taglinks .ignored .taglvl.taglvlsel { background-color: #222 }
-.browse.taglinks .ignored .taglvl.taglvl0 { color: $grayedout$!important }
+.browse.taglinks .tc3 { width: 80px }
.browse.taglinks .setfil { font-size: 10px; padding-right: 3px }
+.tagscore { white-space: nowrap; display: inline-block; width: 58px; }
+.tagscore > span { display: inline-block; width: 25px; text-align: right; padding-right: 3px; font-size: 11px }
+.tagscore > div { display: inline-block; height: 13px; background: linear-gradient(90deg, #cf0 0px, #0f0 30px) }
+.tagscore.negative > div { background: #f00 }
+.tagscore.negative > span { color: $standout$ }
+.tagscore.ignored > div { background: #222 }
+.tagscore.ignored > span { color: $grayedout$ }
+
/***** VN tagmod *****/
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm
index 96a17106..94d1281e 100644
--- a/lib/VNDB/Func.pm
+++ b/lib/VNDB/Func.pm
@@ -11,7 +11,7 @@ use VNDBUtil;
use VNDB::Types;
use VNDB::BBCode;
our @EXPORT = (@VNDBUtil::EXPORT, 'bb2html', 'bb2text', qw|
- clearfloat cssicon tagscore minage fil_parse fil_serialize parenttags
+ clearfloat cssicon minage fil_parse fil_serialize parenttags
childtags charspoil imgpath imgurl
fmtvote fmtmedia fmtvnlen fmtage fmtdatestr fmtdate fmtrating fmtspoil
lang_attr
@@ -41,34 +41,6 @@ sub cssicon {
}
-# Tag score in html tags, argument: score, users
-sub tagscore {
- my $s = shift;
- div class => 'taglvl', style => sprintf('width: %.0fpx', ($s-floor($s))*10), ' ' if $s < 0 && $s-floor($s) > 0;
- for(-3..3) {
- div(class => "taglvl taglvl0", sprintf '%.1f', $s), next if !$_;
- if($_ < 0) {
- if($s > 0 || floor($s) > $_) {
- div class => "taglvl taglvl$_", ' ';
- } elsif(floor($s) != $_) {
- div class => "taglvl taglvl$_ taglvlsel", ' ';
- } else {
- div class => "taglvl taglvl$_ taglvlsel", style => sprintf('width: %.0fpx', 10-($s-$_)*10), ' ';
- }
- } else {
- if($s < 0 || ceil($s) < $_) {
- div class => "taglvl taglvl$_", ' ';
- } elsif(ceil($s) != $_) {
- div class => "taglvl taglvl$_ taglvlsel", ' ';
- } else {
- div class => "taglvl taglvl$_ taglvlsel", style => sprintf('width: %.0fpx', 10-($_-$s)*10), ' ';
- }
- }
- }
- div class => 'taglvl', style => sprintf('width: %.0fpx', (ceil($s)-$s)*10), ' ' if $s > 0 && ceil($s)-$s > 0;
-}
-
-
sub minage {
my($a, $ex) = @_;
$a = $AGE_RATING{$a};
diff --git a/lib/VNDB/Handler/Tags.pm b/lib/VNDB/Handler/Tags.pm
index 9e771997..5acc948f 100644
--- a/lib/VNDB/Handler/Tags.pm
+++ b/lib/VNDB/Handler/Tags.pm
@@ -525,7 +525,7 @@ sub _tagmod_list {
}
td class => 'tc_myspoil', defined $m->{spoiler} ? $m->{spoiler} : -1;
td class => 'tc_allvote';
- tagscore $t->{rating};
+ VNWeb::Tags::Lib::tagscore_($t->{rating});
i $t->{overruled} ? (class => 'grayedout') : (), " ($t->{cnt})";
b class => 'standout', style => 'font-weight: bold', title => 'Tag overruled. All votes other than that of the moderator who overruled it will be ignored.', ' !' if $t->{overruled};
end;
diff --git a/lib/VNDB/Util/BrowseHTML.pm b/lib/VNDB/Util/BrowseHTML.pm
index 1a7e3878..29d131c5 100644
--- a/lib/VNDB/Util/BrowseHTML.pm
+++ b/lib/VNDB/Util/BrowseHTML.pm
@@ -151,7 +151,7 @@ sub htmlBrowseVN {
Tr;
if($tagscore) {
td class => 'tc_s';
- tagscore $l->{tagscore}, 0;
+ VNWeb::Tags::Lib::tagscore_($l->{tagscore});
end;
}
td class => $tagscore ? 'tc_t' : 'tc1';
diff --git a/lib/VNWeb/Tags/Lib.pm b/lib/VNWeb/Tags/Lib.pm
new file mode 100644
index 00000000..61220186
--- /dev/null
+++ b/lib/VNWeb/Tags/Lib.pm
@@ -0,0 +1,16 @@
+package VNWeb::Tags::Lib;
+
+use VNWeb::Prelude;
+use Exporter 'import';
+
+our @EXPORT = qw/ tagscore_ /;
+
+sub tagscore_ {
+ my($s, $ign) = @_;
+ div_ mkclass(tagscore => 1, negative => $s < 0, ignored => $ign), sub {
+ span_ sprintf '%.1f', $s;
+ div_ style => sprintf('width: %.0fpx', abs $s/3*30), '';
+ };
+}
+
+1;
diff --git a/lib/VNWeb/Tags/Links.pm b/lib/VNWeb/Tags/Links.pm
index 81d8e128..de7189ad 100644
--- a/lib/VNWeb/Tags/Links.pm
+++ b/lib/VNWeb/Tags/Links.pm
@@ -1,35 +1,7 @@
package VNWeb::Tags::Links;
use VNWeb::Prelude;
-
-
-# XXX: This is ugly, both in code and UI. Not sure what to replace it with.
-sub tagscore_ {
- my $s = shift;
- div_ class => 'taglvl', style => sprintf('width: %.0fpx', ($s-floor($s))*10), ' ' if $s < 0 && $s-floor($s) > 0;
- for(-3..3) {
- if($_ < 0) {
- if($s > 0 || floor($s) > $_) {
- div_ class => "taglvl taglvl$_", ' ';
- } elsif(floor($s) != $_) {
- div_ class => "taglvl taglvl$_ taglvlsel", ' ';
- } else {
- div_ class => "taglvl taglvl$_ taglvlsel", style => sprintf('width: %.0fpx', 10-($s-$_)*10), ' ';
- }
- } elsif($_ > 0) {
- if($s < 0 || ceil($s) < $_) {
- div_ class => "taglvl taglvl$_", ' ';
- } elsif(ceil($s) != $_) {
- div_ class => "taglvl taglvl$_ taglvlsel", ' ';
- } else {
- div_ class => "taglvl taglvl$_ taglvlsel", style => sprintf('width: %.0fpx', 10-($_-$s)*10), ' ';
- }
- } else {
- div_ class => "taglvl taglvl0", sprintf '%.1f', $s;
- }
- }
- div_ class => 'taglvl', style => sprintf('width: %.0fpx', (ceil($s)-$s)*10), ' ' if $s > 0 && ceil($s)-$s > 0;
-}
+use VNWeb::Tags::Lib;
sub listing_ {
@@ -53,12 +25,16 @@ sub listing_ {
a_ href => $url->(u => $i->{uid}, p=>undef), class => 'setfil', '> ' if !defined $opt->{u};
user_ $i;
};
- td_ mkclass(tc3 => 1, ignored => $i->{ignored}), sub { tagscore_ $i->{vote} };
+ td_ class => 'tc3', sub { tagscore_ $i->{vote}, $i->{ignore} };
td_ class => 'tc4', sub {
a_ href => $url->(t => $i->{uid}, p=>undef), class => 'setfil', '> ' if !defined $opt->{t};
a_ href => "/g$i->{tag}", $i->{name};
};
- td_ class => 'tc5', !defined $i->{spoiler} ? '' : fmtspoil $i->{spoiler};
+ td_ class => 'tc5', sub {
+ my $s = !defined $i->{spoiler} ? '' : fmtspoil $i->{spoiler};
+ b_ class => 'grayedout', $s if $i->{ignore};
+ txt_ $s if !$i->{ignore};
+ };
td_ class => 'tc6', sub {
a_ href => $url->(v => $i->{vid}, p=>undef), class => 'setfil', '> ' if !defined $opt->{v};
a_ href => "/v$i->{vid}", shorten $i->{title}, 50;
@@ -104,11 +80,6 @@ TUWF::get qr{/g/links}, sub {
framework_ title => 'Tag link browser', sub {
div_ class => 'mainbox', sub {
h1_ 'Tag link browser';
- div_ class => 'warning', sub {
- h2_ 'Spoiler warning';
- p_ 'This list displays the tag votes of individual users. Spoilery tags are not hidden, and may not even be correctly flagged as such.';
- };
- br_;
if($filt) {
p_ 'Active filters:';
ul_ sub {
@@ -130,9 +101,11 @@ TUWF::get qr{/g/links}, sub {
}
}
if($lst && @$lst) {
+ br_;
p_ 'Click the arrow before a user, tag or VN to add it as a filter.'
- if !defined $opt->{u} && !defined $opt->{t} && !defined $opt->{v};
+ unless defined $opt->{u} && defined $opt->{t} && defined $opt->{v};
} else {
+ br_;
p_ 'No tag votes matching the requested filters.';
}
};