1
Bender
Kicking some ideas #2: More BB-Codes
  • 2006/8/26 22:37

  • Bender

  • Home away from home

  • Posts: 1899

  • Since: 2003/3/10


[size=x-small]Purpose of this thread:

We have seen some hacks in the past and there is also stuff on the patch tracker over on sf.net. There are not many but some well established bb codes XOOPS is not supporting so far. This topic is to discuss whether we should add some more. At the end of the discussion we will put this into either the feature request or patches tracker to get it into the current XOOPS distribution if reasonable.[/size]


Whats this about?

Lets get some more bb-codes supported in XOOPS module.textsanitizer.php which are quite common these days but did not make their way into Xoops.


Sorry, what are bb-codes?

BB-Codes are a simple replacement for html tags which serve two purposes:
1. you can allow the use of formatting without allowing access to html for the user
2. they are easier to remember and use

Lets say you create a reply in this thread. All the editor buttons that have an effect on the formatting will create a bb-code tag for your actions. Lets say you want to put some bold text. You woulder enter your text, click on the b button and then the add button. The result would be:
Quote:
[ b ]your text[ /b ] in the editor and your text in the output. [size=x-small](note that the tags usually would have no blanks inside. This is just to show it here because otherwise they would not be displayed)[/size]



First: Lets see which codes we have right now as of XOOPS 2.0.15?

Quote:
List of bb-codes:

siteurl --> creating a link with the Url of your XOOPS site plus the folder you entered and displays the given description text

url --> creating a link with the Url provided and displays the given description text

color --> change the font color

size --> change the font-size

font --> change the font type

email --> create an email adress link with a descriptive text displayed

b --> bold text formatting

i --> italic text formatting

u --> underlined text formatting

d --> deleted (aka strikethrough) text formatting

img --> linking an image into the post

quote --> create an outlined box containing a quote of text. This text will have linebreaks to fit into the page

code --> create an outlined box containing a quote of text. This could be program code but could also be anything else. The difference to the quote tag is that there will be no linebreaks. Depending on the handling this means it will either have scrollbars or break your layout if lines are too long to fit in the current screen width.

javascript --> insert a piece of jacascript





Which other ones are out there?

Uhmm, well there are a lot of tags out there if you have a look around. Though some of them are browser specific (IE only) and some others are really used only in special cases so we should not go after finding everyone we could possibly add but see which ones would be commonly used and add only a limited number of new codes.


So which ones are you actually suggesting?

First ones coming to mind would be the list tags. Pretty simple in use and i hate rebuilding list with indention and take care of every single list item manually.

Having a look at all the major forums you could come to the conclusion that the most common approch consists of the following syntax for list tags:

[list][/list] start/end an (unordered) list
[*] marks a list item

an advanced version of this would be support for ordered lists:

[lists=1] list items will be numbered (1,2,3,...)
[lists=a] list items will be given a letter a, b, ...


Another tag which has been discussed in this forum in the past would be the spoiler tag. This one works similar to the Quote code just that the textcolor will be set to the background color which makes it unreadable. To read the text you will have to select it. Something thats for example often used when you don´t want to spoil a movie end or a solution for someone else.

[spoiler][/spoiler] hides text by displaying it in the background color


A very simple one would be the use of the separator line which actually would be the only one without a closing tag.

[hr] displays a line



Ok, how do we do this?

As mentioned in the top these tags are handled within the textsanitizer file so we would just need to add them there. We can steal some code from the existing ones so this should not be to difficult.

So i added those lines to the existing ones for the list tags:

$patterns[] = "/[list](.*)[/list]/sU";
        
$replacements[] = '
    \1
'
;
        
$patterns[] = "/[list=1](.*)[/list]/sU";
        
$replacements[] = '\1';
        
$patterns[] = "/[list=a](.*)[/list]/sU";
        
$replacements[] = '\1';
            
$patterns[] = '/[*](.*)r?n/sU';
        
