Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

BR tags in admin submissions

(Page 2 of 4)
> > > >
Quote Reply
Re: [Evoir] BR tags in admin submissions In reply to
Hi,

What does your global look like now? Thought I'd modify it from that one..

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] BR tags in admin submissions In reply to
Smile

Code:
sub {
my $tags = shift;
my $Full_Story = $tags->{Full_Story};
$Full_Story = GT::CGI::html_escape($Full_Story);
$Full_Story =~ s/\n/<BR>\n/g;
$Full_Story =~ s,\[(/?i)\],<$1>,g;
$Full_Story =~ s,\[(/?b)\],<$1>,g;
return $Full_Story;
}

That's what I am using to format the main articles. Would be cool if it could parse email adresses and urls too.

Alex, this is way cool.

Quote Reply
Re: [Evoir] BR tags in admin submissions In reply to
Hi I think this may work for emails...:

$Full_Story =~ s,([^\s]+@[^\s]+\.[^\s]+),<a href="mailto:$1">$1</a>,sg;

...and for urls....

$Full_Story =~ s,(http://[\w\.-]+),<a href="$1">$1</a>,sg;

The code for checking the email address could just be .+@.+\..+ but that won't work in this case.

I can't believe how bad the code was in this thread after I re-read it this morning :) ...it was only from September too Laugh....having said that the code above isn't great either.

Last edited by:

PaulW: Dec 14, 2001, 4:22 AM
Quote Reply
Re: [PaulW] BR tags in admin submissions In reply to
You can make the email regex a bit nicer by using:

$Full_Story =~ s,(\S+@\S+\.\S+),<a href="mailto:$1">$1</a>,sg;

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] BR tags in admin submissions In reply to
Oh yeah good point.

Hmm an optional s after http may be good too....

