summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-04-24 15:46:02 +0200
committerYorhel <git@yorhel.nl>2020-04-24 15:46:02 +0200
commit935d17e532e8d382e4db22f197a5f53a4cc94f98 (patch)
tree8d02e1e0e12acf4abb117054ed47759996493d0c
parent022e02c34f5579113c1e4ff0908bca32cb1753b0 (diff)
v2rw/VN::Page: Some revision display fixes
-rw-r--r--lib/VNWeb/HTML.pm16
-rw-r--r--lib/VNWeb/VN/Page.pm12
2 files changed, 16 insertions, 12 deletions
diff --git a/lib/VNWeb/HTML.pm b/lib/VNWeb/HTML.pm
index c90945fe..369db474 100644
--- a/lib/VNWeb/HTML.pm
+++ b/lib/VNWeb/HTML.pm
@@ -477,7 +477,7 @@ sub _revision_header_ {
sub _revision_fmtval_ {
- my($opt, $val) = @_;
+ my($opt, $val, $obj) = @_;
return i_ '[empty]' if !defined $val || !length $val || (defined $opt->{empty} && $val eq $opt->{empty});
return lit_ html_escape $val if !$opt->{fmt};
if(ref $opt->{fmt} eq 'HASH') {
@@ -486,12 +486,12 @@ sub _revision_fmtval_ {
}
return txt_ $val ? 'True' : 'False' if $opt->{fmt} eq 'bool';
local $_ = $val;
- $opt->{fmt}->();
+ $opt->{fmt}->($obj);
}
sub _revision_fmtcol_ {
- my($opt, $i, $l) = @_;
+ my($opt, $i, $l, $obj) = @_;
my $ctx = 100; # Number of characters of context in textual diffs
my sub sep_ { b_ class => 'standout', '<...>' }; # Context separator
@@ -526,11 +526,11 @@ sub _revision_fmtcol_ {
}
} elsif(@$l > 1 && $i == 2 && ($ch eq '+' || $ch eq 'c')) {
- b_ class => 'diff_add', sub { _revision_fmtval_ $opt, $val }
+ b_ class => 'diff_add', sub { _revision_fmtval_ $opt, $val, $obj }
} elsif(@$l > 1 && $i == 1 && ($ch eq '-' || $ch eq 'c')) {
- b_ class => 'diff_del', sub { _revision_fmtval_ $opt, $val }
+ b_ class => 'diff_del', sub { _revision_fmtval_ $opt, $val, $obj }
} elsif($ch eq 'c' || $ch eq 'u' || @$l == 1) {
- _revision_fmtval_ $opt, $val;
+ _revision_fmtval_ $opt, $val, $obj;
}
}, @$l;
};
@@ -578,8 +578,8 @@ sub _revision_diff_ {
tr_ sub {
td_ $name;
- _revision_fmtcol_ \%opt, 1, $l;
- _revision_fmtcol_ \%opt, 2, $l;
+ _revision_fmtcol_ \%opt, 1, $l, $old;
+ _revision_fmtcol_ \%opt, 2, $l, $new;
}
}
diff --git a/lib/VNWeb/VN/Page.pm b/lib/VNWeb/VN/Page.pm
index 98142b24..0d2d440d 100644
--- a/lib/VNWeb/VN/Page.pm
+++ b/lib/VNWeb/VN/Page.pm
@@ -27,9 +27,10 @@ sub enrich_vn {
}
-# Enrich everything necessary for rev_() (that also needs enrich_vn())
+# Enrich everything necessary for rev_() (includes enrich_vn())
sub enrich_item {
my($v) = @_;
+ enrich_vn $v;
enrich_merge aid => 'SELECT id AS sid, aid, name, original FROM staff_alias WHERE aid IN', $v->{staff}, $v->{seiyuu};
enrich_merge cid => 'SELECT id AS cid, name AS char_name, original AS char_original FROM chars WHERE id IN', $v->{seiyuu};
enrich_merge scr => 'SELECT id AS scr, width, height FROM images WHERE id IN', $v->{screenshots};
@@ -84,8 +85,12 @@ sub rev_ {
a_ href => tuwf->imgurl($_->{scr}), 'data-iv' => "$_->{width}x$_->{height}", $_->{scr};
txt_ $_->{nsfw} ? ' (Not safe)' : ' (Safe)';
}],
- [ image => 'Image', fmt => sub { a_ href => tuwf->imgurl($_), $_ } ], # TODO: Preview if SFW
- [ img_nsfw => 'Image NSFW', fmt => sub { $_ ? 'Not safe' : 'Safe' } ],
+ [ image => 'Image', fmt => sub {
+ !viewget->{show_nsfw} && $_[0]{img_nsfw}
+ ? a_ href => tuwf->imgurl($_), '(NSFW)'
+ : img_ src => tuwf->imgurl($_)
+ } ],
+ [ img_nsfw => 'Image NSFW', fmt => sub { txt_ $_ ? 'Not safe' : 'Safe' } ],
revision_extlinks 'v'
}
@@ -762,7 +767,6 @@ TUWF::get qr{/$RE{vrev}}, sub {
my $v = db_entry v => tuwf->capture('id'), tuwf->capture('rev');
return tuwf->resNotFound if !$v;
- enrich_vn $v;
enrich_item $v;
framework_ title => $v->{title}, index => !tuwf->capture('rev'), type => 'v', dbobj => $v, hiddenmsg => 1, og => og($v),