Progressed on generalizing functions.

This commit is contained in:
Joshua Ramon Enslin 2018-06-04 16:35:50 +02:00 committed by Stefan Rohde-Enslin
parent f15684f85e
commit 4e5bf673e0
7 changed files with 31 additions and 25 deletions

View File

@ -80,7 +80,7 @@
\parbox[b][\paperheight]{\paperwidth}{%
\vfill
\includegraphics[width=.6\paperwidth,height=\paperheight,%
keepaspectratio]{../../media/Screenshot-Startpage.png}%
keepaspectratio]{\pageTitleImg}%
\vfill}
}

View File

@ -23,7 +23,7 @@ h1 { margin: 0; padding: 10vh 0; margin-bottom: .5em; color: #FFF; t
h2 { color: #F00; }
#aboutMuseum-Digital h1 { background: url(../media/Screenshot-Startpage.png) no-repeat center center; background-size: cover; }
#aboutPresseberichtezuMuseum-Digital h1 { background: url(../media/TitlePage/06073815564.jpg) no-repeat center center; background-size: cover; }
#aboutPresseberichte h1 { background: url(../media/TitlePage/06073815564.jpg) no-repeat center center; background-size: cover; }
body > * { padding: 2em 5vw; }
body > main { padding: 0 0 2em 0; }

View File

@ -254,13 +254,13 @@ function removeFolderGently($folder, $exclude) {
* @param string $folder Determines the folder (say, template) to use for PDF generation.
* @param string $texFilename Name of the TeX file. Used without its ending.
* @param string $filename Filename as it should be shown to the user.
* @param boolean $title Title of the overall output.
* @param boolean $pdfSettings Additional parameters to use \def for.
* @param boolean $lang Language. Optional.
* @param boolean $debug Enables/disables debug mode. Optional.
*
* @return void
*/
function runPDF($folder, $texFilename, $filename, $title, $lang = "de", $debug = false) {
function runPDF($folder, $texFilename, $filename, $pdfSettings, $lang = "de", $debug = false) {
if (!is_dir("./tmp")) mkdir("./tmp");
@ -270,7 +270,7 @@ function runPDF($folder, $texFilename, $filename, $title, $lang = "de", $debug =
copyFolder("$folder", "./tmp/$uniqid");
copy("$texFilename.tex", "./tmp/$uniqid/$texFilename.tex");
$generateUserSettings = function($lang, $title) {
$generateUserSettings = function($lang, $pdfSettings) {
$babelPackages = [
"en" => "english",
"de" => "german",
@ -282,9 +282,10 @@ function runPDF($folder, $texFilename, $filename, $title, $lang = "de", $debug =
else $lan = "en";
return '\\usepackage[' . $babelPackages[$lan] . ']{babel}
\\def \\pageTitle {' . transform($title) . '}' . PHP_EOL;
\\def \\pageTitle {' . transform($pdfSettings['title']) . '}' . PHP_EOL . '
\\def \\pageTitleImg {' . transform($pdfSettings['bgImg']) . '}' . PHP_EOL;
};
$userSettings = $generateUserSettings($lang, $title);
$userSettings = $generateUserSettings($lang, $pdfSettings);
file_put_contents("./tmp/$uniqid/pdfSettings.tex", $userSettings);
@ -318,10 +319,11 @@ function runPDF($folder, $texFilename, $filename, $title, $lang = "de", $debug =
* @param string $lang Language. Optional
* @param array $availableLangs Page description. Optional.
* @param string $descriptions Page description. Optional.
* @param string $pdfLink Link to brochure. Optional.
*
* @return string
*/
function printHTMLPage(string $title, string $contents, string $lang = "en", array $availableLangs = ["en"], string $descriptions = "") {
function printHTMLPage(string $title, string $contents, string $lang = "en", array $availableLangs = ["en"], string $descriptions = "", $pdfLink = "brochure") {
$output = '<!DOCTYPE html>
<html lang="' . $lang . '" id="' . str_replace(":", "", str_replace(" ", "", $title)) . '">
@ -349,14 +351,15 @@ function printHTMLPage(string $title, string $contents, string $lang = "en", arr
<body id="start">
<nav id="mainNav">
<a href="#start">Top</a>
<a href="./?t=about#start">Home</a>
<a href="./?t=press#start">Pressespiegel</a>
<a href="#bottom"></a>
</nav>
';
$output .= $contents . '
<footer id="bottom">
<a href="pdf/' . $lang . '/brochure.pdf" class="buttonLike">PDF</a>
<a href="pdf/' . $lang . '/' . $pdfLink . '.pdf" class="buttonLike">PDF</a>
</footer>
<footer id="optionsFooter">
@ -379,7 +382,7 @@ function printHTMLPage(string $title, string $contents, string $lang = "en", arr
</footer>
<script src="./js/tracking.js"></script>
<noscript><p><img src="https://www.jrenslin.de/museum-digital/piwik/piwik.php?idsite=1" style="border:0;" alt="" ></p></noscript>
<noscript><p><img src="https://www.jrenslin.de/museum-digital/piwik/piwik.php?idsite=1" /></p></noscript>
</html>';

View File

@ -41,15 +41,16 @@ $content->load(__DIR__ . "/$sourceFolder/$lang.htm");
// Find out title
$title = $content->getElementsByTagName("h1")[0]->nodeValue;
$bgImg = $content->getElementsByTagName("h1")[0]->getAttribute("data-bgimage");
// Generate PDF if need be.
if (filemtime(__DIR__ . "/tex/$lang/$sourceTeXFile.tex") -5000 < filemtime(__DIR__ . "/$sourceFolder/$lang.htm")) {
if (filemtime(__DIR__ . "/tex/$lang/$sourceTeXFile.tex") < filemtime(__DIR__ . "/$sourceFolder/$lang.htm")) {
foreach ($content->getElementsByTagName("section") as $c) {
DOMtoTeX($c, "tex/$lang");
}
runPDF("tex/$lang", "$sourceFile", "$sourceFile", $title, $lang, true);
runPDF("tex/$lang", "$sourceFile", "$sourceFile", ["title" => $title, "bgImg" => $bgImg], $lang, true);
}
@ -59,6 +60,6 @@ $content = file_get_contents(__DIR__ . "/$sourceFolder/$lang.htm");
$content = str_replace("\\today", date("Y-m-d", filemtime(__DIR__ . "/$sourceFolder/$lang.htm")), $content);
echo printHTMLPage("about:" . $title, $content, $lang, $availableLangs);
echo printHTMLPage("about:" . $title, $content, $lang, $availableLangs, "", $sourceFile);
?>

View File

@ -1,6 +1,6 @@
<main>
<h1 data-bgimage="../../media/TitlePage/06073815564.jpg" style="background: url(media/TitlePage/06073815564.jpg) no-repeat center center; background-size: cover;">Presseberichte zu Museum-Digital</h1>
<h1 data-bgimage="../../media/TitlePage/06073815564.jpg" style="background: url(media/TitlePage/06073815564.jpg) no-repeat center center; background-size: cover;">Presseberichte</h1>
<section id="introductionPress">
@ -10,7 +10,7 @@
<div>
<p>Alle konzeptuellen Änderungen (z.B. Aufnahme privater Sammlungen in das Verzeichnis) werden in der AG Digitalisierung des Museumsverbandes Sachsen-Anhalt diskutiert und entschieden.</p>
<p>Hier finden Sie eine (unvollständige) Liste von Presseberichten über Museum-Digital.</p>
</div>
@ -24,21 +24,23 @@
<div>
<h3>Mehr als nur Software</h3>
<div>
<div class="centerVertically">
<h4>2018</h4>
<ul class="dl">
<li data-title="Leicht zu erreichen">Wir antworten auf Mails</li>
<li data-title="Zusammen publizieren">Um gefunden zu werden</li>
<li data-title="Zusammen arbeiten">Um nicht doppelt arbeiten zu müssen</li>
<li data-title="Zusammen auf einer Seite">Eine Verbesserung hilft allen</li>
<li data-title="Volksstimme.de - 30.05.2018"><a data-archived="https://web.archive.org/web/20180604133747/https://www.volksstimme.de/lokal/wolmirstedt/geschichte-ein-digitaler-katalog-fuers-museum" href="https://www.volksstimme.de/lokal/wolmirstedt/geschichte-ein-digitaler-katalog-fuers-museum">Ein digitaler Katalog fürs Museum</a></li>
</ul>
</div>
<div class="centerVertically">
<img src="media/Screenshot-Exhibitions.png" />
<div>
<h4>2017</h4>
<ul class="dl">
<li data-title="Volksstimme.de - 30.05.2018">Ein digitaler Katalog fürs Museum</li>
</ul>
</div>
</div>
</section>

View File

@ -80,7 +80,7 @@
\parbox[b][\paperheight]{\paperwidth}{%
\vfill
\includegraphics[width=.6\paperwidth,height=\paperheight,%
keepaspectratio]{../../media/Screenshot-Startpage.png}%
keepaspectratio]{\pageTitleImg}%
\vfill}
}