$Full_Story =~ s,(https?://[\w\.-]+),<a href="$1">$1</a>,sg;

Last edited by:

PaulW: Dec 14, 2001, 10:15 AM
Quote Reply
Re: [PaulW] BR tags in admin submissions In reply to
hey guys, just wanted to say thank you. I'm out of town on a dialup, so I'll check this out when I get back. Very nice of you to cook this up for me Wink

Quote Reply
Re: [Evoir] BR tags in admin submissions In reply to
Cool! Thank you all. And some other ideas:
With the code above i dont need to giveRobert[/size]
Quote Reply
Re: [Paul] BR tags in admin submissions In reply to
Hello again

I'm still working on this. [:P] So, I have the following as a global
sub {
my $tags = shift;
my $Full_Story = $tags->{Full_Story};
$Full_Story = GT::CGI::html_escape($Full_Story);
$Full_Story =~ s/\n/<BR>\n/g;
$Full_Story =~ s,\[(/?i)\],<$1>,g;
$Full_Story =~ s,\[(/?b)\],<$1>,g;
$Full_Story =~ s,(\S+@\S+\.\S+),<a href="mailto:$1">$1</a>,sg;
$Full_Story =~ s,(http://[\w\.-]+),<a href="$1" target=_blank>$1</a>,sg;
$Full_Story =~ s,\[([/\w]+)\],<$1>,g;
return $Full_Story;
}

and when I put a url like: http://dolphin.upenn.edu/~lgba the system only makes the http://dolphin.upenn.edu/ active as a link, it drops off the ~lgba

Is there a way to make it recognize this? I would be fine if I had to surround url's with

[url] [/url]

Thanks again.

Last edited by:

Evoir: Mar 27, 2002, 6:18 PM
Quote Reply
Re: [Evoir] BR tags in admin submissions In reply to
Its my dodgy code. Try changing:

$Full_Story =~ s,(http://[\w\.-]+),<a href="$1" target=_blank>$1</a>,sg;

to:

$Full_Story =~ s,(http://\S+),<a href="$1" target=_blank>$1</a>,sg;

....It won't check for perfect formatting but will hyperlink at least :)
Quote Reply
Re: [Paul] BR tags in admin submissions In reply to
First my enormous thanks for everyone's contributions to this thread, providing solutions for one of my headaches.

May I add a supplementary query?

I cut and paste texts from my Word files into DBMan SQL fields. The original texts display normally with paragraphs etc. in my database programme from which I export tab-delimited records into DBMan SQL.

Despite the mods you and others have indicated, these plain text documents do not display in DBMan views WITH the paragrphs and line breaks. If I modify a record and manually insert a CR just to test, then the global works and the break is displayed.

So I examined the exported data and found two small 'box' symbols between paragraphs. Checking these, their hex value is 0B. Now the question: can we also convert these to <CR>s in the global?
Thanks again for helping me so much.
Charly
Quote Reply
Re: [Paul] BR tags in admin submissions In reply to
Ok, I am still at this. While the code Paul and Alex (am I forgetting anyone?) came up with is cool, what I really want is LSQL to accept a line break as a <br> tag.

I had all the the [b] and other tags working too, but I found I didn't want to set up two sets of code for my editors, one for the full article, and another way to bold and italics the synopsys etc.

So, what I'd like is for LSQL to make a line break mean a <br> and also accept a <b> tag or an <i> tag. This would help my editors have success in learning the tags. Also, I may sometimes want to add html elements to the articles (forms?). For that I'd like to use html.

Is there a way to modify this global to do this? Is there another approach?

My current globl is:

sub {
my $tags = shift;
my $Full_Story = $tags->{Full_Story};
$Full_Story = GT::CGI::html_escape($Full_Story);
$Full_Story =~ s/\n/<BR>\n/g;
return $Full_Story;
}

Last edited by:

Evoir: Jul 18, 2002, 10:41 PM
Quote Reply
Re: [Alex] BR tags in admin submissions In reply to
Alex,

I noticed in the Reviews section of LSQL that there is a toggle for "Convert line breaks to <br> tags:" and I think this is a great admin option! Is there anyway to implememnt this site wide to submissions through LSQL?

This would hopefully solve the issue of having to use this global.

If this were implemented, would the field be able to accept html as well?
Quote Reply
Re: [Paul] BR tags in admin submissions In reply to
Hello Paul :-)

Is it possible to modify this code to recognize also the addresses without http:// prefix (www.some.com) ??

$Full_Story =~ s,(http://\S+),<a href="$1" target=_blank>$1</a>,sg;

Thank you in ahead :-)

Robo
Quote Reply
Re: [Robo] BR tags in admin submissions In reply to
I guess you could although it might start hyperlinking sentences if they match the regex....the http:// just makes it more exclusive to hyperlinks.

Try:
Code:
$Full_Story =~ s,((?:http://)?[\w\-]+\.[\w\-]+\.[\.\w\-]+),substr($1, 0, 7) eq 'http://' ? "<a href="$1" target=_blank>$1</a>" : "<a href="http://$1" target=_blank>$1</a>",seg;
I've not tested that.

Last edited by:

Paul: Jul 31, 2002, 6:38 AM
Quote Reply
Re: [Paul] BR tags in admin submissions In reply to
Hello Paul :-)

Thank you for quick response!
This code is NOT working. I got "Unable to compile..." error.

Robo
Quote Reply
Re: [Robo] BR tags in admin submissions In reply to
Poop, try changing the double quotes around the href="$1" and href="http://$1" to single quotes.

Last edited by:

Paul: Jul 31, 2002, 6:40 AM
Quote Reply
Re: [Paul] BR tags in admin submissions In reply to
HI Paul :-)

Nope - even this is not working:
Code:
$Descripcion_actividades =~ s,((?:http://)?[\w\-]+\.[\w\-]+\.[\.\w\-]+),substr($1, 0, 7) eq 'http://' ? "<a href='$1' target=_blank>$1</a>" : "<a href='http://$1' target=_blank>$1</a>",seg;


Must be something else...

Thank you for your concern Smile

Robo
Quote Reply
Re: [Paul] BR tags in admin submissions In reply to
I am still looking for a solution to this problem: I want LSQL to accept line breaks, hotlink email addresses and urls -- but also to accept html. (I am fine with tagging <b> and <i> in html. Right now it requires [b][/b][i][/i]

Is this at all possible? I don't want to be stuck formatting all my tags in [markup]. And sometimes I'd like to add a form, or a photo to a detailed page in html. This global seems to cut off that option.

Anyway, if someone can help I'd be so appreciative! The current global I have right now is:

sub {
my $tags = shift;
my $Full_Story = $tags->{Full_Story};
$Full_Story = GT::CGI::html_escape($Full_Story);
$Full_Story =~ s/\n/<BR>\n/g;
$Full_Story =~ s,\[(/?i)\],<$1>,g;
$Full_Story =~ s,\[(/?b)\],<$1>,g;
$Full_Story =~ s,(\S+@\S+\.\S+),<a href="mailto:$1">$1</a>,sg;
$Full_Story =~ s,(http://\S+),<a href="$1" target=_blank>$1</a>,sg;
$Full_Story =~ s,\[([/\w]+)\],<$1>,g;
return $Full_Story;
}

Last edited by:

Evoir: Aug 28, 2002, 9:05 AM
Quote Reply
Re: [Evoir] BR tags in admin submissions In reply to
<shudder>

That code of mine was so bad, I'd like to think I could write something better than that now :)

You should be aware of security issues with allowing html for example I could enter:

Code:
<script language="javascript">
for (var i = 0; i < 10000000; i++) {
alert("Hah!");
}
</script>

...along with my resource :)

If you really want it though:

Code:
sub {
my ($full_Story) = GT::CGI::html_escape($_[0]->{Full_Story}) =~ s/\n/<BR>\n/g;
$full_story =~ s/\[([^\]]+)\]/<$1>/g;
return $full_story;
}

That will convert [anything] to <anything>
Quote Reply
Re: [Paul] BR tags in admin submissions In reply to
Thanks. Well, in my case, only staff will be able to add to our database, and users will not have access to it.

I also want it to automagically hotlink urls and email addresses. Coffee would be swell, too.

Does this mean that I still have to put things in [these] brackets? Is there a way to be able to add little html snippits? Like a table, or a form?

(This is a live site, so I want to make sure before I change anything!)

Last edited by:

Evoir: Aug 28, 2002, 9:25 AM
Quote Reply
Re: [Evoir] BR tags in admin submissions In reply to
I can't remember if links sql strips out html or not, it probably does, which it why I think we used [] so if you want to create a table you can just use:

[table]
[tr]
[td]
Something
[/td]
[/tr]
[/table]

...the same way as normal.
Quote Reply
Re: [Paul] BR tags in admin submissions In reply to
The weird thing is that LSQL, as I remember, does NOT strip out html. This global does.

Most ideally, what I'd like is the ability for LSQL to recognize line breaks and urls and email addresses.

Other than line breaks, urls and email addresses, I would prefer to use regular html tags. Is there some way to change the global so that it would allow this? Or is it an all or nothing kind of thing?

Last edited by:

Evoir: Aug 28, 2002, 9:38 AM
Quote Reply
Re: [Evoir] BR tags in admin submissions In reply to
Ok Im confused now, if links doesn't strip out html can't you just enter html as you wish?
Quote Reply
Re: [Paul] BR tags in admin submissions In reply to
tee hee

I wish to automate parts of it, so that when my editors enter a link with a detailed page, line breaks are recognized, urls are recognized and email addresses are recognized (and hyperlinked).

When I use this gloabl, it turns off the ability to just standard html snippets in addition. (for example, a table, or <b> and <i> tags)

I am hoping for a hybrid solution.

I don't want my editors to have to remember <br><br> for paragraph breaks. Or how to link a url. But I want also to have some flexibility for me to add html snippets in there, too.

Is this impossible?

Last edited by:

Evoir: Aug 28, 2002, 9:45 AM
Quote Reply
Re: [Evoir] BR tags in admin submissions In reply to
Code:
sub {
my ($full_Story) = GT::CGI::html_escape($_[0]->{Full_Story}) =~ s/\n/<BR>\n/g;
$full_story =~ s|(\S+@\S+\.\S+)|<a href="mailto:$1">$1</a>|g;
$full_story =~ s|(http://\S+)|<a href="$1" target="newwin">$1</a>|g;
return $full_story;
}

Something like that may work.

Last edited by:

Paul: Aug 28, 2002, 9:52 AM
> > > >