diff --git a/.lefthook/pre-push/check-docs-versions b/.lefthook/pre-push/check-docs-versions
new file mode 100755
index 00000000..276f215c
--- /dev/null
+++ b/.lefthook/pre-push/check-docs-versions
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+re="^v([3-9]\.[0-9]+)\.0$"
+
+versions=$(cat docs/assets/versions.js)
+
+exitcode=0
+
+while read -r tag; do
+ if [[ $tag =~ $re ]]; then
+ version=${BASH_REMATCH[1]};
+ if [[ $versions != *$version* ]]; then
+ echo "Add $version to docs versions" 1>&2;
+ exitcode=1
+ fi
+ fi
+done < <(git tag);
+
+exit $exitcode
diff --git a/docs/assets/docsify-edit-link.js b/docs/assets/docsify-edit-link.js
deleted file mode 100644
index aeb6b29e..00000000
--- a/docs/assets/docsify-edit-link.js
+++ /dev/null
@@ -1,30 +0,0 @@
-; (function (win) {
- win.EditOnGithubPlugin = {}
-
- function create(docBase) {
- var docEditBase = docBase.replace(/\/blob\//, '/edit/')
-
- return function (hook, vm) {
- hook.afterEach(function (html) {
- var url = docBase
- var docName = vm.route.file
-
- if (docName) {
- url = docEditBase + docName
- }
-
- var header = [
- '',
- 'Edit on GitHub',
- ''
- ].join('')
-
- return html + header
- })
- }
- }
-
- win.EditOnGithubPlugin.create = create
-})(window)
diff --git a/docs/assets/docsify-gitter.js b/docs/assets/docsify-gitter.js
deleted file mode 100644
index 0e05b537..00000000
--- a/docs/assets/docsify-gitter.js
+++ /dev/null
@@ -1,29 +0,0 @@
-; (function (win) {
- win.GitterPlugin = {}
-
- function create(room, color) {
- color = color || "blue";
-
- var url = "https://gitter.im/" + room;
- var badgeUrl = "https://img.shields.io/gitter/room/" +
- room +
- "?color=" + color +
- "&style=for-the-badge" +
- "&logo=gitter";
- var html = "" +
- "
" +
- "";
-
- return function (hook) {
- hook.mounted(function () {
- var el = Docsify.dom.create('div', html);
- var appName = Docsify.dom.find('.app-name');
-
- Docsify.dom.toggleClass(el, 'gitter');
- Docsify.dom.appendTo(appName, el);
- })
- }
- }
-
- win.GitterPlugin.create = create
-})(window)
diff --git a/docs/assets/docsify-init.js b/docs/assets/docsify-init.js
new file mode 100644
index 00000000..be3beb0e
--- /dev/null
+++ b/docs/assets/docsify-init.js
@@ -0,0 +1,128 @@
+if (window.DOCSIFY_ROUTER_MODE === "history") {
+ var clink = document.createElement("link")
+ clink.rel = "canonical"
+ document.getElementsByTagName("head")[0].appendChild(clink)
+}
+
+var documentTitleBase = document.title;
+
+var gitterURL = "https://gitter.im/imgproxy/imgproxy";
+var gitterBadgeURL = "https://img.shields.io/gitter/room/imgproxy/imgproxy" +
+ "?color=1775d3&style=for-the-badge&logo=gitter";
+var gitterBadge = '
';
+
+var docEditBase = 'https://github.com/imgproxy/imgproxy/edit/master/docs/';
+
+var proBadge = document.createElement("img")
+proBadge.setAttribute("src", "/assets/pro.svg")
+proBadge.setAttribute("title", "This feature is available in imgproxy Pro")
+
+var proBadgeRegex = /\!\[pro\]\((\S+)\)/g;
+var proLink = '' +
+ proBadge.outerHTML + '';
+
+var oldProBadge = "";
+
+var versions = ["latest"].concat(window.IMGPROXY_VERSIONS);
+var latestVersion = window.IMGPROXY_VERSIONS[0];
+var versionSelect = '';
+
+window.$docsify = {
+ name: '
' +
+ gitterBadge +
+ versionSelect,
+ nameLink: false,
+ repo: 'https://github.com/imgproxy',
+ loadSidebar: true,
+ subMaxLevel: 2,
+ auto2top: true,
+ routerMode: window.DOCSIFY_ROUTER_MODE || "hash",
+ noEmoji: true,
+ alias: {
+ '/latest/': 'README.md',
+ '/latest/(.*)': '$1',
+ '/([0-9]+\.[0-9]+)/(.*)': 'https://raw.githubusercontent.com/imgproxy/imgproxy/v$1.0/docs/$2',
+ '/([0-9]+\.[0-9]+)/': 'https://raw.githubusercontent.com/imgproxy/imgproxy/v$1.0/docs/README.md',
+ '/(.*)': 'https://raw.githubusercontent.com/imgproxy/imgproxy/v' + latestVersion + '.0/docs/$1',
+ '/': 'https://raw.githubusercontent.com/imgproxy/imgproxy/v' + latestVersion + '.0/docs/README.md',
+ },
+ search: {
+ namespace: 'docs-imgproxy',
+ depth: 6,
+ pathNamespaces: versions.map(function (v) { return "/" + v })
+ },
+ namespaces: [
+ {
+ id: "version",
+ values: versions,
+ optional: true,
+ selector: "#version-selector"
+ }
+ ],
+ plugins: [
+ function (hook, vm) {
+ window.DocsifyVM = vm
+ hook.beforeEach(function () {
+ if (clink) {
+ clink.href = "https://docs.imgproxy.net" + vm.route.path
+ }
+ });
+
+ hook.doneEach(function () {
+ var appNameLink = Docsify.dom.find("#home-link");
+
+ if (!appNameLink) return;
+
+ appNameLink.href = vm.config.currentNamespace;
+ });
+
+ hook.doneEach(function() {
+ if (document.title != documentTitleBase)
+ document.title += " | " + documentTitleBase;
+ });
+
+
+ hook.afterEach(function (html) {
+ var docName = vm.route.file.replace(
+ /https\:\/\/raw.githubusercontent\.com\/(.*)\/docs\//, ''
+ )
+
+ if (!docName) {
+ return html;
+ }
+
+ var editButton = '' +
+ 'Edit on GitHub' +
+ '';
+
+ return html + editButton
+ })
+
+ hook.beforeEach(function (content, next) {
+ content = content.replaceAll(proBadgeRegex, proLink)
+ content = content.replaceAll(oldProBadge, proLink)
+ console.log(content)
+ next(content)
+ })
+
+ hook.doneEach(function () {
+ var badges = Docsify.dom.findAll(".sidebar .badge-pro")
+ badges.forEach(function (b) { b.replaceWith(proBadge.cloneNode()) })
+
+ // Docsify cuts off "target" sometimes
+ var links = Docsify.dom.findAll("a.badge")
+ links.forEach(function(l){ l.setAttribute("target", "_blank") })
+ })
+ }
+ ]
+}
diff --git a/docs/assets/docsify-pro-badge.js b/docs/assets/docsify-pro-badge.js
deleted file mode 100644
index fd67deb2..00000000
--- a/docs/assets/docsify-pro-badge.js
+++ /dev/null
@@ -1,19 +0,0 @@
-; (function (win) {
- win.ProBadgePlugin = {}
-
- function create() {
- var regex = /\!\[pro\]\((\S+)\)/g;
- var proLink = '' +
- '
' +
- '';
-
- return function (hook) {
- hook.beforeEach(function (content, next) {
- content = content.replaceAll(regex, proLink)
- next(content)
- })
- }
- }
-
- win.ProBadgePlugin.create = create
-})(window)
diff --git a/docs/assets/style.css b/docs/assets/style.css
index dce464ca..13b491f7 100644
--- a/docs/assets/style.css
+++ b/docs/assets/style.css
@@ -145,3 +145,8 @@ h1 .badge img, h3 .badge img, h3 .badge img, h4 .badge img, h5 .badge img {
display: block;
margin: 5px auto 0;
}
+
+.sidebar-version-select {
+ width: 100%;
+ margin: var(--sidebar-nav-margin);
+}
diff --git a/docs/assets/versions.js b/docs/assets/versions.js
new file mode 100644
index 00000000..643859bc
--- /dev/null
+++ b/docs/assets/versions.js
@@ -0,0 +1,9 @@
+window.IMGPROXY_VERSIONS = [
+ "3.6",
+ "3.5",
+ "3.4",
+ "3.3",
+ "3.2",
+ "3.1",
+ "3.0"
+];
diff --git a/docs/index.html b/docs/index.html
index dba8d61d..c658a549 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -41,56 +41,16 @@
-
-
-
-
+
- window.$docsify = {
- logo: '/assets/logo.svg',
- name: 'imgproxy',
- repo: 'https://github.com/imgproxy',
- loadSidebar: true,
- subMaxLevel: 2,
- auto2top: true,
- routerMode: window.DOCSIFY_ROUTER_MODE || "hash",
- noEmoji: true,
- search: {
- namespace: 'docs-imgproxy',
- depth: 6
- },
- plugins: [
- EditOnGithubPlugin.create('https://github.com/imgproxy/imgproxy/blob/master/docs/'),
- GitterPlugin.create("imgproxy/imgproxy", "1775d3"),
- ProBadgePlugin.create(),
- function (hook, vm) {
- hook.beforeEach(function () {
- if (clink) {
- clink.href = "https://docs.imgproxy.net" + vm.route.path
- }
- });
- },
- function (hook, vm) {
- hook.doneEach((content) => {
- if (document.title != documentTitleBase)
- document.title += " | " + documentTitleBase;
- });
- }
- ]
- }
-
-
+
+
-
+