simonw / sqlite-utils

Python CLI utility and library for manipulating SQLite databases
https://sqlite-utils.datasette.io
Apache License 2.0
1.63k stars 111 forks source link

Link to stable docs from older versions #388

Closed simonw closed 2 years ago

simonw commented 2 years ago

https://sqlite-utils.datasette.io/en/2.14.1/ isn't showing a link to the stable release right now.

I should also apply the same fix I used for Datasette in:

TIL: https://til.simonwillison.net/readthedocs/link-from-latest-to-stable

simonw commented 2 years ago

On https://readthedocs.org/dashboard/sqlite-utils/advanced/ I checked this box (previously unchecked):

CleanShot 2022-01-25 at 17 56 22@2x

simonw commented 2 years ago

While I'm modifying that template I'm also going to add Plausible analytics:

<script defer data-domain="sqlite-utils.datasette.io" src="https://plausible.io/js/plausible.js"></script>
simonw commented 2 years ago

https://sqlite-utils.datasette.io/en/latest/

image
simonw commented 2 years ago

https://sqlite-utils.datasette.io/en/3.20/ now also shows the version warning banner.

simonw commented 1 year ago

This broke on the upgrade to Furo.

I fixed it in Datasette like this: https://github.com/simonw/datasette/commit/5c1cfa451d78e3935193f5e10eba59bf741241a1 and https://github.com/simonw/datasette/commit/db8cf899e286fbaa0a40f3a9ae8d5aaa1478822e

simonw commented 1 year ago

Actually final Datasette fix was:

{% block scripts %}
{{ super() }}
<script>
document.addEventListener("DOMContentLoaded", function() {
  // Show banner linking to /stable/ if this is a /latest/ page
  if (!/\/latest\//.test(location.pathname)) {
    return;
  }
  var stableUrl = location.pathname.replace("/latest/", "/stable/");
  // Check it's not a 404
  fetch(stableUrl, { method: "HEAD" }).then((response) => {
    if (response.status === 200) {
      var warning = document.createElement("div");
      warning.className = "admonition warning";
      warning.innerHTML = `
        <p class="first admonition-title">Note</p>
        <p class="last">
          This documentation covers the <strong>development version</strong> of Datasette.
        </p>
        <p>
          See <a href="${stableUrl}">this page</a> for the current stable release.
        </p>
      `;
      var mainArticle = document.querySelector("article[role=main]");
      mainArticle.insertBefore(warning, mainArticle.firstChild);
    }
  });
});
</script>
{% endblock %}
simonw commented 1 year ago

Fixed: https://sqlite-utils.datasette.io/en/latest/reference.html