Bitcoin Forum
July 21, 2025, 05:33:24 AM *
News: Latest Bitcoin Core release: 29.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Hiding content (SMF patch)  (Read 201 times)
PowerGlove (OP)
Hero Member
*****
hacker
Offline Offline

Activity: 656
Merit: 6207



View Profile
January 08, 2025, 04:23:06 AM
Merited by LoyceV (24), dkbit98 (10), suchmoon (5), Cricktor (5), icopress (4), BlackBoss_ (1), Felicity_Tide (1)
 #1

I mentioned this one at the end of December:

There are requests for a "spoiler" tag going all the way back to 2011. I started work on this a few months ago, and am now finished with it.

I experimented with a lot of different approaches, but the one I eventually settled on is just a simple button that replaces itself (once you click/tap on it) with whatever content you'd like.

I've named the tag [hide] rather than [spoiler]. Basically, you can wrap anything you'd like in [hide]...[/hide] tags, and then rather than the content itself appearing, instead you just get this neat little "Show" button:



(That's obviously just an example image, so clicking on it won't do anything.)

Something that works particularly well with this approach is making quotes more compact:


(Seriously, stop clicking things.) Tongue

I can see this being a nice way (for the people who choose to start using it) to post more courteously, and to save others from having to scroll through huge images and big tables and whatnot. I think I've squared away every concern I've run into. For example, I worried about how this tag might negatively affect SEO, but worked around that by making the content rather than the button appear for guests (on the basis that that's the most reliable way I can think of to make sure that hidden content won't confuse web crawlers). I've also made it so that you can tack a ;unhide on the end of URLs, so that there's some way for people who are both logged-in and refuse to enable JavaScript to still be able to view everything (long term, I really can't see always trying to accommodate the no-JS crowd, but if it turns out to be a genuine sticking point, then I'll add a profile-setting that does the same thing as ;unhide, though I'd really prefer not to, because there are various things that I'd like to add to Bitcointalk that just have no way of working well without client-side scripting, so one or two final concessions to the no-JS peeps would be pretty pointless, all things considered).

And though I expect very few people use them, I've also made sure that the tag recursively auto-expands for the wap/wap2/imode and action=printpage features.

I'll post the patch sometime in January, but, in the meantime, if anyone has any concerns they'd like to raise, or believes that I haven't considered something deeply enough, then I'd be grateful for your thoughts.

Most of the above description still stands, but I've since done more reading/thinking and changed my mind about the SEO impact. So, instead of the feature working one way for guests and another way for non-guests, it now just works the same way for everyone.

Something that the above description skipped over is that it's actually a pair of tags that'll be added: a block-level tag called [hide], and an inline-level tag called [hide-inline]. (Don't worry too much about the difference, the block-level [hide] tag is almost always the one you want, with the [hide-inline] tag only really being useful in what I expect will be rare situations.)

Another thing that the above description didn't mention is that there's a new button added for the [hide] tag (next to the "Insert List" button, located at the bottom-right):



Here are the diffs for @theymos (in the order I recommend applying them):

Code:
--- baseline/Themes/default/style.css	2007-12-20 19:44:06.000000000 +0000
+++ modified/Themes/default/style.css 2025-01-08 02:06:35.000000000 +0000
@@ -451 +451,9 @@
 }
+
+/* The "Show" button for the 'hide' and 'hide-inline' tags. */
+button.show_hidden_content
+{
+ color: #476c8e;
+ background-color: #f1f2f4;
+ border: 1px solid #d0d0e0;
+}

(The above diff makes sense for my version of SMF, but in theymos' version the file that should be adjusted is inside the Themes/custom1 directory.)

Code:
--- baseline/Sources/Subs.php	2011-09-17 21:59:55.000000000 +0000
+++ modified/Sources/Subs.php 2025-01-08 02:16:41.000000000 +0000
@@ -1271,24 +1271,35 @@
  'tag' => 'green',
  'before' => '<span style="color: green;">',
  'after' => '</span>',
  ),
  array(
  'tag' => 'glow',
  'type' => 'unparsed_commas',
  'test' => '[#0-9a-zA-Z\-]{3,12},([012]\d{1,2}|\d{1,2})(,[^]]+)?\]',
  'before' => $context['browser']['is_ie'] ? '<table border="0" cellpadding="0" cellspacing="0" style="display: inline; vertical-align: middle; font: inherit;"><tr><td style="filter: Glow(color=$1, strength=$2); font: inherit;">' : '<span style="background-color: $1;">',
  'after' => $context['browser']['is_ie'] ? '</td></tr></table> ' : '</span>',
  ),
