Data-Edit-Xml-To-Dita
view release on metacpan or search on metacpan
lib/Data/Edit/Xml/To/DitaVb.pm view on Meta::CPAN
my $x = sub # Include xref results
{return q() unless $xrefResults;
$xrefResults->statusLine. " Tags To Text: ".
$xrefResults->tagsTextsRatio // q();
}->();
if (my $n = &numberOfFiles) # Check number of files if a count has been supplied
{if (my $r = $report->numberOfFiles)
{if ($r != $n)
{cluck "Number of output files: $r does not match expected number: $n";
} } }
my $s = <<END; # rrrr - write summary.txt
Summary of passing and failing projects on $d.\t\tVersion: $VERSION
$r
$x
$p
END
say STDERR $s; # Write lint results
owf(summaryFile, $s);
Flip::Flop::lint();
if (my $fails = $report->failingFiles) # Copy failing files into their own folder for easy access s
{if (@$fails)
{for my $file(@$fails)
{my $f = $file->[2]; # Failing file name
my $F = fpf(fails, fne $f); # Shorten file name path so we can find the file easily
copyFile($f, $F);
}
}
}
$lintResults = join "\n\n", ($r =~ s(\n.*\Z) ()sr), $x, $p; # Lint results summary, used to create GitHub notification after upload is complete
}
else
{lll "No Lint report available";;
}
}
else
{ddd "Lint report not requested";
}
} # lintResultsDefault
sub lintResults #r Lint results held in folder L<out|/out>and write reports to folder L<reports|/reports>.
{lintResultsDefault; # Only if lint requested
}
sub copyLogFiles #P Copy log files to reports/ so they get uploaded too
{for my $source(errorLogFile)#, logFile, logStderr)
{my $target = swapFilePrefix($source, perl, reports);
copyBinaryFile($source, $target) if -e $source;
}
}
sub chunkFile($) #P Chunk a file name to make it more readable
{my ($file) = @_; # File to chunk
my $f = swapFilePrefix($file, home); # Remove common prefix
join " <big><b>/</b></big> ", split m(/), $f; # Chunk the file name to make it more readable
}
sub copyFilesToWeb2 #P Copy files into position so that they can be web served
{return if develop;
my $client = client;
my $reports = reports;
my $www = www;
my $wwwClient = publications;
my $searchFolder = qq(<input style="display: none;" type="text" name="folder" value="$client">);
my $date = dateTimeStamp;
my $aws = awsIp;
my $http = "http://$aws/"; # Http address
my $mimEdit = "http://$aws/cgi-bin/fileManager.pl?"; # Mim editor address
push my @html, <<END; # Create html
<head>
<meta charset="UTF-8">
<style>
\@font-face
{font-family: dvs
src : url(http://$aws/woff/DejaVuSans.woff)
}
*
{font-family: dvs
}
.even {
background-color: #ddffdd;
}
.odd {
background-color: #ffdddd;
}
</style>
</head>
<body>
<body>
<table>
<tr>
<td>Run on: $date
<td><form action="/cgi-bin/fileManager.pl">
Grep: <input type="text" name="grep"> <input type="submit" value="Submit">$searchFolder
</form>
<td><form action="/cgi-bin/fileManager.pl">
Find: <input type="text" name="search" value=""> <input type="submit" value="Submit">$searchFolder
</form>
<td>F1 to switch help on and off
</table>
<div id="help" style="display : none; position: fixed;
z-index : 1;
lib/Data/Edit/Xml/To/DitaVb.pm view on Meta::CPAN
my @files = # File list
grep {!-d $_}
grep {!m(/\.)} # Dot files
searchDirectoryTreesForMatchingFiles(perl, reports, out);
my @sorted = ((grep { m($reports.*summary.txt)} @files), # Put reports first so they are to hand
(grep { m($reports)} @files),
(grep {!m($reports)} @files),
searchDirectoryTreesForMatchingFiles(downloads, q(.xml))); # Xml files
my %files; # {existing file name} = GB standard name - this allows all the web served files to be placed in one folder which makes referencing them much easier
my %action; # {existing file name} = action
for my $file(@sorted) # List files
{my ($action, $ext) = sub
{my $e = fe $file;
return (q(skip), q()) unless $e; # Accompanying files
return (q(edit), $e) if $e =~ m((dita|ditamap|xml)\Z)is; # Edit Dita files
return qw(pre html) if $e =~ m(txt\Z)is; # Copy txt files with pre wrapped around them
return (q(copy), $e) if $e =~ m((csv|html|svg)\Z)is; # Copy csv, html and svg as they are.
return (q(image), $e); # Make as an image
}->();
next unless $ext; # Skip companion files
$files {$file} = setFileExtension(uniqueNameFromFile($file), $ext) if $ext; # Target file name for each file with possible new extension
$action{$file} = $action;
}
my $tempFile = temporaryFile;
my $count = 0;
for my $file(@sorted) # Edit files to link to other files and copy to web server area so that when reruns are occurring we can still see the content
{my $relFile = $files{$file}; # File relative to index.html
next unless $relFile; # Keep the special sort order
my $target = fpf($wwwClient, $relFile); # Web file relative to web server home
my $action = $action{$file}; # Wrap text files with pre to make them into html
if ($action eq q(say)) # Skip companion files
{next;
}
elsif ($action eq q(pre)) # Wrap text files with pre to make them into html
{my $s = eval {readFile($file)}; # Read source
if ($@)
{lll "Cannot read file:\$file\n$@";
next;
}
my $S = $s =~ s(<) (<)gsr =~ s(>) (>)gsr; # Replace angle brackets
my $T = sub # Convert fully qualified names in tables to anchors
{my ($s) = @_;
my @s = split /\x{200b}/, $s; # Split on zero width space
for my $s(@s)
{if ($s =~ m(\A(.*?)\s*\Z)s)
{if (my $f = $files{$1})
{$s = qq(<a href="$f">$s</a>);
}
}
}
join q(), @s;
}->($S);
my $H = sub # Expand hrefs
{my ($text) = @_;
my @hrefs = split m((?= href="[^"]+)), $text;
for my $h(@hrefs)
{if ($h =~ m(\A href="([^"]+)"(.*)\Z)s)
{my $hrefFile = $1;
my $rest = $2;
my $F = absFromAbsPlusRel($file, $hrefFile);
if (my $f = $files{$F})
{$h = qq( <a href="$f">$hrefFile</a> $rest);
}
}
}
join q(), @hrefs;
}->($T);
owf($tempFile, <<END);
<html>
<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>
( run in 0.706 second using v1.01-cache-2.11-cpan-71847e10f99 )