Skip to content

Commit 1f8fe6a

Browse files
committed
add default css classes for material theme
1 parent 0561454 commit 1f8fe6a

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

encryptcontent/decrypt-contents.tpl.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,9 @@ async function digestSHA256toBase64(message) {
450450
var username_input = document.getElementById('mkdocs-content-user');
451451
var password_input = document.getElementById('mkdocs-content-password');
452452
// adjust password field width to placeholder length
453-
if (password_input.hasAttribute('placeholder')) {
454-
password_input.setAttribute('size', password_input.getAttribute('placeholder').length);
455-
}
453+
//if (password_input.hasAttribute('placeholder')) {
454+
// password_input.setAttribute('size', password_input.getAttribute('placeholder').length);
455+
//}
456456
var encrypted_content = document.getElementById('mkdocs-encrypted-content');
457457
var decrypted_content = document.getElementById('mkdocs-decrypted-content');
458458
let content_decrypted;

encryptcontent/decrypt-form.tpl.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div id="mkdocs-encrypted-content" style="display:none">{{ ciphertext_bundle }}</div>
22
<div id="mkdocs-decrypted-content">
3-
<form id="mkdocs-decrypt-form">
3+
<form id="mkdocs-decrypt-form"{% if form_class %} class="{{ form_class }}"{% endif %}>
44
<h1>{{ summary }}</h1>
55
{% if encryption_info_message %}<p>{{ encryption_info_message }}</p>{% endif %}
66
{%- if obfuscate %}
@@ -22,8 +22,8 @@ <h1>{{ summary }}</h1>
2222
var decryption_failure_message = {{ decryption_failure_message }};
2323
var encryptcontent_keystore = {{ encryptcontent_keystore }};
2424
var encryptcontent_obfuscate = {{ obfuscate }};
25-
{%- if inject_something %}var inject_something = {{ inject_something }};{% endif %}
26-
{%- if delete_something %}var delete_something = "{{ delete_something }}";{% endif %}
25+
{% if inject_something %}var inject_something = {{ inject_something }};{% endif -%}
26+
{% if delete_something %}var delete_something = "{{ delete_something }}";{%- endif %}
2727
</script>
2828
{% for library in js_libraries %}
2929
<script type="text/javascript" src="{{ library }}"></script>

encryptcontent/plugin.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class encryptContentPlugin(BasePlugin):
6767
('encryption_info_message', config_options.Type(string_types, default=str(SETTINGS['encryption_info_message']))),
6868
('password_button_text', config_options.Type(string_types, default=str(SETTINGS['password_button_text']))),
6969
('password_button', config_options.Type(bool, default=False)),
70+
('form_class', config_options.Type(string_types, default=None)),
7071
('input_class', config_options.Type(string_types, default=None)),
7172
('button_class', config_options.Type(string_types, default=None)),
7273
# password feature
@@ -271,6 +272,7 @@ def __encrypt_content__(self, content, base_path, encryptcontent_path, encryptco
271272
'password_button_text': encryptcontent['password_button_text'],
272273
'encryption_info_message': encryptcontent['encryption_info_message'],
273274
'decryption_failure_message': json.dumps(encryptcontent['decryption_failure_message']),
275+
'form_class': self.config['form_class'],
274276
'input_class': self.config['input_class'],
275277
'button_class': self.config['button_class'],
276278
'uname': uname,
@@ -436,7 +438,16 @@ def on_config(self, config, **kwargs):
436438
# Enable experimental code .. :popcorn:
437439
if self.config['search_index'] == 'dynamically':
438440
logger.info("EXPERIMENTAL search index encryption enabled.")
439-
441+
442+
# set default classes in html template
443+
if config['theme'].name == 'material':
444+
if not self.config['form_class']:
445+
self.config['form_class'] = 'md-content__inner md-typeset'
446+
if not self.config['input_class']:
447+
self.config['input_class'] = 'md-input'
448+
if not self.config['button_class']:
449+
self.config['button_class'] = 'md-button md-button--primary'
450+
440451
# Get path to site in case of subdir in site_url
441452
self.setup['site_path'] = urlsplit(config.data["site_url"] or '/').path[1::]
442453

0 commit comments

Comments
 (0)