summaryrefslogtreecommitdiff
path: root/lib/VNDB/Util
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-10-16 10:31:24 +0200
committerYorhel <git@yorhel.nl>2019-10-16 15:29:38 +0200
commit678f511619708ba893cb2414eead90cdae685708 (patch)
tree2c79c111805f38454e07d96645f3fdc31fe75860 /lib/VNDB/Util
parent1fb8a234cf5a455af6d78c893320b21de8347bc4 (diff)
v2rw: Convert staff adding/editing form
This is the first major editing form to be converted, so I'm expecting a little breakage. A good chunk of this code has been copied from v3. In terms of the UI there has been a small change: aliases that are still referenced do not have the 'remove' link and instead have a flag that shows that they are still referenced. This ought to be a bit friendlier than throwing an error message after the user has submitted the form. Some other things I'd like to improve in this form: - BBCode preview - Pasting in external links and letting the form figure out the Pixiv ID, etc. - Or perhaps even: Integrate AniDB/Wikidata search/autocompletion.
Diffstat (limited to 'lib/VNDB/Util')
-rw-r--r--lib/VNDB/Util/CommonHTML.pm54
-rw-r--r--lib/VNDB/Util/Misc.pm49
2 files changed, 5 insertions, 98 deletions
diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm
index 81309325..b56a7c74 100644
--- a/lib/VNDB/Util/CommonHTML.pm
+++ b/lib/VNDB/Util/CommonHTML.pm
@@ -268,59 +268,9 @@ sub revdiff {
# Generates a generic message to show as the header of the edit forms
-# Arguments: v/r/p, obj
+# Arguments: v/r/p, obj, title, copy
sub htmlEditMessage {
- my($self, $type, $obj, $title, $copy) = @_;
- my $typename = {v => 'visual novel', r => 'release', p => 'producer', c => 'character', s => 'person'}->{$type};
- my $guidelines = {v => 2, r => 3, p => 4, c => 12, 's' => 16}->{$type};
-
- div class => 'mainbox';
- h1 $title;
- if($copy) {
- div class => 'warning';
- h2 'You\'re not editing an entry!';
- p;
- txt 'You\'re about to insert a new entry into the database with information based on ';
- a href => "/$type$obj->{id}", $obj->{title}||$obj->{name};
- txt '.';
- br;
- txt 'Hit the \'edit\' tab on the right-top if you intended to edit the entry instead of creating a new one.';
- end;
- end;
- }
- div class => 'notice';
- h2 'Before editing:';
- ul;
- li;
- txt "Read the ";
- a href=> "/d$guidelines", 'guidelines';
- txt '!';
- end;
- if($obj) {
- li;
- txt 'Check for any existing discussions on the ';
- a href => $type =~ /[cs]/ ? '/t/db' : $type eq 'r' ? "/t/v$obj->{vn}[0]{vid}" : "/t/$type$obj->{id}", 'discussion board';
- end;
- li;
- txt 'Browse the ';
- a href => "/$type$obj->{id}/hist", 'edit history';
- txt ' for any recent changes related to what you want to change.';
- end;
- } elsif($type ne 'r') {
- li;
- a href => "/$type/all", 'Search the database';
- txt " to see if we already have information about this $typename.";
- end;
- }
- end;
- end;
- if($obj && !$obj->{lastrev}) {
- div class => 'warning';
- h2 'Reverting';
- p "You are editing an old revision of this $typename. If you save it, all changes made after this revision will be reverted!";
- end;
- }
- end 'div';
+ shift; VNWeb::HTML::editmsg_(@_);
}
diff --git a/lib/VNDB/Util/Misc.pm b/lib/VNDB/Util/Misc.pm
index 9cfb8210..394003ae 100644
--- a/lib/VNDB/Util/Misc.pm
+++ b/lib/VNDB/Util/Misc.pm
@@ -7,7 +7,7 @@ use Exporter 'import';
use TUWF ':html';
use VNDB::Func;
use VNDB::Types;
-use VNDB::BBCode ();
+use VNDB::BBCode;
our @EXPORT = qw|filFetchDB filCompat bbSubstLinks entryLinks|;
@@ -114,54 +114,11 @@ sub filCompat {
sub bbSubstLinks {
- my ($self, $msg) = @_;
-
- # Parse a message and create an index of links to resolve
- my %lookup;
- VNDB::BBCode::parse $msg, sub {
- my($code, $tag) = @_;
- $lookup{$1}{$2} = 1 if $tag eq 'dblink' && $code =~ /^(.)(\d+)/;
- 1;
- };
- return $msg unless %lookup;
-
- # Now resolve the links
- my %links;
- my @opt = (results => 50);
-
- if ($lookup{v}) {
- $links{"v$_->{id}"} = $_->{title} for (@{$self->dbVNGet(id => [keys %{$lookup{v}}], @opt)});
- }
- if ($lookup{c}) {
- $links{"c$_->{id}"} = $_->{name} for (@{$self->dbCharGet(id => [keys %{$lookup{c}}], @opt)});
- }
- if ($lookup{p}) {
- $links{"p$_->{id}"} = $_->{name} for (@{$self->dbProducerGet(id => [keys %{$lookup{p}}], @opt)});
- }
- if ($lookup{g}) {
- $links{"g$_->{id}"} = $_->{name} for (@{$self->dbTagGet(id => [keys %{$lookup{g}}], @opt)});
- }
- if ($lookup{i}) {
- $links{"i$_->{id}"} = $_->{name} for (@{$self->dbTraitGet(id => [keys %{$lookup{i}}], @opt)});
- }
- if ($lookup{s}) {
- $links{"s$_->{id}"} = $_->{name} for (@{$self->dbStaffGet(id => [keys %{$lookup{s}}], @opt)});
- }
- return $msg unless %links;
-
- # Now substitute
- my $result = '';
- VNDB::BBCode::parse $msg, sub {
- my($code, $tag) = @_;
- $result .= $tag eq 'dblink' && $links{$code}
- ? sprintf '[url=/%s]%s[/url]', $code, $links{$code}
- : $code;
- 1;
- };
- return $result;
+ shift; bb_subst_links @_;
}
+
# Returns an arrayref of links, each link being [$title, $url, $price]
sub entryLinks {
my($self, $type, $obj) = @_;