Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ deploy.cmd
documentation/encryptcontent.key
documentation/canary.py
documentation/theme_override/assets/
documentation/__pycache__/
**/__pycache__/
5 changes: 4 additions & 1 deletion encryptcontent/decrypt-form.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ <h1>{{ summary }}</h1>
{%- if uname %}
<input{% if input_class %} class="{{ input_class }}"{% endif %} type="text" id="mkdocs-content-user" placeholder="{{ placeholder_user }}">
{%- endif %}
<input{% if input_class %} class="{{ input_class }}"{% endif %} type="password" id="mkdocs-content-password" placeholder="{{ placeholder }}">
<p><input{% if input_class %} class="{{ input_class }}"{% endif %} type="password" id="mkdocs-content-password" placeholder="{{ placeholder }}"></p>
{%- if show_password_checkbox %}
<p><input type="checkbox" id="mkdocs-content-show-password" onchange="document.getElementById('mkdocs-content-password').type = this.checked ? 'text' : 'password';"><label for="mkdocs-content-show-password">{{ show_password_text }}</label></p>
{%- endif %}
{%- endif %}
{% if password_button %}<button{% if button_class %} class="{{ button_class }}"{% endif %} id="mkdocs-decrypt-button">{{ password_button_text }}</button>{% endif %}
<p id="mkdocs-decrypt-msg"></p>
Expand Down
12 changes: 11 additions & 1 deletion encryptcontent/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)),
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down