Detecting if wiki is loaded via a file or web protocol

I would like to be able to detect if my wiki is loaded via a file:// or http:// protocol. Is this possible? I want to be able to configure the wiki interface pending on the protocol.

Bobj

see https://tiddlywiki.com/#InfoMechanism

You want to look in {{$:/info/url/protocol}}, which will contain “file:”, “http:”, or “https:”

Thus, you can create a “startup” tiddler (tagged with $:/tags/StartupAction/Browser) containing something like this:

<% if [{$:/info/url/protocol}match[file:]] %>
  ... $action-setfield widgets for local file configuration ...
<% else %>
  ... $action-setfield widgets for hosted file configuration ...
<% endif %>

(see https://tiddlywiki.com/#Conditional%20Shortcut%20Syntax)

enjoy,
-e

3 Likes

Thanks @EricShulman .

For some toys and useful discussion from folks who have leveraged this difference with css etc., see this thread on TiddlyTweaks readOnly solution: Simple solution for an online read-only TW

Thanks very much, @Springer, very useful indeed!