• Welcome to Simple Machines Community Forum. Please login or sign up.
January 25, 2022, 02:28:06 AM

News:

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


Yet Another YouTube BBCode Tag

Started by dougiefresh, December 10, 2014, 06:09:01 PM

Previous topic - Next topic

dougiefresh

@Finn_958:  I would highly suggest using the Package Manager in the admin panel.  That's what it is there for: Installing packages....  ::)  You should also note that sometimes manually installing mods makes it harder to uninstall things properly!

Since you appear to insist on doing it manually, all language file modifications are in language_english.xml and language_spanish_latin.xmladd_remove_hooks.php must be copied to forum root (same directory as SSI.php) and called via browser.  Once executed, you can then delete the file.

Finn_958

I installed the package from the admin panel and it works like a charm. I am a newbye and didn't know this functionality, thank you.

triode-master


Sesquipedalian

February 19, 2018, 07:34:28 PM #263 Last Edit: February 19, 2018, 08:23:33 PM by Sesquipedalian
Quote from: dougiefresh on February 17, 2018, 11:50:36 AM
Clearly, something is screwed up....  Changing the code like this SHOULD solve the errors.....
Code (Find) Select

foreach (($codes = parse_bbc(false)) as $code)
if (!in_array($code['tag'], $allowedEmpty))
$alltags[] = $code['tag'];

Code (Replace) Select

$codes = parse_bbc(false);
$codes = is_array($codes) ? $codes : array();
$alltags = array();
foreach ($codes as $code)
if (!in_array($code['tag'], $allowedEmpty))
$alltags[] = $code['tag'];


That would just mask the real problem. Calling parse_bbc(false) should return the contents of the $codes array that is defined in that function. If instead it is returning null, which is what triode-master's reported error messages appear to indicate, then something in his forum (perhaps this mod, perhaps something else) has broken parse_bbc().

Merely masking the problem by using these proposed changes is not a proper solution, because there are many places in the codebase that use parse_bbc(false) to get the list of BBCode tags. If null is returned instead of the array, quite a few things are going to break, some in ways that may not be immediately obvious but are important.

That said, it would be good form for us to define $alltags = array(); before the foreach, so I will add that in a future PR to SMF2.1. (EDIT: Done in #4554.)
I promise you nothing.
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Sesquipedalian

I took a look at the code in this mod, dougiefresh, and I suggest some changes for the 2.1 version. Specifically, you should get rid of all the file edits to Subs.php and use the hooks there instead. You can use the integrate_pre_parsebbc hook to add BBCodes to $modSettings['disabledBBC'], and integrate_bbc_codes hook to add BBCodes to the main $codes array.
I promise you nothing.
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

dougiefresh

Uploaded v4.8 - February 20th, 2018
o Removed support for SMF 2.1 Beta 2.
o Added support for SMF 2.1 Beta 3.
o Moved bbcode disabling code from Sources/Subs.php to Subs-BBCode-YouTube.php.
o Added translators to the mod's README.txt file.
o Added LICENSE.txt to satisfy licensing concerns.




@Sesquipedalian:  Upon looking at the SMF 2.1 code, I couldn't agree with your suggestions more!  So, your suggestions on SMF 2.1 version have been integrated into this version!

Regarding the code changes here, I didn't realize that it would mask the problem...   (Either that, or I didn't think that hard about the issues involved....)  Either way, I apologize for my oversight.  Please ignore my suggestion/"half-ass-fix"...

Finn_958

How do I update it without losing settings? Uninstall and/or delete and reinstall?

dougiefresh

Yup!  That's always the way to update my mods.

Sesquipedalian

Quote from: dougiefresh on February 20, 2018, 10:34:48 PM
@Sesquipedalian:  Upon looking at the SMF 2.1 code, I couldn't agree with your suggestions more!  So, your suggestions on SMF 2.1 version have been integrated into this version!

Excellent. :)

