inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Oct 31, 2013 15:54:53 GMT -8
no
|
|
inherit
172351
0
Sept 5, 2019 10:56:35 GMT -8
DarkPikachu
Complexity == Fun
320
October 2011
tcll
|
Post by DarkPikachu on Oct 31, 2013 16:21:24 GMT -8
huh... weird >.> in any case... it's working now (I literally had not touched anything since leaving it at the last code I'd posted) so anyways... now what I need to ask is, what's the function for converting BBC to HTML?? since that's all I need to finalize this thing
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,017
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Nov 1, 2013 4:24:45 GMT -8
Since these BBC <==> HTML functions involve sending data back to the server each time you call it, I would suggest writing your own convertor which can then run locally in the browser and not clog up the server/bandwidth with unnecessary traffic. It has been noted before in other threads that your stated trigger of invoking after each keystroke or even after a set delay in typing would be too much traffic for one plugin to generate. I'm sure that to servers that process millions if not billions of requests per day such behavior would be negligible but once such frivolous requests start multiplying then it becomes akin to a DDOS attack, unfairly taking server time from processing more legitimate requests.
|
|
inherit
172351
0
Sept 5, 2019 10:56:35 GMT -8
DarkPikachu
Complexity == Fun
320
October 2011
tcll
|
Post by DarkPikachu on Nov 1, 2013 5:09:16 GMT -8
I see :/ your function must not be in JS if it makes server requests >_> in that case... if you don't feel like making your function public, which I'm sure you guys don't wanna do, then can you send it to me via PM I wanna code it to work exactly like the PB BBC conversion. thanx
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,017
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Nov 1, 2013 6:09:50 GMT -8
I see :/ your function must not be in JS if it makes server requests >_> in that case... if you don't feel like making your function public, which I'm sure you guys don't wanna do, then can you send it to me via PM I wanna code it to work exactly like the PB BBC conversion. thanx To be clear, I do not work for Proboards and I do not speak for the company, only a red name can do that, so it would not be my function but yes, these functions employ AJAX in order to access the services of a parser that is not in the public domain. If you inspect @wcypierre account you'll see multiple injection exploit attempts to undermine security and this provides a perfect example of why I believe the convertor is kept server-side. If a potential attacker cannot study the code looking for possible attack scenarios then it is much harder to cause mischief. I'm sure that is not the only reason or protections in place since security through obscurity has proven to be not very robust (just ask AOL) but I see no upside to making that code public. Assuming the source of this parser remains proprietary then your only recourse would be to study its behavior in various situations so you can reverse engineer a code that approximates it. This however would be a monumental undertaking given that this parser not only supports the full v4 BBcode vocabulary but also has added alternative HTML-like formats and a lot more tags to the V5 vocabulary with your best bet now being to reference the full HTML vocabulary to see what is not supported rather than the other way around. It has also gone through numerous edits to add even more features and there is no reason to believe that will stop in the future. You will therefore not only need to expend great effort trying to approximate it but also periodically expend great effort to keep it updated after any changes have been made. All this effort although noble is in my view not necessary when a preview tab already exists. If you were to somehow obtain special permission to abuse the system as stated above the results returned would be the very same results the preview tab receives so if your reason for creating such a plugin is because you dislike the results returned by the preview tab then depending on the official parser would not help in anyway. You would need to build a better mousetrap if you do not like the current mousetrap.
|
|
inherit
172351
0
Sept 5, 2019 10:56:35 GMT -8
DarkPikachu
Complexity == Fun
320
October 2011
tcll
|
Post by DarkPikachu on Nov 2, 2013 11:47:06 GMT -8
Q: is it possible to use code from certain plugins which modify BBC?? such as todge's spoiler plugin??
if there's any plugins that make server requests, I'll do a workaround.
|
|
inherit
172351
0
Sept 5, 2019 10:56:35 GMT -8
DarkPikachu
Complexity == Fun
320
October 2011
tcll
|
Post by DarkPikachu on Nov 2, 2013 12:29:26 GMT -8
ok... so I've been searching google (for almost a day now) and am taking much longer than expected to find a decent match for what I need... I'm looking for a regex that'll parse URLs in text, but NOT operate on links surrounded by url BBC tags. I'll continue looking, and update if I find anything, but if not, could I request a regex plox?? EDIT: uugh... ok... my searches don't seem to be returning anything good... (to the slightest bit of good) anyone else have any searches with something decent I could try?? I really hate google and question myself as to why I still use it XD (it doesn't seem to be good for programmers)
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,017
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Nov 3, 2013 1:28:04 GMT -8
Q: is it possible to use code from certain plugins which modify BBC?? such as todge's spoiler plugin?? if there's any plugins that make server requests, I'll do a workaround. That would be a question best posed to the author whose work you're looking to lift, you wouldn't want to be a LeDuff and use someone else's work without proper permission and citation ok... so I've been searching google (for almost a day now) and am taking much longer than expected to find a decent match for what I need... I'm looking for a regex that'll parse URLs in text, but NOT operate on links surrounded by url BBC tags. I'll continue looking, and update if I find anything, but if not, could I request a regex plox?? EDIT: uugh... ok... my searches don't seem to be returning anything good... (to the slightest bit of good) anyone else have any searches with something decent I could try?? I really hate google and question myself as to why I still use it XD (it doesn't seem to be good for programmers) JavaScript's flavor of regex supports lookaheads it does not officially support lookbehinds, however if you use the variant of the replace method that allows a function to evaluate and return a replacement string then you have access to the original source string as well as the current index within that string making it easy to look left and right before crossing the street.
|
|
inherit
172351
0
Sept 5, 2019 10:56:35 GMT -8
DarkPikachu
Complexity == Fun
320
October 2011
tcll
|
Post by DarkPikachu on Nov 3, 2013 5:27:05 GMT -8
Q: is it possible to use code from certain plugins which modify BBC?? such as todge's spoiler plugin?? if there's any plugins that make server requests, I'll do a workaround. That would be a question best posed to the author whose work you're looking to lift, you wouldn't want to be a LeDuff and use someone else's work without proper permission and citation ah, so it is possible. and of course I'd ask for permission :3 thanx though +1
|
|
inherit
172351
0
Sept 5, 2019 10:56:35 GMT -8
DarkPikachu
Complexity == Fun
320
October 2011
tcll
|
Post by DarkPikachu on Nov 3, 2013 17:33:37 GMT -8
hmm... the style for <code></code> doesn't seem to be working >.> that could be a problem on other forums as well as mine :/
is there any workaround for this??
also... how could I get the display name and profile pic of the person you're quoting??
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,017
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Nov 4, 2013 2:32:26 GMT -8
hmm... the style for <code></code> doesn't seem to be working >.> that could be a problem on other forums as well as mine :/ is there any workaround for this?? also... how could I get the display name and profile pic of the person you're quoting?? Without knowing the details (what style in particular is not working) as well as a link to where this is demonstrated (so your rule can be compared to the competing rules) then all I can say is in CSS specificity rules the day. If there is a rule more specific than the rule you made then your rule will always lose until you give it more ammunition. And by that I don't mean just slapping an important modifier on your rule since that would be like using a bazooka to take out a fly which will most likely work but also result in taking out the dining room and half of the kitchen. The next time you go to cook you'll have a much harder time at it.
|
|
inherit
172351
0
Sept 5, 2019 10:56:35 GMT -8
DarkPikachu
Complexity == Fun
320
October 2011
tcll
|
Post by DarkPikachu on Nov 4, 2013 5:33:14 GMT -8
I ROFL'd XD I'm using the forum's CSS as I want to use the existing styles which you've already defined in your forum's theme editor (not CSS editor) every other BBC tag works properly when it comes to styles. (links and quotes so far) I've implemented spoilers as the default type... heh so here's my code for the parser so far: function parse_quote_bbc(fields, quote_content) { var quote_author = /author="(.+?)"/g.exec(fields) var quote_timestamp = /timestamp="(.+?)"/g.exec(fields) var quote_source = /source="(.+?)"/g.exec(fields) if (fields==null) { var quote_header = '<div class="quote no_header"><div class="quote_body">' } else { var quote_header = '<div class="quote" source="' quote_header += quote_source quote_header += '" timestamp="' quote_header += quote_timestamp quote_header += '" author="' quote_header += quote_author quote_header += '"><div class="quote_body"><div class="quote_avatar_container">' quote_header += '<div class="avatar-wrapper avatar_size_quote avatar-1">' quote_header += '<img src="http://images.proboards.com/v5/defaultavatar.png" alt="' quote_header += quote_author quote_header += ' Avatar"/></div></div><div class="quote_header"><a href="' quote_header += quote_source quote_header += '"><abbr data-timestamp="' quote_header += quote_timestamp quote_header += '" class="time" title=""></abbr></a><span itemscope="" itemtype="http://schema.org/Person">' quote_header += '<a href="/user/1" class="user-link user-1 group-9" itemprop="url" title="' quote_header += quote_author quote_header += '" style="color: #cc3300;" data-icon-check="1"><span itemprop="name"> ' quote_header += quote_author quote_header += '</span></a></span> said:</div>' } return quote_header+quote_content+'<div class="quote_clear"/></div></div>' } function display_bbc(code) { code = code.replace(/\[/g, "[") code = code.replace(/\]/g, "]") return code }; function Spoiler_action(div) { if (div.getElementsByTagName('div')[0].style.display != 'block') { div.getElementsByTagName('div')[0].style.display = 'block'; div.getElementsByTagName('a')[0].innerHTML = 'SPOILER: Click to hide'; } else { div.getElementsByTagName('div')[0].style.display = 'none'; div.getElementsByTagName('a')[0].innerHTML = 'SPOILER: Click to show'; } } function convert_bbc_to_html( str ) { //display formatting str = str.replace(/</g, "<") str = str.replace(/>/g, ">") str = str.replace(/\n/g, '<br/>') //str = str.replace(/ /g, ' ') //str = str.replace(/'/g, "'") //str = str.replace(/"/g, """) str = str.replace(/\[code\](.+?)\[\/code\]/g, display_bbc('<pre><code>$1</code></pre>') ); str = str.replace(/\[quote\](.+?)\[\/quote\]/g, parse_quote_bbc(null, "$1") ) str = str.replace(/\[quote(.+?)\](.+?)\[\/quote\]/g, parse_quote_bbc("$1", "$2") ) //old-style BBC tags str = str.replace(/\[size=(.+?)\]/g,'<font size="$1">'); str = str.replace(/\[\/size\]/g,'</font>'); str = str.replace(/\[color=(.+?)\]/g,'<font color="$1">'); str = str.replace(/\[\/color\]/g,'</font>'); str = str.replace(/\[url=(.+?)\](.+?)\[\/url\]/g,'<a href="$1">$2</a>'); str = str.replace(/\[url\](.+?)\[\/url\]/g,'<a href="$1">$1</a>'); str = str.replace(/\[img\](.+?)\[\/img\]/g,'<img src="$1" />'); str = str.replace(/\[spoiler\](.+?)\[\/spoiler\]/g, '<div style="cursor:pointer;cursor:hand" onclick="Spoiler_action(this)"><a href="javascript:void(0);">SPOILER: Click to show</a><div style="display: none;">$1</div></div>'); //HTML BBC tags str = str.replace(/\[font(.+?)\]/g,'<font $1>'); str = str.replace(/\[\/font\]/g,'</font>'); str = str.replace(/\[table\](.+?)\[\/table\]/g,'<table>$1</table>'); str = str.replace(/\[tbody\](.+?)\[\/tbody\]/g,'<tbody>$1</tbody>'); str = str.replace(/\[tr\]/g,'<tr>'); str = str.replace(/\[\/tr\]/g,'</tr>'); str = str.replace(/\[td\]/g,'<td>'); str = str.replace(/\[\/td\]/g,'</td>'); return str };
you call the function convert_bbc_to_html( str ) and it calls the above functions anything look malformed to you?? keep in mind, I'm not exactly a JS or Regex expert... my area is Python... heh EDIT: I already have the text editor working with the auto update and what not... the visual editor still has problems even previewing with the button... (I think it's calling the display function, but is getting an invalid value) EDIT2: well I've gotten the preview working for the visual editor, so there's no need to comment or anything (just need to update it's spoilers to make it look more like post spoilers) ^and need to fix tables to remove borders speaking of tables, that's another thing that's weird... they have no padding like they should >.> and before you ask, no, I've removed Wormy's code suggestion that breaks table padding. so the default classes for tables and codes are what's breaking... >.>
|
|
inherit
172351
0
Sept 5, 2019 10:56:35 GMT -8
DarkPikachu
Complexity == Fun
320
October 2011
tcll
|
Post by DarkPikachu on Nov 4, 2013 9:54:13 GMT -8
anyone know how to access user data with a plugin?? (it's for the headers of member quotes)
I'm looking for the plugin that changes an @username to the display name for that user, as I'd like to contact the author about how they did it, but I can't seem to find it... :/
don't worry, I know the function would prbly make calls to the server, so I intend to initialize it at page load, and then index from that data. (as I've learned through GL programming, order means everything, and is improved when efficiency steps in)
|
|
inherit
172351
0
Sept 5, 2019 10:56:35 GMT -8
DarkPikachu
Complexity == Fun
320
October 2011
tcll
|
Post by DarkPikachu on Nov 4, 2013 19:59:44 GMT -8
uugh... this timestamp thing is a freakin pain >.<
what am I doing wrong??
newDate.setTime(quote_timestamp*1000 + newDate.getTimezoneOffset()*60000);
where quote_timestamp = 1277912095 (Jun 30, 2010 at 11:34am)
what's returned is (Thu, 01 Jan 1970 05:00:00 GMT)
|
|