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

BR tags in admin submissions

Quote Reply
BR tags in admin submissions
Hi,
I would like to know what I have to alter to make it so that when I paste in text in the admin section of adding a new link, so that it automatically places the line break html code,
so, if I put in

this place is all about me [br]
and what my dog does in it's spare time[br][br]


I dont want to type in the [br] tags is there someway to get links 2.04sql to insert the line breaks just the way I paste the text into the description?

Also, in the old links it wasnt difficult to use the detailed info page, how do I get that to work in the 2.04 sql version?

Note: < br > was replaced with [br] to make it show up in the forum here.


Quote Reply
Re: BR tags in admin submissions In reply to
regexp will do the trick...

Like:

Code:

$rec->{'ColumnName'} =~ s/\n/< br >/g;


Regards,

Eliot Lee Wink
http://anthrotech.com/
Quote Reply
Re: BR tags in admin submissions In reply to
For the detailed page link use:

<a href="<%build_root_url%>/Detailed/<%ID%>.html">Detailed View!</a>



________________________
Eraser
Insight Eye
http://www.insighteye.com
Quote Reply
Re: BR tags in admin submissions In reply to
< br > tags are so 1997.

my $placeholder = "<p>";
$placeholder .= $input->{Description};
$placeholder =~ s/\n|\r/<\/p>\n<p>/g;
$placeholder .= "</p>";


$input->{'Description'} = $placeholder;

Quote Reply
Re: BR tags in admin submissions In reply to
Could someone explain (in plain english) how one can make LinksSQL recognize line breaks as line breaks? I think the answer is already on this page, but I have no idea how to implement it. Anyone game for explaining this? :)

Quote Reply
Re: BR tags in admin submissions In reply to
Hi,

It's not Links SQL, it's HTML! HTML, or any browser such as Internet Explorer ignores line breaks. So if you have line breaks in your data and display that in HTML, your browser is going to ignore it.

What you want, is to convert line breaks to <BR> tags which your browser will display as breaks. You need a bit of code to do this. Lets say your field name is 'Review' that has a couple paragraphs in plain text that you want to convert to HTML for display. If you add to globals the tag:

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

and then use <%Review_Formatted%> on your template, it will show up nice and formatted. =)

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: BR tags in admin submissions In reply to
Hey Alex :)

So, I added what you suggested:

Column name is Full_Story
so I added a globals tag called Full_Story_Formatted
and used:

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


in the globals description. I then called the column Full_Story with the tag of Full_Story_Formatted and what I get is a bunch of text that shows the <br>'s in the body of the text as seen through a browser. In other words, it didn't insert line breaks, it just inserted <br>'s into the output and I can see them in IE when looking at the detailed page.

Am I implementing this wrong?

Quote Reply
Re: BR tags in admin submissions In reply to
I may be way off but try removing:

$Full_Story = GT::CGI::html_escape($Full_Story);


Quote Reply
Re: BR tags in admin submissions In reply to
Bingo.

Thanks Paul :)

Quote Reply
Re: BR tags in admin submissions In reply to
Oops, no, change:

$Full_Story =~ s/\n/<BR>\n/g;
$Full_Story = GT::CGI::html_escape($Full_Story);

to:

$Full_Story = GT::CGI::html_escape($Full_Story);
$Full_Story =~ s/\n/<BR>\n/g;

The escape is used so if your story contains < or >, the browser doesn't think it's html.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: BR tags in admin submissions In reply to
Thanks, that worked too. :)

Quote Reply
Re: BR tags in admin submissions In reply to
Hello again. I know this wasn't specified in my first request, but I want my editors, upon submitting a "link" or an article, to be able to specify bold or italics while this text accepts a line break.

I've got the line breaks down now thanks to Alex's code snippet. But now, it won't parse any html code for bold or italics. What you got up your sleeve for this problem, Alex? :)

Quote Reply
Re: BR tags in admin submissions In reply to
Try:

$Full_Story =~ s,\[(/?b)\],<$1>,g;

and

$Full_Story =~ s,\[(/?i)\],<$1>,g;

So you'd use [b][/b] and [i][/i]


Last edited by:

PaulWilson: Sep 9, 2001, 4:44 AM
Quote Reply
Re: BR tags in admin submissions In reply to
Thanks Paul,

Just to clarify: Do I add those two lines to the global I defined as Full_Story_Formatted

so now it would look like this:

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;
}

IS this correct? It seems like what this does is diss-allow any html unless we specify it is allowed, is this correct?

Quote Reply
Re: BR tags in admin submissions In reply to
The way you have it above it will turn newlines into <BR> tags and b and i markup tags will be converted into the proper html

Eg.......

Entering:

Hello my name is

[b]Paul[/b]

and I like [i]food[/i]

.....would result in......

Hello my name is <BR> <b>Paul</b> <br> and I like <i>food</i>



Quote Reply
Re: BR tags in admin submissions In reply to
.......and woiuld look like:

Hello my name is

Paul

and I like food


Quote Reply
Re: BR tags in admin submissions In reply to
If you wish to allow more options you could just use....

$Full_Story =~ s,\[([/\w]+)\],<$1>,g;

So then anything inside [] would be converted to html including

[b]
[i]
[br]
[hr]
[li]

etc.......



Quote Reply
Re: BR tags in admin submissions In reply to
Yippee!

Last edited by:

Evoir: Sep 9, 2001, 12:25 PM
Quote Reply
Re: BR tags in admin submissions In reply to
Does

$Full_Story =~ s,\[([/\w]+)\],<$1>,g;

Take care of bold, italics and all the others you listed? Or do I add this to the global in addition to the bold and italics?

Thanks again Paul, this is really helpful!

Quote Reply
Re: BR tags in admin submissions In reply to
Just that one line will do everything apart from tags with attributes...

But things like...

[li]
[table]
[tr]
[td]
[br]
[li]
[hr]
[script]
[style]

....and more... would all work.



Quote Reply
Re: BR tags in admin submissions In reply to
Hokay so I'm bored.......

Using this:

