Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-01-25 00:11:55

vik407
Member
From: Cali - Colombia
Registered: 2006-08-25
Posts: 10
Website

[textile] Native textile code for manage link "rel" attributes

Hi, i manage some time to post a little hack to the code of textile and i want to explain here.

The code for manage direct rel attributes without plugins, i know about the zem_prblock plugin to manage spam with rel=“nofollow” and the hacks for standars compilant new windows with rel=“external”.

But textile itself can manage with 3 little changes in the code of the class.

The actual textile code for manage links is:

"Link text (title)":http://example.com

to manage rel attributes the proposal code looks like:

"link text (title){external}":http://example.com

Any content between the braces of the code its automatic parsed by textile in the rel attribute.

So, for nofollow the textile looks like:

"link text (title){nofollow}":http://example.com

And how about compilant rel code for microformats ?

The Xhtml Friends Network is a simple way to represent human relationships using hyperlinks, so it can be used for that like this example:

for a college friend that i meet, the textile code is:

"link text (title){friend met colleague}":http://example.com

Knowing the features now lets make the changes to the code:

The changes

First, make a backup of the actual textile class ;-) …

Go to line 718

<code>
(?:\(([^)]+)\)(?=”))? # $title
</code>

Replace it with

<code>
(?:\(([^)]+)\))? # $title
\s? (?:\{([^)]+)\}(?=”))? # $URLrel
</code>

Now go to the line 732

Replace

<code>
list(, $pre, $atts, $text, $title, $url, $slash, $post) = $m;
</code>

with

<code>
list(, $pre, $atts, $text, $title, $URLrel, $url, $slash, $post) = $m;
</code>

Go to the line 737

<code>
$atts .= ($title != ‘’) ? ‘ title=”’ . $this->encode_html($title) . ‘"’ : ‘’;
</code>

under it add

<code>
$atts .= ($URLrel != ‘’) ? ‘ rel=”’ . $URLrel . ‘” ‘ : ‘’;
</code>

Note: Rel attribute don´t need special chars encoding.

That’s it!

Now test…

This modification works in a website i manage year and a half ago… i send the changes to Dean allen 2 o 3 times but i think im in some spam pot.

My website got the same information and run with the modified version. I write in spanish (my native languaje) and i want to work in some wizards for microformats so this is the very first step to make all happen.

saludos.

Last edited by vik407 (2007-01-25 04:02:00)

Offline

#2 2007-01-25 00:25:37

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [textile] Native textile code for manage link "rel" attributes

Textile is maintained here.

Your {rel} syntax clashes with the Textile syntax already used for styles.


Alex

Offline

#3 2007-01-25 00:49:07

vik407
Member
From: Cali - Colombia
Registered: 2006-08-25
Posts: 10
Website

Re: [textile] Native textile code for manage link "rel" attributes

i try to figure out a container for store rel data… i test before make the changes with:

"link {text-decoration:none}":http://example.com

but the regex for manage styles doesnt works inside a link after the text… so output:

<code>
<a href=“http://example.com”>link {text-decoration:none}</a>
</code>

anyway {rel} can be changed with [rel] or <rel> only need modificating the regex:

<code>
(?:\[([^)]+)\](?=”))?
<code>

for [rel]

or

<code>
(?:\<([^)]+)\>(?=”))?
<code>

for <rel>

saludos

Last edited by vik407 (2007-01-25 01:15:25)

Offline

#4 2007-08-20 22:45:14

keith
Member
From: Blyth, Northumberland, England
Registered: 2004-12-08
Posts: 199
Website

Re: [textile] Native textile code for manage link "rel" attributes

Thanks for this, Vik – it works perfectly and really should be part of the core code.


Keith
Blyth, Northumberland, England
Capture The Moment

Offline

#5 2007-11-09 20:55:28

qrayg
Member
From: USA
Registered: 2004-08-27
Posts: 81
Website

Re: [textile] Native textile code for manage link "rel" attributes

This is a great idea. The only problem I see is how would this work for links on images?

I’m trying to incorporate the rel attribute on links around images for use with LightBox. This idea is great but Textile links images differently.

!/path-to-image.gif!:http://domain.com

Offline

#6 2008-04-12 23:43:29

keith
Member
From: Blyth, Northumberland, England
Registered: 2004-12-08
Posts: 199
Website

Re: [textile] Native textile code for manage link "rel" attributes

Qrayg,

very late I know – I only realised this today – but the following works perfectly (assuming you’ve installed Lightbox or similar) using the hack created by Vik:

"This is a great picture[lightbox]":http://farm4.static.flickr.com/agreatpicture.jpg

In other words, simply replace the word “external” with “lightbox” within the square brackets, and you’re sorted.

Last edited by keith (2008-04-12 23:45:22)


Keith
Blyth, Northumberland, England
Capture The Moment

Offline