$replacements[] = '
  • \1
  • '
    ;        
            
    // some guessing on this tag ... but it works  ;)
            
    $patterns[] = "/[hr](.*)/sU";
            
    $replacements[] = '
    '
    ;


    As you can see i was not able to create a correct sanitizing of [*] so i had to use [li] instead. Guess someone will be able to help out here.
    [size=x-small][edit: found the required code in XOOPS 2.2.x sanitizer file.][/size]


    And those for the spoiler:

    $patterns[] = "/[spoiler]/sU";
            
    $replacements[] = 'Spoiler: 
    ';
            
    $patterns[] = "/[/spoiler]/sU";
            
    $replacements[] = '
    ';





    --------------------------------------------------------

    [size=x-small]Notes:

    - spoiler tag was discussed here with different (more advanced) solutions by X-Bandit and dgbauer:
    New Spoiler Tag Hack!

    However in this thread i stick to a simple definition since it only requires modifying the sanitizer. Providing a version that requires editing files not distributed with XOOPS core is not an option i think. Since those who prefer the more advanced versions would need to edit other files anyway they can then also hack the sanitizer.

    - the sanitizer contained an old list regexpattern that was commented out. Seems someone wanted to do this in the past already

    - there is a patch for syntax highlighting based on the language for the code tag in the patch tracker on sourceforge.net
    ( [ 1054035 ] New bbcode - Source Code Highlighting )
    Maybe ackbarr or someone else can pick it up and continue it. Would be a nice addition and if only supplied with a limited number of language files not blowing up XOOPS to much. (Should check with skalpa and dj first if thats an option though before putting work in it; and yes its gpl v2)[/size]


    --------------------------------------------------------


    Questions:

    - color in spoiler tag is currently hardcoded ... need to change this to be taken from theme css file

    - more common tags on your mind?

    - what about the speed impact with adding more tags to the sanitizer?
    Sorry, this signature is experiencing technical difficulties. We will return you to the sheduled signature as soon as possible ...

    2
    tom
    Re: Kicking some ideas #2: More BB-Codes
    • 2006/8/27 4:33

    • tom

    • Friend of XOOPS

    • Posts: 1359

    • Since: 2002/9/21


    I would personaly love the addition of some extra BBcodes, which I think the community may well welcome.

    [flash]
    Inserts a flash movie into post.
    Usage:
    [flash=width,height,true,#colorcode]http://url/file.swf[/flash]
    Output:
    (Inserts http://url/file.swf into the post)

    [audio]
    Inserts a sound into post.
    Usage:
    [audio]http://url/sound.mid[/audio]
    Output:
    (Inserts an audio clip into the post)

    Slightly off topic now, but should the above addition be made, I think there should also be a file manager, similar to the image manager or even an advanced version for the system admin, allowing uploads.

    I mention this as there is nothing worse than reading a post surrounding a an outsourced file which has since been taken off the internet from another server.

    Again off topic, and I suppose something more for module developers (and system comments), maybe there should be an option to choose which BBCodes you want users to be able to use, and even an option to turn off BBcodes. I mention this as on one site I have, the spoiler would be perfect, however on others it could become annoying, especily when users are unfamiliar with BBCode.

    Just a thought.

    Is the BBCode for center, left, right browser specific, as I tend to notice when I center something it still left aligns, the left and right works?

    For techical sites maybe the [php] [sql] code could also be useful, but not as commonly used i suppose?

    The highligher BBCode would also be pretty cool, to highlight vertain parts of a post.

    Should the Spoiler code be added, could the option of 'Show / Hide Spoiler Text Above/below!' also be posted above and below the hiden text, thus taking away the need to drag the mouse over the txt as I've seen on some boards.

    Take care

    3
    incama
    Re: Kicking some ideas #2: More BB-Codes
    • 2006/8/27 6:49

    • incama

    • Friend of XOOPS

    • Posts: 513

    • Since: 2003/10/24


    Great article Bender! Thanks alot
    Webdesign
    Sitting Ducks?!
    I hate politics, give me a stylie instead...

    4
    Bender
    Re: Kicking some ideas #2: More BB-Codes
    • 2006/8/27 8:23

    • Bender

    • Home away from home

    • Posts: 1899

    • Since: 2003/3/10


    Quote:

    tom wrote:
    I would personaly love the addition of some extra BBcodes, which I think the community may well welcome.
    [flash]

    I have seen flash tags along my search multiple times but occasionally with a security warning. Therefore i would not be suggesting to make it a default bb-code. We could though put the code in the sanitizer file as outcommented so if someone wants to have it he/she would only have to remove the comment tags. (?)

    Quote:
    [audio] Inserts a sound into post.
    Usage: [audio]http://url/sound.mid[/audio]
    Output: (Inserts an audio clip into the post)

    Is this one of those annoying play music on opening the page and if you just cranked up the volume to hear something with bad sound while the mid sound is at 100% it will throw you against the wall?

    Well ... code?

    [size=x-small][ignoring the off-topic filemanager - a different thread would be good i guess][/size]

    Quote:
    Again off topic, and I suppose something more for module developers (and system comments), maybe there should be an option to choose which BBCodes you want users to be able to use, and even an option to turn off BBcodes. I mention this as on one site I have, the spoiler would be perfect, however on others it could become annoying, especily when users are unfamiliar with BBCode.

    Well apart from "someone needs to write this" factor ...
    Would add further further questions to this like:
    [size=x-small]- would this be appropriate in site preferences so having it as a global setting or do you really see the need to have different settings module wise?
    - along the lines a facility to add own tags could be integrated [/size]
    However for this to happen i think we need to find someone with really big interest in this topic.


    Quote:
    Is the BBCode for center, left, right browser specific, as I tend to notice when I center something it still left aligns, the left and right works?

    What? Hmmmmm ... where/what are these BBcodes? They are not in the sanitizer (excluding the [ img ] tag options).


    Quote:
    For techical sites maybe the [php] [sql] code could also be useful, but not as commonly used i suppose?

    This would be taken care of by the code tag if the patch mentioned in the notes would be continued by someone. Extending the [ code ] tag to [ code=php ] for example.


    Quote:
    The highligher BBCode would also be pretty cool, to highlight vertain parts of a post.

    Definition? Just using a bright background color?


    Quote:
    Should the Spoiler code be added, could the option of 'Show / Hide Spoiler Text Above/below!' also be posted above and below the hiden text, thus taking away the need to drag the mouse over the txt as I've seen on some boards.

    Something similar i think can be found in the link from the notes above. Can you do it in a simple way that allows this to not depend on modifying other (external e.g. theme related) files than the sanitizer?
    Sorry, this signature is experiencing technical difficulties. We will return you to the sheduled signature as soon as possible ...

    5
    Bender
    Re: Kicking some ideas #2: More BB-Codes
    • 2006/8/27 8:26

    • Bender

    • Home away from home

    • Posts: 1899

    • Since: 2003/3/10


    I like days like these ...

    Tracing that lost piece of code regarding the [ list ] tag i mentioned in my first posting i just found that a lot of this stuff is present in the XOOPS 2.2.x sanitizer already. *ummpf*


    [edit] Found something

    ok - not a lot but the list stuff is in there. It contains the solution for the [*] problem. Great.
    Also it includes a tag for ordered lists but without defining the list type (numerical, alphabeticly). We might need to bring this into the game for backwards compatability.


    [edit2] Something about flash and images

    Ok here is some more stuff in regards to extending the [ img ] tag with size options and a [ flash ] tag.

    Add [flash] tag to BB code

    Gotta wait for a response from phppp except someone does have the mentioned xoopsextendedcode hack at hand.
    Sorry, this signature is experiencing technical difficulties. We will return you to the sheduled signature as soon as possible ...

    6
    Chappy
    Re: Kicking some ideas #2: More BB-Codes
    • 2006/8/27 11:20

    • Chappy

    • Friend of XOOPS

    • Posts: 456

    • Since: 2002/12/14


    Sounds like some great improvements, especially the formatting elements. The other stuff I'm not sure I need so much on my sites but the formatting for certain.
    MMM...It tastes like chicken! ...

    7
    CeBepuH
    Re: Kicking some ideas #2: More BB-Codes
    • 2006/8/27 12:34

    • CeBepuH

    • Not too shy to talk

    • Posts: 128

    • Since: 2002/6/10


    Quote:

    Bender wrote:

    ok - not a lot but the list stuff is in there. It contains the solution for the [*] problem. Great.
    Also it includes a tag for ordered lists but without defining the list type (numerical, alphabeticly). We might need to bring this into the game for backwards compatability.


    Just tested the undocumented [*] on 2.2.4 and it does not seem to work very good. For examlpe if I have a list of 3 only the first two will receive a bullet and the last one will remain with a [*]. So it would definitely need some improvement.

    As for inserting flash, audio and other media - it seems a lot of people need it but due to the various issues with those (including security) I would never let them on my site. Using a manager to upload them on the site is a nice idea but the textsanitizer will have to check that the media is served only from XOOPS_URL/uploads and nowhere else.
    Humans need fantasy to be humans. To be the place where the fallen angel meets the rising ape.

    8
    tom
    Re: Kicking some ideas #2: More BB-Codes
    • 2006/8/28 8:34

    • tom

    • Friend of XOOPS

    • Posts: 1359

    • Since: 2002/9/21


    I've seen the flash feature used, but never really looked into it in great depth, I suppose I can see how it could be used to exploit a site. (if permissions where given as to which bbcode XOOPS groups can use, then it could still be handy for admins).

    Quote:
    Is this one of those annoying play music on opening the page and if you just cranked up the volume to hear something with bad sound while the mid sound is at 100% it will throw you against the wall?

    Well ... code?


    I would imagine it could be done, so the play button has to be pressed, I too find it annoying on auto play, and if one thread had multiple audio on, then it would be a nuisance.

    Like I say an option which shows play/stop/pause would work with this.

    Quote:
    - would this be appropriate in site preferences so having it as a global setting or do you really see the need to have different settings module wise?


    Primarily global, however an option to choose 'global' or 'module' would be cool.

    Quote:
    What? Hmmmmm ... where/what are these BBcodes? They are not in the sanitizer (excluding the [ img ] tag options).


    I refer to the aligning option within the image manager.

    Quote:
    Definition? Just using a bright background color?


    Highlighting, like you do on paper, to highlight keywords.

    Not sure what you mean about the background colour?

    Take care

    9
    Daigoro
    Re: Kicking some ideas #2: More BB-Codes
    • 2006/8/28 9:14

    • Daigoro

    • Quite a regular

    • Posts: 223

    • Since: 2003/7/3 2


    One of the first things I do when installing a new XOOPS system, is to add the br BB-code to the text sanitizer.

    Can't live without it!


    The text sanitizer also has a job for those people using the original (perhaps also the new?) multilingual hack. A long time ago, I made some code that automatically build the BB language codes based on the installed XOOPS languages. It might still be useable? (It's only scanning the dirs once, just like the module-icons in the 2.0.x admin page, so it won't give a huge performance penelty).
    Let me know if it's needed, and I'll try to digg for it in my old files.
    Best regards,
    Daigoro

    10
    jensclas
    Re: Kicking some ideas #2: More BB-Codes

    Off topic a bit...I don't know if the best place to put my wish re bb codes is here but I will anyway - This has nothing to do with the codes but they way it works when you change your mind and want to edit something you have already written. yes this is one of those 'what cheeses me off' kinda posts!

    It goes like this.... when I finish writing a post like this one here I think- oh...should have made this bold but I mean my first 'this' and to do this I have to either know the code and go back and edit it or type it in the add box and format it only to find it ends up at the botom of the post and I then have to cut and paste it to where I want it.

    Probably not making sense but lets say I right now decide I want to put a colour change, smiley or quote at the end of the above line Quote:
    I don't know if the best place to put my wish re codes is here but I will anyway
    I would love to be able to put the cursor there and have the edit happen where the cursor is rather than cut and paste it where I want it from the bottom of the post.

    See this smiley below..if I could do it with the cusor insertion it would be at the end of 'I will anyway' at the top..but to illustrate my point I will leave it right where it lans...at the bottom.

    End of big wish

    Login

    Who's Online

    276 user(s) are online (181 user(s) are browsing Support Forums)


    Members: 0


    Guests: 276


    more...

    Donat-O-Meter

    Stats
    Goal: $100.00
    Due Date: Nov 30
    Gross Amount: $0.00
    Net Balance: $0.00
    Left to go: $100.00
    Make donations with PayPal!

    Latest GitHub Commits