From be0c4e1d3032a695f34dd623fa318c9373175a66 Mon Sep 17 00:00:00 2001 From: Martijn Cuppens Date: Mon, 16 Dec 2019 21:41:44 +0200 Subject: [PATCH 1/6] docs: enable OpenSearch --- site/assets/js/search.js | 13 ++++++++++++- site/layouts/partials/header.html | 1 + site/static/documentation-search.xml | 7 +++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 site/static/documentation-search.xml diff --git a/site/assets/js/search.js b/site/assets/js/search.js index e198eddb3..bcaf515ce 100644 --- a/site/assets/js/search.js +++ b/site/assets/js/search.js @@ -20,7 +20,7 @@ } }) - window.docsearch({ + var search = window.docsearch({ apiKey: '5990ad008512000bba2cf951ccf0332f', indexName: 'bootstrap', inputSelector: '#search-input', @@ -50,4 +50,15 @@ // Set debug to `true` if you want to inspect the dropdown debug: false }) + + function hashSearch() { + if (window.location.hash && window.location.hash.indexOf('#search=') === 0) { + search.input.autocomplete.setVal(window.location.hash.slice(8)) + search.input.autocomplete.open() + } + } + + hashSearch() + // For the nerds: search by changing the url hash + window.addEventListener('hashchange', hashSearch, false) })() diff --git a/site/layouts/partials/header.html b/site/layouts/partials/header.html index 2d2eb29d9..114112f80 100644 --- a/site/layouts/partials/header.html +++ b/site/layouts/partials/header.html @@ -10,6 +10,7 @@ {{ if .IsHome }}{{ .Site.Title | markdownify }} · {{ .Site.Params.description | markdownify }}{{ else }}{{ .Title | markdownify }} · {{ .Site.Title | markdownify }} v{{ .Site.Params.docs_version }}{{ end }} + {{ with .Params.robots -}} diff --git a/site/static/documentation-search.xml b/site/static/documentation-search.xml new file mode 100644 index 000000000..9fdd82d49 --- /dev/null +++ b/site/static/documentation-search.xml @@ -0,0 +1,7 @@ + + + Bootstrap Documentation + Search in the latest Bootstrap documentation + https://deploy-preview-29872--twbs-bootstrap.netlify.com/favicon.ico + + From 66c11808b2b26b16ec7677a73700ebcb7309a284 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 17 Feb 2020 18:20:24 +0200 Subject: [PATCH 2/6] Make OpenSearch an output format. Not sure if there's another way to do this... --- config.yml | 12 ++++++++++++ site/layouts/_default/list.opensearch.xml | 7 +++++++ site/layouts/partials/header.html | 5 ++++- site/static/documentation-search.xml | 7 ------- 4 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 site/layouts/_default/list.opensearch.xml delete mode 100644 site/static/documentation-search.xml diff --git a/config.yml b/config.yml index 72776be7d..2e88e44a8 100644 --- a/config.yml +++ b/config.yml @@ -20,6 +20,18 @@ enableRobotsTXT: true metaDataFormat: "yaml" disableKinds: ["404", "taxonomy", "taxonomyTerm", "RSS"] +outputFormats: + OpenSearch: + baseName: opensearch + isPlainText: true + mediaType: application/xml + notAlternative: true + +outputs: + home: + - HTML + - OpenSearch + publishDir: "_gh_pages" module: diff --git a/site/layouts/_default/list.opensearch.xml b/site/layouts/_default/list.opensearch.xml new file mode 100644 index 000000000..a64e0daee --- /dev/null +++ b/site/layouts/_default/list.opensearch.xml @@ -0,0 +1,7 @@ + + + {{ .Site.Title }} + Search {{ .Site.Title }} documentation + {{ (printf "/docs/%s/assets/img/favicons/favicon.ico" .Site.Params.docs_version) | absURL }} + + diff --git a/site/layouts/partials/header.html b/site/layouts/partials/header.html index 114112f80..4eddd4715 100644 --- a/site/layouts/partials/header.html +++ b/site/layouts/partials/header.html @@ -10,7 +10,10 @@ {{ if .IsHome }}{{ .Site.Title | markdownify }} · {{ .Site.Params.description | markdownify }}{{ else }}{{ .Title | markdownify }} · {{ .Site.Title | markdownify }} v{{ .Site.Params.docs_version }}{{ end }} - + +{{ with .OutputFormats.Get "opensearch" -}} + +{{ end -}} {{ with .Params.robots -}} diff --git a/site/static/documentation-search.xml b/site/static/documentation-search.xml deleted file mode 100644 index 9fdd82d49..000000000 --- a/site/static/documentation-search.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - Bootstrap Documentation - Search in the latest Bootstrap documentation - https://deploy-preview-29872--twbs-bootstrap.netlify.com/favicon.ico - - From 648538b5cc3cce4f7694d8d4529b655dce4a740f Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 17 Feb 2020 18:33:57 +0200 Subject: [PATCH 3/6] Update search.js --- site/assets/js/search.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/site/assets/js/search.js b/site/assets/js/search.js index bcaf515ce..ca7607e37 100644 --- a/site/assets/js/search.js +++ b/site/assets/js/search.js @@ -52,13 +52,16 @@ }) function hashSearch() { - if (window.location.hash && window.location.hash.indexOf('#search=') === 0) { - search.input.autocomplete.setVal(window.location.hash.slice(8)) + var SEARCH_WORD = '#search=' + + if (window.location.hash && window.location.hash.startsWith(SEARCH_WORD)) { + search.input.autocomplete.setVal(window.location.hash.slice(SEARCH_WORD.length)) search.input.autocomplete.open() } } hashSearch() + // For the nerds: search by changing the url hash window.addEventListener('hashchange', hashSearch, false) })() From f02783af30fb5028f18cf6bcee65766388c04b35 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 17 Feb 2020 18:57:04 +0200 Subject: [PATCH 4/6] Add InputEncoding --- site/layouts/_default/list.opensearch.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/site/layouts/_default/list.opensearch.xml b/site/layouts/_default/list.opensearch.xml index a64e0daee..15258eb65 100644 --- a/site/layouts/_default/list.opensearch.xml +++ b/site/layouts/_default/list.opensearch.xml @@ -2,6 +2,7 @@ {{ .Site.Title }} Search {{ .Site.Title }} documentation + UTF-8 {{ (printf "/docs/%s/assets/img/favicons/favicon.ico" .Site.Params.docs_version) | absURL }} From c29cd7f770ac4d2af2f1641817ff070198e29815 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 17 Feb 2020 19:02:24 +0200 Subject: [PATCH 5/6] Add OpenSearch images --- site/layouts/_default/list.opensearch.xml | 3 ++- .../5.0/assets/img/opensearch/logo-16x16.png | Bin 0 -> 310 bytes .../5.0/assets/img/opensearch/logo-64x64.png | Bin 0 -> 1437 bytes 3 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 site/static/docs/5.0/assets/img/opensearch/logo-16x16.png create mode 100644 site/static/docs/5.0/assets/img/opensearch/logo-64x64.png diff --git a/site/layouts/_default/list.opensearch.xml b/site/layouts/_default/list.opensearch.xml index 15258eb65..1060fbf3e 100644 --- a/site/layouts/_default/list.opensearch.xml +++ b/site/layouts/_default/list.opensearch.xml @@ -3,6 +3,7 @@ {{ .Site.Title }} Search {{ .Site.Title }} documentation UTF-8 - {{ (printf "/docs/%s/assets/img/favicons/favicon.ico" .Site.Params.docs_version) | absURL }} + {{ (printf "/docs/%s/assets/img/opensearch/logo-16x16.png" .Site.Params.docs_version) | absURL }} + {{ (printf "/docs/%s/assets/img/opensearch/logo-64x64.png" .Site.Params.docs_version) | absURL }} diff --git a/site/static/docs/5.0/assets/img/opensearch/logo-16x16.png b/site/static/docs/5.0/assets/img/opensearch/logo-16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..5f7d11880f60757cd3f1de2681def0e59e6b81b2 GIT binary patch literal 310 zcmV-60m=S}P)o&FyL z)-F6io&ouh{a^zYPu)SJ7ykbHe_;DLFh0EN!vA-#Km9*_@mqwxt0Q-6C>SJ(x z{o;fF-@pC*Kecr&sa`WK0JN?N#d`VKg1kM6ld z&;=k3p!kR5dpDo{KYjSx|M?TQ{*QKUz%YQ~q)c&UqBuJP06X(p%mL%EV*mgE07*qo IM6N<$f{ZYjO#lD@ literal 0 HcmV?d00001 diff --git a/site/static/docs/5.0/assets/img/opensearch/logo-64x64.png b/site/static/docs/5.0/assets/img/opensearch/logo-64x64.png new file mode 100644 index 0000000000000000000000000000000000000000..f72fd66d6744d59bd05aa229a8c87d2c54665fb6 GIT binary patch literal 1437 zcmV;O1!DS%P)T8nOh0>upAHQEr@IF4ExO%_>p{XM`Z3e=c!8ML<+_+w)Ndw?EE2kT$gx)c^S&d<2O4S4qA8``z0|G(}_7}xEDUddF>Qmw*UgEw(K$PCqmPUgA z)QaB4>u5&;IQv{zDI!bqVSWNBH%7w$K^W&2qw~`eZG1%%HTqT z!I^${1{fR}{DWo*;13lgAmj%tg1)yPxDu4l3j5iP2z>w%&>?gLx%4hpZ8KG0oN}1P}P!|o{d4hCW9nI88t`% zh0Da!>JK#hs*g4apj;OACiF*}c(+6O1nk^+41HSs22YpqCFpqNX*L_M3UTsSfN~Lu^y-U`d@zUV)a`Vxv z>933%0wWZrzaBq&DW?6ox_JF#6=wXk2J4pWga4NFv`=Nm4zm~r<)h&gN$G{$w@auqiSi5*HYlEOj8`sMS`p!aE7y#+;n;p4!OQj9&rNp&A z>A~tSj_yAXIr)9id|s>GP?&`9+06W;nd2>!u}2%STn1klKFCX8{-lBpI0Jz~d+ zrO;1B1W4>SaVanskdkqpIjH|dFZB|@Ei&#B`EN=_hm0Qid@T@=B$sRO`Py9q^Cxdo zF99r$*7>vtM%iaTMwn=+lK_I}W@zva7UAx0LQb3=|3#y(`zn`!C8DNR?Y%CgJ{!R3 zj=6qqu{S_B$c+^_N${s4+U%yCP%Z%*mmffjx&upfHlVZ6uF+%Q?C=k!iy8s9$cvLX z6E;ZCE+rAbt?h#R(wz<9bw!0mD2?2{kx1{r@|pIs!Su8&9-3gNOk1HX0xq1s!DYhe zPg(VV>zDngO1X7C5tGI(XZlMcsl1914OV4JhM49TMfrQJ*aaTiZz`=l4IVAN0I$GP zVz#z_!P|{Rjq>T;d&k4k{%>%7w`wpLVL#cK?{fo$z?FSavhg>4X_P9g3~HF(N}m9! zA_ATrmDM{hY5B19v*Yq?9ME*bgjQQ-;skE3Hcc^pnWEXYIpQSVry3{2bPf|63u9H@ zI7ytct+Q+`Rd4HTe_y!HR Date: Fri, 20 Nov 2020 21:00:54 +0200 Subject: [PATCH 6/6] Revert "Add OpenSearch images" --- site/layouts/_default/list.opensearch.xml | 3 +-- .../5.0/assets/img/opensearch/logo-16x16.png | Bin 310 -> 0 bytes .../5.0/assets/img/opensearch/logo-64x64.png | Bin 1437 -> 0 bytes 3 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 site/static/docs/5.0/assets/img/opensearch/logo-16x16.png delete mode 100644 site/static/docs/5.0/assets/img/opensearch/logo-64x64.png diff --git a/site/layouts/_default/list.opensearch.xml b/site/layouts/_default/list.opensearch.xml index 1060fbf3e..15258eb65 100644 --- a/site/layouts/_default/list.opensearch.xml +++ b/site/layouts/_default/list.opensearch.xml @@ -3,7 +3,6 @@ {{ .Site.Title }} Search {{ .Site.Title }} documentation UTF-8 - {{ (printf "/docs/%s/assets/img/opensearch/logo-16x16.png" .Site.Params.docs_version) | absURL }} - {{ (printf "/docs/%s/assets/img/opensearch/logo-64x64.png" .Site.Params.docs_version) | absURL }} + {{ (printf "/docs/%s/assets/img/favicons/favicon.ico" .Site.Params.docs_version) | absURL }} diff --git a/site/static/docs/5.0/assets/img/opensearch/logo-16x16.png b/site/static/docs/5.0/assets/img/opensearch/logo-16x16.png deleted file mode 100644 index 5f7d11880f60757cd3f1de2681def0e59e6b81b2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 310 zcmV-60m=S}P)o&FyL z)-F6io&ouh{a^zYPu)SJ7ykbHe_;DLFh0EN!vA-#Km9*_@mqwxt0Q-6C>SJ(x z{o;fF-@pC*Kecr&sa`WK0JN?N#d`VKg1kM6ld z&;=k3p!kR5dpDo{KYjSx|M?TQ{*QKUz%YQ~q)c&UqBuJP06X(p%mL%EV*mgE07*qo IM6N<$f{ZYjO#lD@ diff --git a/site/static/docs/5.0/assets/img/opensearch/logo-64x64.png b/site/static/docs/5.0/assets/img/opensearch/logo-64x64.png deleted file mode 100644 index f72fd66d6744d59bd05aa229a8c87d2c54665fb6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1437 zcmV;O1!DS%P)T8nOh0>upAHQEr@IF4ExO%_>p{XM`Z3e=c!8ML<+_+w)Ndw?EE2kT$gx)c^S&d<2O4S4qA8``z0|G(}_7}xEDUddF>Qmw*UgEw(K$PCqmPUgA z)QaB4>u5&;IQv{zDI!bqVSWNBH%7w$K^W&2qw~`eZG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