+ array(
+ 'tag' => 'hide',
+ 'before' => isset($_GET['unhide']) || WIRELESS ? '<div>' : '<button type="button" class="show_hidden_content" onclick="this.style.display = \'none\'; this.nextElementSibling.style.display = \'\';" style="display: block;">Show</button><div style="display: none;">',
+ 'after' => '</div>',
+ 'block_level' => true,
+ ),
+ array(
+ 'tag' => 'hide-inline',
+ 'before' => isset($_GET['unhide']) || WIRELESS ? '<span>' : '<button type="button" class="show_hidden_content" onclick="this.style.display = \'none\'; this.nextElementSibling.style.display = \'\';">Show</button><span style="display: none;">',
+ 'after' => '</span>',
+ ),
  array(
  'tag' => 'hr',
  'type' => 'closed',
  'content' => '<hr />',
  'block_level' => true,
  ),
  array(
  'tag' => 'html',
  'type' => 'unparsed_content',
  'content' => '$1',
  'block_level' => true,
  'disabled_content' => '$1',
  ),
@@ -1705,24 +1716,28 @@
  $disabled['me'] = true;
 
  // Color coding doesn't make sense.
  $disabled['php'] = true;
 
  // Links are useless on paper... just show the link.
  $disabled['ftp'] = true;
  $disabled['url'] = true;
  $disabled['iurl'] = true;
  $disabled['email'] = true;
  $disabled['flash'] = true;
 
+ // Can't click-to-reveal on paper... just show the content.
+ $disabled['hide'] = true;
+ $disabled['hide-inline'] = true;
+
  // !!! Change maybe?
  if (!isset($_GET['images']))
  $disabled['img'] = true;
 
  // !!! Interface/setting to add more?
  }
 
  $open_tags = array();
  $message = strtr($message, array("\n" => '<br />'));
 
  // The non-breaking-space looks a bit different each time.
  $non_breaking_space = $context['utf8'] ? ($context['server']['complex_preg_chars'] ? '\x{C2A0}' : chr(0xC2) . chr(0xA0)) : '\xA0';

(This diff is where most of the feature exists.)

Code:
python3 -c "open('hide.gif', 'wb').write(b'GIF89a\x17\x00\x16\x00\xa1\x03\x00\x4f\x4f\x4f\x35\x5d\x80\x86\xa4\xbe\x00\x00\x00\x21\xf9\x04\x01\x0a\x00\x03\x00\x2c\x00\x00\x00\x00\x17\x00\x16\x00\x00\x02\x36\x9c\x8f\xa9\xcb\xed\x0f\xa3\x9c\x62\xb2\x6a\x55\x05\x9c\x5b\x20\x00\x47\x17\x79\x55\x30\x8a\x8e\x67\xa0\xa8\xc1\x32\x71\x40\xa7\xcf\x3c\x6c\xea\x1d\x83\x7b\xd9\x11\x61\x32\x88\x21\xd1\x60\x3c\x2a\x97\xcc\xe6\xa3\x00\x00\x3b')"