I also noticed that because the BBCodes you add with this mod have a lot of parameters, you are doing your own parameter handling. That's a good idea in 2.0, since large numbers of parameters could really bog down 2.0's version of parse_bbc(). However, 2.1 significantly improves the performance of BBC parameter parsing (see here and here) and adds the ability to pass the parsed parameters directly to a BBC's validate function (see, e.g., the attach BBC's validate function here). You might want to consider changing your code to use the standard parameter parsing and validation methods in 2.1. It should make managing and debugging your code much easier in the future.

Quote
Either way, I apologize for my oversight.  Please ignore my suggestion/"half-ass-fix"...

If you are apologizing to me, there's no need. I am completely unharmed by any of this. ;)

However, I do recommend that you do some debugging on the mod to ensure it isn't causing parse_bbc(false) to return null.
I promise you nothing.
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

-Rock Lee-

I'm not sure at all but note 2 lines without translation, it's little but I'll leave it updated!


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

dougiefresh

Uploaded v4.9 - February 22nd, 2018
o Updated Spanish Latin translation, courtsey of Rock Lee.

alaska_guy

February 23, 2018, 04:05:44 PM #271 Last Edit: February 23, 2018, 04:22:52 PM by alaska_guy
I more than likely missed it...  But where do I specify x and y for width and height so anytime someone posts a youtube video in the forum it always specifies a specific height and width shown so it doesn't take 100% of the screen/post up.

I want a way to statically set every video to this size when I use this code manually.

center][youtube width=640]https://www.youtube.com/watch?v=C0DPdy98e4c [nofollow][/youtube][/center]

It looks like maybe this snippet of code from the BBCode-YouTube2.css?

{
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
   position: absolute;
}

Dwev

Quote from: alaska_guy on February 23, 2018, 04:05:44 PM
I more than likely missed it...  But where do I specify x and y for width and height

Admin > Configuration > Modification Settings

Default width used for YouTube bbcode when not specified

and

Use 0 to use responsive video display

rustava

dougiefresh Hi!

Install mod Yet Another YouTube BBCode Tag in the SMF 2.1 Beta 4 (and SMF 2.1 Beta 3), there are errors:



General Bulletin Board Code:


Install mods:


Any thoughts on how to fix the error?

dougiefresh

Uploaded v4.10 - March 4th, 2018
o Fixed issue where BBC manager didn't show any tags.




@rustava:  Finally located why the BBC manager wasn't showing any tags....  My auto-embedding code was screwing things up!  O:)

rustava

Quote from: dougiefresh on March 04, 2018, 10:45:43 AM
Finally located why the BBC manager wasn't showing any tags....
Thanks, it works!

aegersz

@dougiefresh:

you do know that many of us look to the Simple Audio and Video Embedder for this solution (that doesn't even require BBCode tags) ?

but hey, it can't hurt.

what i want is a video embedder or (BBCode) to handle what SAVE doesn't - i post countless links to US news and all but one or two actually embed.

a good example is the JW Player and i don't know if it it isn't free to use as a player only.
The configuration of my Linux VPS (SMF 2.0 with 160+ mods & some assorted manual tweaks) can be found here and notes on my mods can be found here (warning: those links will take you to a drug related forum). My (House) music DJ dedication page is here

Dwev

Quote from: aegersz on March 06, 2018, 04:15:03 AMyou do know that many of us look to the Simple Audio and Video Embedder for this solution (that doesn't even require BBCode tags) ?

Yeah, but some people (like me) prefer mods like this one that use BBcode.

I tried Simple Audio and Video Embedder, but didn't like that it works on all links, also the that you don't want to show.

For instance in links under a text, because that immediately becomes a mess.

butch2k

Quote from: aegersz on March 06, 2018, 04:15:03 AM
what i want is a video embedder or (BBCode) to handle what SAVE doesn't - i post countless links to US news and all but one or two actually embed.
I proposed a US News embed to SAVE: https://www.simplemachines.org/community/index.php?topic=395039.msg3964620#msg3964620

Eventeca


Advertisement: