News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Yet Another Spoiler Mod

Started by dougiefresh, December 21, 2017, 09:38:22 AM

Previous topic - Next topic

dougiefresh

Link to Mod



YET ANOTHER SPOILER MOD v1.2
By Dougiefresh -> Link to Mod



Introduction
This modification adds 3 BBCodes to the forum: spoiler, changelog and offtopic.  These bbcodes allows the post author to hide content in the post, which is clickable to display it to the user.

These BBCode takes the forms:
[nobbc]
[nobbc][spoiler]{content}[/spoiler][/nobbc]
[nobbc][spoiler {params}]{content}[/spoiler][/nobbc]
[nobbc][spoiler=Some Text]{content goes here}[/spoiler][/nobbc]
[/nobbc]


The {params} section may be any of the following parameters:
o text - Replaces default "Spoiler" text in the header.
o quote - Text that follows the "Spoiler" text in the header.  Must be in quotes.
o show - Replaces default "Show" text in the header.
o hide - Replaces default "Hide" text in the header.
o guests - Flag to show spoiler to guests or not.  May be n, no, false, y, yes, or true.
o log - Flag to enable/disable logging of who viewed the spoiler.
o log_id - DO NOT EDIT!  Automatically replaces log parameter with number of spoiler we are tracking.

Admin Settings
Each bbcode has settings in Admin => Configuration => Modification Settings => YASM:
o {tag_name} style to use:
o Replace button text "{tag_name}" with:
o Replace button text "Show" with:
o Replace button text "Hide" with:
o Default to expanded status?
o Disable {tag_name} for guests globally?
o Disable line beneath {tag_name} text?
o Show which members viewed the {tag_name}?
o Number of members to show that viewed the {tag_name}

These BBCodes may be disabled by going into the Admin => Forum => Posts and Topics => Bulletin Board Code and unchecking the bbcodes you don't want to use.  You may also be uninstall this mod in order to disable them.

Mod Install Notes
This mod REPLACES and expands upon the functionality in the following mods:
o Expanding & Collapsing Spoiler Tag
o Expanding & Collapsing Off-Topic Tag
o Expanding & Collapsing Spoiler Tag

These mods NEED TO BE removed prior to installation of this mod, as the installer will not permit this mod to be installed alongside those mods!  I will not be supporting those mods once this mod is approved!

Compatibility Notes
This mod was tested on SMF 2.0.15, but should work on SMF 2.1 Beta 3, as well as SMF 2.0 and up.  SMF 1.x is not and will not be supported.

Related Discussions
o Kortal's request for spoiler redesign
o WellWisher's changes to the design
o Spoilers
o [FREE/PAID] - Spoiler tag with user record
o [FREE] Spoiler Mod Tweaks

Changelog
The changelog can be viewed at XPtsp.com.

License
Copyright (c) 2017 - 2018, Douglas Orend
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

SaltedWeb

Cool idea have seen this i other forums nice.
Knowing your limitations makes you human, exceeding these limitations makes you worthy of being human.

sam666

Is the logging feature working?  I've ticked the check boxes but nothing is showing in the posts.  This is on SMF 2.0.15 with PHP 7.0.26
Thanks for this very useful mod Douglas  :)

dougiefresh

Quote from: stoneageman on December 23, 2017, 04:59:08 AM
Is the logging feature working?  I've ticked the check boxes but nothing is showing in the posts.  This is on SMF 2.0.15 with PHP 7.0.26
Thanks for this very useful mod Douglas  :)
An automatic "force logging" option is planned for the future, however, it is not available at the moment.  For now, you must start the spoiler using something like this:
[spoiler log=y]
Once you submit the post, the log=y portion of the spoiler declaration will be replaced by the spoiler ID, which is generated by the mod.

sam666

Hi Doug, I've tried as you suggested with log=y log=true etc but it's not generating a spoiler ID.  I have no errors in my logs. It just acts like the regular spoiler. Thanks

Wellwisher

