21:51 < nuba> tagclods will consider "this thing" as two separated tags, is that the intended behaviour?21:51 < nuba> one tag being "this21:51 < nuba> the other being thing"21:58 < nuba> perlbot, paste21:58 < perlbot> Paste your code to http://sial.org/pbot/perl or http://erxz.com/pb and #perl will be able to view it.22:01 < nuba> pasted a nice string2list at http://erxz.com/pb/394522:01 < nuba> found at String::Escape22:02 < nuba> oops, i meant tagclouds
this is the stuff on http://erxz.com/pb/3945
# @words = string2list( $space_separated_phrases );sub string2list { my $text = shift; carp "string2list called with a non-text argument, '$text'" if (ref $text); my @words; my $word = ''; while ( defined $text and length $text ) { if ($text =~ s/\A(?: ([^\"\s\\]+) | \\(.) )//mx) { $word .= $1; } elsif ($text =~ s/\A"((?:[^\"\\]|\\.)*)"//mx) { $word .= $1; } elsif ($text =~ s/\A\s+//m){ push(@words, unprintable($word)); $word = ''; } elsif ($text =~ s/\A"//) { carp "string2list found an unmatched quote at '$text'"; return; } else { carp "string2list parse exception at '$text'"; return; } } push(@words, unprintable($word)); return @words;}
Also, when trying to remove all keywords associated with a given wikipage, posting the 'edit' form with the Keywords field empty isn't doing the job. It works when I post it with a space character in the field, tho.
This is a patch for Keywords.pm, I modified the string2list above slightly, now in case of unmatched quotes, it'll return a list with what was found up to that point in the string, and discard the rest. With this patch, words between quotes are treated as a single keywords. I tested that in my 7.4.1-beta setup and it seems to be working fine.
I think that ?func=byKeyword;keyword=foo could use some love re: URL escaping, since with it we can have there words separated by spaces or punctuation etc.
BTW: This patch won't address the "can't clear a wikipage's keywords without posting a whitespace character" bug previously mentioned.
root@aviva# diff -up /data/{WebGUI,Custom}/lib/WebGUI/Keyword.pm
--- /data/WebGUI/lib/WebGUI/Keyword.pm Sat Jul 7 18:09:39 2007+++ /data/Custom/lib/WebGUI/Keyword.pm Wed Aug 8 00:20:18 2007@@ -156,6 +156,8 @@ sub getKeywordsForAsset { return \@keywords; } else {+ @keywords = map { m/\s/ ? '"' . $_ . '"' : $_ } @keywords;+ # replaces 'this string' with '"this string"' return join(" ", @keywords); } }@@ -265,7 +267,7 @@ sub setKeywordsForAsset { $keywords = $options->{keywords}; } else {- @{$keywords} = split(" ", $options->{keywords});+ @{$keywords} = string2list($options->{keywords}); } $self->deleteKeywordsForAsset($options->{asset}); my $assetId = $options->{asset}->getId;@@ -276,8 +278,39 @@ sub setKeywordsForAsset { } }+#------------------------------------------------------------------------------+# @words = string2list( $space_separated_phrases );+sub string2list {+ my $text = shift;++ return if (ref $text);++ my @words;+ my $word = '';++ my $error_flag = 0;++ while ( defined $text and length $text and not $error_flag) {+ if ($text =~ s/\A(?: ([^\"\s\\]+) | \\(.) )//mx) {+ $word .= $1;+ } elsif ($text =~ s/\A"((?:[^\"\\]|\\.)*)"//mx) {+ $word .= $1;+ } elsif ($text =~ s/\A\s+//m){+ push(@words, $word);+ $word = '';+ } elsif ($text =~ s/\A"//) {+ $error_flag = 1;+ } else {+ $error_flag = 1;+ }+ }+ push(@words, $word);++ return @words;+}+#------------------------------------------------------------------------------ # end inside out object }
The inability to delete keywords by emptying the keywords field has been fixed in 7.4.3.
The other functionality is neither intended nor desired.