Hi, I read elsewhere that I could use “reveal” pointing to an “online” indicator to distinguish between a local and remote instance of TW5, but since node.js is a server, it shows as online both ways. is there a way I can change the logic of the reveal statement such that if the instance is node, it reveals the save and edit buttons, but if it is in a single file it is to be read only?
You should be able to check for the presence of $:/plugins/tiddlywiki/tiddlyweb
. It will be present when you’re running in Node and absent otherwise. I have a tiddler tagged $:/tags/StartupAction
that contains:
<$list filter="[[$:/plugins/tiddlywiki/tiddlyweb]is[missing]]">
<$action-setfield $tiddler="$:/status/IsReaderMode" $field=text $value="yes"/>
<$action-setfield $tiddler="$:/config/DragAndDrop/Enable" $field=text $value="no"/>
<$action-listops $tiddler="$:/core/ui/SideBar/Tools" $field=tags $subfilter=" +[remove[$:/tags/SideBar]]"/>
<$action-listops $tiddler="$:/core/ui/SideBar/More" $field=tags $subfilter=" +[remove[$:/tags/SideBar]]"/>
<$action-listops $tiddler="Admin" $field=tags $subfilter=" +[remove[TableOfContents]]"/>
<$action-listops $tiddler="$:/config/DragAndDrop/Enable" $field=text $value="no"/>
</$list>
You can also use my general-purpose read-only tool by downloading this and dragging the resulting file to a wiki:
ReadOnly.json (3.7 KB)
Using CTRL-SHIFT-/
you can toggle read-only mode on and off. But by default it’s on in Node, and off elsewhere.
Hi Scott, I reread the original post and found your solution. the only glitch I have is that I have a special button on top of the tiddler that creates a new tab that is tagged with the current one’s tags. It is at
`
<<button-selector tc-btn-\%24%3A%2Frr%2Fui%2FButtons%2Fnew-here-with+tags>>
but when I add this into the tiddler $:/_/my/reader-mode/styles
like this
...
<<button-selector tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fnew-tiddler>>,
<<button-selector tc-btn-\%24%3A%2Frr%2Fui%2FButtons%2Fnew-here-with+tags>>{
display: none;
}
\end
...
THe tiddler button bar no longer makes the switch. not sure what I am missing, probably need to adjust another of the imported json tiddlers.
thanks for this!
Can you try \%24\%3A\%2Frr\%2Fui\%2FButtons\%2Fnew-here-with\%2Btags
instead (escaping every %
)? This is just a guess.
This was code from @Mohammad’s excellent Utility plugin. I keep meaning to get around to writing a function to derive the selectors from actual titles, but I’ve never spent the time to dig into it.
I believe the core uses:
[<currentTiddler>encodeuricomponent[]addprefix[tc-btn-]]
I think that’s the first step, but that generates output like
tc-btn-%24%3A%2Fcore%2Fui%2FButtons%2Fclone
The CSS code needs one more level of escape.
If you look at $:/plugins/tiddlywiki/tiddlyweb/readonly
in the plugin tiddlyweb1, it has lines like this:
<<button-selector tc-btn-\%24\%3A\%2Fcore\%2Fui\%2FButtons\%2Fclone>>
… and note the extra escapes, before each %
.
I don’t know when I’ll get to it, but I would really like to update button-selector
so that we would call it like this:
<<button-selector "$:/core/ui/Buttons/clone" >>
Requiring a double-escape in our source code seems a little heavyweight!
1 I finally traced down the original source of this code, which I first found in Kookma’s Utilities plugin.
\function button.selector(title) [<title>encodeuricomponent[]addprefix[tc-btn-]escapecss[]]
Thanks. This should make implementing that trivial (although it shouldn’t have been hard either way.)
Thanks for your response.
Unfortunately, that gives the same result. I can’t quite follow the subsequent conversation.
Is this wiki publicly available, by any chance? Or could you extract enough into a simple example wiki to demonstrate the problem? It’s much harder to debug in discussions like this.
But failing that, could you post the whole of this dynamic CSS block?
It’s mostly an aside, not particularly relevant to your problem. I think the current solution is too fragile, and I was thinking about how to make it a bit more robust. Saq offered some tools that should make it easier to do so.
I was able to get it to work with this:
<<button-selector tc-btn-\%24\%3A\%2Frr\%2Fui\%2FButtons\%2Fnew-here-with\%20tags>>,
But this definitely shows that it would be much better to automate this as I discussed above with @saqimtiaz, so that these lines look more like
<<button-selector "$:/rr/ui/Buttons/new-here-with tags" >>
I’ll try to look into that soon.
that did the trick, thanks so much!