News:

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

Main Menu

BBCode with style

Started by davidhs, May 02, 2010, 02:40:59 AM

Previous topic - Next topic

davidhs

Link to the mod

BBCode With Style for SMF 2.1
By GL700Wing
(Based on BBCode With Style mod by davidhs)


Note: For SMF 2.0 use the BBCode With Style mod.


Important note for SMF 2.0 forums that used the BBCode With Style mod:
For messages that have been migrated/imported from SMF 2.0 this mod will correctly display BBCodes containing mod-specific BBCode tag options (img; table; list; hr; etc tags with classes; styles; etc) that were created using the BBCode With Style mod.

However, in order to workaround an issue with the SCEditor (which SMF 2.1 uses) removing non-standard BBCode tag options (eg: classes; styles; etc) from default BBCode tags (eg: img; table; list; hr; etc) when editing an existing message using the More -> Modify option this mod uses custom BBCode tags (ie: bbcws_img; bbcws_table; bbcws_list; bbcws_hr; etc).

If it is necessary to edit a message migrated/imported from SMF 2.0 that contains BBCodes created with the BBCode With Style mod the Quick Edit option should be used and the names of the mod-specific BBCode tags should be changed to the SMF 2.1 format (eg, img => bbcws_img, table => bbcws_table, tr => bbcws_tr, td => bbcws_td, etc).


Description:
Adds the option to use classes and styles in hr, img, list, and table tags and adds two new tags.

New optional attributes of style:
- style, whose values, in double quotes, are inline rules.
- class, whose values, in double quotes, are names of classes.

These attributes are added to the following BBC tags (default BBCode tag name -> mod BBCode tag name):
- Horizontal rule (hr -> bbcws_hr).
- Image (img -> bbcws_img).
- List (list -> bbcws_list, li ->bbcws_li).
- Table (table ->bbcws_table, tr -> bbcws_tr, td -> bbcws_td).

Mod BBCode tags with optional attributes:
- bbcsw_hr: Add styles to horizontal rule.
   Example:  [bbcws_hr style="rule:1; rule:2;"]

