Skip to content

Instantly share code, notes, and snippets.

@AppWerft
Created July 27, 2019 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AppWerft/f214d2a3eaf70b039b1d7ec047f3a84c to your computer and use it in GitHub Desktop.
Save AppWerft/f214d2a3eaf70b039b1d7ec047f3a84c to your computer and use it in GitHub Desktop.
Importer
?php
$ts = '';
$R = 'EXT:hosvisualization/Resources/Public';
$EP = "/home/mirko/.web/raw";
$NS = "hosvirt_";
$doc = new DOMDocument();
$doc->loadHTMLFile($EP . "/index.html");
$xpath = new DOMXPath($doc);
$count = 10;
foreach ($xpath->evaluate("//link[contains(@href, 'css')]") as $node) {
$href = $node->getAttribute("href");
$ts .= "//ext. CSS\n";
file_put_contents("Resources/Public/$NS$count.css",getFile($href,$EP));
$ts .= "page.includeCSS.$count = $R/$NS$count.css\n";
$count+=5;
}
foreach ($xpath->evaluate("//script") as $node) {
$src = $node->getAttribute("src");
if ($src == "") {
$ts .= "//Inline JS code:\n";
$ts .= "page.jsFooterInline {\n";
$ts .= " $NS$count = TEXT\n";
$ts .= " $NS$count.value(\n";
$ts .= " /* inlinecode from $NS */\n $node->textContent\n";
$ts .= " )\n";
$ts .= "}\n";
file_put_contents("Resources/Public/$NS$count.js",$node->textContent);
$ts .= "page.includeJS.$NS$count = $R/$count.js\n";
} else {
$src = $node->getAttribute('src');
$ts .= "//ext JS code:\n";
$basename = basename($src);
file_put_contents("Resources/Public/$basename",getFile($src,$EP));
$ts .= "page.includeJSFooter.$NS$count = $R/$basename\n";
}
$count+=5;
}
file_put_contents("./Configuration/TypoScript/setup.txt",$ts);
function getFile($foo,$EP) {
$bar = str_replace('./','/', $EP .$foo);
return file_get_contents($bar);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment