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

Show unencrypted content in mkdocs serve #76

Open
joapuiib opened this issue Oct 23, 2024 · 8 comments
Open

Show unencrypted content in mkdocs serve #76

joapuiib opened this issue Oct 23, 2024 · 8 comments

Comments

@joapuiib
Copy link
Contributor

I think a enhancement to editors using this plugin would be to be able to see the page content directly without entering a password while serving the site with mkdocs serve.

@unverbuggt
Copy link
Owner

unverbuggt commented Oct 23, 2024

You can set remember_password: true. This way the user only need to enter his credentials once in a serve session. Initially we had the option to save credentials to local storage, but local storage can be read from anyone who got access to the browser, which is not really secure.

Other way would be to make a copy of the "mkdocs.yml" and disable the plugin in there completely and then run mkdocs serve -f test_mkdocs.yml

@joapuiib
Copy link
Contributor Author

joapuiib commented Oct 23, 2024

Yeah. I've thought of remember_password: true, but I don't want to accidentally enable this feature on production.

At the moment, I am just commenting the password in the page.meta section. Again, there's a risk I forget to set it back.

I'd like to be able to see the content in development mode without changing the configuration.

I've thought of:

  • Check if we are building/serving the site (on_startup) and save it.
  • If we are serving, append the unencrypted content in the template.

I will implement this on my fork, but if you think this is useful to more users, maybe we can discuss how do you want to approach this.

@unverbuggt
Copy link
Owner

I think when a user does mkdocs serve he wants to have the same result as mkdocs build but with automatic rebuild on change.
That is not 100% accurate, as mkdocs injects some javascript to make the browser auto-reload on change, but nevertheless I wouldn't override the plugin.

If you use two different versions "mkdocs.yml", then you can easily separate development from production.

@joapuiib
Copy link
Contributor Author

I get your point. But, if you're mantaining multiple projects, having different mkdocs would increase the efforts considerably.

In that sense, a option show_on_serve (or something similar) could be added (defaulting to False) that would allow rendering the page without a password.

@joapuiib
Copy link
Contributor Author

joapuiib commented Oct 23, 2024

I got a prototype going in https://github.com/joapuiib/mkdocs-encryptcontent-plugin/tree/feature/show-serving.

The changes are specified here: joapuiib@0b43fb2

@unverbuggt
Copy link
Owner

I'd rather concentrate on slimming down the plugin of features most people won't need. It is as complex as it is because it grew in features over a long time.

Another idea would be to use environment variables to enable/disable the plugin ompletely if needed. We just need to add a switch in the plugin configuration.

@joapuiib
Copy link
Contributor Author

Do you want me to try to implement this toggle?

@unverbuggt
Copy link
Owner

unverbuggt commented Oct 29, 2024

I found an issue on the mkdocstrings plugin where someone had a similar suggestion. It lead to some changes which were also discussed in the markdown-exec plugin. And there I found the information that this functionality is already implemented since mkdocs 1.6.

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