Repository: incubator-samza Updated Branches: refs/heads/master 82aa01fa6 -> 41d17568d
SAMZA-383: fix switch-version button may link to invalid pages Project: http://git-wip-us.apache.org/repos/asf/incubator-samza/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-samza/commit/3b15e54d Tree: http://git-wip-us.apache.org/repos/asf/incubator-samza/tree/3b15e54d Diff: http://git-wip-us.apache.org/repos/asf/incubator-samza/diff/3b15e54d Branch: refs/heads/master Commit: 3b15e54d41d2ed02c2f381a5d55b9765f94343ba Parents: 82aa01f Author: Yan Fang <[email protected]> Authored: Fri Aug 15 16:01:22 2014 -0700 Committer: Yan Fang <[email protected]> Committed: Fri Aug 15 16:01:22 2014 -0700 ---------------------------------------------------------------------- docs/_layouts/default.html | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-samza/blob/3b15e54d/docs/_layouts/default.html ---------------------------------------------------------------------- diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html index e0438b8..0b388e1 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -25,6 +25,7 @@ <link href="/css/main.css" rel="stylesheet"/> <link href="/css/syntax.css" rel="stylesheet"/> <link rel="icon" type="image/png" href="/img/samza-icon.png"> + <script src="/js/jquery-1.11.1.min.js"></script> </head> <body> <div class="wrapper"> @@ -40,8 +41,14 @@ <a href="/startup/download"><i class="fa fa-arrow-circle-o-down masthead-icon"></i></a> <a href="https://git-wip-us.apache.org/repos/asf?p=incubator-samza.git;a=tree" target="_blank"><i class="fa fa-code masthead-icon" style="font-weight: bold;"></i></a> <a href="https://twitter.com/samzastream" target="_blank"><i class="fa fa-twitter masthead-icon"></i></a> + <!-- this icon only shows in versioned pages --> {% if page.url contains "versioned" %} - <a href="{{site.baseurl}}/{% if site.version == "latest" %}{{page.url | replace:'versioned', site.latest-release | replace_first: '/', ''}}{% else %}{{page.url | replace:'versioned', 'latest' | replace_first: '/', ''}}{% endif %}"><i class="fa fa-history masthead-icon"></i></a> + {% if site.version == "latest" %} + {% capture linkUrl %}{{page.url | replace:'versioned', site.latest-release | replace_first: '/', ''}}{% endcapture %} + {% else %} + {% capture linkUrl %}{{page.url | replace:'versioned', 'latest' | replace_first: '/', ''}}{% endcapture %} + {% endif %} + <a href="{{ site.baseurl }}/{{ linkUrl }}"><i id="switch-version-button"></i></a> {% endif %} </div> </div> @@ -108,6 +115,26 @@ </div> </div> + {% if page.url contains "versioned" %} + <script> + $( document ).ready(function() { + if ( $.fn.urlExists( "{{ site.baseurl }}/{{ linkUrl }}" ) ) { + $("#switch-version-button").addClass("fa fa-history masthead-icon"); + } + }); + + /* a function to test whether the url exists or not */ + (function( $ ) { + $.fn.urlExists = function(url) { + var http = new XMLHttpRequest(); + http.open('HEAD', url, false); + http.send(); + return http.status != 404; + }; + }( jQuery )); + </script> + {% endif %} + <!-- Google Analytics --> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
