diff --git a/themes/jquery/functions.jquery.php b/themes/jquery/functions.jquery.php index 5339acbb..634bef57 100644 --- a/themes/jquery/functions.jquery.php +++ b/themes/jquery/functions.jquery.php @@ -96,4 +96,22 @@ function jq_page_links_for_category( $category ) { return $ret; } +function jq_get_github_url() { + $url = $_SERVER['REQUEST_URI']; + $path = parse_url($url)['path']; + $github_prefix = 'https://github.com/jquery/'.get_stylesheet().'/tree/master/page'; + + return $github_prefix . str_lreplace('/','.md', $path); +} + +function str_lreplace($search, $replace, $subject) { + $pos = strrpos($subject, $search); + + if($pos !== false) { + $subject = substr_replace($subject, $replace, $pos, strlen($search)); + } + + return $subject; +} + ?> diff --git a/themes/learn.jquery.com/page.php b/themes/learn.jquery.com/page.php index c6b09390..f855ba3d 100644 --- a/themes/learn.jquery.com/page.php +++ b/themes/learn.jquery.com/page.php @@ -11,7 +11,9 @@ - +