Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for encryption #125

Open
weyCC81 opened this issue Nov 12, 2024 · 2 comments
Open

Add support for encryption #125

weyCC81 opened this issue Nov 12, 2024 · 2 comments

Comments

@weyCC81
Copy link

weyCC81 commented Nov 12, 2024

Idea to add support for encryption

Plugin: encryptcontent
Link: https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/

@weyCC81
Copy link
Author

weyCC81 commented Nov 12, 2024

Workaround for Request 1

plugins:   
- encryptcontent:
    encrypted_something:
      encrypted_something:
        #md-nav: [nav, class]              # Hide's Toc
        #md-tabs__link: [a, class]        # Hide's Menü (Alternative)
        #md-tabs: [nav, class]             # Hide's Menü
        #md-footer__inner: [nav, class]    # Hide's footer
        md-content__button: [a, class]    # Hide's print button

@CoinK0in
Copy link

CoinK0in commented Nov 17, 2024

Related to issue opened here.

Since the print-site plugin absolutely wants to be the last plugin executed (cf: line 75 here) you must exclude the pages so that they are not visible as @unverbuggt said here.

However, it is possible for this print-site plugin to perform custom actions on its side to specifically manage the EncryptContent plugin, since all encrypted pages are identified / identifiable by the other plugins.

For example, a way to automatically exclude all encrypted pages from print rendering (content & table of contents):

--- renderer.py 2024-11-17 12:40:00.430187474 +0100
+++ renderer_patched.py  2024-11-17 12:41:00.962667228 +0100
@@ -81,6 +81,11 @@
 
             for item in items:
                 if item.is_page:
+                    # Auto exclude protected pages from rendering (EncryptContent plugin)
+                    if hasattr(item, 'encrypted'):
+                        if item.encrypted == True:
+                            self.plugin_config.get("exclude", []).append(item.file.src_path)
+
                     # Do not include page in print page if excluded
                     if exclude(item.file.src_path, excluded_pages):
                         logging.debug(f"Excluding page '{item.file.src_path}'")

I hope this helps you.

PS: The encrypted content of a page generated by encryptcontent plugin, is available in page.content (instead of page.html) in case you want to go further in compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants