Loading template/index.php +19 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ 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); echo preg_replace(array('/\{subtitle}/', '/\{body}/', '/\{canonical}/'), array($subtitle, fix_links($body), $canonical), $html); } function print_index_page() { Loading @@ -31,6 +31,24 @@ function decode_file($filename) { } } // Turns #! links into ?print= links when in print mode. // // <a href="#!/api/Ext.Element"> --> <a href="?print=/api/Ext.Element"> // <a href="#!/api/Ext.Element-cfg-id"> --> <a href="?print=/api/Ext.Element#cfg-id"> // function fix_links($html) { if (isset($_GET["print"])) { $patterns = array( '/<a href=([\'"])#!?\/(api\/[^-\'"]+)-([^\'"]+)/' => '<a href=$1?print=/$2#$3', '/<a href=([\'"])#!?\//' => '<a href=$1?print=/', ); return preg_replace(array_keys($patterns), array_values($patterns), $html); } else { return $html; } } if (isset($_GET["_escaped_fragment_"]) || isset($_GET["print"])) { $fragment = isset($_GET["_escaped_fragment_"]) ? $_GET["_escaped_fragment_"] : $_GET["print"]; try { Loading Loading
template/index.php +19 −1 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ 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); echo preg_replace(array('/\{subtitle}/', '/\{body}/', '/\{canonical}/'), array($subtitle, fix_links($body), $canonical), $html); } function print_index_page() { Loading @@ -31,6 +31,24 @@ function decode_file($filename) { } } // Turns #! links into ?print= links when in print mode. // // <a href="#!/api/Ext.Element"> --> <a href="?print=/api/Ext.Element"> // <a href="#!/api/Ext.Element-cfg-id"> --> <a href="?print=/api/Ext.Element#cfg-id"> // function fix_links($html) { if (isset($_GET["print"])) { $patterns = array( '/<a href=([\'"])#!?\/(api\/[^-\'"]+)-([^\'"]+)/' => '<a href=$1?print=/$2#$3', '/<a href=([\'"])#!?\//' => '<a href=$1?print=/', ); return preg_replace(array_keys($patterns), array_values($patterns), $html); } else { return $html; } } if (isset($_GET["_escaped_fragment_"]) || isset($_GET["print"])) { $fragment = isset($_GET["_escaped_fragment_"]) ? $_GET["_escaped_fragment_"] : $_GET["print"]; try { Loading