Skip to content

Commit 2f5017f

Browse files
committed
Version 2.0.1
1 parent 4abe4e6 commit 2f5017f

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Install the package from source with pip:
5050
```bash
5151
cd mkdocs-encryptcontent-plugin/
5252
python3 setup.py sdist bdist_wheel
53-
pip3 install dist/mkdocs_encryptcontent_plugin-2.0.0.1-py3-none-any.whl
53+
pip3 install dist/mkdocs_encryptcontent_plugin-2.0.1-py3-none-any.whl
5454
```
5555

5656
Enable the plugin in your `mkdocs.yml`:

encryptcontent/decrypt-form.tpl.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ <h1>{{ summary }}</h1>
1212
{% for library in js_libraries %}
1313
<script type="text/javascript" src="{{ library }}"></script>
1414
{% endfor %}
15-
<script type="text/javascript" src="/assets/javascripts/decrypt-contents.js" defer></script>
15+
<script type="text/javascript" src="{{ base_path }}assets/javascripts/decrypt-contents.js" defer></script>

encryptcontent/plugin.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ class encryptContentPlugin(BasePlugin):
7373
('experimental', config_options.Type(bool, default=False)),
7474
# legacy features, doesn't exist anymore
7575
('disable_cookie_protection', config_options.Type(bool, default=False)),
76-
('decrypt_search', config_options.Type(bool, default=False)),
77-
76+
('decrypt_search', config_options.Type(bool, default=False))
7877
)
7978

8079
def __hash_md5__(self, text):
@@ -100,7 +99,7 @@ def __encrypt_text_aes__(self, text, password):
10099
PADDING_CHAR
101100
)
102101

103-
def __encrypt_content__(self, content):
102+
def __encrypt_content__(self, content, base_path):
104103
""" Replaces page or article content with decrypt form. """
105104
ciphertext_bundle = self.__encrypt_text_aes__(content, str(self.config['password']))
106105
decrypt_form = Template(DECRYPT_FORM_TPL).render({
@@ -114,6 +113,7 @@ def __encrypt_content__(self, content):
114113
# otherwise the output string will be wrapped with b''
115114
'ciphertext_bundle': b';'.join(ciphertext_bundle).decode('ascii'),
116115
'js_libraries': JS_LIBRARIES,
116+
'base_path': base_path
117117
})
118118
return decrypt_form
119119

@@ -130,7 +130,7 @@ def __generate_decrypt_js__(self):
130130
'default_expire_dalay': int(self.config['default_expire_dalay']),
131131
'encrypted_something': self.config['encrypted_something'],
132132
'reload_scripts': self.config['reload_scripts'],
133-
'experimental': self.config['experimental'],
133+
'experimental': self.config['experimental']
134134
})
135135
return decrypt_js
136136

@@ -233,7 +233,7 @@ def _add_entry_from_context(self, page):
233233
config['extra_javascript'].append('search/main.js')
234234
except Exception as exp:
235235
logger.exception(exp)
236-
236+
237237
def on_page_markdown(self, markdown, page, config, **kwargs):
238238
"""
239239
The page_markdown event is called after the page's markdown is loaded from file and
@@ -275,10 +275,12 @@ def on_page_content(self, html, page, config, **kwargs):
275275
if self.config['tag_encrypted_page']:
276276
# Set attribute on page to identify encrypted page on template rendering
277277
setattr(page, 'encrypted', True)
278+
# Create relative path in case of subdir in site_url
279+
base_path = page.abs_url.replace(page.url,'')
278280
# Set password attributes on page for other mkdocs events
279281
setattr(page, 'password', str(self.config['password']))
280282
# Keep encrypted html as temporary variable on page cause we need clear html for search plugin
281-
setattr(page, 'html_encrypted', self.__encrypt_content__(html))
283+
setattr(page, 'html_encrypted', self.__encrypt_content__(html, base_path))
282284
return html
283285

284286
def on_page_context(self, context, page, config, **kwargs):
@@ -360,4 +362,4 @@ def on_post_build(self, config, **kwargs):
360362
decrypt_js_path = Path(config.data["site_dir"] + '/assets/javascripts/decrypt-contents.js')
361363
with open(decrypt_js_path, "w") as f:
362364
f.write(self.__generate_decrypt_js__())
363-
config['extra_javascript'].append("/assets/javascripts/decrypt-contents.js")
365+

setup.py

Lines changed: 2 additions & 2 deletions
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.0.0',
14+
version='2.0.1',
1515
author='CoinK0in',
1616
author_email='[email protected]',
1717
description='A MkDocs plugin that encrypt/decrypt markdown content with AES',
@@ -28,7 +28,7 @@ def read(fname):
2828
'beautifulsoup4',
2929
],
3030
classifiers=[
31-
'Development Status :: 3 - Alpha',
31+
'Development Status :: 5 - Production/Stable',
3232
'Intended Audience :: Developers',
3333
'Intended Audience :: Information Technology',
3434
'License :: OSI Approved :: MIT License',

0 commit comments

Comments
 (0)