PDA

View Full Version : UBB mods [was "not enough??"]


Jacob Stetser
02-03-1999, 01:26 PM
Hey justin,

Like your changes... how did you add that status label in your UBB? That's cool! and where did you add the "each message is a table" mod?

I need to make some mods myself!

Jake

Justin
02-03-1999, 07:42 PM
Is this the sequel to "not enough??" http://www.aota.net/ubb/smile.gif

I will assume the free version (that's what I've got), and I would also assume that the full version would differ slightly.

I don't know the line numbers, either, because I've done a lot of HTML tweaking as well (I still say that the writers of the UBB don't know HTML like they do Perl). But anyway, here goes:

First, the tables. Open up ubb_library2.pl in your favorite text editor. Scroll down until you find this:

} # end if not stat line and not father line
} # end reply loop
} # end Count > 0 loop

Those are comments, but they're the only thing that makes this sub distinct. Scroll up a few lines to the next $ThisThread .= qq( statement. Between the ( and ) is the reply loop, meaning it gets repeated for each reply. Here's what mine looks like:

if (int($Num/2) == ($Num/2)) {
$Acol = $Cell1;
} else {
$Acol = $Cell2;
}
$Num = ($Num + 1);
$ThisThread .= qq(
<table width=$TableWidth border=0 cellpadding=2 cellspacing=2>
<tr bgcolor=$Acol>
<TD width=18% valign=top><FONT SIZE=3 face="$FontFace" color=$TextHiLite>$thisline[2]</FONT>
<font size=1 face="$FontFace">$UserType</font></td>
<TD><IMG SRC="$NonCGIURL/posticon.gif" BORDER=0>
<FONT SIZE=1 face="$FontFace">posted $ThisDate $FormatTime $TimeZone [nbsp][nbsp][nbsp]
<A HREF="$CGIURL/ubbmisc.cgi?action=getbio&UserName=$UserNameCoded" target=_new>
<IMG SRC="$NonCGIURL/profile.gif" WIDTH=22 HEIGHT=11 BORDER=0 ALT="Click Here to See the Profile for $thisline[2]"></A>$EmailString [nbsp][nbsp]</font>
<HR><font size=2 face="$FontFace">$ReplyText</FONT></td>
</tr>
</table> );

The little math evaluation is what decides which of the two alternating colors to make the background of each reply - for some reason, the table thing breaks the alternating colors, so I just did it myself. Mine is the only one I've seen with the table mod AND still having alternating BGCOLOR's.

$Cell1 and 2 are defined in Styles.file and are set to my alternating colors. There are other variables that I created too, so I hope they don't confuse you too much.

Basically, just insert <table width=95% border=0> at the beginning of that loop, and </table> at the end, and also go above this to the part that looks similar and clost that table at the end, and set it's <tr bgcolor= to $Cell2. That way the starting color is 2, the next reply is 1, etc.

Now, you'll also notice another variable in there: $UserType. This is defined a few lines above the reply sub by me, and that sets the user's status:

@thisprofile = &OpenProfile("$thisline[2].cgi");
$EmailView = $thisprofile[11];
$UserType = $thisprofile[8];

That will set the variable to the user's status and show it in the table.

You also have to open up postings.cgi and find the same subs (similar) and do the same mods, so that a new topic gets these too, not just replies.

