How secure do you want it?
I often use a technique borrowed from one of Mohammad’s plugin that offer an obscure keystroke to toggle between read-only mode and edit mode. Read-only mode hides many of the buttons, but I don’t go as far as you in hiding the whole sidebar. (Even in read-only mode, my wikis need it for navigation.) I’m sure we could configure this to also hide the sidebar and its button.
I have different needs than yours. My edit mode is Node, and my read-only mode is a single-file wiki served over http(s). At startup, I look to see if the Node modules are included. If not, I turn on read-only mode. For you, we could probably do something with $:/info/url/protocol
to decide when to turn on read-only mode.
But this mode is about hiding controls and not disabling them. If someone added this to the URL: they’d load the control panel, and could use it as they like: #%24%3A%2FControlPanel
. And there are other ways around my restrictions. I’m ok with that. A TW sophisticate could download a copy and make changes, but they couldn’t upload their changes, so I feel safe enough; I mostly don’t want to confuse users with things they can’t do. You may have different requirements.
You can see mine in action at https://charter2024.andoverct.info/. To toggle modes, you can use CTRL/SHIFT-/
(control-shift-slash). Because @pmario pointed out that this is difficult to type on German keyboards, I also added CTRL-SHIFT-1
to do the same thing.
I don’t know how far it has wandered from Mohammad’s Utility plugin, but that’s where it started. The current code looks something like this:
ReadOnly.json (3.7 KB)
If this sounds like a good fit, let me know, and I think we could adapt it relatively easily.