Small patch to /Elements/MakeClicky

Some users of mine didn’t like the fact that we’re using a space every
30 characters instead of using , because it means copying and
pasting the URL as displayed (rather than clicking on it) doesn’t work
correctly.

Now, I realise that is a bit broken on some browsers, but Google
found what appears to be a useful workaround for those broken
browsers, which is to use a bit of CSS. I could put that into each
theme, but because this is a theme-independent thing, I’ve done it as
inline CSS - I hope that isn’t too abhorrent. I’ve also modified the
regex to put the at each / in the URL, or every 30 non-/
characters, which most of the time makes it put the line breaks in a
more meaningful location.

The patch is as follows:

— share/html/Elements/MakeClicky 2009-02-03 11:53:02.000000000 +0000
+++ local/html/Elements/MakeClicky 2009-03-05 17:52:30.000000000 +0000
@@ -60,9 +60,11 @@
},
url_overwrite => sub {
my %args = @_;

  •    my $result = qq{<a target="new" href="$args{'value'}">};
    
  •    #XXX: use spaces here. &shy; <wbr> are not well supported :(
    
  •    $args{'value'} =~ s/(\S{30})/$1 /g;
    

target=“new” href=“$args{‘value’}”>};

  •    $args{'value'} =~ s:(/|[^/]{30}):$1<wbr>:g;
        $result .= qq{$args{'value'}</a>};
        return qq{<span class="clickylink">$result</span>};
    },
    

So far I have tested this on Safari 4.0, Firefox 3.0.7 and IE 7, and
it seems to be OK…

Have I missed something?

Tim

The Wellcome Trust Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.

Tim Cutts wrote:

Some users of mine didn’t like the fact that we’re using a space every
30 characters instead of using , because it means copying and
pasting the URL as displayed (rather than clicking on it) doesn’t work
correctly.

Now, I realise that is a bit broken on some browsers, but Google
found what appears to be a useful workaround for those broken
browsers, which is to use a bit of CSS. I could put that into each
theme, but because this is a theme-independent thing, I’ve done it as
inline CSS - I hope that isn’t too abhorrent. I’ve also modified the
regex to put the at each / in the URL, or every 30 non-/
characters, which most of the time makes it put the line breaks in a
more meaningful location.

The patch is as follows:

— share/html/Elements/MakeClicky 2009-02-03 11:53:02.000000000 +0000
+++ local/html/Elements/MakeClicky 2009-03-05 17:52:30.000000000 +0000
@@ -60,9 +60,11 @@
},
url_overwrite => sub {
my %args = @_;

  •    my $result = qq{<a target="new" href="$args{'value'}">};
    
  •    #XXX: use spaces here. &shy; <wbr> are not well supported :(
    
  •    $args{'value'} =~ s/(\S{30})/$1 /g;
    

target=“new” href=“$args{‘value’}”>};

Wouldn’t it be cleaner to just define

.clickylink a wbr { display: inline-block; } in the main CSS?

Wouldn’t it be cleaner to just define

.clickylink a wbr { display: inline-block; } in the main CSS?

As I said, yes, you could do that, but there are three themes already,
so it would need to be done for all of them. That’s perfectly OK, but
it would be something that needed to be remembered each time someone
produced a new theme. This particular bit of CSS needs to be there
for all themes, which is why I put it inline. I don’t really mind how
it’s done in the end.

Tim

The Wellcome Trust Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.

Tim Cutts wrote:

Wouldn’t it be cleaner to just define

.clickylink a wbr { display: inline-block; } in the main CSS?

As I said, yes, you could do that, but there are three themes already,
so it would need to be done for all of them. That’s perfectly OK, but
it would be something that needed to be remembered each time someone
produced a new theme. This particular bit of CSS needs to be there
for all themes, which is why I put it inline. I don’t really mind how
it’s done in the end.

In that case, it would be cleaner to just put it as part of a common
CSS that all themes include from. Inline CSS is generally something
that should be avoided, as it makes maintenance a pain and increases
page size.