URL Protocol & Read Only Wikis

If you are looking to setup a read only wiki, you can create a startup action tiddler with the tag $:/tags/StartupAction and having the tiddler field set accordingly

<%if [{$:/info/url/protocol}match[file:]] %>
  <$action-setfield $tiddler="$:/TLS/State/EditMode" $field="editMode" $value="true" />
<%elseif [{$:/info/url/protocol}match[https:]] %>
  <$action-setfield $tiddler="$:/TLS/State/EditMode" $field="editMode" $value="false" />
<%elseif [{$:/info/url/protocol}match[http:]] %>
  <$action-setfield $tiddler="$:/TLS/State/EditMode" $field="editMode" $value="false" />
<%elseif [{$:/info/url/protocol}match[content:]] %>
  <$action-setfield $tiddler="$:/TLS/State/EditMode" $field="editMode" $value="true" />
<%endif%>

Note the additional test for Android using Tiddloid, it has the protocol ‘content:’.

This tiddler will be actioned when opening the wiki and, in this case, set the appropriate field to true or false.

Then in your wiki tiddlers, you can simply test for edit mode with the statement

<%if [{$:/TLS/State/EditMode!!editMode}match[true]] %>
...
<%endif%>

I’m getting better!!

bobj

1 Like

Here’s a much shorter bit of “startup” code that achieves the same result:

<$action-setfield $tiddler="$:/TLS/State/EditMode" $field="editMode"
   $value={{{ [{$:/info/url/protocol}prefix[http]then[false]else[true]] }}} />

Note the use of prefix[http] instead of match[...]. This covers both “remote access” protocols (http: and https:), and defaults to editMode=“true” for all other protocols.

-e