+doc #18295 show warning if browsing outdated docs

+doc #18295 include versions.json updation during release
This commit is contained in:
Konrad Malawski 2015-08-22 18:35:20 +02:00
parent a6279b7b3f
commit c527987cc3
6 changed files with 170 additions and 1 deletions

1
.java-version Normal file
View file

@ -0,0 +1 @@
1.6

View file

@ -12,6 +12,7 @@
{% set script_files = script_files + ['_static/scrollTo.js'] %}
{% set script_files = script_files + ['_static/contentsFix.js'] %}
{% set script_files = script_files + ['_static/ga.js'] %}
{% set script_files = script_files + ['_static/warnOldDocs.js'] %}
{% set css_files = css_files + ['_static/prettify.css'] %}
{% set css_files = css_files + ['_static/base.css'] %}
{% set css_files = css_files + ['_static/docs.css'] %}
@ -22,6 +23,7 @@
{% block relbar2 %}{% endblock %}
{% block extrahead %}
<!-- Akka release version-->
{%- if include_analytics %}
<!--Google Analytics-->
<script type="text/javascript">

View file

@ -184,4 +184,34 @@ strong {color: #0B5567; }
.section h2:hover > a,.section h3:hover > a,.section h4:hover > a,.section h5:hover > a { visibility: visible; }
div.align-center { width: 100%; text-align: center; }
p.caption { width: 80%; text-align: justify; font-size: 0.95em; font-style: italic; position: relative; left: 10%; }
p.caption { width: 80%; text-align: justify; font-size: 0.95em; font-style: italic; position: relative; left: 10%; }
/* floaty warning about old version of docs */
#floaty-warning {
display: block;
position: fixed;
bottom: 0;
left: 0;
margin-bottom: 0;
z-index: 99999;
width: 100%;
background-color: rgb(84, 180, 204);
text-align: center;
padding: 10px;
color: #FFF;
}
/*
* Used when browsing 2.3.12 yet 2.4.x is out already.
* This is more critical than browsing 2.3.10 and 2.3.11 is latest (the default color).
*/
#floaty-warning .warning {
background-color: rgb(227, 88, 89);
}
#floaty-warning a {
color: white;
font-weight: bold;
text-decoration: underline;
}

View file

@ -0,0 +1,96 @@
jQuery(document).ready(function ($) {
initOldVersionWarnings($);
});
function initOldVersionWarnings($) {
$.get(versionsJsonUri(), function (akkaVersionsData) {
var thisVersion = browsedAkkaVersion();
if (thisVersion.includes("-SNAPSHOT")) {
console.log("Detected SNAPSHOT Akka version...");
// we could show a 'hey, this is a snapshot' notice
} else {
for (var series in akkaVersionsData) {
if (thisVersion.startsWith(series)) {
showVersionWarning(thisVersion, akkaVersionsData, akkaVersionsData[series]);
}
}
}
});
}
function insteadUrl(version, instead) {
return ("" + window.location).replace(version, instead);
}
function showVersionWarning(version, akkaVersionsData, seriesInfo) {
console.log("Akka version:", version);
var targetUrl = ("" + window.location).replace(version, seriesInfo.latest);
var $floatyWarning = $('<div id="floaty-warning"/>');
console.log("Current version info", seriesInfo);
var isOutdated = !!seriesInfo.outdated;
var isLatestInSeries = version != seriesInfo.latest;
if (isOutdated) {
$floatyWarning.addClass("warning");
var instead = akkaVersionsData[seriesInfo.instead].latest;
console.log("Akka " + version + " is outdated. Suggesting 'latest' of ", seriesInfo.instead, "by 'instead' key.");
var unsupportedMessage = '<p>' +
'<span style="font-weight: bold">This version of Akka (' + version + ') has been end-of-lifed and is currently not supported! </span><br/>' +
'Please upgrade to <a href="' + insteadUrl(version, instead) + '">Akka ' + instead + '</a> or <a href="http://www.typesafe.com/products/typesafe-reactive-platform">Typesafe Reactive Platform</a> as soon as possible.' +
'</p>';
$floatyWarning.append(unsupportedMessage);
}
if (isLatestInSeries) {
$floatyWarning
.append('<p>' +
'You are browsing the docs for Akka ' + version + ', ' +
'however the latest release in this series is: ' +
'<a href="' + targetUrl + '">' + seriesInfo.latest + '</a>. <br/>' +
'</p>');
}
// add bottom clicky link "to same page"
if (isOutdated) {
$floatyWarning.append(
'<p>' +
'<a href="' + insteadUrl(version, instead) + '">Click here to go to the same page on the ' + akkaVersionsData[seriesInfo.instead].latest + ' version of the docs.</a>' +
'</p>')
} else if (isLatestInSeries && isOutdated) {
$floatyWarning.append(
'<p>' +
'<a href="' + targetUrl + '">Click here to go to the same page on the ' + seriesInfo.latest + ' version of the docs.</a>' +
'</p>')
}
$floatyWarning
.hide()
.prependTo("body")
.show()
.delay(10 * 1000)
.fadeOut()
}
// e.g. "docs/akka/2.3.10/scala/persistence.html" => "2.3.10"
function browsedAkkaVersion() {
var globalSetting = window.DOCUMENTATION_OPTIONS.VERSION; // generated by Sphinx
if (globalSetting) {
return globalSetting;
} else {
var path = window.location.pathname;
var path2 = path.substring(path.indexOf("/", "/docs/akka".length) + 1);
var version = path2.substring(0, path2.indexOf("/"));
console.log("Detected version of docs using window.location parsing:", version);
return version;
}
}
function versionsJsonUri() {
if (window.location.pathname.includes("stream-and-http"))
return "http://doc.akka.io/docs/akka-stream-and-http-experimental/versions.json"
else
return "http://doc.akka.io/docs/akka/versions.json";
}

32
akka-docs/versions.json Normal file
View file

@ -0,0 +1,32 @@
{
"2.1.": {
"latest": "2.1.4",
"outdated": true,
"instead": "2.4."
},
"2.2.": {
"latest": "2.2.5",
"outdated": true,
"instead": "2.4."
},
"2.3.": {
"latest": "2.3.14",
"outdated": true,
"instead": "2.4."
},
"2.4-M": {
"latest": "2.4.0"
},
"2.4.0-RC": {
"latest": "2.4.0"
},
"2.4.": {
"latest": "2.4.0"
},
"rp-15v01": {
"rp": true,
"latest": "rp-15v01p05"
}
}

View file

@ -364,6 +364,14 @@ else
important sbt upload-release
fi
echolog "Updating http://doc.akka.io/docs/versions.json [from $script_dir/../../akka-docs/versions.json]..."
if [ $dry_run ]; then
echodry "Not actually updating versions.json. Command:"
echodry " important scp $script_dir/../../akka-docs/versions.json ${publish_path}/docs/"
else
important scp $script_dir/../../akka-docs/versions.json ${publish_path}/docs/
fi
if [ $dry_run ]; then
if [ $no_revert ]; then
echodry "No revert: git branch ${release_branch} and git tag v${version} remain"