TW5 hiding tiddlers by username, and locking?

92 views
Skip to first unread message

myst...@gmail.com

unread,
Jul 9, 2017, 6:25:45 PM7/9/17
to TiddlyWiki

I'm attempting to use TiddlyWiki as a Gaming notebook for my gaming groups campaign.
The DM needs a way to save notes, but 'obscure' some things until he's ready.

First, i'd like to point out that I am unconcerned about multi-user writing issues, and actual security isn't my goal.
We're on a honor system here. clearly if one of my users bypasses the system,  he's just spoiling the story for himself.

My attempt at accomplishing this was 2 fold:

for subsections of a tiddler, fall back on a simple <$reveal> against the $:/state/UserName to make sure it equals the GMs id.
I THINK I can even do <$reveal>s against a tag called say.. 'GM Only'..

But i'm at a loss for how to stop a player from editing a signed tiddler unless they are the signer.
And hiding a tiddler unless you are the signer.

Does anyone know if this is possible?
Code is awesome, but even a link to the proper resources would be a great help.



Mark S.

unread,
Jul 9, 2017, 7:42:55 PM7/9/17
to TiddlyWiki
I'm not sure if you meant $:/state/UserName. I went with $:/status/UserName.

TW5 will let you put widgets inside of stylesheet tiddlers. If you put this inside a tiddler tagged as a stylesheet...

<$reveal type="nomatch" state="$:/status/UserName" text="MARK">
   button[title="Edit this tiddler"] {display:none}
</$reveal>

It would hide all the tiddler edit buttons as long as the signed-in user didn't match "MARK" (or whatever name you designated).

Does that get you partway there?

Good hunting!
Mark

myst...@gmail.com

unread,
Jul 10, 2017, 12:39:58 AM7/10/17
to TiddlyWiki
Partway? You just gave me exactly the piece i need!

I honestly expected a response of  "Sorry, TW5 doesn't support that, you'll have to code your own." responses.

Here is what i settled on:

I changed the CSS part to:   .tc-tagged-GM_Only button[title="Edit this tiddler"] {display:none}

So now he can tag an entire tiddler as uneditable.

and since <$reveal> w/ no options defaults to hidden. He just needs to use those as spoiler tags to hide information.
And since <$reveal> doesn't let its contents reach the browser, its better than a {display:none}

I seriously love this frigging application!

You don't HAVE to be insane to make it sit, stay, and beg.. but it might help.

Thank you again!

Mark S.

unread,
Jul 10, 2017, 12:51:44 AM7/10/17
to TiddlyWiki
Oh. Great! Then you probably don't need to change $:/core/ui/ViewTemplate/body  to:

<$reveal tag="div" class="tc-tiddler-body" type="nomatch" state=<<folded-state>> text="hide" retain="yes" animate="yes">

<$list filter="[all[current]!tag[GameNote]!has[plugin-type]!field:hide-body[yes]]">

<$transclude>

<$transclude tiddler="$:/language/MissingTiddler/Hint"/>

</$transclude>

</$list>

<$list filter="[all[current]tag[GameNote]!has[plugin-type]!field:hide-body[yes]creator{$:/status/UserName}]">

<$transclude>

<$transclude tiddler="$:/language/MissingTiddler/Hint"/>

</$transclude>

</$list>


Which would automatically hide the contents of any note tagged GameNote (you can change that to your tagging) when the author/creator doesn't match the signer. (always make backups before changing shadow tiddlers).

Have fun,
Mark

Mark S.

unread,
Jul 10, 2017, 1:14:28 AM7/10/17
to TiddlyWiki
Ignore that post. I just realized (D'oh) you can accomplish the same thing just by adding this line to the stylesheet inside the <$reveal> widget:

.tc-tagged-GM_Only .tc-tiddler-body {display:none}

Have fun,
Mark
Reply all
Reply to author
Forward
0 new messages