@dougiefresh, just tested this on my local. I love how easy to manage the plugin is.

Incredible, incredible plugin!  ;D

For people running the older version, some good news:
I uninstalled the older version without a problem, and installed the new version and it saved my old spoiler tags so this was a very pleasant surprise.

Also adding the URL link works, I even manage to add font-awesome icon (as seen on the gif below) works like a charm! I did this through the plugin panel. I didn't have to modify any files - which was amazing; saved me a bunch of time! Really happy with that. :laugh:

I learnt this by playing around (maybe I set something up incorrectly), the "Hide" button wasn't there any more and the Spoiler button disappeared after you clicked on "Show" once:

Plus the URL link disappears which you click on show, but for my purposes, it's not an issue.

  :P

dougiefresh

Uploaded v1.1 - December 23rd, 2017
o Fixed issue showing/hiding proper links within the JavaScript code.
o Fixed database insertion issue within Subs-YASM.php code.




@Wellwisher:  I think I've taken care of the issue you pointed out.... *(Hell, I thought I took care of it before, too....)  The issue involved was a matter of focusing on the proper link elements....

@stoneageman:  Please try this version.  I think I've fixed the issue, but I'm not sure....

sam666

That's sorted it Doug. When using log=yes now works as expected. Much appreciated  ;)

Wellwisher

@dougiefresh it's perfect 10/10 bud.

villasg


Steve

Hey Dougie, you've duplicated what this mod replaces in the first post:

Mod Install Notes
This mod REPLACES and expands upon the functionality in the following mods:
o Expanding & Collapsing Spoiler Tag
o Expanding & Collapsing Off-Topic Tag
o Expanding & Collapsing Spoiler Tag
DO NOT pm me for support!

dougiefresh

@Steve:  Sorry, I don't see the duplication, not in this version nor in the previous versions I have in my possession....

Steve

Not in the mod, in the first post of this thread.
DO NOT pm me for support!

dougiefresh

 :o Okay, I see it now!   If I told you it was intentional, would you believe me?    ::) Nah, didn't think so, either....   8)

Steve

DO NOT pm me for support!

dougiefresh

Okay, I've made that change in the mod itself, as updating the mod description also updates the first post for the support thread....  Won't update the mod until I have something more substantial that changed....

Kortal

Thanks dougiefresh for your support, this new mod is perfect !

dougiefresh

Uploaded v1.2 - November 9th, 2018
o No functionality change.
o Updated documentation to point to new website.

-Rock Lee-

I leave the translation in Latin Spanish.


Regards!

¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

rez_spb

Hey, it's me again. Was setting up another forum, found a new incarnation of the mod.
Well, still on that 'guests' thing when local per-tag setting does not override global (contrary to description: "NOTE: Does not affect tags that specify guest status!").

The fix is mostly the same as in previous mod: parse '$guests' first and bypass global if explicitly allowed for them. Just shorter this time =)

I.e, replace:


// If guests aren't allowed to view, then tell the user to login or register:
if ((!empty($modSettings['YASM_' . $name . '_no_guests']) || $guests == 'n' || $guests == 'no' || $guests == 'false') && !empty($user_info['is_guest']))
{
$search = array('{script_url}', '{tag_name}');
$replace = array($scripturl, $txt[$name]);
$message = str_replace($search, $replace, $txt['YASM_strings']['no_guest_html']);
}


...with:


$allow_guests = false;
if ($guests == 'y' || $guests == 'yes' || $guests == 'true') {
$allow_guests = true;
}
// If guests aren't allowed to view, then tell the user to login or register:
if (!empty($modSettings['YASM_' . $name . '_no_guests']) && !empty($user_info['is_guest']) && $allow_guests == false)
{
$search = array('{script_url}', '{tag_name}');
$replace = array($scripturl, $txt[$name]);
$message = str_replace($search, $replace, $txt['YASM_strings']['no_guest_html']);
}


Still as dirty as it was (so has $guests doubleparsing which is needed to be fixed for speed optimizations).

Advertisement: