Skip to content

Commit 3128c63

Browse files
committed
make material/search index handling work again
1 parent aff8b86 commit 3128c63

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Install the package from source with pip:
6363
```bash
6464
cd mkdocs-encryptcontent-plugin/
6565
python setup.py sdist bdist_wheel
66-
pip install dist/mkdocs_encryptcontent_plugin-2.4.3-py3-none-any.whl
66+
pip install dist/mkdocs_encryptcontent_plugin-2.4.4-py3-none-any.whl
6767
```
6868

6969
Enable the plugin in your `mkdocs.yml`:
@@ -260,7 +260,7 @@ plugins:
260260
```
261261

262262
> **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.
263-
> 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`
263+
> 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`
264264

265265
### Encrypt something
266266

encryptcontent/plugin.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,13 @@ def on_post_page(self, output_content, page, config, **kwargs):
432432
for plugin in config['plugins']:
433433
if plugin.endswith('search'):
434434
try:
435-
search_entries = config['plugins'][plugin].search_index._entries
435+
if hasattr(config['plugins'][plugin].search_index, '_entries'):
436+
search_entries = config['plugins'][plugin].search_index._entries
437+
elif hasattr(config['plugins'][plugin].search_index, 'entries'):
438+
search_entries = config['plugins'][plugin].search_index.entries
439+
else:
440+
logger.error('The search plugin "' + plugin + '" is currently unknown!')
441+
436442
for entry in search_entries.copy(): #iterate through all entries of search_index
437443
location = page.url.lstrip('/')
438444
if entry['location'] == location or entry['location'].startswith(location+"#"): #find the ones located at encrypted pages
@@ -449,7 +455,12 @@ def on_post_page(self, output_content, page, config, **kwargs):
449455
entry['title'] = b';'.join(code).decode('ascii')
450456
code = self.__encrypt_text_aes__(toc_anchor, page.password)
451457
entry['location'] = location + ';' + b';'.join(code).decode('ascii')
452-
config['plugins'][plugin].search_index._entries = search_entries
458+
459+
if hasattr(config['plugins'][plugin].search_index, '_entries'):
460+
config['plugins'][plugin].search_index._entries = search_entries
461+
elif hasattr(config['plugins'][plugin].search_index, 'entries'):
462+
config['plugins'][plugin].search_index.entries = search_entries
463+
453464
except:
454465
logger.error('Could not encrypt search index of "' + page.title + '" for "' + plugin+ '" plugin!')
455466

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def read(fname):
1111

1212
setup(
1313
name='mkdocs-encryptcontent-plugin',
14-
version='2.4.3',
14+
version='2.4.4',
1515
author='unverbuggt',
1616
author_email='[email protected]',
1717
description='A MkDocs plugin that encrypt/decrypt markdown content with AES',

0 commit comments

Comments
 (0)