#Some debug
'test' => \&PciIds::Html::Debug::test,
#Notifications
- 'notifications' => \&PciIds::Html::Notifications::notifForm
+ 'notifications' => \&PciIds::Html::Notifications::notifForm,
+ 'help' => \&PciIds::Html::Help::getHelp
},
'POST' => {
'newitem' => \&PciIds::Html::Changes::newItemSubmit,
my( $req, $hasSSL ) = @_;
return HTTPRedirect( $req, $req->uri()."index.html" ) if( $req->uri() eq '/' );
return DECLINED if( $req->uri() =~ /^\/((static)\/|robots.txt|index.html)/ );
- return getHelp( $req ) if( $req->uri() =~ /^\/help/ );
my $args = parseArgs( $req->args() );
my $action = $args->{'action'};
$action = '' unless( defined $action );
use warnings;
use PciIds::Startup;
use PciIds::Html::Util;
+use PciIds::Address;
use Apache2::Const qw(:common :http);
use base 'Exporter';
our @EXPORT=qw(getHelp);
-sub getHelp($) {
- my( $req ) = @_;
- my( $helpname ) = ( $req->uri() =~ /^\/help\/(.*)/ );
- return NOT_FOUND if( $helpname =~ /[\/.]/ || $helpname eq '' );
+sub getHelp( $$ ) {
+ my( $req, $args, $tables, $auth ) = @_;
+ my $helpname = $args->{'help'};
+ return NOT_FOUND if( !defined $helpname || $helpname =~ /[\/.]/ || $helpname eq '' );
open HELP, "$directory/help/$helpname" or return NOT_FOUND;
my $head = <HELP>;
chomp $head;
genHtmlHead( $req, $head, undef );
- print "<h1>$head</h1>\n";
+ my $addr = PciIds::Address::new( $req->uri() );
+ print "<h1>$head (".$addr->pretty().")</h1>\n";
+ genMenu( $req, $addr, $args, $auth, undef );
+ genPath( $req, $addr, 1 );
+ my $url = '/read'.$req->uri().buildExcept( 'help', $args ).'?help=';
+ print "<div class='navigation'><ul><li><a href='$url=index'>Help index</a></ul></div>\n" if( $helpname ne 'index' );
while( defined( my $line = <HELP> ) ) {
+ $line =~ s/\$CUR_LINK\$/$url/g;
print $line;
}
close HELP;
my $id = $address->pretty();
genHtmlHead( $req, $id, undef );
print '<h1>'.encode( $id ).'</h1>';
- genMenu( $req, $address, $args, $auth );
+ genMenu( $req, $address, $args, $auth, 'list' );
+ genPath( $req, $address, 0 );
print htmlDiv( 'name', '<p>'.encode( $name ) ) if( defined( $name ) );
print htmlDiv( 'note', '<p>'.encode( $note ) ) if( defined( $note ) );
- genPath( $req, $address, 0 );
my $diss = 0;
my $history;
foreach $history ( @{$tables->history( $address->get() )} ) {
}
print "</div>\n" if( $diss );
unless( $address->leaf() ) {
- print "<h2>Subitems</h2>\n";
+ print "<h2>Sub-items</h2>\n";
my $restricts = $address->defaultRestrictList();
if( scalar @{$restricts} ) {
print "<p>";
}
print "</ul></div>\n" if( $started );
print "<form name='notifications' id='notifications' method='POST' action=''>\n";
- print "<h3>Effect range</h3>\n";
+ print "<h2>Effect range</h2>\n";
print "<p><input type='checkbox' value='recursive' name='recursive'".( $data->{'recursive'} ? " checked='checked'" : "" )."> Recursive\n";
- print "<h3>Notification level</h3>\n";
+ print "<h2>Notification level</h2>\n";
print "<p>\n";
genRadios( [ [ 'None', '3' ], [ 'Main comment & new subitem', '2' ], [ 'Description', '1' ], [ 'Comment', '0' ] ], 'notification', ( defined $data->{'notification'} ) ? $data->{'notification'} : '3' );
- print "<h3>Notification way</h3>\n";
+ print "<h2>Notification way</h2>\n";
print "<p>\n";
genRadios( [ [ 'Email', '0' ], [ 'Xmpp', '1' ], [ 'Both', '2' ] ], 'way', ( defined $data->{'way'} ) ? $data->{'way'} : '0' );
print "<p><input type='submit' value='Submit' name='submit'>\n";
print "</form>\n";
if( @{$notifs} ) {
- print "<div class='navigation'><h3>All notifications</h3><ul>\n";
+ print "<div class='navigation'><h2>All notifications</h2><ul>\n";
foreach( @{$notifs} ) {
my( $location ) = @{$_};
print "<li><a href='/$location".buildArgs( $args )."'>".PciIds::Address::new( $location )->pretty()."</a>\n";
return '<div class="'.$class.'">'.$text.'</div>';
}
-sub item( $$$ ) {
- my( $url, $label, $action ) = @_;
- print " <li><a href='".$url.$action."'>$label</a>\n";
+sub item( $$ ) {
+ my( $url, $label ) = @_;
+ print " <li><a href='".$url."'>$label</a>\n";
}
sub genCustomMenu( $$$$ ) {
my $url = '/'.$address->get().buildExcept( 'action', $args ).'?action=';
print "<div class='menu'>\n<ul>\n";
foreach( @{$list} ) {
- my( $label, $action ) = @{$_};
+ my( $label, $action, $param ) = @{$_};
my $prefix = '/mods';
- $prefix = '/read' if( !defined( $action ) or ( $action eq 'list' ) or ( $action eq '' ) );
- item( 'http://'.$req->hostname().$prefix.$url, $label, $action );
+ $prefix = '/read' if( !defined( $action ) or ( $action eq 'list' ) or ( $action eq '' ) or ( $action eq 'help' ) );
+ my $suffix = '';
+ $suffix = '?help='.$param if( $action eq 'help' );
+ item( 'http://'.$req->hostname().$prefix.$url.$action.$suffix, $label );
}
print "</ul></div>\n";
}
}
}
-sub genMenu( $$$$ ) {
- my( $req, $address, $args, $auth ) = @_;
+sub genMenu( $$$$$ ) {
+ my( $req, $address, $args, $auth, $help ) = @_;
my @list = ( logItem( $auth ) );
push @list, [ 'Add item', 'newitem' ] if( $address->canAddItem() );
push @list, [ 'Discuss', 'newhistory' ] if( $address->canDiscuss() );
push @list, [ 'Administrate', 'admin' ] if( hasRight( $auth->{'accrights'}, 'validate' ) );
push @list, [ 'Profile', 'profile' ] if defined $auth->{'authid'};
push @list, [ 'Notifications', 'notifications' ] if defined $auth->{'authid'};
+ push @list, [ 'Help', 'help', $help ] if defined $help;
genCustomMenu( $req, $address, $args, \@list );
}
--- /dev/null
+Browsing ID list
+<p>
+You can examine the current list of IDs.
+The IDs are organized into a tree.
+<h2>Page anatomy</h2>
+<p>
+Page is divided into parts:
+<ul>
+ <li><strong>Menu</strong> ‒ you can perform actions, both in connection with current item (like <a href='$CUR_LINK$newitem'>adding a new sub-item</a>) and global (<a href='$CUR_LINK$profile'>editing your profile</a>).
+ <li><strong>Hierarchy</strong> ‒ lists all parental items.
+ <li><strong>Discussion</strong> ‒ contains history of suggested names, notes and general talk about current item.
+ <li><strong>List of sub-items</strong> ‒ all direct sub-items are listed here and you can browse into them.
+</ul>
+
+You can find menu and hierarchy in most other pages and they have the same function.
+
+<h2>Colors</h2>
+Colors are used both in discussion and list of sub-items to mark status of discussion comments and sub-items respectively.
+<span class='main-history'>Green entries</span> are discussion comments which provide current item name.
+<span class='unseen-history'>Grey ones</span> are entries with some problem. They are either items without any assigned name (discussion about non-existing item, new item which was not yet approved by an admin) or discussion comments not yet seen by an admin.
+<span class='history'>White ones</span> are the rest, usual discussion and valid items.
+
+<h2>Example</h2>
+<div class='help-example'>
+<h1>ID 0000</h1>
+<div class='menu'><ul>
+ <li><a href='$CUR_LINK$account'>Log in</a>
+ <li><a href='$CUR_LINK$newitem'>Add item</a>
+ <li><a href='$CUR_LINK$newhistory'>Discuss</a>
+</ul></div>
+<div class='navigation'><ul>
+ <li><a href='$CUR_LINK$index'>Parent</a>
+</div>
+<div class='name'><p>ID name</div>
+<div class='discussion'><h2>Discussion</h2>
+<div class='main-history'>
+ <p class='itemname'>Name: ID name
+ <p class='discussion-text'>This item is here just as an example.
+ <p class='author'>Author
+ <p class='time'>1900-01-01 00:00
+</div>
+</div>
+<h2>Sub-items</h2>
+<table class='subnodes'><col class='id-col'><col class='name-col'><col class='note-col'>
+<th>Id<th>Name<th>Note
+<tr class='item'><td>1234<td>Sub-item<td>This is just example
+</table>
+</div>
{
background: #DDFFDD;
}
+.help-example
+{
+ background: #BBBBFF;
+ padding: 0.3em;
+}
.itemname, .name
{
font-weight: bold;