(The above isn't a diff, but rather a command that can be executed to re-create the icon I made with Inkscape and GIMP. The 101-byte hide.gif file that the above command creates should be moved into the Themes/custom1/images/bbc directory.)

Code:
--- baseline/Themes/default/Post.template.php	2008-04-30 18:30:34.000000000 +0000
+++ modified/Themes/default/Post.template.php 2025-01-08 02:28:46.000000000 +0000
@@ -783,24 +783,25 @@
  'table' => array('code' => 'table', 'before' => '[table]', 'after' => '[/table]', 'description' => $txt[436]),
  'tr' => array('code' => 'td', 'before' => '[tr]', 'after' => '[/tr]', 'description' => $txt[449]),
  'td' => array('code' => 'td', 'before' => '[td]', 'after' => '[/td]', 'description' => $txt[437]),
  array(),
  'sup' => array('code' => 'sup', 'before' => '[sup]', 'after' => '[/sup]', 'description' => $txt[447]),
  'sub' => array('code' => 'sub', 'before' => '[sub]', 'after' => '[/sub]', 'description' => $txt[448]),
  'tele' => array('code' => 'tt', 'before' => '[tt]', 'after' => '[/tt]', 'description' => $txt[440]),
  array(),
  'code' => array('code' => 'code', 'before' => '[c​ode]', 'after' => '[/c​ode]', 'description' => $txt[259]),
  'quote' => array('code' => 'quote', 'before' => '[quote]', 'after' => '[/quote]', 'description' => $txt[260]),
  array(),
  'list' => array('code' => 'list', 'before' => '[list]\n[li]', 'after' => '[/li]\n[li][/li]\n[/list]', 'description' => $txt[261]),
+ 'hide' => array('code' => 'hide', 'before' => '[hide]', 'after' => '[/hide]', 'description' => 'Hide Content'),
  );
 
  $found_button = false;
  // Here loop through the array, printing the images/rows/separators!
  foreach ($context['bbc_tags'][0] as $image => $tag)
  {
  // Is there a "before" part for this bbc button? If not, it can't be a button!!
  if (isset($tag['before']))
  {
  // Is this tag disabled?
  if (!empty($context['disabled_tags'][$tag['code']]))
  continue;

(This diff adds the new "Hide Content" button to the BBCode editor.)

I considered including diffs to update the help section on posting and the BBCode reference, but those diffs are a bit messy (and bigger than the above diffs combined). Perhaps I'll update that in some later patch (and maybe add the other tags that are missing from it, too).



(I often try to make these "patch" topics substantive beyond the code, and pitch everyone on the usefulness of a thing, and maybe explain some of the thinking and trial-and-error that went into it. But, I've been struggling to stay enthusiastic about the forum lately, and though I expect I'll bounce back and feel positive about the forum once again, for now I'm in kind of a matter-of-fact/humorless mood. I'm sorry about that. If there's some technical detail that interests you, or you'd like to know why I did or didn't do something in a certain way, send me a PM. It's time-wise very expensive for me to recall/unpack all of my thinking on something and to respond properly to questions/suggestions, and I often leave posts unanswered because I either can’t find the time to reply to them, or because I’ve forgotten about them by the time that I do have surplus bandwidth. If you send me a question that you've clearly put some thought into, I promise to at some point get back to you with an answer.)
icopress
Ken Masters
Legendary
*
Offline Offline

Activity: 2044
Merit: 10843



View Profile
January 08, 2025, 11:06:27 AM
Merited by PowerGlove (1)
 #2

Finally my prayers were answered!  Smiley

2. New tag for editorial panel bbcode:

  • Additions to the standard parameters of the publication. I noticed that the [spoiler] tag is not working, so it would be great if a button appeared that opened or hid text between [spoiler] and [/spoiler].



  • Example: Write tag [spoiler][/spoiler][/b] and it will hide the content on anywhere that you can render bbcodes.

Quote
Code:
[spoiler=Spoiler][img]https://www.talkimg.com/images/2025/01/08/Ovip1.png[/img][/spoiler]

  • Readability: Reading a massive message causes irritation (attention is scattered). Thanks to this tag, the readability of the text will improve many times, and the user will be able to clearly and compactly convey the essence of the post (for example, image, proofs).

░░░░▄▄████████████▄
▄████████████████▀
▄████████████████▀▄█▄
▄██████▀▀░░▄███▀▄████▄
▄██████▀░░░▄███▀▀██████▄
██████▀░░▄████▄░░░▀██████
██████░░▀▀▀▀▄▄▄▄░░██████
██████▄░░░▀████▀░░▄██████
▀██████▄▄███▀░░░▄██████▀
▀████▀▄████░░▄▄███████▀
▀█▀▄████████████████▀
▄████████████████▀
▀████████████▀▀░░░░
 
 CCECASH 
 
    ANN THREAD    
 
      TUTORIAL      
Felicity_Tide
Sr. Member
****
Offline Offline

Activity: 462
Merit: 293


cout << "Bitcoin";


View Profile
January 08, 2025, 11:09:01 AM
Merited by PowerGlove (1)
 #3

This is a great feature.

But I have a few questions regarding user preferences,
Is it possible for a forum user/account to set their own preference so that every spoiler (hidden content) is either always hidden by default or always displayed?

And maybe not every user will notice on time, so is there a way to add hover feedback to the "show" button so that when someone who isn't aware hovers over it, a short text in the form of a tooltip will appear. I some something like that in the text editor.


R


▀▀▀▀▀▀▀██████▄▄
████████████████
▀▀▀▀█████▀▀▀█████
████████▌███▐████
▄▄▄▄█████▄▄▄█████
████████████████
▄▄▄▄▄▄▄██████▀▀
LLBIT|
4,000+ GAMES
███████████████████
██████████▀▄▀▀▀████
████████▀▄▀██░░░███
██████▀▄███▄▀█▄▄▄██
███▀▀▀▀▀▀█▀▀▀▀▀▀███
██░░░░░░░░█░░░░░░██
██▄░░░░░░░█░░░░░▄██
███▄░░░░▄█▄▄▄▄▄████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
█████████
▀████████
░░▀██████
░░░░▀████
░░░░░░███
▄░░░░░███
▀█▄▄▄████
░░▀▀█████
▀▀▀▀▀▀▀▀▀
█████████
░░░▀▀████
██▄▄▀░███
█░░█▄░░██
░████▀▀██
█░░█▀░░██
██▀▀▄░███
░░░▄▄████
▀▀▀▀▀▀▀▀▀
|||
▄▄████▄▄
▀█▀
▄▀▀▄▀█▀
▄░░▄█░██░█▄░░▄
█░▄█░▀█▄▄█▀░█▄░█
▀▄░███▄▄▄▄███░▄▀
▀▀█░░░▄▄▄▄░░░█▀▀
░░██████░░█
█░░░░▀▀░░░░█
▀▄▀▄▀▄▀▄▀▄
▄░█████▀▀█████░▄
▄███████░██░███████▄
▀▀██████▄▄██████▀▀
▀▀████████▀▀
.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
░▀▄░▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄░▄▀
███▀▄▀█████████████████▀▄▀
█████▀▄░▄▄▄▄▄███░▄▄▄▄▄▄▀
███████▀▄▀██████░█▄▄▄▄▄▄▄▄
█████████▀▄▄░███▄▄▄▄▄▄░▄▀
███████████░███████▀▄▀
███████████░██▀▄▄▄▄▀
███████████░▀▄▀
████████████▄▀
███████████
▄▄███████▄▄
▄████▀▀▀▀▀▀▀████▄
▄███▀▄▄███████▄▄▀███▄
▄██▀▄█▀▀▀█████▀▀▀█▄▀██▄
▄██▀▄███░░░▀████░███▄▀██▄
███░████░░░░░▀██░████░███
███░████░█▄░░░░▀░████░███
███░████░███▄░░░░████░███
▀██▄▀███░█████▄░░███▀▄██▀
▀██▄▀█▄▄▄██████▄██▀▄██▀
▀███▄▀▀███████▀▀▄███▀
▀████▄▄▄▄▄▄▄████▀
▀▀███████▀▀
OFFICIAL PARTNERSHIP
SOUTHAMPTON FC
FAZE CLAN
SSC NAPOLI
LoyceV
Legendary
*
Offline Offline

Activity: 3738
Merit: 19371


Thick-Skinned Gang Leader and Golden Feather 2021


View Profile WWW
January 08, 2025, 01:45:17 PM
Merited by PowerGlove (1)
 #4

This would be great for some of my data dumps! Even better if BBcode still works inside the hide-tags.
I don't mind not having a hide-button in the editor, it would be totally fine if this is one of the few forum's hidden features.

[hide]Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore! Give us this one theymos, so you don't have to see this wall of text anymore![/hide]

¡uʍop ǝpᴉsdn pɐǝɥ ɹnoʎ ɥʇᴉʍ ʎuunɟ ʞool no⅄
PowerGlove (OP)
Hero Member
*****
hacker
Offline Offline

Activity: 656
Merit: 6207



View Profile
January 17, 2025, 12:18:48 AM
Merited by Felicity_Tide (1)
 #5

Finally my prayers were answered!  Smiley
Ha! I see you even proposed a button in the same location. Cheesy

(I can't say whether or not I've previously seen that topic, but I'd guess not; that topic exists in the time-wise hole between Meta topics that are either recent enough for me to have bumped into them naturally, or old enough for me to have bumped into them while reverse-reading Meta.)



Is it possible for a forum user/account to set their own preference so that every spoiler (hidden content) is either always hidden by default or always displayed?
It's possible, but I'd prefer the need for that to become very apparent before doing so.

And maybe not every user will notice on time, so is there a way to add hover feedback to the "show" button so that when someone who isn't aware hovers over it, a short text in the form of a tooltip will appear.
Yep. I put a tooltip in there originally. It started as "Click to reveal", but then I (reluctantly) changed it to "Click/tap to reveal" (or something similar; I don't remember exactly).

(I was in my early 20s when I unboxed my first iPhone, so you'd think that I'd be part of the mobile-first world, but, I'm not. I was blown away by the possibilities, sure, but, on the other hand, my mama didn't raise no fool, so it didn't take very long for me to get over the initial excitement and to recognize that much like with social media, this was something that, if I allowed it to, would just slowly chip away at a deeper kind of happiness in me, in exchange for an artificial and always-temporary boost to a much less satisfying kind of happiness. More and more, and for many years now, I go out of my way to avoid using my smartphone, to the point of placing it in a wooden box in one of my spare rooms and then just forgetting about the contemptible thing for weeks at a time, so, using it as infrequently as I do, and then anyway only as an actual telephone, I genuinely couldn't say with very much confidence what might sound "right" to a modern ear: Tap? Touch? Fingerbang?)

Anyway, I then changed it to "Interact to reveal". I left it that way for a month or two (while working on other stuff), and when I came back to it with fresh eyes it looked wrong to me, so I took it out.

I think maybe "Reveal hidden content" would work. It's a simple thing for theymos to add himself (it's just a title="Reveal hidden content" added to the <button> element within each of the two new 'before' => ... lines present in the second diff).



Even better if BBcode still works inside the hide-tags.
It does. Smiley

(You can even nest both [hide] and [hide-inline] tags to make content that can only be revealed once other content has been revealed; I'm hoping that not too many ding-dongs will estimate it funny to make irritating use of hide-nesting.)

I don't mind not having a hide-button in the editor, it would be totally fine if this is one of the few forum's hidden features.
Yep. In that case, theymos only has to consider the first two diffs. (Though, I do like the icon, both because it looks natural to me next to those other low-resolution, hard-alpha-channel icons, and because adding it is really very simple; that toolbar is one of the few things I've found in the SMF codebase that can be extended without too much thought.)
TryNinja
Legendary
*
Offline Offline

Activity: 3262
Merit: 8498


♻️ Automatic Exchange


View Profile WWW
January 17, 2025, 12:36:49 AM
Merited by PowerGlove (1)
 #6

So this doesn't use any new javascript, right? HTML only? Smiley

I would only be worried about my bot scraping posts with this new button and not being able to actually see the content because it requires some js embed on the bitcointalk page.

░░░░▄▄████████████▄
▄████████████████▀
▄████████████████▀▄█▄
▄██████▀▀░░▄███▀▄████▄
▄██████▀░░░▄███▀▀██████▄
██████▀░░▄████▄░░░▀██████
██████░░▀▀▀▀▄▄▄▄░░██████
██████▄░░░▀████▀░░▄██████
▀██████▄▄███▀░░░▄██████▀
▀████▀▄████░░▄▄███████▀
▀█▀▄████████████████▀
▄████████████████▀
▀████████████▀▀░░░░
 
 CCECASH 
 
    ANN THREAD    
 
      TUTORIAL      
PowerGlove (OP)
Hero Member
*****
hacker
Offline Offline

Activity: 656
Merit: 6207



View Profile
January 17, 2025, 02:06:51 AM
 #7

So this doesn't use any new javascript, right? HTML only? Smiley
It does use a bit of JavaScript, but only what's emitted in the onclick attribute on the <button> element (and that JS is self-contained).

I would only be worried about my bot scraping posts with this new button and not being able to actually see the content because it requires some js embed on the bitcointalk page.
Nice catch. Factoring both you and Loyce into my thinking was part of the reason I settled on the approach that I did. That is, this feature should continue to work correctly in the context of HTML post scraping, without any special handling. (The only difference, and I find it to be a sensible one, will be in how the "Show" button itself is styled: on the forum proper it'll have the non-rounded and blue-tinted appearance that I think makes it look at-home in the context of a Bitcointalk post or PM, but on Ninjastic it'll just look like an unstyled button, I think, which would appear natural to me in the context of a post archive.)
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!