App-zen
view release on metacpan or search on metacpan
"--latex" => [\$opt_latex, 'Set output format for documentation'],
"--source-map FILENAME" => [\$opt_source_map, 'Generate source map'],
"--top-heading LEVEL" => [\$opt_top_heading, 'Set top level section type: <part|chapter|section>'],
"--document-class CLASS" => [\$opt_document_class, 'Set latex document class'],
"--verbose" => [\$opt_verbose, 'More logging'],
"--output FILENAME" => [\$opt_output_file, 'Set output file'],
"--port PORT:i" => [\$opt_port, 'Start HTTP Server at port'],
"--daemon" => [\$opt_daemon, "Run server in background"],
"--json-dump" => [\$opt_json_dump, 'Dump the document'],
"-x SECTION" => [\$opt_exec, 'short for --exec'],
"-o OUTPUTFILE" => [\$opt_output_file, 'short for --output'],
"-t SECTION" => [\$opt_target, 'short for --target'],
"-s SECTION" => [\$opt_target, 'short for --section'],
"-h" => [\$opt_help, 'Shows help information'],
);
my %optionsSpec = map {
my $k = $_;
my $ref = $options{$_}[0];
my @x = split /\s+/, $k;
$ln++;
}
print $output $_->{text},"\n";
}
}
use Data::Dumper;
sub docgen_html {
my $zf = shift;
my $old = select(shift);
print "<!DOCTYPE HTML>\n\n<html>\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/gh/highlightjs/cdn-release\@10.7.3/build/style...
print "<script>";
print "window.zen = ";
print JSON::encode_json({
last_modified => $zf->{last_modified},
size => $zf->{size},
});
print "</script>";
print '<div class="container">';
print '<aside class="col foldable narrow">';
my $method = $cgi->request_method();
if ($method eq 'GET' && $path =~ m/\/$/) {
on_list_dir($cgi, ".$path");
} elsif ($method eq 'GET' && $path eq '/hello') {
on_hello($cgi);
} elsif ($method eq 'GET') {
on_get_file($cgi, ".$path");
} elsif ($method eq 'POST') {
on_append_file($cgi, ".$path");
} elsif ($method eq 'PUT') {
on_put_file($cgi, ".$path");
} else {
print "HTTP/1.0 400 Bad Request\r\n\r\nUnsupported Request\n";
}
}
# Should return the data since last fetch offset.
sub on_append_file {
my ($cgi, $path) = @_;
my $data = $cgi->param('POSTDATA');
if (!$last_mtime) {
write_error(409, "Conflict", "Missing query parameter 'last_modified' l=$l");
print Dumper $cgi;
return;
}
if ($last_mtime != $mtime) {
write_error(409, "Conflict", "last modified doesn't match: $mtime");
return;
}
}
my $data = $cgi->param('PUTDATA');
if ($l == 0) {
write_file($path, $data);
} elsif ($l > 0) {
$data .= "\n" unless !$data || substr($data, -1) eq "\n";
open my $fh, '<', $path or die "Can not open file: $!";
my $x = '';
my $y = '';
while (<$fh>) {
if ($l > 1) {
$x .= $_;
( run in 0.363 second using v1.01-cache-2.11-cpan-4e96b696675 )