diff --git a/.gitignore b/.gitignore index 8074fdc..6f4fbe3 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ deploy.cmd documentation/encryptcontent.key documentation/canary.py documentation/theme_override/assets/ -documentation/__pycache__/ \ No newline at end of file +**/__pycache__/ diff --git a/encryptcontent/decrypt-form.tpl.html b/encryptcontent/decrypt-form.tpl.html index 354c7da..e36c5bd 100644 --- a/encryptcontent/decrypt-form.tpl.html +++ b/encryptcontent/decrypt-form.tpl.html @@ -9,7 +9,10 @@

{{ summary }}

{%- if uname %} {%- endif %} - +

+ {%- if show_password_checkbox %} +

+ {%- endif %} {%- endif %} {% if password_button %}{{ password_button_text }}{% endif %}

diff --git a/encryptcontent/plugin.py b/encryptcontent/plugin.py index d8f5caf..f8fa821 100644 --- a/encryptcontent/plugin.py +++ b/encryptcontent/plugin.py @@ -52,7 +52,9 @@ 'placeholder_user': 'User name', 'password_button_text': 'Decrypt', 'decryption_failure_message': 'Invalid password.', - 'encryption_info_message': 'Contact your administrator for access to this page.' + 'encryption_info_message': 'Contact your administrator for access to this page.', + 'show_password_checkbox': False, + 'show_password_text': 'Show password', } logger = logging.getLogger("mkdocs.plugins.encryptcontent") @@ -76,6 +78,8 @@ class encryptContentPlugin(BasePlugin): ('form_class', config_options.Type(string_types, default=None)), ('input_class', config_options.Type(string_types, default=None)), ('button_class', config_options.Type(string_types, default=None)), + ('show_password_checkbox', config_options.Type(bool, default=SETTINGS['show_password_checkbox'])), + ('show_password_text', config_options.Type(string_types, default=str(SETTINGS['show_password_text']))), # password feature ('global_password', config_options.Type(string_types, default=None)), ('remember_keys', config_options.Type(bool, default=True)), @@ -339,6 +343,8 @@ def __encrypt_content__(self, content, base_path, encryptcontent_path, encryptco 'password_button_text': encryptcontent['password_button_text'], 'encryption_info_message': encryptcontent['encryption_info_message'], 'decryption_failure_message': json.dumps(encryptcontent['decryption_failure_message']), + 'show_password_checkbox': self.config['show_password_checkbox'], + 'show_password_text': encryptcontent['show_password_text'], 'form_class': self.config['form_class'], 'input_class': self.config['input_class'], 'button_class': self.config['button_class'], @@ -990,6 +996,8 @@ def on_page_context(self, context, page, config, **kwargs): page.encryptcontent['decryption_failure_message'] = translations['decryption_failure_message'] if 'encryption_info_message' in translations and 'encryption_info_message' not in page.encryptcontent: page.encryptcontent['encryption_info_message'] = translations['encryption_info_message'] + if 'show_password_text' in translations and 'show_password_text' not in page.encryptcontent: + page.encryptcontent['show_password_text'] = translations['show_password_text'] #init default strings from config if 'title_prefix' not in page.encryptcontent: @@ -1006,6 +1014,8 @@ def on_page_context(self, context, page, config, **kwargs): page.encryptcontent['decryption_failure_message'] = self.config['decryption_failure_message'] if 'encryption_info_message' not in page.encryptcontent: page.encryptcontent['encryption_info_message'] = self.config['encryption_info_message'] + if 'show_password_text' not in page.encryptcontent: + page.encryptcontent['show_password_text'] = self.config['show_password_text'] if page.encryptcontent['title_prefix']: page.title = str(self.config['title_prefix']) + str(page.title)