Skip to content

Documentation for Themis, Acra, Hermes, Toughbase

License

Notifications You must be signed in to change notification settings

cossacklabs/product-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

product-docs

Documentation for Themis, Acra, Hermes, Toughbase

License

Documentation content itself is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International license. Source code snippets and examples are licensed under the Apache License, Version 2.0.

Howto add product scoped search

<scope_name> - scope name placeholder

  • Go to assets dir: themes/book/assets/

  • Create new file search-<scope_name>.js:

'use strict';

{{ $searchDataFile := printf "%s.search-<scope_name>-data.js" .Language.Lang }}
{{ $searchData := resources.Get "search-<scope_name>-data.js" | resources.ExecuteAsTemplate $searchDataFile . | resources.Minify | resources.Fingerprint }}

{{ partial "js/search.js" (dict "searchData" $searchData) | safeJS }}
  • Create new file search-<scope_name>-data.js:
'use strict';

(function() {
  const indexCfg = {{ with i18n "bookSearchConfig" }}
    {{ . }};
  {{ else }}
   {};
  {{ end }}

  indexCfg.doc = {
    id: 'id',
    field: ['title', 'content'],
    store: ['title', 'href'],
  };

  const index = FlexSearch.create('balance', indexCfg);
  window.bookSearchIndex = index;

  {{ range $index, $page := where .Site.Pages "Kind" "in" (slice "page" "section") }}
  {{ if eq $page.FirstSection.Params.searchScope "<scope_name>"}}
  index.add({
    'id': {{ $index }},
    'href': '{{ $page.RelPermalink }}',
    'title': {{ (partial "docs/title" $page) | jsonify }},
    'content': {{ $page.Plain | jsonify }}
  });
  {{ end }}
  {{- end -}}
})();
  • Add searchScope parameter in product-docs repository, filepath content/<product_name>/_index.md:
---
searchScope: "<scope_name>"
---

CSP nonce attribute for script, link, style tags.

For all script, link, style tags added nonce attribute with a random value of 16 characters generated by sha256sum. Generation code $ echo "nonce=\"$(dd if=/dev/urandom bs=16 count=4 2>/dev/null | sha256sum | head -c 16)\""

run in terminal

How to work with it:

If the body of the script or link changes, then we do nothing.

If a new tag is added from the above, you need to generate a value for the nonce attribute and report it to the admins.

If the value of the nonce attribute changes, in this case we also inform the admins.

See T2468.