#7 2008-05-06 02:17:28

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 206
Website

Re: [textile] Native textile code for manage link "rel" attributes

This doesn’t work for me "link (title){nofollow}":http://my.cool.com why?

Offline

#8 2008-06-24 04:38:21

ehbee
New Member
Registered: 2008-06-24
Posts: 1

Re: [textile] Native textile code for manage link "rel" attributes

First of all, thanks to vik in the first place, I just started using this and it’s great.

I did find a few problems in the code if you were to implement this for Textpattern version 4.06

In my modifications you need to use <> to denote the rel tag, just to keep everybody happy.

line 748 and 749 the code should be:

(?:\(([^)]+?)\)(?="))? # $title
(?:\<([^)]+?)\>(?="))? # $URLrel

That is slightly different than Vik’s both to use the <> and to fix some missing code.

Next, on line 761 the code should be:

list(, $pre, $atts, $text, $title, $URLrel, $url, $slash, $post, $tail) = $m;

This was missing the $tail variable in Vik’s code.

Finally, make sure that all of your single and double quote’s are standard straight quotes and not curly one’s. If you write in a coding app you’ll notice that the color coding of the new line’s are not matching the one’s directly above if the quotes are wrong.

Also I believe you cannot have spaces, correct syntax is

"link(title)<rel>":url

not

"link (title) <rel>":url

That should do it.

Last edited by ehbee (2008-06-24 04:43:04)

Offline

#9 2009-01-16 19:47:29

erikstyles
New Member
Registered: 2009-01-16
Posts: 1

Re: [textile] Native textile code for manage link "rel" attributes

thanks to all of you, especially to you, Vik for this help! I know, the thread is quite old, but anyway, I wil give it a try.

I am trying to have a very simple way to use a lightbox for images in my articles. Everything works fine with the html-workaround:
==<a href="../images/2.jpg" rel="lightbox" title="just a caption"><img src="../images/2t.jpg" alt="some picture" /></a>==

And your code is working fine for text links, e.g.
"a great picture<lightbox>":images/3.jpg

But now, my question is why isn’t this working with images or how can I make it work? I tried a lot of things, but nothing worked. I will continue experimenting, but maybe somebody can help me?

kind regards,
erikstyles

——————————————————

ok, I searched the source code myself and found a solution … the functions image() and fImage() have to be edited.

Last edited by erikstyles (2009-01-16 21:00:01)

Offline

#10 2009-01-16 21:27:13

vik407
Member
From: Cali - Colombia
Registered: 2006-08-25
Posts: 10
Website

Re: [textile] Native textile code for manage link "rel" attributes

Hi people, yes this topic is quite old now but i try to check it again and repost some current versión workaround, i hope to come to a solution in a form of plugin better than a forked file to stick with the main line of the software and forget hacks.

For the people that ask for images. there are no good news, this hack scan the textile code for links and not for images :-S.

I hope to post a final solution soon. Saludos.

Offline

#11 2009-02-06 06:04:28

jrguitar21
New Member
From: Cuenca - Ecuador
Registered: 2009-02-06
Posts: 2
Website

Re: [textile] Native textile code for manage link "rel" attributes

Hi, I’ve posted a patch at drupal.org that enables support for the rel attribute in both regular text-based links and image-based links.

I needed this for a Drupal integration of Textile module and Lightbox2 module, and I’m sorry I’m completely new to the TextPattern community so I posted the patch there because i know their system. I just created this account in order to post this message to let you all know…

This patch includes non-destructive support for the class-level $rel attribute as defined with the TextileThis() function. You can read more about how to use this patch on drupal.org.

The patchfile can be applied against version 2.0 of classTextile.php. I was specifically working with the version included with the latest stable release of TextPattern (4.0.8).

Get the patch file here

The changes are many so including them inline here isnt such a good idea, you’re better off just applying the patch. You can apply it using the patch command line tool.

thanks Victor for setting up the ground work here and for the inspiration to get something working… Me dejaras saber si todo se encuentra bien en el parche, no?

email: <the username i just created for this forum> at gmail dot com

Offline

#12 2009-02-06 13:39:19

vik407
Member
From: Cali - Colombia
Registered: 2006-08-25
Posts: 10
Website

Re: [textile] Native textile code for manage link "rel" attributes

I checked an works great, i think people need to know hot to use the patch command line tool an point to a wikipedia entry to know how run it:

http://en.wikipedia.org/wiki/Patch_(Unix)

I work currently in a version of this patch but integrated in a plugin, also with a support with SMTP that is the most hacking and patching things that i do in every textpattern install.

—- Note
{es}: Gracias, jrguitar21, todo funcionó perfecto, voy a subir lo que estoy haciendo en github, creo es mejor para que podamos avanzar en este tipo de cambios y aplicarlos sin problemas.

Offline

Board footer

Powered by FluxBB