If you are confused at all (I am) just let me know and maybe I can explain certain parts more clearly (I probably left out some details, asuming you know at least a little Perl - then again, you probably don't have an Apache server installed either http://www.aota.net/ubb/smile.gif)

I have to say that without Apache installed I would have never even attempted to modify the crap out of a script. The point is that I'm not sure if I remember each individual step:
try this, save, reload, that didn't work, cut this and paste that, save, reload, ok, that's better, maybe if that was over there, no, not quite, um, shoot, I screwed it up, ok, where did I just paste that, somewhere, ok, there it is, now if only I knew where I put that darn sub, which file was it in, too many notepads open, ok, it was one of these, not sure...

That's the programmer in me showing. I'm not the type to document every move, even in my real programs (hell, I don't even have the source to my two older versions anymore!).

Let me know (and good luck) http://www.aota.net/ubb/biggrin.gif Actually, if you want, I could just send you the files (the colors are defined by variables, the way it should have been!).

Justin
-- I think I just confused myself --

Justin
02-04-1999, 08:42 AM
Here's a mod that I think we at FQ could benefit from greatly. Actually, there are two.

In ubb_library.pl, in this sub:

sub UBBCode {

put in this line:

$ThePost =~ s/( )/\&nbsp\;/isg;

That will allow spaces in excess of the normal one allowed in HTML. Now, as for a new UBB code tag, how about [CODE]?

$ThePost =~ s/(\[CODE\])(\S+?)(\[\/CODE\])/<font face=\"Courier\" size=3><blockquote>$2<\/blockquote><\/font>/isg;

This allows a fixed width font, for code samples (like the one above), and in combination with the [nbsp] hack, you could easily format code snippets.

You could skip the blockquotes, but it makes for a nice display. I would use the <code> html tag, but the font size gets too small, plus it looks different in different browsersaurs. Of course, you could add HR's, but I prefer to leave that to quote's.

One note: the [nbsp] hack MUST go first in the UBBCode sub so as not to put [nbsp]'s in the HTML that it adds later. Remember, it converts every space to an nbsp. Makes for some nasty looking code, but the end result in nice.

I did this to mine locally and will be uploading it shortly. I also added a [red] tag, to hilight text in addition to the bold tag.

I really think that the code tag would be awesome (they are considering it in the next version - a one minute job to add!)

http://www.aota.net/ubb/smile.gif

Justin

Justin
02-04-1999, 08:44 AM
hehe http://www.aota.net/ubb/smile.gif Everywhere in the above post where there is an extra space is an nbsp with an ampersand in front and a semicolon afterwords http://www.aota.net/ubb/smile.gif

Oops!

Justin
02-04-1999, 09:58 AM
Ok, this is much easier shown than explained. If you'd like to see the code tags and the space hack in action, go to:

http://www.vdj.net/ubb/Forum1/HTML/000003.html

Feel free to post in there, too http://www.aota.net/ubb/smile.gif I really don't care too much. It's not really all that official. I'd like any opinions on the mods, and it's easier to give an opinion if you've used it.

I will be leasing the full version when I can afford to, and I will probably modify it beyond recognition http://www.aota.net/ubb/smile.gif

Justin

Justin
02-04-1999, 01:19 PM
Thanks http://www.aota.net/ubb/smile.gif Don't use the above code, as it didn't quite come out right. I'm trying to get it to automagically show raw HTML like & nbsp ; without the spaces. It is supposed to convert these when it stores them, and it does, but when formatting the actual HTML page, it puts it back - resulting in a non breaking space being shown. I want it to show everything literally, as typed, like the spaces, but with code.

Especially useful for the HTML sections of this UBB. How do you show someone how to properly display a < and > if they come out < and >? http://www.aota.net/ubb/smile.gif (they aren't supposed to look the same above).

Basically, I want to idiot-proof the thing, so that what you type in comes out exactly (except, of course, for the UBB tags).

Thanks for the compliments http://www.aota.net/ubb/smile.gif I'm having a blast learning Perl.

Justin
-- Now, if only I can get some people to visit the thing --

Del
02-04-1999, 03:35 PM
Okay, here's an idea. Instead of just having a [red] tag, how bout a [color=whatever] tag? I haven't tweaked on it at all yet, but it prolly should be similar to below (but I'm the first to admin my regexp's need some serious work. For the life of me I can't remember how well Perl handles nested parens to save stuff, and I'm at school without my Perl/O'Reilly library *sniffle*);

$ThePost =~ s/(\[COLOR=(\S+?)\])(\S+?)(\[\/COLOR\])/<font color=\"$2\">$3<\/font>/isg;

Or, it's quite possible noone likes that idea but me, so I'm gonna shut up now http://www.aota.net/ubb/smile.gif

<edit>
Oh yeah,
Justin, in the previous thread of 'not enough' you commented on Nutscape having a 'no self.status'. If I understand that correctly, you mean the status bar at the bottom displaying a message? (like onMouseOver="self.status='blah'; return true'"). The one that works for nutscape is
onMouseOver="window.status='blah'; return true'". However, please don't forget the
onMouseOut="window.status=''; return true;"
cause I really hate it when my status bar sticks on the last message I mouseovered http://www.aota.net/ubb/wink.gif
</edit>

------------------
Del
www.downinit.com (http://www.downinit.com)

da da da


[This message has been edited by Del (edited 02-04-99).]

Justin
02-04-1999, 11:21 PM
I hate that too - I've always used the mouseout thing. I just tried the window.status, and it works in IE also. Why didn't I know that before?

I still don't know what "return true" is for - never noticed a difference at all, so I just leave it out.

About the [color=xxxxxx], I like that idea. Your code should work for that, or something similar. I might do that instead of red - I just figured that people might get too carried away. Then again, some UBB's allow HTML - big mistake IMO.

If I keep this up, I'm going to have to rewrite the faq for mine http://www.aota.net/ubb/smile.gif I also did a copyright thing, where typing (c) becomes &copy;.

Justin
--&copy;1999 SFE Inc. All Rights Reserved (reserved for who?)--

Deb
02-05-1999, 12:43 AM
This is GREAT!!!

I know we'll be adding some of this to the v.2.5 as soon as they release it! Terra will like it for the A/B/G Forum w/o a doubt http://www.aota.net/ubb/smile.gif

(hate to add it now knowing will be upgrading soon)

Good job!!!

Deb

Justin
02-05-1999, 11:50 PM
Well, I decided to add a search engine to the UBB and I ran into an infinate loop or two. Luckily it was only on my own computer http://www.aota.net/ubb/smile.gif I am just glad that I did all of my experimenting locally.

The search thing works well so far, now that I figured out what was locking it up. It did this while writing an index of what it found - I wound up with an 8 meg index (of a few k site) after 20 seconds...

Just wondering if there is protection on FQ's server against this type of problem - in the unlikely event that someone cause an infinate loop like that. I remember seeing something about runaway scripts being killed or something - don't remember where though.

It didn't actually crash the computer though, just Apache - where in Visual Basic, certain API's, if not called carefully, can cause blue screen errors of death http://www.aota.net/ubb/redface.gif

I'm just curious (as always).

Justin
--may all your packets have optimal checksums-- <-- I stole that from somewhere...

Justin
02-07-1999, 01:08 PM
Actually, I found a free search engine script and combined it with the UBB. I just had to fix it, too - it said "Content Type: text/plain" instead of HTML. IE didn't care, but Netscape displayed the HTML.

But anyway, here's what I did. I had the ubb_library2.pl file put comment tags in the HTML pages that are generated. There's <!-- TOTAL=n --> , and before and after each message is <!-- MESSAGE n --> and <!-- /MESSAGE n -->.

The search script searched through meta tags and title tags by default. I changed it to first look at the TOTAL tag, then look in each message for the keywords. It also looks at the title and that counts 3 times what other words do. The title is the message subject, so it's more important.

But basically it's a full text search. It doesn't have all of the options, like searching for certain user's posts, or certain dates and stuff, but it works for now. I will eventually have it search the UBB files instead of the HTML, but it seems efficient enough for a smaller UBB like mine.

I now have a password protected section, too, where you need a password to view messages as well as post. It uses .htaccess for that, and a little tweaking to forumdisplay.cgi to redirect to a password protected page. So far so good, but it's only been there a few minutes...

But the search isn't too hard to do. I took the indexing script and the search script and combined them into one, then put a search box right on the front of the BB for easy spotting. It's pretty good about finding stuff, but we'll see what happens when I get a lot more posts (just look for the keywords "test post", you'll get some hits!)

It has the same overall look of the UBB, too, even if i change the color scheme. I used the variable files for that. Free version doesn't have them, but I went through all of the HTML and added variables. I just edit one file and the whole thing changes.

Oh, you might want the URL to the search engine script: http://www.xav.com/scripts/xavatoria/index.html

There's three different one's there; that link takes you to the one I used.

There are a lot of mods that I did, so I hope you know Perl very well or at least programming in general. I'm more the latter, but Perl is easy.

Good luck. Let me know if you have any questions, or if you just want the modified script for the search part.

http://www.aota.net/ubb/biggrin.gif


------------------
Justin Nelson, SFE Inc.
http://www.vdj.net

Stephen
02-07-1999, 09:05 PM
Justin,

Thanks. I downloaded a copy of the Xavatoria script and will check it out when I have some spare time. I appreciate the pointer. I don't believe in re-inventing the wheel, so starting where someone else is currently taking a breather is generally the way to go in my opinion.

Cheers,
Stephen

Stephen
02-08-1999, 12:27 AM
Justin,

I noticed that you mentioned yours is a customized version of the UBB freeware package. I've gone the same way and (to teach myself some Perl/CGI) tried to reconfigure the freeware version so that it pretty much performs as the licensed version does. The only major missing component is a search engine. Did you write yours yourself? If so, what are its capabilities (do they compare to the SE on the licensed version)?

I figured I'd probably get around to writing the code for this myself, but it has been the last thing on my list. Any comments about what I should or should not do about adding an SE would be appreciated.

Thanks,

-Stephen (who's new to this board by the way)