unverbuggt / mkdocs-encryptcontent-plugin

A MkDocs plugin that encrypt/decrypt markdown content with AES
https://unverbuggt.github.io/mkdocs-encryptcontent-plugin/
MIT License
123 stars 15 forks source link

Stop working in production #40

Closed damienmasson closed 1 year ago

damienmasson commented 1 year ago

Hi, everything worked fine until I made a recent update of my website. It still work when testing with mkdocs serve, but does not work on generated site after a mkdocs build.

Does not work means that the page keep continue to ask the password instead of decrypt the content.

I set up a very simple empty new project to expose the issue. The result is here : http://igm.univ-mlv.fr/~masson/site/

The mkdocs.yml file:

# yaml-language-server: $schema=https://squidfunk.github.io/mkdocs-material/schema.json

site_name: My Docs
theme:
  name: material

nav:
  - index.md
  - protected.md

plugins:
  - search: {}
  - encryptcontent: {}

and the content of the file protected.md:

---
password: pwd
---

this page is protected!

My mkdocs version: mkdocs, version 1.4.2 from /home/dm/.local/lib/python3.10/site-packages/mkdocs (Python 3.10)

Any ideas ?

unverbuggt commented 1 year ago

Hi,

the current release (2.3.1) will fail to build in combination with mkdocs 1.4 (if search_index is "clear"), because they changed the class of "PluginCollection". Error Message: AttributeError: 'PluginCollection' object has no attribute 'move_to_end'

This patch silences the error and simply displays a waring to move search and encryptcontetn to the end of the plugins list.
Apply the patch manually or use the current development version.

Your demo site (at http://igm.univ-mlv.fr/~masson/site/protected/) tries to download the file: https://igm.univ-gustave-eiffel.fr/assets/javascripts/decrypt-contents.js which it cannot find.

UPDATE: please check your configuration. If you are planning to upload the site in a subdirectory like "/~masson/site/" you need to make sure that you set the site_dir in the mkdocs.yml correctly like this:

site_url: http://igm.univ-mlv.fr/~masson/site/

The igm.univ-mlv.fr part is irrelevant you could also upload to example.com, but the rest isn't. If site_dir is incorrect or unset the base_path will be "/" and it will search the javascript assets in the wrong directory...

damienmasson commented 1 year ago

Great, adding the site_url: to the yml fixed the issue ! thanks a lot.