From 4e5bf673e0600ef665498fb2a58799c34df7893f Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Mon, 4 Jun 2018 16:35:50 +0200 Subject: [PATCH] Progressed on generalizing functions. --- brochure.tex | 2 +- css/main.css | 2 +- functions.php | 21 ++++++++++++--------- index.php | 7 ++++--- tracking.js => js/tracking.js | 0 press/de.htm | 22 ++++++++++++---------- press_review.tex | 2 +- 7 files changed, 31 insertions(+), 25 deletions(-) rename tracking.js => js/tracking.js (100%) diff --git a/brochure.tex b/brochure.tex index 89745e4..609e0a6 100644 --- a/brochure.tex +++ b/brochure.tex @@ -80,7 +80,7 @@ \parbox[b][\paperheight]{\paperwidth}{% \vfill \includegraphics[width=.6\paperwidth,height=\paperheight,% - keepaspectratio]{../../media/Screenshot-Startpage.png}% + keepaspectratio]{\pageTitleImg}% \vfill} } diff --git a/css/main.css b/css/main.css index 0eff15f..a6ccac2 100644 --- a/css/main.css +++ b/css/main.css @@ -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; } diff --git a/functions.php b/functions.php index 6f42d57..b2cd9ed 100644 --- a/functions.php +++ b/functions.php @@ -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 = ' @@ -349,14 +351,15 @@ function printHTMLPage(string $title, string $contents, string $lang = "en", arr '; $output .= $contents . ' - + '; diff --git a/index.php b/index.php index e55d31c..3e95144 100644 --- a/index.php +++ b/index.php @@ -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); ?> diff --git a/tracking.js b/js/tracking.js similarity index 100% rename from tracking.js rename to js/tracking.js diff --git a/press/de.htm b/press/de.htm index 5385e55..60bf474 100644 --- a/press/de.htm +++ b/press/de.htm @@ -1,6 +1,6 @@
-

Presseberichte zu Museum-Digital

+

Presseberichte

@@ -10,7 +10,7 @@
-

Alle konzeptuellen Änderungen (z.B. Aufnahme privater Sammlungen in das Verzeichnis) werden in der AG Digitalisierung des Museumsverbandes Sachsen-Anhalt diskutiert und entschieden.

+

Hier finden Sie eine (unvollständige) Liste von Presseberichten über Museum-Digital.

@@ -24,21 +24,23 @@
-

Mehr als nur Software

+
-
+

2018

-
- +
+ +

2017

+
    +
  • Ein digitaler Katalog fürs Museum
  • +
+
diff --git a/press_review.tex b/press_review.tex index f4978cd..3a0ae3f 100644 --- a/press_review.tex +++ b/press_review.tex @@ -80,7 +80,7 @@ \parbox[b][\paperheight]{\paperwidth}{% \vfill \includegraphics[width=.6\paperwidth,height=\paperheight,% - keepaspectratio]{../../media/Screenshot-Startpage.png}% + keepaspectratio]{\pageTitleImg}% \vfill} }