[concept] Method to hide/show bits of tiddler content. Other suggestions?

219 views
Skip to first unread message

twgrp

unread,
Jun 30, 2012, 11:17:28 PM6/30/12
to TiddlyWiki
Are there any suggestions how to hide and show *bits* of a tiddler?

For example, I want to show this first half of this sentence but this
second half only if some criteria is fulfilled.

A more practical application (that I use!) is to have a "+" (i.e a
newHere or similar) appear next to each item in forEach-generated
lists... but the "+" only appears for me, not to a visitor!

I achieve this with a simple macro call, for each item in the fET, to
a tiddler containing <<newHere label:"+" tag:$1>> which is set as
private. The result is a that I can easily create subtiddlers to the
listed items but the visitor can't see any such button at all.

Are there other methods to show or hide bits on command?

I guess the ideal would be some kind of local tags like:
This is public but <private>this is private and</private> some things
are <private if user==president> only relevant for your eyes such as</
private> secrets...

There is Simons great HideWhenPlugin[1] but this is applied in
ViewTemplate and EditTemplate so it is not as specific inside tiddlers
and it has to be defined in advance. Or am I missing something? Here
are two examples from his plugin:

<div macro="showWhenTagged Task">[[TaskToolbar]]</div>
<div macro="showWhen tiddler.modifier == 'BartSimpson'"><img
src="bart.gif"/></div>

Other suggestions? Now with tiddlyspace, things are much more out in
the open so I see a need for greater control on this.

Thank you!



[1] http://mptw.tiddlyspot.com/#HideWhenPlugin



PMario

unread,
Jul 1, 2012, 11:24:03 AM7/1/12
to TiddlyWiki
>I guess the ideal would be some kind of local tags like:
>This is public but <private>this is private and</private> some things
>are <private if user==president> only relevant for your eyes such as</
>private> secrets...
uuups
This type of markup doesn't provide privacy, since the server would
need to filter every tiddlers text. At the moment TW does the
rendering clientside so the TW core would filter the private stuff
while rendering. The server will send the whole text to the client. If
you have a look at the TW source code and search for "<private>" you'd
get a nice list of "private" stuff. IMO this is a no go, if you think
of privacy or security. It's ok if you need to deal with visibility.

While TiddlyWeb recipe system knows about different (per bag) access
types, it hasn't been implemented client side. So there is no UI to
configure it and TS isn't designed to use it (yet).

====

showWhenTagged also only deals with visibility but it is a macro, so
it should be useable inside a tiddler

eg:
a)
{{myWrapper{<<showWhenTagged test>> some text }}}
b)
{{myWrapper{<<hideWhen readOnly>> some text }}}

all these hide/show mptw macros remove the containing DOM element, if
they need to hide stuff. Thats why a wrapper like {{x{...}}} is
needed.
So example b) may be what you want. It will hide the text if you are
not a member of the space. IMO it's ugly but it would work for small
junks of text.

hope this helps
-mario





twgrp

unread,
Jul 1, 2012, 9:39:03 PM7/1/12
to TiddlyWiki
> This type of markup doesn't provide privacy,
> It's ok if you need to deal with visibility.

Ah, yes, invisibility would be enough. I guess security is always at
risk when it all is downloaded to the viewer, encrypted or not.

If (when?) they make it possible to import individual tiddlers from
other tiddlyspaces then I imagine it should be straight forward
though. ("If password correct, then import tiddler x")

> a)
> {{myWrapper{<<showWhenTagged test>> some text }}}
> b)
> {{myWrapper{<<hideWhen readOnly>> some text }}}

Interesting! Forgive my ignorance but how do I actually define this?
In StyleSheet I write something like this, yes? -

#contentWrapper
.hide { ???? }

Thanks!

<:-)

PMario

unread,
Jul 2, 2012, 3:04:51 AM7/2/12
to TiddlyWiki
On 2 Jul., 03:39, twgrp <matiasg...@gmail.com> wrote:
> If (when?) they make it possible to import individual tiddlers from
> other tiddlyspaces then I imagine it should be straight forward
> though. ("If password correct, then import tiddler x")
There have been discussions about this in TWdev group or TiddlyWeb
group but have no links at hand :)

> > {{myWrapper{<<hideWhen readOnly>> some text }}}
>
> Interesting! Forgive my ignorance but how do I actually define this?
> In StyleSheet I write something like this, yes? -

short version:
==========
just copy paste this
{{x{<<hideWhen readOnly>> some text }}}

into a tiddler.
make the tiddler public.
log out.
at my space "some text" it is hidden then.


geeky version:
==========
if you have a look at hideWhen plugin [1]

you'll see:

b)
window.removeElementWhen = function(test,place) {
window.hideWhenLastTest = test;
c)
if (test) {
jQuery(place).empty()
place.parentNode.removeChild(place);
}
};

merge(config.macros,{
hideWhen: { handler:
function(place,macroName,params,wikifier,paramString,tiddler) {
a)
removeElementWhen( eval(paramString), place );
}},

===
a) hideWhen: {handler: ...} calls removeElementWhen()
b) removeElementWhen is defined globally and asks for the test
variable and the place variable
c) if test it true the containing element (place) will be removed.
===

if the following line is rendered by TW
{{x{<<hideWhen readOnly>> some text }}}

it produces the "place" if readOnly is false
place-> <span class="x"> some text</span>

it readOnly is true it removes the "place" in the browsers DOM. So it
is not hidden with CSS, it is removed.

-m

[1] http://mptw.tiddlyspot.com/#HideWhenPlugin

Jon

unread,
Jul 2, 2012, 3:54:11 PM7/2/12
to tiddl...@googlegroups.com

Are there any suggestions how to hide and show *bits* of a tiddler?
For example, I want to show this first half of this sentence but this
second half only if some criteria is fulfilled.

Last year, Brent Bartlett posted [1] a link to his SpoilerText plugin [2]. He created a formatter so that any text surrounded by %% was hidden by changing the background to black until moused over. The application was for a flashcard system, and I've used it to hide answers to study questions.

He did this by just setting onmouseover and onmouseout to change the CSS background color attributes of the text. But, you could adapt this easily, testing for your criterion (perhaps readOnly or a successfully entered password?) and toggling display:none instead.

[1] https://groups.google.com/forum/?fromgroups#!topic/tiddlywiki/Rf307bV45S8
[2] http://starjelly.net/portfolio/esperanto.html

TonyM

unread,
Jul 4, 2012, 1:01:49 AM7/4/12
to tiddl...@googlegroups.com
Did you see this recent discussion ?
https://groups.google.com/forum/#!topic/tiddlywiki/SEIPnAVxRA0

Thanks to Eric Using CSS
Reply all
Reply to author
Forward
0 new messages