$str =~ s,\[([/\w\s#"=;:{}]+)\],<$1>,g;

Will support stuff like:

[style]
.{ font-family: verdana; font-size: 10px; }
[/style]

Hello my name is [b]Paul[/b] and [i]I like FOOD![/i]

Hmm what [br][br]is [font color="#ff3333"]your[/font] name?

[li]Bill?[br]
[li]Ben?



Quote Reply
Re: BR tags in admin submissions In reply to
Thanks again.

How would I add this to the resource section? I think this thread would be really helpful for others, too.

Quote Reply
Re: BR tags in admin submissions In reply to
one last ninny question:

If I use Alex's code snippet:
$Full_Story =~ s/\n/<BR>\n/g;

with your code snippet:
$str =~ s,\[([/\w\s#"=;:{}]+)\],<$1>,g;

will the system allow folks to have breaks in lines

like this and will they show up as line breaks, as well as allowing all the [b] codes you just demonstrated?

This is so cool Paul. Really really helpful!

Does one cancel out the other at all?


Last edited by:

Evoir: Sep 9, 2001, 12:55 PM
Quote Reply
Re: BR tags in admin submissions In reply to
Both lines should work together.

Alex's code will convert hidden newlines into br tags and my code will convert [br] into <br>

I'm expecting a reply from Alex any minute hammering my code :)

You can add the thread to the resources section by going to Support > Resources > Add/Update


Quote Reply
Re: [PaulW] BR tags in admin submissions In reply to
ok...another addition to this request.

Is there a way to get this global to recognize email adresses and url's? & automaically parse an email adress or url, so if I type evoir@mail.com, it would automagically make it a hyperlink? (All within this global, of course.)

Couldn't hurt to ask. Cool

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
Quote Reply
Re: [Paul] BR tags in admin submissions In reply to
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;
}


Hi Paul,

Can you tell me how I'd go about making this a global that I could pass "any" field into for formatting - not limiting it just to Description or full_Story in this case?

For eg. If I wanted to pass in "Description" or "ShortDescription" or "full_Story" or any other field I've got - this sub will handle them all?

Cheers,
Regan.
Quote Reply
Re: [ryel01] BR tags in admin submissions In reply to
My Xtended Add-Modify-Delete plugin will be able to post links with formatted text (formatted now means: formatted only with newlines). It converts all newlines to <BR> if needed. It is an optional feature, and can be turned off by admin anytime.

The plugin is not available yet. It is still under development. But almost all planned features was implemented & finished already. The admin interface and install script is still missing.

I can also implement, the linking feature of email or http addresses, if some of you ask for this feature.

If you are interested in a such plugin, watch the following thread for news about development state of the Xtended Add-Modify-Delete plugin:
[PLUGIN] Xtended Add.Modify.Delete plugin (XAMD) development news

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [ryel01] BR tags in admin submissions In reply to
You would change $_[0]->{Full_Story} to $_[0]->{$field} and then use:

my $field = shift;

Then you can do:

<%change_to_html($some_field)%>

I think that should work.
Quote Reply
Re: [Paul] BR tags in admin submissions In reply to
Hi!
Yes, I have previously attempted (with others on this thread) to resolve the [br] problem. Having seen that a page on this subject has been added to the resources section, and having re-read all the contributions to this thread, allow me to insist that for me at least the solutions advocated are not satisfactory. Let me add that I am working from a Mac - this may be significant. Here's my case study:

Implementing the following global (based on Alex's which satisfies others):
<%Content_Formatted%>

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

If I enter the following into my Content field:

this is all <B>about</B> me[cr] [cr] => an ordinary carriage return
and this is my second line after a carriage return

Using the global as indicated above, when viewing <%Content_Formatted%> on my browser (IE 5.15) I obtain:

this is all <B>about</B> me<BR>
and this is my second line after a carriage return

You will see that the global has NOT translated either the carriage return - or Bold tags.

Now if I delete from the global the line:
$content = GT::CGI::html_escape ($content);
the following is displayed:

this is all about me (the 'about' is, yes, in bold)

and this is my second line after a carriage return

You will see that the bold tag has been implemented but that now the [cr] has been translated not into a <BR> but a <P> !!

Finally if I display the Content field (ie. not via the global), I obtain:

this is all about me (the 'about' is, yes, in bold)
and this is my second line after a carriage return

and where the [cr] is a proper <BR> !!!

Be assured that I have read/re-read and repeatedly tested all the suggestions of this thread and do not find the solution. This is why I mention I am working from a Mac - when I presume most of you are on PCs. Is this a factor? (All this is important because I have large numbers of long texts where I want to avoid additional hard-coding with html tags.)

I hope someone can provide the explanation and solution.
Charly
Quote Reply
Re: [charly] BR tags in admin submissions In reply to
I am on a mac, and I use LSQL as a content management tool, rather than a link directory. Here is the thing: once you use this global, you cannot use html tags as well. You must choose. Use the global and no html, OR use html and no global. Not both.

I did, however, come up with a solution that allows me to mostly use the global, and sometimes NOT use the global (if I WANT) to use html on a certain page. It is very simple.

Create a global that accepts line breaks, [b], [i] and hotlinks urls and email addresses. This is for general submissions. Sort of like using markup on the forums here. (BTW: Full_Story is my Detailed column name)

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;
}

Then, create a new column in my Links Table, called: html
the colum has two radio buttons: html and markup, I set it default to markup.

Now, in my detailed.html template, I create an If statement.:
<%--this is where LSQL will format the text and accept line breaks and stuff. Defined by a template global in the admin--%>
<br><%if html eq "markup"%><%full_story_formatted%><%endif%>

<%--this is where LSQL will NOT format the text and accept line breaks and stuff. you can use html--%>
<%if html eq "html"%><%Full_Story%><%endif%>

Now, all links are defaulted to "markup" and will use the global, but if I sometimes want to use html, I just check the box when submitting or modifying a link, and it switches back to the old way of calling a column in the database.

Whew. I hope this helps!
You can't have it both ways at the same time!
Evoir

Last edited by:

Evoir: Sep 15, 2002, 10:23 AM
Quote Reply
Re: [Evoir] BR tags in admin submissions In reply to
I guess you can have it both ways if you use the following global (I took your and changed it slightly):
Code:
sub {
my $tag = shift;
$tag = GT::CGI::html_escape($tag);
$tag =~ s/\n/<BR>\n/g;
$tag =~ s,\[(/?i)\],<$1>,g;
$tag =~ s,\[(/?b)\],<$1>,g;
$tag =~ s,(\S+@\S+\.\S+),<a href="mailto:$1">$1</a>,sg;
$tag =~ s,(http://\S+),<a href="$1" target=_blank>$1</a>,sg;
$tag =~ s,\[([/\w]+)\],<$1>,g;
return $tag;
}
then you can just use

<%my_global($Full_Story)%>

in you template (or you can put <%Full_Story%> if you don't want the substitutions done). This works with any other tag, not only Full_Story.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] BR tags in admin submissions In reply to
Yogi,

are you saying that if I use your global (above) and use this in my detailed page:

<%my_global($Full_Story)%> I can then mix html and markup on my pgaes? Like if I wanted to add more complex html, like a nested table or a form (in html) I could as well as using markup like: [b] [i] and line breaks? I guess I don't understand, becasue if it is parsing urls and email addresses, then those could not be part of the html. [:/]

Curious....

Last edited by:

Evoir: Sep 15, 2002, 10:36 AM
Quote Reply
Re: [Evoir] BR tags in admin submissions In reply to
Evoir, thanks for the assistance. I'm testing it out. By the way, I'm also managing a content management system and it's with DBMan SQL.

What you made me realise is that I had probably misunderstood some basic terms. Correct me/ confirm my new understanding:

What you term 'HTML' is ordinary text that is processed by our gossamer engined sw to produce good old HTML that shows up nice in our browsers. and what you call 'mark up' is text where WE give it HTML tags BEFORE it is given to the sw.

Am I correct? (I fear I got it the other way around!!)

I'll test and get back on to you, because there's another aspect to this problem, namely the importing of text data from our dtabase programs (mine's Filemaker Pro)... more later, thanks
Charly
Quote Reply
Re: [charly] BR tags in admin submissions In reply to
well, I created a column, and called it html (just a name) and within it, I created two choices html/markup

Markup uses the global that recognizes , line breaks and urls and email addresses. I used the term markup because GF uses that term when you post on the forum here.

html uses the standard column (that allows you to use html tags in it) but does not understand what line breaks are or is.

Honestly, they are just names that I gave things. I hope that doesn't confuse it more.

The idea is that based on which choice you make when adding a "link" you can have it either use the markup global, or not. This way, when my editors want to add a story, they can do so pretty easily. Urls and email addresses are hotlinked automatically, line breaks are recognized. But sometimes I want to add pages that have a table in it, or a form, and I would choose the "html" option, and have it bypass the global.

Smile took me a while to figure it out, but it is a really simple solution.
Quote Reply
Re: [Evoir] BR tags in admin submissions In reply to
Hi again,
Here is the answer to my problem of invisible carriage returns, solution provided by Paul (thanks)

my global is called <%convert0B% and converts all occurences of hex 0B in the data records that I import into my DBMan SQL database.

sub {
my $tags = shift;
my $content = $tags->{Content};
$content =~ s/\x0B/<br>/sg;
return $content;
}

Now my un-tagged straight text (with paragraphs) gets correctly displayed - with paragraphs.
Phew, that was a long search!
Thanks all
Quote Reply
Re: [Alex] BR tags in admin submissions In reply to
Thank you everyone to provide skills. I add a bit to it.

sub {
my $tags = shift;
my $content = $tags->{Content};
unless ($content =~ /<br>/i or $content =~ /<p>/i) {
$content =~ s/\n/<BR>\n/g;
$content =~ s,(\S+@\S+\.\S+),<a href="mailto:$1">$1</a>,sg;
$content =~ s,(http://\S+),<a href="$1" target="_blank">$1</a>,sg;

}
return $content;
}

Then the system can smartly decided wether convert line break. If text contain <br> or <p> (it seemed a html content), it will show as is. Otherwise (it seemed a plain text), it will convert line break.
Quote Reply
Re: [cfox] BR tags in admin submissions In reply to
Hi,

I have a small problem with the conversion of URL's.

I use the following Global:

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

However - if a URL looks like:
http://www.oracle.com/me with a <br> right after it (or even worse some text) then the following URL is created...

<a href="http://www.oracle.com/me<BR>" target=_blank>http://www.oracle.com/me<BR>some text</a>


Any ideas?

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] BR tags in admin submissions In reply to
Got it sorted...

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

http://www.ameinfo.com
Quote Reply
Re: [kuplo] BR tags in admin submissions In reply to
Hi Guys,

I was looking for the same solution and was forwarded to this thread. Suddenly I recalled something I've seen before by which you can format your input in textarea in WYSIWYG way. Then I found HtmlArea at http://www.interactivetools.com/products/htmlarea/. It's free and easy to add to your html input form.

This will get rid of all the pain adding <>s or []s.

Enjoy.

Thanks to this thread, it leads me to HtmlArea.

Long
Quote Reply
Re: [long327] BR tags in admin submissions In reply to
Hi,
I'm using this global, just to have a line break in the link description.

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

The global works fine on category pages, but it does not work in search results!
Did I miss something?
I can not find a description tag in the search_results.html template. So where is the description from?

Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] BR tags in admin submissions In reply to
Hi,

Erm, you sure you don't mean in link.html? search_results.html only has <%Description%> in the <%loop links_results%> loop.

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] BR tags in admin submissions In reply to
Hi Andy,
here is the important part in my link.html

<%if Description%><div class="linkdescription"><%if highlight%><%Links::Tools::highlight($Description, $query)%><%else%><%description_br%><%endif%></div><%endif%>

description_br is the name of the following global, which enables a line break on every page except in search results?

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

Again, the global works fine, but not in search_results.html. In search_results.html there are no line breaks???

Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] BR tags in admin submissions In reply to
Hi,

Do you have "highlighting" enabled?

My guess, is that this bit in link.html:

Code:
<%if Description%><div class="linkdescription"><%if highlight%><%Links::Tools::highlight($Description, $query)%><%else%><%description_br%><%endif%></div><%endif%>

...is running:

Code:
<%Links::Tools::highlight($Description, $query)%>

You could try this:


Code:
<%if Description%><div class="linkdescription"><%if highlight%><%set Description = Links::Tools::highlight($Description, $query)%><%description_br%><%else%><%description_br%><%endif%></div><%endif%>

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] BR tags in admin submissions In reply to
Andy wrote:
Hi,
Do you have "highlighting" enabled?

Hi Andy,
yes the error comes from the highlighting and your code works nearly fine, but now the hightlightning is disabled in description.
The css tags for the highlightning are only printed out as text?

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] BR tags in admin submissions In reply to
Hi,

Mmm.. you could try commenting out:
Code:
$Description = GT::CGI::html_escape($Description);

..so it looks like:

Code:
#$Description = GT::CGI::html_escape($Description);

It looks like its escaping the code from the "highlighting" bit =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] BR tags in admin submissions In reply to
Andy wrote:
Hi,

Mmm.. you could try commenting out:
Code:

$Description = GT::CGI::html_escape($Description);


..so it looks like:

Code:
#$Description = GT::CGI::html_escape($Description);


It looks like its escaping the code from the "highlighting" bit =)

Cheers

Upps,
that's not a good idea. It destroys the layout of the desription field :-(

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] BR tags in admin submissions In reply to
Hi,

