summaryrefslogtreecommitdiff
path: root/lib/VNDB/Util
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VNDB/Util')
-rw-r--r--lib/VNDB/Util/CommonHTML.pm34
-rw-r--r--lib/VNDB/Util/FormHTML.pm18
-rw-r--r--lib/VNDB/Util/LayoutHTML.pm20
3 files changed, 51 insertions, 21 deletions
diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm
index 6b6725c6..6e50632d 100644
--- a/lib/VNDB/Util/CommonHTML.pm
+++ b/lib/VNDB/Util/CommonHTML.pm
@@ -17,18 +17,22 @@ our @EXPORT = qw|
# generates the "main tabs". These are the commonly used tabs for
# 'objects', i.e. VN/producer/release entries and users
-# Arguments: u/v/r/p, object, currently selected item (empty=main)
+# Arguments: u/v/r/p/g, object, currently selected item (empty=main)
sub htmlMainTabs {
my($self, $type, $obj, $sel) = @_;
$sel ||= '';
my $id = $type.$obj->{id};
+ return if $type eq 'g' && !$self->authCan('tagmod');
+
ul class => 'maintabs';
- li $sel eq 'hist' ? (class => 'tabselected') : ();
- a href => "/$id/hist", 'history';
- end;
+ if($type =~ /[uvrp]/) {
+ li $sel eq 'hist' ? (class => 'tabselected') : ();
+ a href => "/$id/hist", 'history';
+ end;
+ }
- if($type ne 'r') {
+ if($type =~ /[uvp]/) {
my $cnt = $self->dbThreadCount($type, $obj->{id});
li $sel eq 'disc' ? (class => 'tabselected') : ();
a href => "/t/$id", "discussions ($cnt)";
@@ -43,22 +47,34 @@ sub htmlMainTabs {
li $sel eq 'list' ? (class => 'tabselected') : ();
a href => "/$id/list", 'list';
end;
+
+ li $sel eq 'tags' ? (class => 'tabselected') : ();
+ a href => "/$id/tags", 'tags';
+ end;
+ }
+
+ if($type eq 'v' && $self->authCan('tag')) {
+ li $sel eq 'tagmod' ? (class => 'tabselected') : ();
+ a href => "/$id/tagmod", 'modify tags';
+ end;
}
- if($type eq 'u' && ($self->authInfo->{id} && $obj->{id} == $self->authInfo->{id} || $self->authCan('usermod'))
- || $type ne 'u' && $self->authCan('edit') && (!$obj->{locked} || $self->authCan('lock')) && (!$obj->{hidden} || $self->authCan('del'))) {
+ if( $type eq 'u' && ($self->authInfo->{id} && $obj->{id} == $self->authInfo->{id} || $self->authCan('usermod'))
+ || $type =~ /[vrp]/ && $self->authCan('edit') && (!$obj->{locked} || $self->authCan('lock')) && (!$obj->{hidden} || $self->authCan('del'))
+ || $type eq 'g' && $self->authCan('tagmod')
+ ) {
li $sel eq 'edit' ? (class => 'tabselected') : ();
a href => "/$id/edit", 'edit';
end;
}
- if($type ne 'u' && $self->authCan('del')) {
+ if($type =~ /[vrp]/ && $self->authCan('del')) {
li;
a href => "/$id/hide", $obj->{hidden} ? 'unhide' : 'hide';
end;
}
- if($type ne 'u' && $self->authCan('lock')) {
+ if($type =~ /[vrp]/ && $self->authCan('lock')) {
li;
a href => "/$id/lock", $obj->{locked} ? 'unlock' : 'lock';
end;
diff --git a/lib/VNDB/Util/FormHTML.pm b/lib/VNDB/Util/FormHTML.pm
index 75471830..17de6663 100644
--- a/lib/VNDB/Util/FormHTML.pm
+++ b/lib/VNDB/Util/FormHTML.pm
@@ -14,6 +14,7 @@ my %formerr_names = (
alias => 'Aliases',
anime => 'Anime',
desc => 'Description',
+ description => 'Description',
editsum => 'Edit summary',
gtin => 'JAN/EAN/UPC',
lang => 'Language',
@@ -33,7 +34,7 @@ my %formerr_names = (
platforms => 'Platforms',
producers => 'Producers',
released => 'Release date',
- tags => 'Tags',
+ boards => 'Boards',
title => 'Title',
type => 'Type',
usrname => 'Username',
@@ -79,7 +80,14 @@ sub htmlFormError {
li sprintf '%s should have at least %d characters', $field, $rule if $type eq 'minlength';
li sprintf '%s: only %d characters allowed', $field, $rule if $type eq 'maxlength';
li sprintf '%s must be one of the following: %s', $field, join ', ', @$rule if $type eq 'enum';
- li sprintf 'Wrong tag: %s', $rule if $type eq 'wrongtag';
+ li sprintf 'Wrong board: %s', $rule if $type eq 'wrongboard';
+ if($type eq 'tagexists') {
+ li;
+ lit $rule->{state} != 1 ? qq|Tag <a href="/g$rule->{id}">$rule->{name}</a> already exists!|
+ : qq|A tag <a href="/g$rule->{id}">with the same name</a> has been deleted in the past,|
+ .qq| please use <a href="/t/db">the discussion board</a> if you want it to be re-added.|;
+ end;
+ }
li $rule->[1] if $type eq 'func' || $type eq 'regex';
if($type eq 'template') {
li sprintf
@@ -151,7 +159,9 @@ sub htmlFormPart {
if(!$o{nolabel}) {
td class => 'label';
if($o{short} && $o{name}) {
- label for => $o{short}, $o{name} ;
+ label for => $o{short};
+ lit $o{name};
+ end;
} elsif($o{label}) {
txt $o{label};
} else {
@@ -251,7 +261,9 @@ sub htmlForm {
end;
br;
}
+ b "Don't forget! -> " if $options->{hitsubmit};
input type => 'submit', value => 'Submit', class => 'submit';
+ b ' <-' if $options->{hitsubmit};
end;
end;
diff --git a/lib/VNDB/Util/LayoutHTML.pm b/lib/VNDB/Util/LayoutHTML.pm
index ccf2a9c6..fcd088a4 100644
--- a/lib/VNDB/Util/LayoutHTML.pm
+++ b/lib/VNDB/Util/LayoutHTML.pm
@@ -57,6 +57,7 @@ sub _menu {
div;
a href => '/', 'Home'; br;
a href => '/v/all', 'Visual novels'; br;
+ a href => '/g', 'Tags'; br;
a href => '/p/all', 'Producers'; br;
a href => '/u/all', 'Users'; br;
a href => '/hist', 'Recent changes'; br;
@@ -87,6 +88,7 @@ sub _menu {
a href => "$uid/wish", 'My Wishlist'; br;
a href => "/t$uid", 'My Messages'; br;
a href => "$uid/hist", 'My Recent Changes'; br;
+ a href => "$uid/tags", 'My Tags'; br;
br;
a href => '/v/new', 'Add Visual Novel'; br;
a href => '/p/new', 'Add Producer'; br;
@@ -141,6 +143,14 @@ sub _menu {
sub htmlFooter {
my $self = shift;
div id => 'footer';
+
+ my $q = $self->dbRandomQuote;
+ if($q && $q->{vid}) {
+ lit '"';
+ a href => "/v$q->{vid}", style => 'text-decoration: none', $q->{quote};
+ txt qq|"\n|;
+ }
+
txt "vndb $self->{version} | ";
a href => '/d7', 'about us';
txt ' | ';
@@ -149,14 +159,6 @@ sub htmlFooter {
a href => $self->{source_url}, 'source';
end;
end; # /div maincontent
- if($self->debug) {
- div id => 'debug';
- h2 'This is not VNDB!';
- txt 'The real VNDB is ';
- a href => 'http://vndb.org/', 'here';
- txt '.';
- end;
- }
end; # /body
end; # /html
@@ -165,7 +167,7 @@ sub htmlFooter {
lit "\n<!--\n SQL Queries:\n";
for (@{$self->{_YAWF}{DB}{queries}}) {
my $q = !ref $_->[0] ? $_->[0] :
- $_->[0][0].(exists $_->[0][1] ? ' | "'.join('", "', @{$_->[0]}[1..$#{$_->[0]}]).'"' : '');
+ $_->[0][0].(exists $_->[0][1] ? ' | "'.join('", "', map defined()?$_:'NULL', @{$_->[0]}[1..$#{$_->[0]}]).'"' : '');
$q =~ s/^\s//g;
lit sprintf " [%6.2fms] %s\n", $_->[1]*1000, $q;
}