summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-07-13 16:29:55 +0200
committerYorhel <git@yorhel.nl>2019-07-13 16:29:57 +0200
commit326b6088461856bd5486afa0ab12fe9c3e117a20 (patch)
treea0e3e1075e47c9025e1b7a120a8188eb03d019cf
parent3780cc63d7e5e07beb72a2e652715c29cd0de492 (diff)
Uh, let's limit the shortened diffs to doc pages
Otherwise character trait listings will also get shortened, which results in broken HTML and doesn't work well.
-rw-r--r--lib/VNDB/Handler/Docs.pm2
-rw-r--r--lib/VNDB/Util/CommonHTML.pm3
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/VNDB/Handler/Docs.pm b/lib/VNDB/Handler/Docs.pm
index 6311ba8f..5848eb2b 100644
--- a/lib/VNDB/Handler/Docs.pm
+++ b/lib/VNDB/Handler/Docs.pm
@@ -82,7 +82,7 @@ sub page {
my $prev = $rev && $rev > 1 && $self->dbDocGetRev(id => $id, rev => $rev-1)->[0];
$self->htmlRevision('d', $prev, $d,
[ title => 'Title', diff => 1 ],
- [ content => 'Content', diff => qr/\s+/ ],
+ [ content => 'Content', diff => qr/\s+/, short_diff => 1 ],
);
}
diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm
index 6d0225e0..1adb726b 100644
--- a/lib/VNDB/Util/CommonHTML.pm
+++ b/lib/VNDB/Util/CommonHTML.pm
@@ -163,6 +163,7 @@ sub htmlHiddenMessage {
# [ shortname, displayname, %options ],
# Where %options:
# diff => 1/0/regex, whether to show a diff on this field, and what to split it with (1 = character-level diff)
+# short_diff=> 1/0, when set, cut off long context in diffs
# serialize => coderef, should convert the field into a readable string, no HTML allowed
# htmlize => same as serialize, but HTML is allowed and this can't be diff'ed
# split => coderef, should return an array of HTML strings that can be diff'ed. (implies diff => 1)
@@ -265,7 +266,7 @@ sub revdiff {
my $a = join($o{join}, @ser1[ $d[$i*2] .. $d[$i*2+2]-1 ]);
my $b = join($o{join}, @ser2[ $d[$i*2+1] .. $d[$i*2+3]-1 ]);
# Reduce context if we have too much
- if($i % 2 == 0 && length($a) > 300) {
+ if($o{short_diff} && $i % 2 == 0 && length($a) > 300) {
my $sep = '<b class="standout">&lt;...&gt;</b>';
my $ctx = 100;
$a = $i == 0 ? $sep.'<br>'.substr $a, -$ctx :