Can you paste an example of the code that is showing escaped? (i.e the HTML output). Should be able to do a reverse conversion =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] BR tags in admin submissions In reply to
Hi Andy,
here a some weird descriptions after I uncommented escape html.
http://www.gpaed.de/Unterrichtsmaterial/Arbeitsblaetter/Deutsch/index.html

Perhaps its only that part ---> that causes the problem.

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] BR tags in admin submissions In reply to
Hi,

Are you refering to this kind of thing?

Quote:
Erarbeitung der Buchstaben U, u neu

visuelle Diskriminierung U, u
- AB Gedicht: Uhu Ulu --> visuelle Diskriminierung U, u
--->
- AB U prickeln, schreiben
- AB U legen, schreiben
- AB U Schreibblatt Diff leicht
- AB U Schreibblatt Diff leicht
- AB u prickeln, schreiben Diff leicht
- AB u prickeln, schreiben Diff schwer
- AB u legen, schreiben
- AB u Schreibblatt
- AB Stempelblatt U, u (angepasst an den Leselehrgang Lernen mit Hand und Fuß)
- AB Gedicht: Der Wurm macht nachts --> visuelle Diskriminierung U, u
- AB Gedicht: Uhu Ulu --> visuelle Diskriminierung U, u

Another option - do you need the highlighting? It does complicate things somewhat =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] BR tags in admin submissions In reply to
Hi,