- bbcws_img:
  rotateangle, rotatebgcolor. Rotate an image with a given angle in degree and using a background color for the uncovered zone after the rotation.
  Default value is 0 for rotateangle and black for rotatebgcolor. Values without quotes.
  Also add styles to images.
  The background color is an hexadecimal with 3 or 6 digits (#rgb or #rrggbb), a RGB color (r,g,b) or a color name of these:
    aqua = #00ffff = #0ff = 0,255,255
    black = #000000 = #000 = 0,0,0
    blue = #0000ff = #00f = 0,0,255
    fuchsia = #ff00ff = #f0f = 255,0,255
    gray = #808080 = 128,128,128
    green = #008000 = 0,128,0
    lime = #00ff00 = #0f0 = 0,255,0
    maroon = #800000 = 128,0,0
    navy = #000080 = 0,0,128
    olive = #808000 = 128,128,0
    orange = #ffa500 = 255,165,0
    purple = #800080 = 128,0,128
    red = #ff0000 = #f00 = 255,0,0
    silver = #c0c0c0 = 192,192,192
    teal = #008080 = 0,128,128
    white = #ffffff = #fff = 255,255,255
    yellow = #ffff00 = #ff0 = 255,255,0
    If the color does not exist in the image and can not be added, the closest color is used.
  flip. Flip an image in a direction. Permitted values are: horizontal, vertical. Value without quotes.
  Example:  [bbcws_img rotateangle=degree rotatebgcolor=color flip=direction style="rule:1; rule:2;"]image[/bbcws_img]

- bbcws_table:
  border. Width (in pixels) of the double border around a table. Value without quotes.
  Example:  [bbcws_table border=number]table content[/bbcws_table]

- bbcws_tr: Add classes or styles to row.
  Example:  [bbcws_td class="class_name1 class_name2" style="rule:1; rule:2;"]table cell[/bbcws_td]

- bbcws_td:
  colspan, rowspan. Span columns and rows in a table cell. Value without quotes.  Also add styles to columns.
  Example:  [bbcws_td colspan=number rowspan=number style="rule:1; rule:2;"]table cell[/bbcws_td]

New BBC tags:
- Paragraph style (div): Adds classes or styles to one or more paragraphs.
   Example:  [bbcws_div class="class_name1 class_name2" style="rule:1; rule:2;"]paragraph with style[/bbcws_div]

- Character style (span): Adds classes or styles to characters/text within a paragraph.
   Example:  [bbcws_span class="class_name1 class_name2" style="rule:1; rule:2;"]text with style[/bbcws_span]

Custom buttons are added to the editor toolbar for each of the BBCode tags above.

Release History:
v1.0 - 14-Sep-24
o Initial Release

License
Copyright (c) 2010-2020 davidhs, 2024 Kathy Leslie
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.

Eliana Tamerin

Ambitious! I don't know when I might get around to installing this, but there are times when this would have been useful. Very nice mod, I hope it works smoothly and bugfree.
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

vicram10


Arantor

Nicely done, great to see you dealt with the other stuff too.

One question: were any tests made for XSS attacks? I can't remember if SMF attempts to sanitise bbcodes like that for XSS.
Holder of controversial views, all of which my own.


Bugo


davidhs

Quote from: Arantor on May 02, 2010, 05:18:24 PM
One question: were any tests made for XSS attacks? I can't remember if SMF attempts to sanitise bbcodes like that for XSS.
I do not  ???

Quote from: Bugo on May 02, 2010, 11:34:29 PM
Russian translation
Thanks!

Arantor

Fortunately, SMF does protect; I just tested for you.

XSS is where HTML is compromised by user input not being sanitised properly, such as trying to embed Javascript into the "" options provided.
Holder of controversial views, all of which my own.


davidhs

Quote from: Arantor on May 09, 2010, 05:15:16 PM
Fortunately, SMF does protect; I just tested for you.

XSS is where HTML is compromised by user input not being sanitised properly, such as trying to embed Javascript into the "" options provided.
Thanks.

New version:

1.0.1   2010-05-09
------------------
+ Languages: Add russian, russian-utf8, thanks to Bugo.

dannbass

Have you thought of putting html attributes also? the rowspan and colspan would be very helpful also.
Thanks for the mod!

davidhs

A great idea, thanks. (There is no colspan / rowspan in CSS).

Soon I will add it.

dannbass

I know, I know... it was just an idea to put colspan and rowspan... it's a pain to do that with tables...  to get it to where you can see the effect of colspan.
Thank you!

davidhs

#11
New version:

Legend:   ! Fixed   + Added   - Removed   * Changed   @ Note

1.1     2010-05-11
------------------
+ New optional attributes in td BBCode tag: colspan, rowspan.

dannbass

Great!!!! thank you for doing that so fast!! I'm going to test drive it right now!
Now I don't have to do things like this
[table]
[tr][td]
[table]
[tr][td][xxxxxxxxxxx][/td][/tr]
[/table]
[/td]
[td]
[table]
[tr][td][xxxxxxxxxxx][/td][/tr]
[tr][td][xxxxxxxxxxx][/td][/tr]
[tr][td][xxxxxxxxxxx][/td][/tr]
[/table]
[/td][/tr]
[/table]

davidhs

New version:

Legend:   ! Fixed   + Added   - Removed   * Changed   @ Note

1.2     2010-06-14
------------------
+ New optional attributes in img BBCode tag: rotateangle, rotatebgcolor, flip.

davidhs

New version:

Legend:   ! Fixed   + Added   - Removed   * Changed   @ Note

1.2.1   2010-06-17
------------------
! Source code of img BBCode tag.
@ There is a version to be installed after MOD nCode Image Resizer 1.3-1.3.1.

tRu3_sKiTz0

The rotate feature doesn't seem to work for me. I used your example and tested them all on my own forum and everything works except for the rotate image feature.

davidhs

The rotate/flip features are made with PHP (with CSS/JavaScript not is possible). If your forum is in a free server (for example) may not allow work with images in PHP.

This page made the rotate/flip (not use any function of SMF):
YOUR_FORUM/Source/Subs-BBCodeWithStyle-image.php
You can give the code to the server owner and ask that does not work.

This page have parameters:
YOUR_FORUM/Source/Subs-BBCodeWithStyle-image.php?image=url&rotateangle=nr&rotatebgcolor=color&flip=dir
For example:
YOUR_FORUM/Sources/Subs-BBCodeWithStyle-Image.php?image=http%3A%2F%2Fimg338.imageshack.us%2Fimg338%2F3980%2Funextrannoentrenosotros.jpg&rotateangle=45&flip=vertical

tRu3_sKiTz0

I'm not quite sure what you're getting at there. I'm sorry, I'm a nub, but I do not use a free hosting service or anything and I guess I will look into those other strings but could you post an example that works on yours so I can test it on mine. Maybe I'm just not using the bbcode correctly.

poolhall


davidhs

Quote from: tRu3_sKiTz0 on July 12, 2010, 08:14:57 AMI'm not quite sure what you're getting at there. I'm sorry, I'm a nub, but I do not use a free hosting service or anything and I guess I will look into those other strings but could you post an example that works on yours so I can test it on mine. Maybe I'm just not using the bbcode correctly.

For example, this show image rotate 15º with background red and flip vertical:
[img rotateangle=15 rotatebgcolor=red flip=vertical]http://img338.imageshack.us/img338/3980/unextrannoentrenosotros.jpg[/img]

Advertisement: