Data-Edit-Xml-To-Dita

 view release on metacpan or  search on metacpan

lib/Data/Edit/Xml/To/DitaVb.pm  view on Meta::CPAN

<meta charset="UTF-8">
<pre>
$H
</pre>
</html>
END
      my $cmd = qq(sudo cp "$tempFile" "$target");
      lll $cmd;
      lll qx($cmd);
     }
    else                                                                        # Not a text file so copy directly
     {my $cmd = qq(sudo cp "$file" "$target");
      lll $cmd;
      lll qx($cmd);
     }

    my $publish = sub                                                           # Link to html version of bookmap
     {if ($file =~ m(.ditamap\Z)s)
       {my $p = bookMapPublicationFolder($file);
        my $f = fn $file;
        return qq(<td><a href="$f/index.html"><b>html</b></a>);
       }
      return q(<td>);
     }->();


    if (1)                                                                      # Generate html table row for file
     {++$count;
      my $bg          = qw(even odd)[$count % 2];                               # Row back ground colour
      my $row         = sprintf("%04d", $count);
      my $size        = fileSize($file);                                        # Size of file
      my $original    = gbBinaryStandardCompanionFileContent($file);            # Original file name
      my $chunkedFile = chunkFile($original // $file);                          # Easier to format file name

      push @html, qq(<tr class="$bg"><td align="right">$row).                   # Row number
                  qq(<td align="right">$size).                                  # File size
                  $publish.                                                     # Html after conversion by Dita OT
                  qq(<td>);

      if ($action    =~ m(image|svg))                                           # Image
       {push @html, qq(<img src="$relFile">$chunkedFile);
       }
      elsif ($action eq q(edit))                                                # Edit
       {push @html, <<END;
<a href="${mimEdit}mim=$relFile&folder=$client">$chunkedFile</a>
END
       }
      else                                                                      # Browse
       {push @html, qq(<a href="$relFile">$chunkedFile</a>);
       }
     }
   }
  push @html, <<END;
</table>
</body>
END

  if (1)                                                                        # Create index
   {my $target = fpe($wwwClient, qw(index html));
    my $source = owf($tempFile, join "\n", @html);
    xxx qq(sudo cp $source $target; sudo chmod -R ugo+r $wwwClient), qr();
   }
  unlink $tempFile;
 }

sub copyFilesToWeb                                                              #P Copy files into position so that they can be web served
 {if (mimajen)
   {lll "Copy file to server for viewing with mimajen";
    copyFilesToWeb2;
   }
  else
   {ddd "Upload to S3 not requested";
   }
 }

sub beforeUploadToS3                                                            #r Copy additional files into position before upload to s3
 {
 }

sub uploadFoldersToS3                                                           #r Upload folders to S3
 {my ($processStarter) = @_;                                                    # Process starter

  my $p = s3Parms.s3ProfileValue;

  for my $dir(reports, out, perl, parseFailed, targets)
   {next unless -d $dir;
    my $target = swapFolderPrefix($dir, home, s3OutputFolder);
    my $c = qq(aws s3 sync $dir $target $p);
    lll $c;
    $processStarter->start(sub
     {say STDERR qx($c);
     });
   }
 }

sub uploadToS3($)                                                               #P Copy entire home folder to S3
 {my ($processStarter) = @_;                                                    # Process starter

  beforeUploadToS3;                                                             # Copy in additional files if required
  my $upload = sub                                                              # Decode upload requirements
   {return undef unless upload;
    return 2 if upload == 2;
    if ($lintReport)
     {return 1 if $lintReport->totalErrors == 0;
     }
    undef
   }->();

  if ($upload)
   {lll "Upload to S3";
    if (s3OutputFolder)                                                         # Upload to output area if requested
     {uploadFoldersToS3($processStarter);
     }
    else
     {eee q(Upload to S3 requested but S3OutputFolder not set);
     }
    Flip::Flop::uploadToS3();                                                   # Reset upload flip flop
   }
  elsif (upload)
   {lll "Upload to S3 ".upload."/".$lintReport->totalErrors." suppressed by lint results";
   }



( run in 1.727 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )