summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--data/config_example.pl1
-rw-r--r--data/js/chartraits.js2
-rw-r--r--lib/VNDB/DB/Traits.pm8
-rw-r--r--lib/VNDB/Handler/Traits.pm9
-rw-r--r--util/sql/schema.sql3
6 files changed, 16 insertions, 9 deletions
diff --git a/README.md b/README.md
index 7ddc7755..3ae842cd 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,7 @@ this database manually as follows:
Global requirements:
- Linux, or an OS that resembles Linux. Chances are VNDB won't run on Windows.
-- PostgreSQL 9.10 (older versions may work)
+- PostgreSQL 10 (older versions may work)
- perl 5.24 recommended, 5.10+ may also work
**Perl modules** (core modules are not listed):
diff --git a/data/config_example.pl b/data/config_example.pl
index 4d0988c6..aab37d10 100644
--- a/data/config_example.pl
+++ b/data/config_example.pl
@@ -11,6 +11,7 @@ package VNDB;
log_queries => 0,
debug => 1,
cookie_defaults => { domain => 'localhost', path => '/' },
+ mail_sendmail => 'log',
);
%S = (
diff --git a/data/js/chartraits.js b/data/js/chartraits.js
index eece14dc..05f6e53d 100644
--- a/data/js/chartraits.js
+++ b/data/js/chartraits.js
@@ -70,7 +70,7 @@ function ctrFormAdd(item) {
else if(item.getAttribute('meta') == 'yes')
alert('Meta traits can\'t be used here.');
else
- ctrAdd(item, 0);
+ ctrAdd(item, Math.floor(item.getAttribute('defaultspoil')));
return '';
}
diff --git a/lib/VNDB/DB/Traits.pm b/lib/VNDB/DB/Traits.pm
index 728e4e85..4ed64e3f 100644
--- a/lib/VNDB/DB/Traits.pm
+++ b/lib/VNDB/DB/Traits.pm
@@ -42,7 +42,7 @@ sub dbTraitGet {
);
my @select = (
- qw|t.id t.meta t.name t.description t.state t.alias t."group" t."order" t.sexual t.c_items|,
+ qw|t.id t.meta t.name t.description t.state t.alias t."group" t."order" t.sexual t.c_items t.defaultspoil|,
'tg.name AS groupname', 'tg."order" AS grouporder', q|extract('epoch' from t.added) as added|,
$o{what} =~ /addedby/ ? ('t.addedby', 'u.username') : (),
);
@@ -86,7 +86,7 @@ sub dbTraitEdit {
$self->dbExec('UPDATE traits !H WHERE id = ?', {
$o{upddate} ? ('added = NOW()' => 1) : (),
- map exists($o{$_}) ? ("\"$_\" = ?" => $o{$_}) : (), qw|name meta description state alias group order sexual|
+ map exists($o{$_}) ? ("\"$_\" = ?" => $o{$_}) : (), qw|name meta description state alias group order sexual defaultspoil|
}, $id);
if($o{parents}) {
$self->dbExec('DELETE FROM traits_parents WHERE trait = ?', $id);
@@ -99,8 +99,8 @@ sub dbTraitEdit {
# returns the id of the new trait
sub dbTraitAdd {
my($self, %o) = @_;
- my $id = $self->dbRow('INSERT INTO traits (name, meta, description, state, alias, "group", "order", sexual, addedby) VALUES (!l, ?) RETURNING id',
- [ map $o{$_}, qw|name meta description state alias group order sexual| ], $o{addedby}||$self->authInfo->{id}
+ my $id = $self->dbRow('INSERT INTO traits (name, meta, description, state, alias, "group", "order", sexual, defaultspoil, addedby) VALUES (!l, ?) RETURNING id',
+ [ map $o{$_}, qw|name meta description state alias group order sexual defaultspoil| ], $o{addedby}||$self->authInfo->{id}
)->{id};
$self->dbExec('INSERT INTO traits_parents (trait, parent) VALUES (?, ?)', $id, $_) for(@{$o{parents}});
return $id;
diff --git a/lib/VNDB/Handler/Traits.pm b/lib/VNDB/Handler/Traits.pm
index a8c344c9..683418a1 100644
--- a/lib/VNDB/Handler/Traits.pm
+++ b/lib/VNDB/Handler/Traits.pm
@@ -149,6 +149,7 @@ sub traitedit {
{ post => 'description', required => 0, maxlength => 10240, default => '' },
{ post => 'parents', required => !$self->authCan('tagmod'), default => '', regex => [ qr/^(?:$|(?:[1-9]\d*)(?: +[1-9]\d*)*)$/, 'Parent traits must be a space-separated list of trait IDs' ] },
{ post => 'order', required => 0, default => 0, template => 'uint' },
+ { post => 'defaultspoil',required => 0, default => 0, enum => [0..2] },
);
my @parents = split /[\t ]+/, $frm->{parents};
my $group = undef;
@@ -175,6 +176,7 @@ sub traitedit {
sexual => $frm->{sexual}?1:0,
alias => $frm->{alias},
order => $frm->{order},
+ defaultspoil => $frm->{defaultspoil},
parents => \@parents,
group => $group,
);
@@ -190,7 +192,7 @@ sub traitedit {
}
if($t) {
- $frm->{$_} ||= $t->{$_} for (qw|name meta sexual description state alias order|);
+ $frm->{$_} ||= $t->{$_} for (qw|name meta sexual description state alias order defaultspoil|);
$frm->{parents} ||= join ' ', map $_->{id}, @{$t->{parents}};
}
@@ -222,6 +224,8 @@ sub traitedit {
[ checkbox => short => 'sexual', name => 'Indicates sexual content' ],
[ textarea => short => 'alias', name => "Aliases\n(Separated by newlines)", cols => 30, rows => 4 ],
[ textarea => short => 'description', name => 'Description' ],
+ [ select => short => 'defaultspoil', name => 'Default spoiler level', options => [ map [$_, fmtspoil $_], 0..2 ] ],
+ [ static => content => 'This is the spoiler level that will be selected by default when adding this trait to a character.' ],
[ input => short => 'parents', name => 'Parent traits' ],
[ static => content => 'List of trait IDs to be used as parent for this trait, separated by a space.' ],
$self->authCan('tagmod') ? (
@@ -422,7 +426,8 @@ sub traitxml {
xml;
tag 'traits', more => $np ? 'yes' : 'no';
for(@$list) {
- tag 'item', id => $_->{id}, meta => $_->{meta} ? 'yes' : 'no', group => $_->{group}||'', groupname => $_->{groupname}||'', state => $_->{state}, $_->{name};
+ tag 'item', id => $_->{id}, meta => $_->{meta} ? 'yes' : 'no', group => $_->{group}||'',
+ groupname => $_->{groupname}||'', state => $_->{state}, defaultspoil => $_->{defaultspoil}, $_->{name};
}
end;
}
diff --git a/util/sql/schema.sql b/util/sql/schema.sql
index 02f15e09..b3669dd5 100644
--- a/util/sql/schema.sql
+++ b/util/sql/schema.sql
@@ -559,7 +559,8 @@ CREATE TABLE traits (
"group" integer,
"order" smallint NOT NULL DEFAULT 0,
sexual boolean NOT NULL DEFAULT false,
- c_items integer NOT NULL DEFAULT 0
+ c_items integer NOT NULL DEFAULT 0,
+ defaultspoil smallint NOT NULL DEFAULT 0
);
-- traits_chars