I've been having a play on your site, and got it to work fine =)

I made a new global, <%description_br_search%> - with this code:

Code:
sub {
my $tags = shift;
my $Description = $tags->{Description};
$Description = GT::CGI::html_escape($Description);
$Description =~ s/\n/<br>\n/g;
$Description = Links::Tools::highlight($Description, $IN->param('query'));
return $Description;
}

Basically, what it does - is does the "highlight" AFTER the <br /> tags have been done. This way, it works perfectly, as its not trying to encode the highlight HTML :)

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] BR tags in admin submissions In reply to
HI Andy,
yes thats the part.
Yes I need the highlighting, I think it's better to go back to NO linebreaks in search results ;-(
May be in one of the next versions line breaks are part of glinks and there is no need of a global anymore...

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] BR tags in admin submissions In reply to
Hi,

It should all be sorted for you :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] BR tags in admin submissions In reply to
And I was wondering where the new global comes from :-)

Just to understand it.
So you created a second link.html called search_link.html with the <%description_br_search%> tag inside?

Thanks Andy works fine.

In the last months I changed a lot in my gossamer links installation.
I have many changes in the templates and a lot of globals.
Will I run into problems, when they release updates?

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] BR tags in admin submissions In reply to
Hi,

It is actually called link_search.html :)

Quote:
In the last months I changed a lot in my gossamer links installation.
I have many changes in the templates and a lot of globals.
Will I run into problems, when they release updates?

Nope, as long as you make sure you backup your whole /admin/templates/luna template folder, in case it gets overwritten :) (it shouldn't do, but its always better safe than sorry =))

Also, I think all the changes you have made code wise, are in plugins - so they shouldn't be affected with updates either.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] BR tags in admin submissions In reply to
Andy wrote:

Nope, as long as you make sure you backup your whole /admin/templates/luna template folder, in case it gets overwritten :) (it shouldn't do, but its always better safe than sorry =))

Also, I think all the changes you have made code wise, are in plugins - so they shouldn't be affected with updates either.

Glad to hear that. I think I will do some backups now Cool
And thanks again.
Matthias

Matthias
gpaed.de