Improved BBCode Plugin

Creating and modifying plugins.
Post Reply

Do you think there is a need for an improved BBCode plugin?

Absolutly!
8
50%
Absolutly!
8
50%
No way you jerk, everythings just fine.
0
No votes
No way you jerk, everythings just fine.
0
No votes
The idea is nice but you are heading the wrong way.
0
No votes
The idea is nice but you are heading the wrong way.
0
No votes
 
Total votes: 16

meine-erde
Regular
Posts: 8
Joined: Sat Jan 13, 2007 1:52 pm
Location: Potsdam, Germany
Contact:

Improved BBCode Plugin

Post by meine-erde »

I'm relatively new to the s9y community and as of today feel the pains of switching the blogging platform. I used to work with a homegrown system written entirely be myself, which I felt was the best way to achieve maximum flexibility in terms of configuration.

Since I don't have the time to add every new cool feature be myself I thought about switching and adding the powers of others ;)

In my old system I used to write my entries and comments formatted with bbcode, using the StringParser_BBCode class by Christian Seiler. That gives the advantage of being highly flexible while ensuring correct nesting leading to valid html.

And now I miss exactly that configurability. For example I used to add Youtube or Google videos just by adding something like [youtube=VIDEOID] to the entry, without the need to work myself through crude insertion codes. Futhermore I miss the possibility to select which tags are allowed in a specific context. Maybe you want to restrict the tags available in comments while allowing yourself full flexibility.

That said I'm in the progress of thinking about the development of a highly improved version of the bbcode plugin which gives you much more control over your content. The plugin should also use the aforementioned StringParser_BBCode class for parsing.

At the moment I think about some sort of extendable plugin, where one could simply drop a php-file containing the definitions of a particular tag into a specific server directory from where they are included, activate the newly added tag for the desired contexts and start right on using them.

My aim is to create a plugin which has the power to be the only formatting plugin on a s9y system so one could disallow the use of html completely while writing entries or comments.

Do you think I could (or have to) add another special killer feature? Is the idea itself complete bull shitake? Do you feel I'm completely mad trying to write something like this while really having enough other stuff to do? Okay, then tell me :P

---
Holger Just
http://www.meine-er.de
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Improved BBCode Plugin

Post by garvinhicking »

Hi!

First, this is a great idea. Having more bbcode flexibility would be nice!

Maybe you could even make it so that the tag-definitions are stored in a text-area configuration item of the plugin, so that people do not need to upload files via FTP? However, a way needs to be found that does not require the use of "eval" ;-)

One problem I see is that the BBCOde parser is GPL, which we cannot include in the core serendipity distribution. We could add it to Spartacus, but we could not bundle it with our releases...

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
meine-erde
Regular
Posts: 8
Joined: Sat Jan 13, 2007 1:52 pm
Location: Potsdam, Germany
Contact:

Post by meine-erde »

I could give the user the opportunity to enter the definitions in a textbox. But since it is plain php (one function per tag), I assume that only advanced users directly type the functions. Therefore only administrators should be given the right to add new functions. Since they are directly executed I think it would be a good idea to not let anyone create that code.

To ease up the process of adding new tags one could use some sort of stripped down uploading mechanism to get the files to the server.

Concerning the license problem I could write to Christian if there is the possibility to change the license to BSD (which is iirc the s9y license). If he doesn't agree is there the possibility the keep the GPL license for the plugin and spread it via spartacus (maybe advertise it in some way 8))?

---
Holger Just
http://www.meine-er.de
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Okay, I understand your argument. Agreed. :)

Contacting christian would be a nice thing, yes. However the plugin needs definitive and thorough checks - our previous bbcode plugin was prone to XSS attacks, so this new one needs to be as safe in its use as our current one, if it shall replace our core bbcode plugin. It's security must be the tightest component of s9y ;)

GPL-licenses plugins via Spartacus are possible, yes!

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
meine-erde
Regular
Posts: 8
Joined: Sat Jan 13, 2007 1:52 pm
Location: Potsdam, Germany
Contact:

Post by meine-erde »

Since the plugin should contribute in adding more security to s9y I agree to your security requirements.

There should be noted, that I'm pretty packed with work at the moment, so the development could use some time. I'm going to use this thread to advertise some early versions on time so the community (and maybe you :roll:) could have a look at the code and kill that annoying little bugs.

Hail to the power of open source :D
meine-erde
Regular
Posts: 8
Joined: Sat Jan 13, 2007 1:52 pm
Location: Potsdam, Germany
Contact:

Post by meine-erde »

I've written a mail to Christian, asking him for permission to release his code under bsd. I haven't got an answer jet, but according to german Wikipedia the 3-clause BSD license used for s9y is compatible with the GPL. So we can take his code and release the full package under the bsd license.

