Wedge

Public area => The Pub => Plugins => Topic started by: Arantor on January 11th, 2012, 01:44 PM

Title: Exposing bbcode to the plugin manager
Post by: Arantor on January 11th, 2012, 01:44 PM
I've been thinking a bit about the bbcode management side of things, and in particular ways that users can extend bbcode.

Yes, I want to make a custom bbcode interface part of the core, but I can also see the validity of plugins that provide bbcode either through conventional means or custom means (if they need to do things that aren't supported in the core, or some preparsing for example)

What I'm envisaging, then, is that the bbcode table might grow an id column to indicate where a bbcode has come from, and that there might be a direct interface in the plugin-info.xml file to actually add a bbcode that way.

Having the id in the table would allow cleanly removing bbcode from the table when disabling a plugin (something that is currently not entirely reliable), and it would certainly make it easier to package up new bbcode, even if users would otherwise just be able to insert bbcode themselves... some users really are lazy in that respect. :P
Title: Re: Exposing bbcode to the plugin manager
Post by: Arantor on January 12th, 2012, 02:52 AM
/meis working on this right now.
The id in the column is also not a performance concern because it won't materially affect the query to actually load it.
Posted: January 12th, 2012, 02:40 AM

Holy monkey bladders is there a lot of rules for the XML for this, just for validity checking (that's even before I get into the full code for the plugin manager, but it'll be worth it)
Title: Re: Exposing bbcode to the plugin manager
Post by: Arantor on January 12th, 2012, 03:37 AM
Note to self: this will be greatly helped if the internal bbcode editor also provides for showing the XML block, meaning that mod authors can build it in the normal editor, test it on their forums, and package it very, very quickly.
Title: Re: Exposing bbcode to the plugin manager
Post by: Nao on January 12th, 2012, 08:18 AM
Well that seems to be a good idea.
However I'm more interesting right now to see a bbcode editor in action... Last time I removed the Opera-specific code, it was a bit painful to debug :P
Title: Re: Exposing bbcode to the plugin manager
Post by: Arantor on January 12th, 2012, 09:01 AM
Ah, patience, patience! It's all inter-related in my head!

I'm still trying to decide whether the enable/disable bbcode needs to work per tag (like it does currently, that disabling 'quote' disables all the variants of 'quote') or per individual bbcode.
Title: Re: Exposing bbcode to the plugin manager
Post by: Arantor on January 12th, 2012, 09:36 AM
Hmm, if users don't like a particular tag they'll probably just remove it anyway.

Might as well just leave it structurally as it is (disabling overall tags)
Title: Re: Exposing bbcode to the plugin manager
Post by: Nao on January 12th, 2012, 10:10 AM
Sure. It's mostly a matter of taste -- just like my latest addition, which had me stumbled for a while on whether the file should be called 'custom.template.php' or 'Custom.template.php', or even if I should test for both... Ended up deciding I should follow SMF's guidelines for filenames, and index.template.php is just an 'odd' exception.
Title: Re: Exposing bbcode to the plugin manager
Post by: MultiformeIngegno on January 12th, 2012, 03:34 PM
What about an interface where users can easily add new BBCode tags?


There is a box where admin choose the tag (for example: [wiki]) and in another he can choose the "behavior" of the tag (there can be variables, for example if a user write [wiki]The Rolling Stones[/wiki] the admin should indicate something like: "http://$1/$2" where $1 is the path to the wiki he wants to use and $2 is the phrase within the [wiki] tags).
Title: Re: Exposing bbcode to the plugin manager
Post by: Nao on January 12th, 2012, 03:47 PM
Quote from MultiformeIngegno on January 12th, 2012, 03:34 PM
What about an interface where users can easily add new BBCode tags?
That was Pete's point (allowing plugins to modify bbcodes, and on the other hand allowing users to edit them, and add more, through a UI.)
But it was never done...
Quote
There is a box where admin choose the tag (for example: [wiki]) and in another he can choose the "behavior" of the tag (there can be variables, for example if a user write [wiki]The Rolling Stones[/wiki] the admin should indicate something like: "http://$1/$2" where $1 is the path to the wiki he wants to use and $2 is the phrase within the [wiki] tags).
Invision or vBulletin do that, IIRC...?
Title: Re: Exposing bbcode to the plugin manager
Post by: Arantor on January 12th, 2012, 03:55 PM
-sigh- I'm not being funny but I really wish people would read the entire thread before posting.

Right up there in my first post.
Quote
Yes, I want to make a custom bbcode interface part of the core,
It's going to happen. Just after I do this bit because some of the code will be reliant on the things I'm doing right now (not a lot, mind, but enough to make me want to be sure I have this part working before I do that)
Title: Re: Exposing bbcode to the plugin manager
Post by: MultiformeIngegno on January 12th, 2012, 06:11 PM
 :blush:
Title: Re: Exposing bbcode to the plugin manager
Post by: Arantor on January 13th, 2012, 02:56 AM
OK, so the core functionality is now supported, plugins can add their own bbcode and have it cleaned up on disable. More reliable than doing manual DB queries, anyway.

Now, for my next trick, some kind of UI...
Posted: January 13th, 2012, 02:54 AM

I bet most people here do not realise how complex bbcode actually is. There are, for example, 8 different internal types of bbcode all for different purposes.
Title: Re: Exposing bbcode to the plugin manager
Post by: live627 on January 13th, 2012, 03:22 AM
Kick ass! (And yes, BB codes are a complex beast. I bet this holds true even in other platforms, like ipb, vb, etc.)
Title: Re: Exposing bbcode to the plugin manager
Post by: Arantor on January 13th, 2012, 03:42 AM
Actually, in the other platforms they're a fair bit simpler, because they don't have the same flexibility. You just don't see the variations, IIRC in vB at least they're always [bbcode=something] format, never anything else.

Even their quote code is really dull, it's simply [quote=author;postid].
Title: Re: Exposing bbcode to the plugin manager
Post by: Nao on January 13th, 2012, 08:10 AM
Yeah. vB sucks, no need to specify it again :lol:
What about xF?
Title: Re: Exposing bbcode to the plugin manager
Post by: Arantor on January 13th, 2012, 08:11 AM
Offhand I actually don't know. I'll try it out later today.
Title: Re: Exposing bbcode to the plugin manager
Post by: Arantor on February 8th, 2012, 04:10 PM
XenForo's facilities in this department are functional but confusing and not that wonderful to work with, IMO. Trying to write a bbcode that has any callback is a PITA of the first water.

I've been thinking about this, though, and the much rumoured bbcode editor and thinking that I might have to up-end how things are done, especially if a user ever wants to edit a bbcode that a plugin has issued (because right now, enabling/disabling a plugin causes it to be added/removed directly from the table)

So I've been thinking about having an 'active' parameter in the table, and querying against that, which would allow removal of the existing 'big list of bbcode' tickboxes and allow for per-code disabling (potentially) but it would also require non-trivial changes to the bbc parser, and I'm not sure I'm up to that right now.
Title: Re: Exposing bbcode to the plugin manager
Post by: Nao on February 8th, 2012, 07:50 PM
...Me neither! :^^;:
Title: Re: Exposing bbcode to the plugin manager
Post by: Arantor on February 8th, 2012, 08:29 PM
That said, I don't *have* to gut the existing logic (around what gets set in $disabled), I can make it work by figuring it out from other stuff, I guess.
Title: Re: Exposing bbcode to the plugin manager
Post by: Nao on February 8th, 2012, 11:29 PM
Would it have a noticeable effect on parse_bbc?
Title: Re: Exposing bbcode to the plugin manager
Post by: Arantor on February 8th, 2012, 11:42 PM
I'm not thinking it would, generally.

Here's the thing: disabled has 3 uses, all sort of related.

Firstly, it's extracted from the master modSettings entry, and that's done on first entering parse_bbc. Now, it's used once by the print code to turn off certain codes, then it's used to check whether certain codes are active or not, and add other codes (e.g. the mutant list codes) and lastly it's actually used to ignore tags when parsing.

The key point is that it isn't cached, so that the master list of tags is always consistent, even if you switch between normal and print-page within the cache lifetime, you won't get mashed up tags.

Ignoring the master modSetting and rebuilding it from the main tag list should be a one-per-page affair (when the master bbcodes are loaded, after cache retrieval occurs), so the hit should not be that serious at all.

Really, though, a lot more of it is figuring out how the UI should interact so that the loading can handle everything it's supposed to and set disabled appropriately - setting 'url' to disabled takes out all variants on the url bbcode, not just any one particular style.