|
@@ -72,7 +72,7 @@ END;
|
|
|
}
|
|
}
|
|
|
function check_software()
|
|
function check_software()
|
|
|
{
|
|
{
|
|
|
- if (!str_starts_with(shell_exec("latexmk --version"),"Latexmk,"))
|
|
|
|
|
|
|
+ if (strpos(shell_exec("latexmk --version"),"Latexmk,") === false)
|
|
|
error_exit("latexmk not installed");
|
|
error_exit("latexmk not installed");
|
|
|
if (!str_starts_with(shell_exec("pdftotext --help 2>&1"),"pdftotext version"))
|
|
if (!str_starts_with(shell_exec("pdftotext --help 2>&1"),"pdftotext version"))
|
|
|
error_exit("pdftotext not installed");
|
|
error_exit("pdftotext not installed");
|
|
@@ -186,20 +186,41 @@ END;
|
|
|
{
|
|
{
|
|
|
[$targets,$texfiles,$sourcedirs] = check_folders($argv);
|
|
[$targets,$texfiles,$sourcedirs] = check_folders($argv);
|
|
|
//echo "Source -> Target Directory Mapping:\n";
|
|
//echo "Source -> Target Directory Mapping:\n";
|
|
|
- $mapping = array_combine($sourcedirs,$targets);
|
|
|
|
|
|
|
+ $n = count($sourcedirs);
|
|
|
//print_r($mapping);
|
|
//print_r($mapping);
|
|
|
- foreach ($mapping as $s => $t)
|
|
|
|
|
|
|
+ for ($i = 0; $i < $n; $i++)
|
|
|
{
|
|
{
|
|
|
- if (!file_exists($s))
|
|
|
|
|
- error_exit("$s not found");
|
|
|
|
|
- if (file_exists($t) && !user_consent("$t already exists... overwrite?","--force-overwrite","--no-overwrite"))
|
|
|
|
|
|
|
+ $s = $sourcedirs[$i];
|
|
|
|
|
+ $t = $targets[$i];
|
|
|
|
|
+ $f = $texfiles[$i];
|
|
|
|
|
+ if (str_ends_with($f,".pdf"))
|
|
|
{
|
|
{
|
|
|
- echo "Skipping ".$s.", ".$t." already exists...\n";
|
|
|
|
|
|
|
+ if (!file_exists("$s/$f"))
|
|
|
|
|
+ error_exit("$s/$f not found");
|
|
|
|
|
+ if (file_exists("$t/$f.pdf") && !user_consent("$t/$f.pdf already exists... overwrite?","--force-overwrite","--no-overwrite"))
|
|
|
|
|
+ {
|
|
|
|
|
+ echo "Skipping $s/$f, $t/$f.pdf already exists...\n";
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ echo "Copying $s/$f to $t/$f...\n";
|
|
|
|
|
+ if (!file_exists($t)) mkdir($t);
|
|
|
|
|
+ rcopy("$s/$f","$t/$f");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- echo "Copying ".$s." to ".$t."...\n";
|
|
|
|
|
- rcopy($s,$t);
|
|
|
|
|
|
|
+ if (!file_exists($s))
|
|
|
|
|
+ error_exit("$s not found");
|
|
|
|
|
+ if (file_exists($t) && !user_consent("$t already exists... overwrite?","--force-overwrite","--no-overwrite"))
|
|
|
|
|
+ {
|
|
|
|
|
+ echo "Skipping ".$s.", ".$t." already exists...\n";
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ echo "Copying ".$s." to ".$t."...\n";
|
|
|
|
|
+ rcopy($s,$t);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return array_combine($targets,$texfiles);
|
|
return array_combine($targets,$texfiles);
|
|
@@ -222,6 +243,8 @@ END;
|
|
|
$bibresources = [];
|
|
$bibresources = [];
|
|
|
foreach ($papers as $d => $f)
|
|
foreach ($papers as $d => $f)
|
|
|
{
|
|
{
|
|
|
|
|
+ if (str_ends_with($f,".pdf"))
|
|
|
|
|
+ continue;
|
|
|
$files = rscandir($d,$extensions);
|
|
$files = rscandir($d,$extensions);
|
|
|
foreach ($files as $file)
|
|
foreach ($files as $file)
|
|
|
{
|
|
{
|
|
@@ -300,8 +323,26 @@ END;
|
|
|
{
|
|
{
|
|
|
foreach ($papers as $d => $f)
|
|
foreach ($papers as $d => $f)
|
|
|
{
|
|
{
|
|
|
|
|
+ $tex = "";
|
|
|
$paper_fulltitle = "";
|
|
$paper_fulltitle = "";
|
|
|
$authors = "";
|
|
$authors = "";
|
|
|
|
|
+ if (str_ends_with($f,".pdf"))
|
|
|
|
|
+ {
|
|
|
|
|
+ $paper_fulltitle = trim(user_prompt("Please enter the full title for the paper in folder '$d'","TODO"));
|
|
|
|
|
+ $paper_shorttitle = trim(user_prompt("Please enter a short title for the paper in folder '$d'","TODO"));
|
|
|
|
|
+ $authors = trim(user_prompt("Please enter the author list for paper '$d'","TODO"));
|
|
|
|
|
+ $header=<<<END
|
|
|
|
|
+\chapter[$paper_shorttitle]{{$paper_fulltitle}}\label{chapter:$d}
|
|
|
|
|
+\section*{Publication Data}
|
|
|
|
|
+\\fullcite{TODO}
|
|
|
|
|
+
|
|
|
|
|
+\section*{Contributions}
|
|
|
|
|
+TODO
|
|
|
|
|
+
|
|
|
|
|
+\includepdf[pages=-]{{$d}/{$f}}
|
|
|
|
|
+END;
|
|
|
|
|
+file_put_contents("$d/main.tex",$header);
|
|
|
|
|
+ }
|
|
|
$files = rscandir($d,$extensions);
|
|
$files = rscandir($d,$extensions);
|
|
|
foreach ($files as $file)
|
|
foreach ($files as $file)
|
|
|
{
|
|
{
|
|
@@ -356,8 +397,11 @@ END;
|
|
|
$tex = preg_replace("/\\\documentclass.*\\n/i",'',$tex);
|
|
$tex = preg_replace("/\\\documentclass.*\\n/i",'',$tex);
|
|
|
$tex = preg_replace("/\\\begin{document}/i",$header,$tex);
|
|
$tex = preg_replace("/\\\begin{document}/i",$header,$tex);
|
|
|
$tex = preg_replace("/\\\begin{abstract}/i",'\section*{Abstract}',$tex);
|
|
$tex = preg_replace("/\\\begin{abstract}/i",'\section*{Abstract}',$tex);
|
|
|
- $tex = preg_replace("/\\\end{abstract}/i",'',$tex);
|
|
|
|
|
- $tex = preg_replace("/\\\end{document}/i",'',$tex);
|
|
|
|
|
|
|
+ $tex = preg_replace("/\\\\end{abstract}/i",'',$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\thispagestyle{empty}/i",'',$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\bibliographystyle\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\n\s*\\\\bibliography\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\end{document}/i",'',$tex);
|
|
|
$tex = preg_replace("/\n\s*\\\\author\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
$tex = preg_replace("/\n\s*\\\\author\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
$tex = preg_replace("/\n\s*\\\\title\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
$tex = preg_replace("/\n\s*\\\\title\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
$tex = preg_replace("/\n\s*\\\\date\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
$tex = preg_replace("/\n\s*\\\\date\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
@@ -422,10 +466,16 @@ END;
|
|
|
}
|
|
}
|
|
|
function compile_check($papers,$precopy = false)
|
|
function compile_check($papers,$precopy = false)
|
|
|
{
|
|
{
|
|
|
|
|
+ array_shift($papers);
|
|
|
if ($precopy)
|
|
if ($precopy)
|
|
|
$papers = array_combine($papers,$papers);
|
|
$papers = array_combine($papers,$papers);
|
|
|
foreach ($papers as $p => $f)
|
|
foreach ($papers as $p => $f)
|
|
|
{
|
|
{
|
|
|
|
|
+ if (str_ends_with($f,".pdf"))
|
|
|
|
|
+ {
|
|
|
|
|
+ echo "======= Skipping PDF: $f =======\n";
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
echo "======= Paper $p -> $f START =======\n";
|
|
echo "======= Paper $p -> $f START =======\n";
|
|
|
if ($precopy)
|
|
if ($precopy)
|
|
|
{
|
|
{
|
|
@@ -497,6 +547,11 @@ END;
|
|
|
$existing_mathops = array_unique(array_merge($mathops1, $mathops2));
|
|
$existing_mathops = array_unique(array_merge($mathops1, $mathops2));
|
|
|
echo "\n=== Step 5/$steps: Adjusting Papers (checking only *.tex files) ===\n\n";
|
|
echo "\n=== Step 5/$steps: Adjusting Papers (checking only *.tex files) ===\n\n";
|
|
|
adjust_papers($papers,[".tex"]);
|
|
adjust_papers($papers,[".tex"]);
|
|
|
|
|
+ foreach ($papers as $k => $v)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (str_ends_with($papers[$k],".pdf"))
|
|
|
|
|
+ $papers[$k] = 'main.tex';
|
|
|
|
|
+ }
|
|
|
echo "\n=== Step 6/$steps: Generate main.tex ===\n\n";
|
|
echo "\n=== Step 6/$steps: Generate main.tex ===\n\n";
|
|
|
$thesis_type = user_prompt("Enter Thesis Type ","PhD Thesis");
|
|
$thesis_type = user_prompt("Enter Thesis Type ","PhD Thesis");
|
|
|
$thesis_title = user_prompt("Enter Thesis Title ","Security of TODO");
|
|
$thesis_title = user_prompt("Enter Thesis Title ","Security of TODO");
|
|
@@ -542,4 +597,5 @@ END;
|
|
|
if (!file_exists("cv.tex"))
|
|
if (!file_exists("cv.tex"))
|
|
|
file_put_contents("cv.tex","This is my CV! Thanks for checking it out!");
|
|
file_put_contents("cv.tex","This is my CV! Thanks for checking it out!");
|
|
|
}
|
|
}
|
|
|
|
|
+ echo "=== done ===\nNext step, run this command:\nlatexmk -latexoption=\"-shell-escape\" -g -pdf main.tex\n";
|
|
|
?>
|
|
?>
|