Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Three formatting/quotations problems

AprecheApreche
edited May 2007 in Vanilla 1.0 Help
So I've been running a Vanilla forum for quite sometime now. There are plenty of users and posts, and everything is going nicely. There are however, three related issues I would like to resolve. They are related issues, and I'm hoping they can be solved with one stone rather than three. I'm a programmer by trade, and I've thought of many solutions, but I've done relatively little work with Vanilla itself, so I'm wondering what you guys think. I'm going to be updating all the services and web applications on my hosting sometime in the near future, and I'd like to take that opportunity to fix things like this. The first problem is the radio buttons below the comment box. My users are not all very quick. They often post comments without selecting the proper radio button. They will make an HTML link and not click the Html radio button. This creates extra work for moderators who have to edit these posts to properly set the formatting. I would like to either have only one formatting option which will properly format posts no matter if users use BBCode, Html or text. I know that's difficult, so second best would be to have Vanilla somehow automatically detect and select the correct formatting option. The second problem is that our database is full of unformatted posts. It would be quite the pain to go through every thread to find posts written in HTML that are rendered as text to change them all. So I need some way to go through the database and detect what format a posts should have, and set it properly. The final problem is the quotations extension. The quotations extension can be easily configured to use BBCode or Html. However, many users click the quote button and do not set the radio button. This problem has created most of the posts in our database that need fixing. Is there a way to automatically select the Html radio button when a users presses the quote button? Maybe we should have two quote buttons, one for BBCode and one for Html? Generally I want to make sure that every comment already in the database is formatted properly. I also want to make things easier on the users as well as the moderators in the future. What is the best way to go about this?

Comments

  • One possible (but addmittedly inefficient) angle of attack would be to set your formatters as all global formatters--then every comment will pass through every format option.

    You just have to figure out the order... i.e. BBCode might strip HTML tags that would be put in place by the extended text formatter.

    So maybe try unformatted text parsed with BBCode -> html code formatted with extended text formatter -> HTML formatter strips nasty code -> Done!
  • I'm thinking that someone who uses html markup won't use bbcode, and vise versa. So perhaps setting formatter as a user preference, and remove the radio buttons on the comments form, and then getting the preference when someone posts.

    Of course, the simplest solution would be to just remove either bbcode or html. ;)
  • Removing BBCode is something I've thought about, but there are posts written in BBCode still in the database. I'd have to somehow convert them to HTML. Either that, or I'd allow the BBCode formatter to do its thing to existing posts with BBCode, but not allow any new BBCode posts.
  • Good point, I hadn't thought of that. It's a bit of a tricky situation. Perhaps you can take the parsing code from the BBCode Parser and run your BBCode database entries through that (because the parser makes it into HTML for display, right?), and then save it back to the database.
  • This sounds like a good idea. There aren't that many BBCode posts in the database, so how would I go about converting them all to HTML in a way that doesn't involve lots of manual labor? I'm a programmer, and could probably write the solution myself. However, it will probably take me longer to learn how Vanilla extensions work that it will take someone who is already knowledgeable to write something up. However, it's looking more and more like I have to learn anyway...
  • You don't really need to learn anything about how Vanilla works. What you'd want to do is write something that pulls out all entries from LUM_Comment where the FormatType is BBCode. Then you need to get something to convert the BBCode to html. I'd think that for instance the BetterBBCodeParser does that (when displaying bbcode comments), so perhaps you can take the parsing code from that extension, and stick it in your script, and then write the comments back to the database one by one.

    Or (and this would ignore any code blocks in the comments and such) you just do straight replacing with SQL statements, so you'd have a bunch of
    UPDATE LUM_Comment SET Body=(REPLACE (Body, '[b]', '<b>')); UPDATE LUM_Comment SET Body=(REPLACE (Body, '[/b]', '</b>'));etc.

    I wouldn't replace all '[' with '<', because you might have comments where square brackets have been used for other things besides bbcode, and replacing might screw those comments up.
  • Sounds good. I'll put my script here once it's done.
This discussion has been closed.