tag formatting: whitespace or two words (or more) tags problem
enzoch - December 3, 2006 - 04:32
| Project: | Technorati |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Hi,
I just found out this problem:
technorati requires you to add the "+" sign for two words (or more) tags,
but this module doesn't do it.
eg. drop shipping, should be written as drop+shipping.
please read the detail here:
http://www.technorati.com/help/tags.html
Thanks,
enzoch

#1
I too found this problem in drupal 5.1 version. So I decided to fix the problem. Perhaps my fix (see attached file) can be used to create a new official version. The fix was rather simple: add a new function, RDF_wsstrip($str), to parse for whitespace, and use it in the function that display's the tags, _technorati_link($tag). See the file attachment, my technorati.module, to see the fix being used...
You can see the fix in action on my drupal site here:
http://www.ronfredericks.net/drupal5/node/11
Here is a code snippett showing the patch in place:
function _technorati_link($tag) {$tag = RDF_wsstrip(check_plain($tag)); // part of Ron's patch
return '<a href="http://technorati.com/tag/' . str_replace(" ", "+", $tag) . '" rel="tag">' . $tag . '</a>'; // part of Ron's patch
// old line replaced by the two new lines above:
// return '<a href="http://technorati.com/tag/' . check_plain($tag) . '" rel="tag">' . check_plain($tag) . '</a>';
}
#2
As a follow-up note. The patch I suggest (technorati_module.txt) fixes the "two (or more) words" problem. But it fixes another problem as well. When you enter your tags like this:
tag1, tag2, ...
instead of like this
tag1,tag2,...
Then the space to the left of tag2 and beyond, have the whitespace embedded in the technorati link. The whitespace defeats the eventual ping back to technorati:
instead of this:
Thanks,
RonF
#3
Please submit proper patches, not the entire module. See http://drupal.org/patch
Also, submit separate problems/features in separate issues.
This makes reviews easier.
#4
OK,
I am new to Drupal. Thanks for the pointer on how to submit a drupal patch. I will go ahead and read the patch link and follow the established methods. Look for a formal patch in a day or two.
Ron
#5
Introduction
I have created and tested a patch, to the technorati.module dated "April 13, 2007", that fixes two very similar tag formatting issues:
1) Whitespace to the left of a tag during tag entry creates an invalid link to technorati's web site.
2) Whitespace separating two or more words making up one compound tag creates an invalid multi-word tag.
I am new to drupal so I am not sure how best to set the status or assigned person for this post, let me know if I have done this incorrectly. I have tested the patch and believe it is ready for use to my best effort.
Detailed Description
For example:
If you enter these tags during the publishing of your blog post:
tag1, tag2, compound_tag3a compound_tag3bYour post would end up sending an invalid ping for tag2 and compund_tag3 to technorati looking like this:
<strong>Technorati Tags: </strong><a href="http://technorati.com/tag/tag1 rel="tag">tag1</a> <a href="http://technorati.com/tag/ tag2 rel="tag"> tag2</a> <a href="http://technorati.com/tag/ compound_tag3a compound_tag3b rel="tag"> compound_tag3a compound_tag3b</a>With this patch, the same tag entry would end up sending a valid ping for all tags looking like this:
<strong>Technorati Tags: </strong><a href="http://technorati.com/tag/tag1 rel="tag">tag1</a> <a href="http://technorati.com/tag/tag2 rel="tag">tag2</a> <a href="http://technorati.com/tag/compound_tag3a+compound_tag3b rel="tag">compound_tag3a compound_tag3b</a>Note the difference in spacing for tag2 and compound_tag3, as well as addition of a "+" symbol that follows technorati's standard for joining multi-word elements into a single tag.
Note: The patch presented here handles the case where a user enters "+" symbols during data entry themselves, and it also handles badly formatted tag entry where the user may include multiple whitespace right and left of tags and/or multiple "+" symbols incorrectly placed during tag entry.
Work Around: The patch is not needed if the user simply enters tags in an very specific way:
tag1,tag2,compound_tag3a+compound_tag3bThe work around does have one crummy side effect in that the "+" symbol is present in the display of the linked tags.
Patch Installation
To install the patch:
1) Go to your drupal 5.1 root directory
2) Place the patch in this same root directory
3) Type the following command:
patch -p0<myFixTagFormat.patchThe result is an updated technorati.module with these two updates included:
1) an updated function: _technorati_link($tag)
2) a new function: _technorati_wsstrip($str)
Limitations and Warranty
Terms of use:
Ron Fredericks, and Embedded Components, Inc., collectively referred to as ECI for terms of use, offer no liability coverage, no warranty of use given or implied, and no indemnity offered, with respect to use of or results from ECI's patch. Support is optional and will be provided at the sole discursion of ECI. If any of these claims are not valid in your geographic location, then all other claims shall still apply. User further agrees that the prevailing party in any legal challenge shall be compensated by the looser for their legal and/or arbitration expenses. These terms shall apply to the user of this patch and also to his/her company where possible. International users take note that your use of this patch waives any trade practice, claim, or protection defined by any U.N. policy or program. ECI expressly excludes use of United Nations Convention on Contracts for the International Sale of Goods (sometimes called the International UCC). Any questions? Then best not use this patch.
#6
Thanks for this.
The patch includes the entire module which makes it hard to review.
Try creating it without line feed/new line sensitivity.
Check http://drupal.org/patch for more details.
The warranty and limitations are not necessary, since by including this in the Drupal repository, it becomes licensed under GPL 2, which includes its own disclaimer and no warranty section.
If you do not want your code to be included, or licensed as GPL, then do not post patches.
#7
Thanks Khalid:
Introduction
I have posted a new patch titled:
myNewFixTagFormat.patchIt solves the same whitespace and multi-word issues as explained in my previous [April 28, 2007] post and patch above. The new patch, supplied here, is much shorter and only makes changes in two small areas of technorati.module:
How to Create a Patch File in a Mixed Windows and Linux Environment
To create a patch file so it only reports the changes and not every line, required some understanding of the programming environment:
I am using a Windows environment for my PHP programming,
while I'm using a Linux server for my deployed drupal web site.
Here is the updated patch creation command that solves the Windows to Unix mixed environment. First, I upload the new module from my Windows programming environment to my Linux server in the same location as the original module. Then open a telenet session window. Change to the drupal 5 root directory. Finally, type the following diff command to create the patch:
diff -up --strip-trailing-cr modules/technorati/technorati.module modules/technorati/technoratiNew.module > myNewFixTagFormat.patchAn alternative would have been to convert my Windows [aka Dos] technoratiNew.module into Linux [aka Unix] format before creating the patch with these commands in a telnet window to my Linux server:
dos2unix modules/technorati/technoratiNew.modulediff -up modules/technorati/technorati.module modules/technorati/technoratiNew.module > myNewFixTagFormat.patch
Both methods above, produced exactly the same patch.
Patch Installation
To install the patch:
1) Go to your drupal 5.1 root directory
2) Place the patch in this same root directory
3) Type the following command:
patch -p0 <myNewFixTagFormat.patchThe result is an updated technorati.module
Limitations and Warranty
Terms of use:
This license may be replaced at will with the Drupal GPL license in the event this patch becomes part of any drupal distribution. In the mean time: Ron Fredericks, and Embedded Components, Inc., collectively referred to as ECI for terms of use, offer no liability coverage, no warranty of use given or implied, and no indemnity offered, with respect to use of or results from ECI's patch. Support is optional and will be provided at the sole discursion of ECI. If any of these claims are not valid in your geographic location, then all other claims shall still apply. User further agrees that the prevailing party in any legal challenge shall be compensated by the looser for their legal and/or arbitration expenses. These terms shall apply to the user of this patch and also to his/her company where possible. International users take note that your use of this patch waives any trade practice, claim, or protection defined by any U.N. policy or program. ECI expressly excludes use of United Nations Convention on Contracts for the International Sale of Goods (sometimes called the International UCC). Any questions? Then best not use this patch.
#8
Committed to 5.x and HEAD.
#9