CLICKHOUSE-2981: links to editing reference - https://github.com/yandex/ClickHouse/issues/849

This commit is contained in:
Ivan Blinkov 2017-06-09 14:28:36 +03:00
parent b032278da5
commit 7b917a4683
3 changed files with 39 additions and 3 deletions

View File

@ -0,0 +1,28 @@
$(function() {
$('a[href="#edit"]').on('click', function(e) {
e.preventDefault();
var pathname = window.location.pathname;
var url;
if (pathname.indexOf('html') >= 0) {
url = pathname.replace('/docs/', 'https://github.com/yandex/ClickHouse/edit/master/doc/reference/').replace('html', 'rst');
} else {
if (pathname.indexOf('/single/') >= 0) {
if (pathname.indexOf('ru') >= 0) {
url = 'https://github.com/yandex/ClickHouse/tree/master/doc/reference/ru';
} else {
url = 'https://github.com/yandex/ClickHouse/tree/master/doc/reference/en';
}
} else {
if (pathname.indexOf('ru') >= 0) {
url = 'https://github.com/yandex/ClickHouse/edit/master/doc/reference/ru/index.rst';
} else {
url = 'https://github.com/yandex/ClickHouse/edit/master/doc/reference/en/index.rst';
}
}
}
if (url) {
var win = window.open(url, '_blank');
win.focus();
}
});
});

View File

@ -125,10 +125,11 @@ html_theme_options = {
'link': '#08f', 'link': '#08f',
'link_hover': 'red', 'link_hover': 'red',
'extra_nav_links': collections.OrderedDict([ 'extra_nav_links': collections.OrderedDict([
('Switch to Russian <img id="svg-flag" src="/docs/en/_static/ru.svg" width="20" height="12" />', '/docs/ru/'), ('Switch to Russian <img id="svg-flag" src="/docs/en/_static/ru.svg" width="20" height="12" />', '/docs/ru/'),
('Single page documentation', '/docs/en/single/'), ('Single page documentation', '/docs/en/single/'),
('Website home', '/'), ('Website home', '/'),
('GitHub', 'https://github.com/yandex/ClickHouse'), ('ClickHouse repository', 'https://github.com/yandex/ClickHouse'),
('Edit this page', '#edit'),
]) ])
} }
@ -290,3 +291,6 @@ texinfo_documents = [
# If true, do not generate a @detailmenu in the "Top" node's menu. # If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False #texinfo_no_detailmenu = False
def setup(app):
app.add_javascript('custom.js')

View File

@ -128,7 +128,8 @@ html_theme_options = {
('Switch to English <img id="svg-flag" src="/docs/ru/_static/en.svg" width="20" height="12" />', '/docs/en/'), ('Switch to English <img id="svg-flag" src="/docs/ru/_static/en.svg" width="20" height="12" />', '/docs/en/'),
('Документация на одной странице', '/docs/ru/single/'), ('Документация на одной странице', '/docs/ru/single/'),
('Главная страница сайта', '/'), ('Главная страница сайта', '/'),
('GitHub', 'https://github.com/yandex/ClickHouse'), ('Репозиторий ClickHouse', 'https://github.com/yandex/ClickHouse'),
('Редактировать страницу', '#edit'),
]) ])
} }
@ -290,3 +291,6 @@ texinfo_documents = [
# If true, do not generate a @detailmenu in the "Top" node's menu. # If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False #texinfo_no_detailmenu = False
def setup(app):
app.add_javascript('custom.js')