Sha256: 709cc17809e342a0269e0c6841b1891a66e873fa76cbfabf5537a544712f67df
Contents?: true
Size: 1.75 KB
Versions: 4
Compression:
Stored size: 1.75 KB
Contents
<?php function print_page($subtitle, $body, $fragment) { $uri = 'http://' . $_SERVER["HTTP_HOST"] . preg_replace('/\?.*$/', '', $_SERVER["REQUEST_URI"]); $canonical = $uri."#!".$fragment; $html = file_get_contents('print-template.html'); echo preg_replace(array('/\{subtitle}/', '/\{body}/', '/\{canonical}/'), array($subtitle, $body, $canonical), $html); } function print_index_page() { echo file_get_contents("template.html"); } function jsonp_decode($jsonp) { $jsonp = preg_replace('/^.*?\(/', "", $jsonp); $jsonp = preg_replace('/\);\s*$/', "", $jsonp); return json_decode($jsonp, true); } function decode_file($filename) { if (file_exists($filename)) { return jsonp_decode(file_get_contents($filename)); } else { throw new Exception("File $filename not found"); } } if (isset($_GET["_escaped_fragment_"]) || isset($_GET["print"])) { $fragment = isset($_GET["_escaped_fragment_"]) ? $_GET["_escaped_fragment_"] : $_GET["print"]; try { if (preg_match('/^\/api\/([^-]+)/', $fragment, $m)) { $className = $m[1]; $json = decode_file("output/".$className.".js"); print_page($className, "<h1>" . $className . "</h1>\n" . $json["html"], $fragment); } elseif (preg_match('/^\/api\/?$/', $fragment, $m)) { print_index_page(); } elseif (preg_match('/^\/guide\/(.+)/', $fragment, $m)) { $json = decode_file("guides/".$m[1]."/README.js"); print_page($json["title"], '<div id="guide" style="padding: 1px">' . $json["guide"] . '</div>', $fragment); } elseif (preg_match('/^\/guide\/?$/', $fragment, $m)) { print_index_page(); } else { print_index_page(); } } catch (Exception $e) { print_page($e->getMessage(), $e->getMessage()); } } else { print_index_page(); } ?>
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
jsduck-3.0.1 | template-min/index.php |
jsduck-3.0 | template-min/index.php |
jsduck-3.0.pre3 | template-min/index.php |
jsduck-3.0.pre2 | template-min/index.php |