Skip to content

Commit 8c42db4

Browse files
committed
update readme
1 parent bba34eb commit 8c42db4

File tree

1 file changed

+83
-46
lines changed

1 file changed

+83
-46
lines changed

README.md

Lines changed: 83 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,24 @@ The content is encrypted with AES-256 in Python using PyCryptodome, and decrypte
4040
* [Installation](#installation)
4141
* [Usage](#usage)
4242
* [Global password protection](#global-password-protection)
43-
* [Secret from environment](#secret-from-environment) **(UPDATE)**
43+
* [Secret from environment](#secret-from-environment)
4444
* [Customization](#default-vars-customization)
45+
* [Translations](#translations)
46+
* [Obfuscate pages](#obfuscate-pages)
4547
* [Features](#features)
4648
* [HighlightJS support](#highlightjs-support) *(default)*
4749
* [Arithmatex support](#arithmatex-support) *(default)*
4850
* [Mermaid2 support](#mermaid-support) *(default)*
4951
* [Tag encrypted page](#tag-encrypted-page) *(default)*
5052
* [Remember password](#remember-password)
5153
* [Encrypt something](#encrypt-something)
52-
* [Inject decrypt-form.tpl to theme](#inject-decrypt-formtpl-to-theme) **(NEW)**
54+
* [Inject decrypt-form.tpl to theme](#inject-decrypt-formtpl-to-theme)
5355
* [Search index encryption](#search-index-encryption)
54-
* [Search index encryption for mkdocs-material](#search-index-encryption-for-mkdocs-material) **(NEW)**
56+
* [Search index encryption for mkdocs-material](#search-index-encryption-for-mkdocs-material)
5557
* [Override default templates](#override-default-templates)
5658
* [Add button](#add-button)
5759
* [Reload scripts](#reload-scripts)
58-
* [Self-host crypto-js](#self-host-crypto-js) **(NEW)**
59-
* [Translations](#translations) **(NEW)**
60+
* [Self-host crypto-js](#self-host-crypto-js)
6061
* [Contributing](#contributing)
6162

6263

@@ -103,7 +104,8 @@ plugins:
103104

104105
If a password is defined in an article, it will **ALWAYS** overwrite the global password.
105106

106-
> **NOTE** Keep in mind that if the `password:` tag exists without value in an article, it will **not be protected** !
107+
> **NOTE** Keep in mind that if the `password:` tag exists without value in a page, it will **not be protected** !
108+
> Use this to **disable** `global_password` on specific pages.
107109

108110

109111
### Secret from environment
@@ -128,7 +130,7 @@ plugins:
128130
> However this can be converted into a warning by setting `ignore_missing_secret: true`.
129131
> Use this only if you use a secret environment variable for production and a plain password for testing. You have been warned.
130132

131-
> **NEW** The meta tag `use_secret` can also be set to achieve the same functionality on page level.
133+
> The meta tag `use_secret` can also be set to achieve the same functionality on page level.
132134

133135
### Default vars customization
134136

@@ -140,8 +142,8 @@ plugins:
140142
title_prefix: '[LOCK]'
141143
summary: 'another informational message to encrypted content'
142144
placeholder: 'another password placeholder'
143-
decryption_failure_message: 'another informational message when decryption fail'
144-
encryption_info_message: 'another information message when you dont have acess !'
145+
decryption_failure_message: 'another informational message when decryption fails'
146+
encryption_info_message: "another information message when you don't have access !"
145147
input_class: 'md-search__form md-search__input'
146148
button_class: 'md-search__icon'
147149
```
@@ -158,7 +160,38 @@ Defaut encryption information message is `Contact your administrator for access
158160

159161
> **NOTE** Adding a prefix to the title does not change the default navigation path !
160162

161-
Use `input_class` and `button_class` to optionally set a CSS class for the password field and the button.
163+
### Translations
164+
165+
If the plugin is used in conjunction with the [static-i18n](https://ultrabug.github.io/mkdocs-static-i18n/) plugin you can provide `translations` for the used `i18n_page_file_locale`.
166+
167+
```yaml
168+
- encryptcontent:
169+
#...
170+
translations:
171+
de:
172+
title_prefix: '[Verschlüsselt] '
173+
summary: 'Der Inhalt dieser Seite ist mit AES verschlüsselt. '
174+
placeholder: 'Mit Strg+Enter wird das Passwort global gesetzt'
175+
password_button_text: 'Entschlüsseln'
176+
decryption_failure_message: 'Falsches passwort.'
177+
encryption_info_message: 'Bitte wenden Sie sich an den Systemadministrator um auf diese Seite zuzugreifen.'
178+
```
179+
180+
#### Custom per-page strings
181+
182+
You can set the meta tag `encryption_summary` to customize `summary` and `encryption_info_message` on every page.
183+
184+
### Obfuscate pages
185+
186+
If you want to make it harder for search engines to scrape you pages content,
187+
you can set `obfuscate: SomeNotSoSecretPassword` meta tag in markdown.
188+
189+
The page than will display `summary` and `encryption_info_message` together with a button labeled with.
190+
`password_button_text`. In order to view the pages content one hast to press the button first.
191+
192+
If a `password` or `use_secret` is set, then the `obfuscate` feature will be disabled.
193+
If you want to use `obfuscate` in a configuration where `global_password` is defined,
194+
you'll need to set `password:` meta tag (with no password defined) to undefine the password on this page.
162195

163196
# Features
164197

@@ -258,7 +291,8 @@ the page will be automatically decrypted using the value previously created.
258291
By default, the key is created with a name relative to the page on which it was generated.
259292
This 'relative' key will always be used as first attempt to decrypt the current page when loading.
260293

261-
If your password is a [global password](#global-password-protection), you can fill in the form field `mkdocs-content-password`, then use the keyboard shortcut `CTRL + ENTER` instead of the classic `ENTER`.
294+
If your password is a [global password](#global-password-protection), you can fill in the form
295+
field `mkdocs-content-password`, then use the keyboard shortcut `CTRL + ENTER` instead of the classic `ENTER`.
262296
The key that will be created with a generic name to making it accessible, by default, on all the pages of your site.
263297

264298
The form of decryption remains visible as long as the content has not been successfully decrypted, which allows in case of error to retry.
@@ -272,15 +306,16 @@ plugins:
272306
default_expire_delay: 24 # <-- Default expire delay in hours (optional)
273307
```
274308

275-
> **NOTE** The expired elements of the localStorage are only deleted by the execution of the decrypt-content.js scripts and therefore by the navigation on the site. Secret items can therefore remain visible in local storage after their expiration dates.
276-
> Now The default is to use sessionStorage instead of localStorage, so the browser forgets the password after the current tab was closed. However it can be set to use localStorage by setting `session_storage: False`
309+
> **NOTE** The expired elements of the localStorage are only deleted by the execution of the decrypt-content.js
310+
> scripts and therefore by the navigation on the site. Secret items can therefore remain visible in local storage
311+
> after their expiration dates.
312+
> Now The default is to use sessionStorage instead of localStorage, so the browser forgets the password after
313+
> the current tab was closed. However it can be set to use localStorage by setting `session_storage: False`
277314

278315
### Encrypt something
279316

280317
Related to [issue #9](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin/issues/9)
281318

282-
The [tag encrypted page feature](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin#tag-encrypted-page) **MUST** be enabled (it's default) for this feature to work properly.
283-
284319
Add `encrypted_something: {}` in the plugin configuration variable, to encrypt something else.
285320

286321
The syntax of this new variable **MUST** follow the yaml format of a dictionary.
@@ -332,7 +367,7 @@ plugins:
332367
mkdocs-encrypted-toc: [div, id]
333368
```
334369

335-
2. Other example, with multiples target. In you Material Theme, you want to encrypt ToC content and Footer.
370+
2. Other example, with multiples target. In your custom Material theme, you want to encrypt ToC content and Footer.
336371

337372
Materiel generate 2 `<nav>` structure with the same template `toc.html`, so you need to use a `class` instead of an id for this part.
338373
The footer part, is generated by the `footer.html` template in a classic div so an `id` is sufficient
@@ -351,7 +386,7 @@ After modification, your template looks like this :
351386
</footer>
352387
```
353388

354-
Your configuration like this :
389+
Your configuration would look like this :
355390
```yaml
356391
plugins:
357392
- encryptcontent:
@@ -361,7 +396,8 @@ plugins:
361396
mkdocs-encrypted-footer-meta: [div, id]
362397
```
363398

364-
3. If you are using mkdocs-material, then this example will also encrypt menu, toc and footer
399+
3. If you are using unmodified mkdocs-material, then this example will encrypt menu, toc and footer
400+
But you'd need the Navigation pruning feature to hide the title of encrypted pages from navigation (or see 2.).
365401

366402
```yaml
367403
plugins:
@@ -396,6 +432,8 @@ plugins:
396432
md-content: [div, class]
397433
```
398434

435+
> This feature overrides the normal practice of replacing the rendered content of a page.
436+
399437
### Search index encryption
400438

401439
> **Default value is "encrypted"**
@@ -413,7 +451,7 @@ Three configuration modes are possible:
413451

414452
* **clear** : Search index is not encrypted. Search is possible even on protected pages.
415453
* **dynamically** : Search index is encrypted on build. Search is possible once the pages have been decrypted.
416-
* **encrypted** : Search index of encrypted pages is removed on build. Search is not possible on all encrypted pages.
454+
* **encrypted** : Search index of encrypted pages is removed on build. Search is not possible on encrypted pages.
417455

418456
You can set `search_index: '<mode_name>'` in your `mkdocs.yml` to change the search index encryption mode. Possible values are `clear`, `dynamically`, `encrypted`. The default mode is "**encrypted**".
419457

@@ -424,22 +462,28 @@ plugins:
424462
```
425463

426464
This functionality modifies the search index created by the “search” plug-in.
427-
Some themes might override the default “search” plug-in provided by mkdocs, but so far the structure of the `search/search_index.json` file is consistent.
465+
Some themes might override the default search plug-in provided by mkdocs,
466+
but so far the structure of the `search/search_index.json` file is consistent.
428467

429468
> The modification of the search index is carried out last (if `encryptcontent` is also last in `plugins`).
430469
> But always double-check the generated index after `mkdocs build` to see if your information is protected.
431470

432-
When the configuration mode is set to "**dynamically**", the [javascripts contribution files](https://github.com/unverbuggt/mkdocs-encryptcontent-plugin/tree/master/encryptcontent/contrib/templates/search)
433-
are used to override the default search plugin files provided by MkDocs. They include a process of decrypting and keeping the search index in a SessionStorage.
471+
When the configuration mode is set to "**dynamically**", the
472+
[javascripts contribution files](https://github.com/unverbuggt/mkdocs-encryptcontent-plugin/tree/master/encryptcontent/contrib/templates/search)
473+
are used to override the default search plugin files provided by MkDocs.
474+
They include a process of decrypting and keeping the search index in a SessionStorage.
434475

435476
### Search index encryption for mkdocs-material
436477

437-
[Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) uses a different search plugin that cannot "easily" be overridden like the default search plugin.
438-
However this Plugin will still remove encrypted pages (`encrypted`) or encrypt the search entries (`dynamically`) for `mkdocs-material`.
478+
[Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) uses a different search plugin that
479+
cannot "easily" be overridden like the default search plugin.
480+
However this Plugin will still remove encrypted pages (`encrypted`) or encrypt the search entries (`dynamically`)
481+
for `mkdocs-material`.
439482

440483
In order to be able to decrypt the search index (`dynamically`) `mkdocs-material` needs to be customized (patched).
441484

442-
You'll need some [prerequisites](https://squidfunk.github.io/mkdocs-material/customization/#environment-setup) and also execute these commands:
485+
You'll need some [prerequisites](https://squidfunk.github.io/mkdocs-material/customization/#environment-setup)
486+
and also execute these commands:
443487

444488
```bash
445489
git clone https://github.com/squidfunk/mkdocs-material
@@ -461,16 +505,25 @@ pip install --force-reinstall .
461505

462506
Related to [issue #32](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin/issues/32)
463507

464-
You can override the default templates with your own templates by providing an actual replacement path in the `html_template_path` *(HTML)* and `js_template_path` *(JS)* directives. Overridden templates **completely** replace the default templates. You **must** therefore copy the default templates to keep this module working.
508+
You can override the default templates with your own templates by providing an actual replacement
509+
path in the `html_template_path` *(HTML)* and `js_template_path` *(JS)* directives.
510+
Overridden templates **completely** replace the default templates. You **must** therefore copy the
511+
default templates to keep this module working.
465512

466513
```yaml
467514
plugins:
468515
- encryptcontent:
469516
html_template_path: "/root/real/path/mkdocs_poc/my_html_template.html"
470517
js_template_path: "/root/real/path/mkdocs_poc/my_js_template.js"
518+
input_class: 'md-search__form md-search__input'
519+
button_class: 'md-search__icon'
471520
```
472521

473-
When you overriding the default templates, you can add and use your own Jinja variables to condition and enrich your template, by defining `html_extra_vars` and `js_extra_vars` directives in key/value format. Added values can be used in your Jinja templates via the variable `extra`.
522+
Use `input_class` and `button_class` to optionally set a CSS class for the password input field and the button.
523+
524+
When you overriding the default templates, you can add and use your own Jinja variables to condition
525+
and enrich your template, by defining `html_extra_vars` and `js_extra_vars` directives in key/value format.
526+
Added values can be used in your Jinja templates via the variable `extra`.
474527

475528
```yaml
476529
plugins:
@@ -491,7 +544,9 @@ For example, you can modify your HTML template, to add a new title with your own
491544
[ ... ]
492545
```
493546

494-
> **NOTE** You must avoid replacing/overwriting the variables used by default by this module. The limitations are the same as those of the jinja models. Issues related to template override will not be addressed.
547+
> **NOTE** You must avoid replacing/overwriting the variables used by default by this module.
548+
> The limitations are the same as those of the jinja models.
549+
> Issues related to template override will not be addressed.
495550

496551
### Add button
497552

@@ -540,24 +595,6 @@ plugins:
540595
selfhost_download: false
541596
```
542597

543-
### Translations
544-
545-
If the plugin is used in conjunction with the [static-i18n](https://ultrabug.github.io/mkdocs-static-i18n/) plugin you can provide `translations` for the used `i18n_page_file_locale`.
546-
547-
```yaml
548-
- encryptcontent:
549-
#...
550-
translations:
551-
de:
552-
title_prefix: '[Verschlüsselt] '
553-
summary: 'Der Inhalt dieser Seite ist mit AES verschlüsselt. '
554-
placeholder: 'Mit Strg+Enter wird das Passwort global gesetzt'
555-
password_button_text: 'Entschlüsseln'
556-
decryption_failure_message: 'Falsches passwort.'
557-
encryption_info_message: 'Bitte wenden Sie sich an den Systemadministrator um auf diese Seite zuzugreifen.'
558-
```
559-
560-
561598
# Contributing
562599

563600
From reporting a bug to submitting a pull request: every contribution is appreciated and welcome.

0 commit comments

Comments
 (0)