The artistic license, under which his code is optionally available seems to fit even more though I'm not a lawyer. I think Christian can easily resolve the problem...
meine-erde
Regular
Posts: 8
Joined: Sat Jan 13, 2007 1:52 pm
Location: Potsdam, Germany
Contact:

Post by meine-erde »

So, now I have an answer. He releases his code under the MIT-License. That license is considered compatible with BSD (at least with the 3-clause BSD) so there should be no further licensing problems.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

AWesome, thanks for diggint into this so quickly.

Let us know of your progress, I'll be happy to testdrive it as well :)

Of course it would be awesome, if no current flexibility of the plugin or bbcode would be lost for the new plugin?

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

Re: Improved BBCode Plugin

Post by stm999999999 »

meine-erde wrote:just by adding something like [youtube=VIDEOID] to the entry, without the need to work myself through crude insertion codes.
something like this is possible with regexpMarkup-Plugin:

<sevenload:xxxxx width=425 height=350/> for example
Ciao, Stephan
Xeranon
Regular
Posts: 21
Joined: Sun Jul 09, 2006 3:15 pm
Location: Near Zurich
Contact:

Re: Improved BBCode Plugin

Post by Xeranon »

stm999999999 wrote:
meine-erde wrote:just by adding something like [youtube=VIDEOID] to the entry, without the need to work myself through crude insertion codes.
something like this is possible with regexpMarkup-Plugin:

<sevenload:xxxxx width=425 height=350/> for example
For YouTube, i've added to the PHP-Code of the BBCode Plugin of Garvin under

Code: Select all

$bbcodes = array(
the following lines

Code: Select all

// [youtube]
			  '/(?<!\\\\)\[youtube(?::\w+)?\](.*?)\[\/youtube(?::\w+)?\]/si'                                  => '<object type="application/x-shockwave-flash" style="width:350px; height:290px;" data="http://www.youtube.com/v/\\1"><param name="movie" value="http://www.youtube.com/v/\\1" /></object><br /><span style="text-align: right"><a href="http://www.youtube.com/watch?v=\\1" target="_blank">Video auf YouTube</a></span>',
			  '/(?<!\\\\)\[ytlink(?::\w+)?=(.*?)\](.*?)\[\/ytlink(?::\w+)?\]/si'                                    => '<a href="http://www.youtube.com/watch?v=\\2" target="_blank"><img src="http://sjl-static\\1.sjl.youtube.com/vi/\\2/2.jpg" alt="YouTube Video" /><br />Video anschauen</a>',
The first Code is simply for embedding a YouTube Video (I changed the code to make it W3C valid) like [youtube]theVideoHash[/youtube].
The second one is for linking to a YouTube Video with the orginale preview-Ppic. So you had to put the Server-number, on wich it is saved, also in there (the number is shown in the path of the pic). It will looks like that:[ytlink=ServerNumber]theVideoHash[/ytlink].

The first on ein use: http://www.xeranon.ch/archiv/67-YouTube ... ekord.html
The second on in use: http://www.xeranon.ch/archiv/78-Line-Ri ... rsuch.html[/code]
meine-erde
Regular
Posts: 8
Joined: Sat Jan 13, 2007 1:52 pm
Location: Potsdam, Germany
Contact:

Post by meine-erde »

Okay, I understand, that there are ways to fulfill most of my requirements with existing tools. But the main point (at least for me) is: I don't want to use that many tools just because each of them works a bit different.

With the regexMarkup Plugin I can create HTML like tags, wich are then expanded. By extending the bbcode plugin I can use additional bbcode tags. But honestly, I don't want to hack regex all day ;)

Btw, the main problem with these regexes (besides beeing unreadable) is, that it can't guarantee correct markup. What if you or one of your commenters write something like this:

Code: Select all

This is [i]a [url=http://www.google.com]link[/i] to google[/url].
The resulting html is everything, but not valid.

So I looked for a way to combine all the nice features in one place and keep everything configurable, nice and clean. The good thing is, today I found some hours to code, so I finished the first (at least running) version of the plugin. The tag implementation should be compatible with the current version of the bbcode plugin (except the workarounds for least according to http://www.s9y.org/62.html). All tags and their options are documented in the source code (but should sometime also somewhere else)

There are many things, which need to be done, until it can be used as I intended it. E.g. there are some possible problems with nl2br which need to be spotted and solved. The configuration is rudimentary and isn't completely followed by. And of course there are some tiny but very annoying bugs (maybe also some big ones...).

Anyway, I will leave it there for today. I would be great, if someone could take a look.

The code can be found at http://www.meine-er.de/pub/s9y/bbcode2.zip
Just put the unziped files files into your plugin directory and enable it.

There is some code included from the phpFlickr project, which is released under LGPL. In my opinion, that should be compatible with our license. Garvin?
Post Reply