From bea23ca166168cad2289cfa2e21926f968332843 Mon Sep 17 00:00:00 2001 From: haml-707 <845831435@qq.com> Date: Thu, 17 Nov 2022 10:20:01 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=E9=93=BE=E6=8E=A5=E8=BD=AC=E8=AF=91?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/404.html | 5 +++-- layouts/docs/single.html | 2 +- static/css/common.css | 7 ++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/layouts/404.html b/layouts/404.html index 9ee70ed1d..96973a3d8 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -7,10 +7,11 @@
- {{ .Site.Params.notFound }} 404 not found + {{ .Site.Params.notFound }}
- + + \ No newline at end of file diff --git a/layouts/docs/single.html b/layouts/docs/single.html index fc7ec57dd..6e8de99e7 100644 --- a/layouts/docs/single.html +++ b/layouts/docs/single.html @@ -1,6 +1,6 @@ {{ define "main" }}
- {{ $pt := (replace .Content ".md\"" ".html\"") }} + {{ $pt := (replace .Content "\"" "\"") }} {{ $pt1 := (replace $pt ".md#" ".html#") }} {{ $st := (replace $pt1 "‘" "'") }} {{ $ot := (replace $st "’" "'") }} diff --git a/static/css/common.css b/static/css/common.css index 0fcc73ac7..d5a92289d 100644 --- a/static/css/common.css +++ b/static/css/common.css @@ -29,8 +29,8 @@ i { position: relative; margin-top: 180px !important; display: flex; - flex-direction: row; - justify-content: space-between; + justify-content: center; + align-items: center; } .not-found img { @@ -544,10 +544,7 @@ i { } .not-found { margin-top: 40px !important; - flex-direction: column; - justify-content: center; } - .not-found img { width: 265px; height: 272px; -- Gitee From e11cffcc0ce3507bf081009f3e662fd088d12169 Mon Sep 17 00:00:00 2001 From: haml-707 <845831435@qq.com> Date: Thu, 17 Nov 2022 10:54:41 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix=EF=BC=9Abuild=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/docs-builder.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deploy/docs-builder.sh b/deploy/docs-builder.sh index 641670e1e..2687f5873 100644 --- a/deploy/docs-builder.sh +++ b/deploy/docs-builder.sh @@ -8,7 +8,8 @@ if [ -d "./website" ]; then fi mkdir website -git clone https://gitee.com/openeuler/docs +# git clone https://gitee.com/openeuler/docs +git clone https://gitee.com/haml/docs cd ./docs git checkout -b website origin/website cp -r * ../website -- Gitee From f5a79b4abbb088a5b0d6dcd7dacd0abce1e2552d Mon Sep 17 00:00:00 2001 From: haml-707 <845831435@qq.com> Date: Wed, 7 Dec 2022 18:06:19 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=E5=88=87=E6=8D=A2=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/nginx.conf | 10 +- deploy/nginx.ru.conf | 10 +- static/css/docsearch.css | 4 +- static/js/docsearch.js | 499 ++++++++++++++++++++------------------- 4 files changed, 268 insertions(+), 255 deletions(-) diff --git a/deploy/nginx.conf b/deploy/nginx.conf index d30ecb280..d70f53c0b 100644 --- a/deploy/nginx.conf +++ b/deploy/nginx.conf @@ -72,8 +72,8 @@ http { } location / { - root /usr/share/nginx/html; - index index.html index.htm; + root /usr/share/nginx/html; + index index.html index.htm; } error_page 404 /zh/404.html; @@ -82,7 +82,7 @@ http { root /usr/share/nginx/html; } - location /omapi/ { + location /omapi/ { proxy_pass https://omapi.osinfra.cn/; } @@ -90,6 +90,10 @@ http { proxy_pass http://ip-api.com/json/; } + location /api-search/ { + proxy_pass https://doc-search.openeuler.org/; + } + location ~ /\. { deny all; return 404; diff --git a/deploy/nginx.ru.conf b/deploy/nginx.ru.conf index 52ba65ce1..a76366278 100644 --- a/deploy/nginx.ru.conf +++ b/deploy/nginx.ru.conf @@ -72,8 +72,8 @@ http { } location / { - root /usr/share/nginx/html; - index index.html index.htm; + root /usr/share/nginx/html; + index index.html index.htm; } error_page 404 /ru/404.html; @@ -82,7 +82,7 @@ http { root /usr/share/nginx/html; } - location /omapi/ { + location /omapi/ { proxy_pass https://omapi.osinfra.cn/; } @@ -90,6 +90,10 @@ http { proxy_pass http://ip-api.com/json/; } + location /api-search/ { + proxy_pass https://doc-search.openeuler.org/; + } + location ~ /\. { deny all; return 404; diff --git a/static/css/docsearch.css b/static/css/docsearch.css index 7c37bd37c..6482f8bfe 100644 --- a/static/css/docsearch.css +++ b/static/css/docsearch.css @@ -40,8 +40,8 @@ } .search-result .main-text, -.search-result .res-title em, -.search-result .res-desc em { +.search-result .res-title span, +.search-result .res-desc span { color: var(--e-color-brand1); } diff --git a/static/js/docsearch.js b/static/js/docsearch.js index dc9063fb5..66d7a9e0b 100644 --- a/static/js/docsearch.js +++ b/static/js/docsearch.js @@ -1,247 +1,252 @@ -$(function($) { - var keyword = ""; - $(".baseof_mask").click(function (e) { - $(".baseof_mask").css('display','none'); - $('.alert').css('display','none') - $("#result-container").css("display","none"); - $("#title-evaluate").removeClass("bug-hide") - }); - - $(".search-header>.icon-search").click(function (e) { - keyword = $(".search-header>.search-text").val(); - $("#search_content").css('display','block'); - searchMethods.search(decodeURI(keyword),1,"#baseof-pagination"); - }); - - $(".search-header>.search-text").bind('keypress',function(event){ - if(event.keyCode == "13") { - keyword = $(".search-header>.search-text").val(); - $("#search_content").css('display','block'); - searchMethods.search(decodeURI(keyword),1,"#baseof-pagination"); - } - }); - - $(document).ready(function() { - $(".search-header>.search-text").blur(function() { - var value = $(this).val(); - value = $.trim(value); - if (value == '') { - searchMethods.search(decodeURI(value),1,"#baseof-pagination"); - $(".search-result>#baseof-pagination").css("display",'none') - } - }) - }); - - $("#search-input>.icon-search").click(function (e) { - keyword = $("#search-input>.search-text").val(); - $("#search_content").css('display','block'); - searchMethods.search(decodeURI(keyword),1,"#web-pagination"); - }); - - $("#search-input>.search-text").bind('keyup',function(event){ - if(!$("#search-input>.search-text").val()) { - $("#search_content").css('display','none'); - } - if(event.keyCode == "13") { - keyword = $("#search-input>.search-text").val(); - $("#search_content").css('display','block'); - searchMethods.search(decodeURI(keyword),1,"#web-pagination"); - } - }); - - $(".white_search").click(function (e) { - $(".searcher").css('display','block'); - $(".zhezhao").css('display','block'); - var height = $(".h5_index").outerHeight(true)-279; - $(".zhezhao").css("height",height); - - }); - $(".cancel-btn").click(function (e) { - $(".searcher").css('display','none'); - $(".zhezhao").css('display','none'); - var height = $(".h5_index").outerHeight(true)-279; - $(".zhezhao").css("height",height); - - }); - - $(".zhezhao").click(function (e) { - $(".searcher").css('display','none'); - $(".zhezhao").css('display','none'); - $(".h5_index .h5_nav").removeClass("h5_nav_show"); - }); - - $(".h5-search").find(".search-btn").click(function (e) { - keyword = $(".h5-search").find("input").val(); - $(".search-result").css('display','none'); - searchMethods.search(decodeURI(keyword),1,"#pagination"); - }); - $(".h5-search input").keyup(function(){ - if($(this).val()!==""){ - $(".icon-clear").show() - }else{ - $(".icon-clear").hide() - } - }) - $(".icon-clear").click(function(){ - $(".h5-search input").val("") - $(".icon-clear").hide() - }) - $(".h5-search>.search-text").bind('keypress',function(event){ - if(event.keyCode == "13") { - keyword = $(".h5-search>.search-text").val(); - - $(".search-result").css('display','block'); - searchMethods.search(decodeURI(keyword),1,"#pagination"); - - } - }); - var versionText = ''; - var articles = ''; - var totalAmount = 0; - var pagecount = 5; - var currentScreen = document.body.clientWidth; - if(currentScreen <= 1000) { - pagecount = 3; - } - if(lang === 'zh') { - versionText = '版本'; - articles = 'openeuler_articles'; - }else if(lang === 'en') { - versionText = 'version'; - articles = 'openeuler_articles_en'; - }else { - versionText = 'Версия'; - articles = 'openeuler_articles_ru'; - } - - var searchMethods = { - search: function (value,page,el) { - if (value && el) { - const search_event_id = `${value}${new Date().getTime()}${window['sensorsCustomBuriedData']?.ip || ''}`; - const obj = { - search_key: value, - search_event_id - }; - window['addSearchBuriedData'] = obj; - let sensors = window['sensorsDataAnalytic201505']; - sensors?.setProfile({ - profileType: 'searchValue', - ...(window['sensorsCustomBuriedData'] || {}), - ...(window['addSearchBuriedData'] || {}) - }); - } - - let postData = { - keyword: value, - model: 'docs', - indexEs: articles, - version: '', - page: page - } - $.ajax({ - type: "POST", - url: '/docs-search/search/keyword', - data: JSON.stringify(postData), - contentType: "application/json; charset=utf-8", - datatype: "json", - headers: { - Authorization: 'Basic b3BlbmV1bGVyc2VydmVyOm9wZW5ldWxlcnNlcnZlckAxMjM0' - }, - success: function (data) { - let dataArr = data.data.records; - totalAmount = data.data.totalNum; - if(page === 1) { - let pag = new Pagination({ - element: el||'#baseof-pagination', - type: 1, - pageIndex: 1, - pageSize: 10, - pageCount: pagecount, - total: totalAmount, - jumper: false, - singlePageHide: false, - prevText: '<', - nextText: '>', - disabled: false, - currentChange: function(index) { - searchMethods.search(decodeURI(keyword),index); - } - }); - // $(".search-result>.title").find(".res-amount").text(totalAmount); - $(".search-result>.title").find(".keyword").text(value); - } - searchMethods.solveData(dataArr,versionText, page); - }, - error: function (data) { - totalAmount = 0; - // $(".search-result>.title").find(".res-amount").text(totalAmount); - $(".search-result>.title").find(".keyword").text(value); - }, - }); - }, - solveData: function (result, text, page) { - $(".search-result>ul").empty(); - if (!result.length) { - $("#search_content").hide(); - return; - } - $("#search_content").show(); - result.forEach(function(item, index) { - let urlArr = item.path.split('/'); - let name = item.title.replace("",""); - name = name.replace("",""); - let url = "/" + urlArr[7] + "/docs/" + urlArr[6] + "/docs/" + urlArr[9] + "/" + name + ".html" ; - $(".search-result>ul").append('
  • '+ - '
    ' + - searchMethods.escapeHTML(item.title) + - '
    ' + - '
    ' + - searchMethods.escapeHTML(item.textContent) + - '
    ' + - '
    ' + - searchMethods.escapeHTML(text)+ ':' + searchMethods.escapeHTML(item.version) + '' + - '
    ' + - '
  • '); - - $(".search-result>ul li").find(".res-title").click(function (e) { - const searchKeyObj = { - search_tag: 'docs', - search_rank_num: 10 * (page - 1) + (index + 1), - search_result_total_num: totalAmount - }; - let sensors = window['sensorsDataAnalytic201505']; - sensors.setProfile({ - profileType: 'selectSearchResult', - ...(item || {}), - ...(window['sensorsCustomBuriedData'] || {}), - ...(window['addSearchBuriedData'] || {}), - ...searchKeyObj - }) - window.location.href = $(this).attr("href"); - }); - }); - }, - escapeHTML: function (str) { - return str.replace( - /[&<>'"]/g, - function (tag) { - return ({ - '&': '&', - // '<': '<', - // '>': '>', - "'": ''', - '"': '"' - }[tag] || tag) - } - ); - } - }; - - if(typeof(keyword) === 'undefined') { - $(".search-result").empty(); - }else { - $(".search-result>.title").find(".keyword").text(decodeURI(keyword)); - $(".input>.search-text").val(decodeURI(keyword)); - $(".h5-search>div").find("input").val(decodeURI(keyword)); - } -}) \ No newline at end of file +$(function ($) { + var keyword = ''; + $('.baseof_mask').click(function (e) { + $('.baseof_mask').css('display', 'none'); + $('.alert').css('display', 'none'); + $('#result-container').css('display', 'none'); + $('#title-evaluate').removeClass('bug-hide'); + }); + + $('.search-header>.icon-search').click(function (e) { + keyword = $('.search-header>.search-text').val(); + $('#search_content').css('display', 'block'); + searchMethods.search(decodeURI(keyword), 1, '#baseof-pagination'); + }); + + $('.search-header>.search-text').bind('keypress', function (event) { + if (event.keyCode == '13') { + keyword = $('.search-header>.search-text').val(); + $('#search_content').css('display', 'block'); + searchMethods.search(decodeURI(keyword), 1, '#baseof-pagination'); + } + }); + + $(document).ready(function () { + $('.search-header>.search-text').blur(function () { + var value = $(this).val(); + value = $.trim(value); + if (value == '') { + searchMethods.search(decodeURI(value), 1, '#baseof-pagination'); + $('.search-result>#baseof-pagination').css('display', 'none'); + } + }); + }); + + $('#search-input>.icon-search').click(function (e) { + keyword = $('#search-input>.search-text').val(); + $('#search_content').css('display', 'block'); + searchMethods.search(decodeURI(keyword), 1, '#web-pagination'); + }); + + $('#search-input>.search-text').bind('keyup', function (event) { + if (!$('#search-input>.search-text').val()) { + $('#search_content').css('display', 'none'); + } + if (event.keyCode == '13') { + keyword = $('#search-input>.search-text').val(); + $('#search_content').css('display', 'block'); + searchMethods.search(decodeURI(keyword), 1, '#web-pagination'); + } + }); + + $('.white_search').click(function (e) { + $('.searcher').css('display', 'block'); + $('.zhezhao').css('display', 'block'); + var height = $('.h5_index').outerHeight(true) - 279; + $('.zhezhao').css('height', height); + }); + $('.cancel-btn').click(function (e) { + $('.searcher').css('display', 'none'); + $('.zhezhao').css('display', 'none'); + var height = $('.h5_index').outerHeight(true) - 279; + $('.zhezhao').css('height', height); + }); + + $('.zhezhao').click(function (e) { + $('.searcher').css('display', 'none'); + $('.zhezhao').css('display', 'none'); + $('.h5_index .h5_nav').removeClass('h5_nav_show'); + }); + + $('.h5-search') + .find('.search-btn') + .click(function (e) { + keyword = $('.h5-search').find('input').val(); + $('.search-result').css('display', 'none'); + searchMethods.search(decodeURI(keyword), 1, '#pagination'); + }); + $('.h5-search input').keyup(function () { + if ($(this).val() !== '') { + $('.icon-clear').show(); + } else { + $('.icon-clear').hide(); + } + }); + $('.icon-clear').click(function () { + $('.h5-search input').val(''); + $('.icon-clear').hide(); + }); + $('.h5-search>.search-text').bind('keypress', function (event) { + if (event.keyCode == '13') { + keyword = $('.h5-search>.search-text').val(); + + $('.search-result').css('display', 'block'); + searchMethods.search(decodeURI(keyword), 1, '#pagination'); + } + }); + var versionText = ''; + var articles = ''; + var totalAmount = 0; + var pagecount = 5; + var currentScreen = document.body.clientWidth; + if (currentScreen <= 1000) { + pagecount = 3; + } + if (lang === 'zh') { + versionText = '版本'; + articles = 'openeuler_articles'; + } else if (lang === 'en') { + versionText = 'version'; + articles = 'openeuler_articles_en'; + } else { + versionText = 'Версия'; + articles = 'openeuler_articles_ru'; + } + + var searchMethods = { + search: function (value, page, el) { + if (value && el) { + const search_event_id = `${value}${new Date().getTime()}${ + window['sensorsCustomBuriedData']?.ip || '' + }`; + const obj = { + search_key: value, + search_event_id, + }; + window['addSearchBuriedData'] = obj; + let sensors = window['sensorsDataAnalytic201505']; + sensors?.setProfile({ + profileType: 'searchValue', + ...(window['sensorsCustomBuriedData'] || {}), + ...(window['addSearchBuriedData'] || {}), + }); + } + + try { + const version = window.location.pathname.split('/')[3]; + let postData = { + keyword: value, + lang: lang, + version, + page: page, + }; + $.ajax({ + type: 'POST', + url: '/api-search/search/sort/docs', + data: JSON.stringify(postData), + contentType: 'application/json; charset=utf-8', + datatype: 'json', + success: function (data) { + let dataArr = data.obj?.records; + totalAmount = data.obj?.count; + if (page === 1) { + $('.search-result>.title').find('.keyword').text(value); + let pag = new Pagination({ + element: el || '#baseof-pagination', + type: 1, + pageIndex: 1, + pageSize: 10, + pageCount: pagecount, + total: totalAmount, + jumper: false, + singlePageHide: false, + prevText: '<', + nextText: '>', + disabled: false, + currentChange: function (index) { + searchMethods.search(decodeURI(keyword), index); + }, + }); + } + searchMethods.solveData(dataArr, versionText, page); + }, + error: function (data) { + totalAmount = 0; + $('.search-result>.title').find('.keyword').text(value); + }, + }); + } catch (error) { + console.log(error); + } + }, + solveData: function (result, text, page) { + $('.search-result>ul').empty(); + if (!result?.length) { + $('#search_content').hide(); + return; + } + $('#search_content').show(); + result.forEach(function (item, index) { + let url = `/${lang}/${item.path}.html`; + $('.search-result>ul').append( + '
  • ' + + '
    ' + + searchMethods.escapeHTML(item.title) + + '
    ' + + '
    ' + + searchMethods.escapeHTML(item.textContent) + + '
    ' + + '
    ' + + searchMethods.escapeHTML(text) + + ':' + + searchMethods.escapeHTML(item.version) + + '' + + '
    ' + + '
  • ' + ); + + $('.search-result>ul li') + .find('.res-title') + .click(function (e) { + const searchKeyObj = { + search_tag: 'docs', + search_rank_num: 10 * (page - 1) + (index + 1), + search_result_total_num: totalAmount, + }; + let sensors = window['sensorsDataAnalytic201505']; + sensors.setProfile({ + profileType: 'selectSearchResult', + ...(item || {}), + ...(window['sensorsCustomBuriedData'] || {}), + ...(window['addSearchBuriedData'] || {}), + ...searchKeyObj, + }); + window.location.href = $(this).attr('href'); + }); + }); + }, + escapeHTML: function (str) { + return str.replace(/[&<>'"]/g, function (tag) { + return ( + { + '&': '&', + // '<': '<', + // '>': '>', + "'": ''', + '"': '"', + }[tag] || tag + ); + }); + }, + }; + + if (typeof keyword === 'undefined') { + $('.search-result').empty(); + } else { + $('.search-result>.title').find('.keyword').text(decodeURI(keyword)); + $('.input>.search-text').val(decodeURI(keyword)); + $('.h5-search>div').find('input').val(decodeURI(keyword)); + } +}); -- Gitee From f192eb6758046defac08f1eb41574f0f19843c3e Mon Sep 17 00:00:00 2001 From: haml-707 <845831435@qq.com> Date: Wed, 7 Dec 2022 18:10:30 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix=EF=BC=9A=E7=89=88=E6=9C=AC=E5=9B=9E?= =?UTF-8?q?=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/docs-builder.sh | 3 +-- layouts/docs/single.html | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/deploy/docs-builder.sh b/deploy/docs-builder.sh index 83db8ea85..13f37815b 100644 --- a/deploy/docs-builder.sh +++ b/deploy/docs-builder.sh @@ -8,8 +8,7 @@ if [ -d "./website" ]; then fi mkdir website -# git clone https://gitee.com/openeuler/docs -git clone https://gitee.com/haml/docs +git clone https://gitee.com/openeuler/docs cd ./docs git checkout -b website origin/website cp -r * ../website diff --git a/layouts/docs/single.html b/layouts/docs/single.html index 6e8de99e7..fc7ec57dd 100644 --- a/layouts/docs/single.html +++ b/layouts/docs/single.html @@ -1,6 +1,6 @@ {{ define "main" }}
    - {{ $pt := (replace .Content "\"" "\"") }} + {{ $pt := (replace .Content ".md\"" ".html\"") }} {{ $pt1 := (replace $pt ".md#" ".html#") }} {{ $st := (replace $pt1 "‘" "'") }} {{ $ot := (replace $st "’" "'") }} -- Gitee