Skip to content

Commit bcadec1

Browse files
committed
fix missing base_url variable in material theme
1 parent e82a356 commit bcadec1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

encryptcontent/decrypt-contents.tpl.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,11 @@ function base64url_decode(input) {
568568
});
569569
}
570570

571+
{%- if material %}
572+
if (typeof base_url === 'undefined') {
573+
var base_url = JSON.parse(document.getElementById('__config').textContent).base;
574+
}
575+
{%- endif %}
571576
{%- if webcrypto %}
572577
document.addEventListener('DOMContentLoaded', () => init_decryptor());
573578
{%- else %}

encryptcontent/plugin.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ def __generate_decrypt_js__(self):
340340
'webcrypto' : self.config['webcrypto'],
341341
'remember_prefix': quote(self.config['remember_prefix'], safe='~()*!\''),
342342
'sharelinks' : self.config['sharelinks'],
343+
'material' : self.setup['theme'] == 'material',
343344
# add extra vars
344345
'extra': self.config['js_extra_vars']
345346
})
@@ -400,6 +401,8 @@ def on_config(self, config, **kwargs):
400401
"""
401402
self.setup['config_path'] = Path(config['config_file_path']).parent
402403

404+
self.setup['theme'] = config['theme'].name
405+
403406
# set default templates or override relative to mkdocs.yml
404407
if not self.config['html_template_path']:
405408
html_template_path = PLUGIN_DIR.joinpath('decrypt-form.tpl.html')
@@ -473,7 +476,7 @@ def on_config(self, config, **kwargs):
473476
logger.info("EXPERIMENTAL search index encryption enabled.")
474477

475478
# set default classes in html template
476-
if config['theme'].name == 'material':
479+
if self.setup['theme'] == 'material':
477480
if not self.config['form_class']:
478481
self.config['form_class'] = 'md-content__inner md-typeset'
479482
if not self.config['input_class']:
@@ -619,7 +622,7 @@ def on_pre_build(self, config, **kwargs):
619622
try:
620623
#search_index encryption was moved to on_post_page
621624
if self.config['search_index'] == 'dynamically':
622-
if config['theme'].name == 'material':
625+
if self.setup['theme'] == 'material':
623626
logger.warning("To enable EXPERIMENTAL search index decryption mkdocs-material needs to be customized (patched)!")
624627
else:
625628
# Overwrite search/*.js files from templates/search with encryptcontent contrib search assets
@@ -1086,7 +1089,6 @@ def on_post_build(self, config, **kwargs):
10861089
with open(self.setup['sharelinks_output'], 'w') as stream:
10871090
stream.write('\n'.join(sharelinks))
10881091

1089-
10901092
if self.config['sign_files']:
10911093
signatures = {}
10921094
urls_to_verify = []

0 commit comments

Comments
 (0)