diff options
author | Yorhel <git@yorhel.nl> | 2008-11-22 10:04:35 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2008-11-22 10:04:35 +0100 |
commit | 91c9b4428260c9a4b22de78d41d946a95503c50f (patch) | |
tree | e7e5b8c24172b67042b41d2e89fc7cf0231a5a01 /lib | |
parent | aac83c8b840f62d3febf2212b86bf7cf40eb3fa1 (diff) |
Created htmlEditMessage() and started on /v+/edit
It'll take a while before the VN edit form is finished... it's
one of the most complex things of VNDB.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VNDB/Handler/Producers.pm | 22 | ||||
-rw-r--r-- | lib/VNDB/Handler/VNEdit.pm | 32 | ||||
-rw-r--r-- | lib/VNDB/Util/CommonHTML.pm | 33 |
3 files changed, 65 insertions, 22 deletions
diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm index 27f3a852..5669d7b4 100644 --- a/lib/VNDB/Handler/Producers.pm +++ b/lib/VNDB/Handler/Producers.pm @@ -129,27 +129,7 @@ sub edit { $self->htmlHeader(title => $pid ? 'Edit '.$p->{name} : 'Add new producer'); $self->htmlMainTabs('p', $p, 'edit') if $pid; - div class => 'mainbox'; - h1 $pid ? 'Edit '.$p->{name} : 'Add new producer'; - div class => 'notice'; - h2 'Before editing:'; - ul; - li; lit 'Read the <a href="/d4">guidelines</a>!'; end; - if($pid) { - li; lit qq|Check for any existing discussions on the <a href="/t/p$pid">discussion board</a>|; end; - li; lit qq|Browse the <a href="/p$pid/hist">edit history</a> for any recent changes related to what you want to change.|; end; - } else { - li; lit qq|<a href="/p/all">Search the database</a> to see if we already have information about this producer|; end; - } - end; - end; - if($rev) { - div class => 'warning'; - h2 'Reverting'; - p 'You are editing an old revision of this producer. If you save it, all changes made after this revision will be reverted!'; - end; - } - end; + $self->htmlEditMessage('p', $p); $self->htmlForm({ frm => $frm, action => $pid ? "/p$pid/edit" : '/p/new', editsum => 1 }, "General info" => [ [ select => name => 'Type', short => 'type', options => [ map [ $_, $self->{producer_types}{$_} ], sort keys %{$self->{producer_types}} ] ], diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm new file mode 100644 index 00000000..13856fb3 --- /dev/null +++ b/lib/VNDB/Handler/VNEdit.pm @@ -0,0 +1,32 @@ + +package VNDB::Handler::VNEdit; + +use strict; +use warnings; +use YAWF ':html'; + + +YAWF::register( + qr{v([1-9]\d*)/edit}, \&edit, +); + + +sub edit { + my($self, $vid) = @_; + + my $v = $self->dbVNGet(id => $vid, what => 'extended screenshots relations anime categories changes')->[0]; + return 404 if !$v->{id}; + + return $self->htmlDenied if !$self->authCan('edit') + || ($v->{locked} && !$self->authCan('lock') || $v->{hidden} && !$self->authCan('del')); + + + $self->htmlHeader(title => 'Edit '.$v->{title}); + $self->htmlMainTabs('v', $v, 'edit'); + $self->htmlEditMessage('v', $v); + $self->htmlFooter; +} + + +1; + diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm index 7a41f81e..48509d65 100644 --- a/lib/VNDB/Util/CommonHTML.pm +++ b/lib/VNDB/Util/CommonHTML.pm @@ -9,7 +9,7 @@ use Algorithm::Diff::XS 'compact_diff'; use VNDB::Func; use Encode 'encode_utf8', 'decode_utf8'; -our @EXPORT = qw|htmlMainTabs htmlDenied htmlHiddenMessage htmlBrowse htmlBrowseNavigate htmlRevision|; +our @EXPORT = qw|htmlMainTabs htmlDenied htmlHiddenMessage htmlBrowse htmlBrowseNavigate htmlRevision htmlEditMessage|; # generates the "main tabs". These are the commonly used tabs for @@ -326,4 +326,35 @@ sub revdiff { } +# Generates a generic message to show as the header of the edit forms +# Arguments: v/r/p, obj +sub htmlEditMessage { + my($self, $type, $obj) = @_; + my $full = {v => 'visual novel', r => 'release', p => 'producer'}->{$type}; + my $guidelines = {v => 2, r => 3, p => 4}->{$type}; + + div class => 'mainbox'; + h1 $obj ? "Edit $obj->{name}" : "Add new $full"; + div class => 'notice'; + h2 'Before editing:'; + ul; + li; lit qq|Read the <a href="/d$guidelines">guidelines</a>!|; end; + if($obj) { + li; lit qq|Check for any existing discussions on the <a href="/t/$type$obj->{id}">discussion board</a>|; end; + li; lit qq|Browse the <a href="/$type$obj->{id}/hist">edit history</a> for any recent changes related to what you want to change.|; end; + } elsif($type ne 'r') { + li; lit qq|<a href="/$type/all">Search the database</a> to see if we already have information about this $full|; end; + } + end; + end; + if($obj && $obj->{latest} != $obj->{cid}) { + div class => 'warning'; + h2 'Reverting'; + p qq|You are editing an old revision of this $full. If you save it, all changes made after this revision will be reverted!|; + end; + } + end; +} + + 1; |