update warnOldDocs.js and symlink for release

This will also git commit before and after the upload of the docs, so as
to make sure that changes to warnOldDocs.js are recoverable.
This commit is contained in:
Roland Kuhn 2016-03-08 15:11:43 +01:00
parent e89b5e3a58
commit 0acf03f528
2 changed files with 121 additions and 70 deletions

View file

@ -3,28 +3,67 @@ jQuery(document).ready(function ($) {
}); });
function initOldVersionWarnings($) { function initOldVersionWarnings($) {
$.get(versionsJsonUri(), function (akkaVersionsData) { $.get("//akka.io/versions.json", function (akkaVersionsData) {
var thisVersion = browsedAkkaVersion(); var site = splitPath();
if (thisVersion.includes("-SNAPSHOT")) { console.log(site);
if (site.v === 'snapshot') {
console.log("Detected SNAPSHOT Akka version..."); console.log("Detected SNAPSHOT Akka version...");
// we could show a 'hey, this is a snapshot' notice showSnapshotWarning(site);
} else { } else {
for (var series in akkaVersionsData) { for (var series in akkaVersionsData[site.p]) {
if (thisVersion.startsWith(series)) { if (site.v.startsWith(series)) {
showVersionWarning(thisVersion, akkaVersionsData, akkaVersionsData[series]); return showVersionWarning(site, akkaVersionsData, series);
} }
} }
} }
}); });
} }
function insteadUrl(version, instead) { function splitPath() {
return ("" + window.location).replace(version, instead); var path = window.location.pathname;
path = path.substring(path.indexOf("akka")); // string off leading /docs/
var base = '' + window.location;
base = base.substring(0, base.indexOf(path));
var projectEnd = path.indexOf("/");
var versionEnd = path.indexOf("/", projectEnd + 1);
var project = path.substring(0, projectEnd);
var version = path.substring(projectEnd + 1, versionEnd);
var rest = path.substring(versionEnd + 1);
return {"b":base, "p":project, "v":version, "r":rest};
} }
function showVersionWarning(version, akkaVersionsData, seriesInfo) { function getInstead(akkaVersionsData, project, instead) {
console.log("Akka version:", version); if (Array.isArray(instead)) {
var targetUrl = ("" + window.location).replace(version, seriesInfo.latest); var found = akkaVersionsData[instead[0]][instead[1]];
var proj = instead[0];
} else {
var found = akkaVersionsData[project][instead];
var proj = project;
}
return {"latest":found.latest, "project":proj};
}
function targetUrl(samePage, site, instead) {
var page = site.r;
if (samePage !== true) {
if (page.substring(0, 5) == 'scala') {
page = 'scala.html';
} else if (page.substring(0, 4) == 'java') {
page = 'java.html';
} else {
page = 'index.html';
}
}
var project = instead.project;
if (!project) {
project = site.p;
}
return site.b + project + '/' + instead.latest + '/' + page;
}
function showVersionWarning(site, akkaVersionsData, series) {
var version = site.v;
var seriesInfo = akkaVersionsData[site.p][series];
var $floatyWarning = $('<div id="floaty-warning"/>'); var $floatyWarning = $('<div id="floaty-warning"/>');
console.log("Current version info", seriesInfo); console.log("Current version info", seriesInfo);
@ -36,17 +75,25 @@ function showVersionWarning(version, akkaVersionsData, seriesInfo) {
if (isOutdated) { if (isOutdated) {
needsToShow = true; needsToShow = true;
$floatyWarning.addClass("warning"); $floatyWarning.addClass("warning");
var instead = akkaVersionsData[seriesInfo.instead].latest;
console.log("Akka " + version + " is outdated. Suggesting 'latest' of ", seriesInfo.instead, "by 'instead' key."); var instead = getInstead(akkaVersionsData, site.p, seriesInfo.instead);
var insteadSeries = targetUrl(false, site, instead);
var insteadPage = targetUrl(true, site, instead);
$floatyWarning $floatyWarning
.append( .append(
'<p>' + '<p><span style="font-weight: bold">This version of Akka (' + site.p + ' / ' + version + ') is outdated and not supported! </span></p>' +
'<span style="font-weight: bold">This version of Akka (' + version + ') has been end-of-lifed and is currently not supported! </span><br/>' + '<p>Please upgrade to version <a href="' + insteadSeries + '">' + instead.latest + '</a> as soon as possible.</p>' +
'Please upgrade to <a href="' + insteadUrl(version, instead) + '">Akka ' + instead + '</a> or <a href="http://www.lightbend.com/products/lightbend-reactive-platform">Lightbend Reactive Platform</a> as soon as possible.' + '<p id="samePageLink"></p>');
'</p>'); $.ajax({
url: insteadPage,
type: 'HEAD',
success: function() {
$('#samePageLink').html('<a href="' + insteadPage + '">Click here to go to the same page on the ' + instead.latest + ' version of the docs.</a>');
}
});
} }
if (!isLatestInSeries) { if (!isLatestInSeries) {
needsToShow = true; needsToShow = true;
$floatyWarning $floatyWarning
@ -54,28 +101,18 @@ function showVersionWarning(version, akkaVersionsData, seriesInfo) {
'<p>' + '<p>' +
'You are browsing the docs for Akka ' + version + ', ' + 'You are browsing the docs for Akka ' + version + ', ' +
'however the latest release in this series is: ' + 'however the latest release in this series is: ' +
'<a href="' + targetUrl + '">' + seriesInfo.latest + '</a>. <br/>' + '<a href="' + targetUrl(true, site, seriesInfo) + '">' + seriesInfo.latest + '</a>. <br/>' +
'</p>'); '</p>');
} }
if (isOutdated) { if (needsToShow && !versionWasAcked(site.p, version)) {
$floatyWarning var style = '';
.append( if (site.p != 'akka-stream-and-http-experimental') {
'<p>' + style = 'style="color:black"'
'<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>'); var $close = $('<button id="close-floaty-window" ' + style + '>Dismiss Warning for a Day</button>')
} else if (!isLatestInSeries) {
$floatyWarning
.append(
'<p>' +
'<a href="' + targetUrl + '">Click here to go to the same page on the ' + seriesInfo.latest + ' version of the docs.</a>' +
'</p>')
}
if (needsToShow && !outdatedVersionWasAcked(version)) {
var $close = $('<span id="close-floaty-window">Close [X]</span>')
.click(function () { .click(function () {
ackOutdatedVersionForADay(version); ackVersionForADay(site.p, version);
$floatyWarning.hide(); $floatyWarning.hide();
}); });
@ -84,48 +121,62 @@ function showVersionWarning(version, akkaVersionsData, seriesInfo) {
.append($close) .append($close)
.prependTo("body") .prependTo("body")
.show() .show()
.delay(10 * 1000)
.fadeOut();
} }
} }
// e.g. "docs/akka/2.3.10/scala/persistence.html" => "2.3.10" function showSnapshotWarning(site) {
function browsedAkkaVersion() { if (!versionWasAcked(site.p, 'snapshot')) {
var globalSetting = window.DOCUMENTATION_OPTIONS.VERSION; // generated by Sphinx var $floatyWarning = $('<div id="floaty-warning" class="warning"/>');
if (globalSetting) {
return globalSetting; var instead = { 'latest' : 'current' };
} else { var insteadSeries = targetUrl(false, site, instead);
var path = window.location.pathname; var insteadPage = targetUrl(true, site, instead);
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() { $floatyWarning
if (window.location.pathname.includes("stream-and-http")) .append(
return "http://doc.akka.io/docs/akka-stream-and-http-experimental/versions.json"; '<p><span style="font-weight: bold">You are browsing the snapshot documentation, which most likely does not correspond to the artifacts you are using! </span></p>' +
else '<p>We recommend that you head over to <a href="' + insteadSeries + '">the latest stable version</a> instead.</p>' +
return "http://doc.akka.io/docs/akka/versions.json"; '<p id="samePageLink"></p>');
$.ajax({
url: insteadPage,
type: 'HEAD',
success: function() {
$('#samePageLink').html('<a href="' + insteadPage + '">Click here to go to the same page on the latest stable version of the docs.</a>');
}
});
var style = '';
if (site.p != 'akka-stream-and-http-experimental') {
style = 'style="color:black"'
}
var $close = $('<button id="close-floaty-window" ' + style + '>Dismiss Warning for a Day</button>')
.click(function () {
ackVersionForADay(site.p, 'snapshot');
$floatyWarning.hide();
});
$floatyWarning
.hide()
.append($close)
.prependTo("body")
.show()
}
} }
// --- ack outdated versions --- // --- ack outdated versions ---
function ackOutdatedVersionCookieName(version) { function ackVersionCookieName(project, version) {
return "ack-outdated-" + version; return "ack-" + project + "-" + version;
} }
function ackOutdatedVersionForADay(version) { function ackVersionForADay(project, version) {
function setCookie(cname, cvalue, exdays) { function setCookie(cname, cvalue, exdays) {
var d = new Date(); var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000)); d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+d.toUTCString(); var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires; document.cookie = cname + "=" + cvalue + "; " + expires;
} }
setCookie(ackOutdatedVersionCookieName(version), 'true', 1) setCookie(ackVersionCookieName(project, version), 'true', 1)
} }
function outdatedVersionWasAcked(version) { function versionWasAcked(project, version) {
function getCookie(cname) { function getCookie(cname) {
var name = cname + "="; var name = cname + "=";
var ca = document.cookie.split(';'); var ca = document.cookie.split(';');
@ -137,5 +188,5 @@ function outdatedVersionWasAcked(version) {
return ""; return "";
} }
return getCookie(ackOutdatedVersionCookieName(version)) === 'true'; return getCookie(ackVersionCookieName(project, version)) === 'true';
} }

View file

@ -360,17 +360,17 @@ if [ $dry_run ]; then
echodry " rsync -rlpvz --chmod=Dg+ws,Fg+w --exclude ${release_dir}/downloads ${release_dir}/ ${publish_path}/" echodry " rsync -rlpvz --chmod=Dg+ws,Fg+w --exclude ${release_dir}/downloads ${release_dir}/ ${publish_path}/"
echodry " sbt uploadRelease" echodry " sbt uploadRelease"
else else
important ssh ${release_server} "cd ${release_path}/docs/akka; git add .; git commit -m 'before publishing version $version'; true"
important rsync -rlpvz --chmod=Dg+ws,Fg+w --exclude ${release_dir}/downloads ${release_dir}/ ${publish_path}/ important rsync -rlpvz --chmod=Dg+ws,Fg+w --exclude ${release_dir}/downloads ${release_dir}/ ${publish_path}/
important sbt uploadRelease important sbt uploadRelease
important ssh ${release_server} cp -v ${release_path}/docs/akka/${version}/_static/warnOldDocs.js ${release_path}/docs/akka
important ssh ${release_server} ln -snvf ../../warnOldDocs.js ${release_path}/docs/akka/${version}/_static/warnOldDocs.js
important ssh ${release_server} "cd ${release_path}/docs/akka; git add .; git commit -m 'publish version $version'"
fi fi
echolog "Updating http://doc.akka.io/docs/versions.json [from $script_dir/../../akka-docs/versions.json]..." echolog "*****"
if [ $dry_run ]; then echolog "Do not forget to update versions.json on akka.github.com!"
echodry "Not actually updating versions.json. Command:" echolog "*****"
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 [ $dry_run ]; then
if [ $no_revert ]; then if [ $no_revert ]; then