How could I activate a "read-only" mode over "http://" or "https://" automatically?

What I really would like to happen is to have no sidebar, and toolbars when it is deployed to the webserver or host.

I wrote this code at the very bottom of the wiki file:

<!--~~ Raw markup for the bottom of the body section ~~-->
<div id="tta-read-only-mode"></div>
<script>
var readOnlySetting = window.location.href;
if (readOnlySetting.match("http://") || readOnlySetting.match("https://")) {
	var readOnlyStyles = "";
	readOnlyStyles += "<style>";
	readOnlyStyles += "span.tc-tiddler-controls,";
	readOnlyStyles += "div.tc-sidebar-scrollable {";
	readOnlyStyles += "display: none !important;";
	readOnlyStyles += "}";
	readOnlyStyles += "</style>";
	document.getElementById("tta-read-only-mode").innerHTML = readOnlyStyles;
}
</script>

I am wondering if there is a TiddlyWiki way of doing something like this.

You can use conditional CSS that uses wikitext to control whether it is used or not.

Place your CSS in a stylesheet tiddler and wrap it in a list widget that checks the URL protocol from info tiddlers.

Info mechanism
Stylesheets

2 Likes

As already suggested by Saq, create a tiddler, tagged with $:/tags/Stylesheet, containing something like this:

<$list filter="[{$:/info/url/protocol}prefix[http]]">
   span.tc-tiddler-controls, div.tc-sidebar-scrollable { display: none; }
   .tc-story-river { padding-right:3em;margin-right:0; }
</$list>

Note that, in addition to hiding the .tc-tiddler-controls and .tc-sidebar-scrollable, you probably also want to adjust the .tc-story-river right margin and padding to use the space left behind by the now-hidden sidebar.

-e

2 Likes

Also if you wanted a finer level control of what happens you could use startup actions to set various tiddlers and settings depending on the content of $:/info/url/protocol as above.
eg actionSetFieldWidgets

Yep, here’s an example : Read only TW — experiment for a read only wiki hosted on tiddlyhost

1 Like