Jump to content

witch way to store bbcode?


tinker

Recommended Posts

Hi, i'm doing a little bbcode editor and was wondering how others do certain things.

 

1) When the bbcode is entered, how would you store it, i.e. convert to html and store, or store as bbcode and convert as served. I'm thinking that converting to html and storing, if needs to be edited then convert back (because there will be more views served than edits!)

 

2) How to deal with code tags, I know the code shouldn't be bbcode, but i'm to filter out any threatening code. I'm thinking of either splitting the whole lot, or cutting the code sections out and dealing with separately, then putting back. Both of these sound convoluted so i'm hoping there's a better way.

 

CHeers for any suggestions!

Link to comment
Share on other sites

When you say 'because you may change the way things are interpreted.', do you mean it may mean something different through time, or that it may be updated. The way i'm thinking is, this post has been read 12+ times but not as such edited, admittedly theres not much content as such but if there was, every time it would need to be converted and regex is quite cpu intensive. Is this a fair tradeoff, surely it's possible to convert back to bbcode from html, (once again the code tags being the stickler).

 

? ? ?

Link to comment
Share on other sites

When you say 'because you may change the way things are interpreted.', do you mean it may mean something different through time, or that it may be updated. The way i'm thinking is, this post has been read 12+ times but not as such edited, admittedly theres not much content as such but if there was, every time it would need to be converted and regex is quite cpu intensive. Is this a fair tradeoff, surely it's possible to convert back to bbcode from html, (once again the code tags being the stickler).

 

???

I mean what jesirose said

Link to comment
Share on other sites

This was my original thinking and definitely the easier option, even less code to preprocess when loading, however i'm just reasoning the wear and tear on the server. For 1k of post you could be talking more than 20k of cpu cycles. I've just copied the first page of this, and that comes in at about 11.4k or say 220k cycles, probably more. And that page has been viewed 127 times.

 

I don't want to be impertinent but would you mind giving me some reasoning as to your views, they sound pretty solid. Many thanks!

Link to comment
Share on other sites

I'd do it like that because you can always decide to take out a particular bbcode at anytime, or add any at any given time.

If the HTML is stored, that code will not be processed anymore. Therefore take this for example:

You start your script with [*b][*/b] bbcode.

People post comments on your script using that particular bb code. Your script turns and stores bbcode in the database in HTML form

Later in your scripts life you want to remove the [*b][*/b] bbcode. All the posts that were made before this decision will have bolded text.

 

Understand?

As for server resources, well thats just one of those things lol.

Link to comment
Share on other sites

Thanks for rationalising it for me. Not that I can find that usage of the bold (but hey, thats why i'm here). However that's sort of why i'm questioning it all now, so that changes don't have to be made latter (I wish I was perfect, not, I like my imperfections)... but enough on that for the moment.

 

Any suggestions for Q2 please?

2) How to deal with code tags, I know the code shouldn't be bbcode, but i'm to filter out any threatening code. I'm thinking of either splitting the whole lot, or cutting the code sections out and dealing with separately, then putting back. Both of these sound convoluted so i'm hoping there's a better way.

Link to comment
Share on other sites

Thanks for rationalising it for me. Not that I can find that usage of the bold (but hey, thats why i'm here). However that's sort of why i'm questioning it all now, so that changes don't have to be made latter (I wish I was perfect, not, I like my imperfections)... but enough on that for the moment.

 

Any suggestions for Q2 please?

2) How to deal with code tags, I know the code shouldn't be bbcode, but i'm to filter out any threatening code. I'm thinking of either splitting the whole lot, or cutting the code sections out and dealing with separately, then putting back. Both of these sound convoluted so i'm hoping there's a better way.

http://uk2.php.net/manual/en/function.strip-tags.php is that what you're looking for?

Link to comment
Share on other sites

Yes but no, they would be handled as you say, but as like this forum, if you put bbcode within a code block it stays as bbcode...

1) Split post on code delimiters and deal with code blocks differently.

2) Extract code block contents, leaving an id, dealing with, then replacing.

Without hacking the code for this site, there currently my two options...

Any suggestions?

 

 

P.S.

As for point 1, through discussion i'm deciding to store as bbcode, then disallow post updates after n time, then on first view thereafter to convert to html and re-store (db flag is required)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.