How to get spoilers for trac wiki?

233 views
Skip to first unread message

pro...@tormail.net

unread,
Feb 24, 2012, 12:01:50 PM2/24/12
to trac-...@googlegroups.com
How can I get spoilers for the trac wiki?

It would be best, if that plugin would still support javascript-free
browsers.

I found a very good javascript-free implementation for spoilers. [1]
Unfortunately it does not work together with the #!html tag.

In the past there was one thread in the mailing list about spoilers for
trac wiki, but the links are down. So if you have any recommendation about
how to get spoilers into the trac wiki I'd really appreciate that.

[1] http://forums.digitalpoint.com/showthread.php?t=768374#post7109062


Benjamin Lau

unread,
Feb 24, 2012, 8:26:35 PM2/24/12
to trac-...@googlegroups.com
Spoilers? Are you talking about having something like spoiler font...
like on tvtropes or sites like that? (actually followed the link... so
yes this is what you want)

I did a naive version of this myself using the span macro. Here are
some examples of usage... of course this assumes that the background
is white... you'd have to adjust if you use a custom theme (just chuck
this in the Sandbox on your trac installation to play with it):

=== '''Span Macro for Coloring ''(Or Other Things)''''' ===
* [[span(style=color:red, red)]]
* [[span(style=color:green, green)]]
* [[span(style=color:yellow, yellow)]]
* [[span(style=color:#8A2BE2, blueviolet)]]
* [[span(style=color:#FFFFFF, spoiler)]]

But seeing your post got me thinking about a fancier implementation...

So here you go:
http://trac-hacks.org/wiki/SpoilerMacro

There are some other things that probably still need to be done to
make this work good... and there might be a value in making it work
using the preprocessor mode and to support wiki markup within the
content... but that's a start and basically implements the capability
in the link you referenced.

Feedback welcome/appreciated. If you have suggestions for changes
submit tickets for them over at trac-hacks.org.

Ben

> --
> You received this message because you are subscribed to the Google Groups "Trac Users" group.
> To post to this group, send email to trac-...@googlegroups.com.
> To unsubscribe from this group, send email to trac-users+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.
>

pro...@tormail.net

unread,
Feb 25, 2012, 1:58:03 PM2/25/12
to trac-...@googlegroups.com
Thanks for your reply.

> Spoilers? Are you talking about having something like spoiler font...
> like on tvtropes or sites like that? (actually followed the link... so
> yes this is what you want)

Yes, we are talking about the same thing. :)

> I did a naive version of this myself using the span macro. Here are
> some examples of usage... of course this assumes that the background
> is white... you'd have to adjust if you use a custom theme (just chuck
> this in the Sandbox on your trac installation to play with it):
>
> === '''Span Macro for Coloring ''(Or Other Things)''''' ===
> * [[span(style=color:red, red)]]
> * [[span(style=color:green, green)]]
> * [[span(style=color:yellow, yellow)]]
> * [[span(style=color:#8A2BE2, blueviolet)]]
> * [[span(style=color:#FFFFFF, spoiler)]]
>
> But seeing your post got me thinking about a fancier implementation...
>
> So here you go:
> http://trac-hacks.org/wiki/SpoilerMacro

Looks very well! Can I see a live demo somewhere? (I do not have my own
trac installed, I am just a contributor in a trac wiki and the webmaster
might install it for me (if I provide a plugin link and demonstration).

<snip>


> Feedback welcome/appreciated. If you have suggestions for changes
> submit tickets for them over at trac-hacks.org.

Maybe I am going to suggest a button/function "Open/Close all spoilers at
once" per wiki page.

Benjamin Lau

unread,
Feb 25, 2012, 5:52:51 PM2/25/12
to trac-...@googlegroups.com
On Sat, Feb 25, 2012 at 10:58 AM, <pro...@tormail.net> wrote:
> Looks very well! Can I see a live demo somewhere? (I do not have my own
> trac installed, I am just a contributor in a trac wiki and the webmaster
> might install it for me (if I provide a plugin link and demonstration).

I don't have a public Trac anywhere either. Let me see if I can set
something up... and if not... I'll add a video of the behavior to the
page for the plugin on trac-hacks.

>> Feedback welcome/appreciated. If you have suggestions for changes
>> submit tickets for them over at trac-hacks.org.
>
> Maybe I am going to suggest a button/function "Open/Close all spoilers at
> once" per wiki page.

Cool. I can look into that... it'd be a good feature for me as well.
Here's my current list:
* Allow inline layout. The current implementation doesn't let us have
a part of a sentence that can be shown/hidden. Unfortunately I'm
running into a bug with that which I'm getting some help with on the
trac-dev list.
* Allow the spoiler to be hidden again by clicking on the text

Once those two are done (and your request) we'll see if we need
anything else. I'll release again as soon as I get any of those
features working. If the sysadmin who maintains your trac instance
decides they don't want to install the plug-in even after a demo...
than span macro approach will work too. I don't remember when it was
introduced though...

Ben

pro...@tormail.net

unread,
Feb 26, 2012, 2:18:37 PM2/26/12
to trac-...@googlegroups.com
> On Sat, Feb 25, 2012 at 10:58 AM, <pro...@tormail.net> wrote:
>> Looks very well! Can I see a live demo somewhere? (I do not have my own
>> trac installed, I am just a contributor in a trac wiki and the webmaster
>> might install it for me (if I provide a plugin link and demonstration).
>
> I don't have a public Trac anywhere either. Let me see if I can set
> something up... and if not... I'll add a video of the behavior to the
> page for the plugin on trac-hacks.

That would be great!

>
>>> Feedback welcome/appreciated. If you have suggestions for changes
>>> submit tickets for them over at trac-hacks.org.
>>
>> Maybe I am going to suggest a button/function "Open/Close all spoilers
>> at
>> once" per wiki page.
>
> Cool. I can look into that... it'd be a good feature for me as well.
> Here's my current list:
> * Allow inline layout. The current implementation doesn't let us have
> a part of a sentence that can be shown/hidden. Unfortunately I'm
> running into a bug with that which I'm getting some help with on the
> trac-dev list.
> * Allow the spoiler to be hidden again by clicking on the text
>
> Once those two are done (and your request) we'll see if we need
> anything else. I'll release again as soon as I get any of those
> features working. If the sysadmin who maintains your trac instance
> decides they don't want to install the plug-in even after a demo...
> than span macro approach will work too. I don't remember when it was
> introduced though...

Okay, I wait for the video and then I'll contact the admin.

Benjamin Lau

unread,
Feb 26, 2012, 4:39:44 PM2/26/12
to trac-...@googlegroups.com
> Okay, I wait for the video and then I'll contact the admin.

http://www.youtube.com/watch?v=TyuelS_e0Js

Here you go. I'll also add a link to the video on the trac-hacks page
for the plug-in.

Ben

Benjamin Lau

unread,
Feb 26, 2012, 7:12:50 PM2/26/12
to trac-...@googlegroups.com

I'm basically done with this now except some minor css tweaks to
highlight the spoiler area. I added the reveal/hide all capability.
And you can also click on the content of a spoiler and it'll be hidden
again.

Hopefully that'll meet your needs.

Enjoy,

Ben

pro...@tormail.net

unread,
Feb 26, 2012, 7:31:30 PM2/26/12
to trac-...@googlegroups.com

Great! Can't believe it.

I just asked the admin.
https://trac.torproject.org/projects/tor/ticket/5240
Now I can only wait.

Thank you very much.

Benjamin Lau

unread,
Feb 26, 2012, 7:45:55 PM2/26/12
to trac-...@googlegroups.com
> Great! Can't believe it.

This is what I love about Trac. It's the most malleable tool of its
kind that I've ever used. The approach of having a very simple but
extensible core makes it really really easy to add new capabilities.
For the most part you can just install it and use it as is. And if you
need fancier stuff there's frequently a plug-in and if not... it's not
too difficult to write one once you've got the hang of it. I've only
had to write a few plug-ins from scratch (this Spoiler macro and
another to support Scrippets[1]... that got some feature creep and
turned into a renderer for Final Draft Pro documents). Other than that
I've just been able to use stuff as is... and in a few cases hat to
fix some bugs or update them to support a newer version of Trac.

Out of curiosity... what are you doing with Trac that you need a
Spoiler Reveal/Hide capability? I've been using Trac as a base for
doing film production planning and we have some content where we
wanted to use spoiler text to hide things from people who don't want
to get spoiled to the story while we're still doing development. We
had been using that span macro approach I mentioned before... but we
didn't like it. This was a good excuse to fix that.

Hopefully your sysadmin will install this for you soon and you can benefit. :-)

Ben
[1] http://trac-hacks.org/wiki/ScrippetMacro

pro...@tormail.net

unread,
Feb 26, 2012, 9:08:57 PM2/26/12
to trac-...@googlegroups.com
> Out of curiosity... what are you doing with Trac that you need a
> Spoiler Reveal/Hide capability?

And I am happy to answer. It's quite different. =)

I am writing tutorials, my current main project is TorBOX. [1] It's an
addition to Tor. [2]

For new users the instructions seam overwhelming, too comprehensive, to
much to read, difficult, scaring. It's because there are different types
of users: users, developers and a mix of both. Users may become developers
some day but you got to lure them, this means, they have to get a working
current version before they start improving it. The tutorial has to look
easy. The first impression is important.

The users type just want to know "what commands do I have to copy and
paste" while the developer type thinks more like "What does this command?
What's the purpose? Wouldn't it be better to do x instant of y? What if x
happens?" and wants some additional reasoning why what is done.

Spoilers would allow to separate the "this is what you have copy and
paste" and the "this is the big comprehensive reasoning for our doing" -
and still combine both.

[1] https://trac.torproject.org/projects/tor/wiki/doc/TorBOX/
[2] https://www.torproject.org/

pro...@tormail.net

unread,
Feb 27, 2012, 8:57:30 PM2/27/12
to trac-...@googlegroups.com
> If the sysadmin who maintains your trac instance
> decides they don't want to install the plug-in even after a demo...
> than span macro approach will work too. I don't remember when it was
> introduced though...

Unfortunately my request was denied.
https://trac.torproject.org/projects/tor/ticket/5240

Can you tell me please, how to use spoilers without a plugin?

(I don't think I evade a decision. The decision was against the
maintenance overhead (and installation work). Not against spoilers as
such. If I can use them with the current installed stuff, that should be
okay.)

Benjamin Lau

unread,
Feb 27, 2012, 9:34:42 PM2/27/12
to trac-...@googlegroups.com
> Unfortunately my request was denied.
> https://trac.torproject.org/projects/tor/ticket/5240

Oh well. But I understand where they're coming from.

> Can you tell me please, how to use spoilers without a plugin?

The only technique I've found that "kind of works" is the use of a
"spoiler font". Basically you make use of the span macro to set the
text to match the background color... Here's an example:

[[span(style=color:#FFFFFF, spoiler)]]

You then have to highlight the content to read it... but it's
awkward... especially for large blocks of text.

Unfortunately I don't this is going to cut it for what you need to
do... You'd probably be better off maintaining two documents. One for
the simple stuff for users. With links to the second document's
section which would contain the more detailed content. That's the best
suggestion I can give you. You should probably make use of the
[[PageOutline]] macro as well... since that'll make navigating the
longer document a bit easier. The page outline looks like the yellow
box up in the corner on this page:
http://trac.edgewall.org/demo-0.11/wiki/WikiMacros

You could also use the [[TOC]] macro... just stick either at the top
of your wiki page and it'll create the box.

Good luck!

Ben

Reply all
Reply to author
Forward
0 new messages