in reply to Proposal - Update shortcuts pointing to cpan.org to link to mcpan.org

We had a similar discussion last year and I wrote a nodelet hack which automatically redirects such links, so I'm not affected.

But seems like I never published it...

I can do it later if anyone is interested (?)

Cheers Rolf

(addicted to the Perl Programming Language)

  • Comment on Re: Proposal - Update shortcuts pointing to cpan.org to link to mcpan.org

Replies are listed 'Best First'.
Re^2: Proposal - Update shortcuts pointing to cpan.org to link to mcpan.org
by marto (Cardinal) on Jun 03, 2014 at 11:49 UTC

    I'd be interested to see that. However this only solves the problem for those who would use your nodelet hack, those without accounts can't use it even if they wanted to. In the interests of side stepping this issue for everyone I still think this should be changed. Thanks.

      Here we go

      <!-- ========================== PM LINK FIXER ========================== --> <!-- please disable after successful testing --> <h5> Testlinks </h5> [cpan://Data::Dump] <p> [mod://Data::Dump] <p> [http://www.perlmonks.net|www.perlmonks.net] <p> <script><!-- /* redirect links - avoid log out: redirect perlmonks domains to current one! - cpan -> metacpan */ (function (do_log){ var log = function (html){ if (do_log) document.writeln(html); } var fixes=''; var doc_host=document.location.hostname; for (var i in document.links) { var link_host = document.links[i].hostname; var link_href = document.links[i].href; var link_search = document.links[i].pathname; var link = document.links[i]; /* redirect links from other perlmonks domains to current one! * +/ if ( link_host && link_host != doc_host && link_host.match(/^(www\.)?perlmonks.(org|net|com)$/) ) { fixes += '<li> #'+i+' was '+link_host+'</li>\n'; document.links[i].hostname = doc_host; } /* redirect links from cpan to metacpan */ if ( link_host && link_host == 'search.cpan.org' ) { fixes += '<li> #'+i+' fixing '+link.href+'</li>\n'; if ( link.pathname == '/perldoc' ) { link.hostname = 'metacpan.org'; link.pathname = '/module/'+ link.search.split('?')[1]; link.search=''; link.protocol='https:'; } else if ( link.pathname == '/search' ) { link.hostname = 'metacpan.org'; link.search='?q'+link.search.split('&query')[1]; } } } if (fixes) { log('<h5>Fixed Links</h5><small><ol>'); log(fixes); log('</ol></small>'); } })(true); --></script>

      Logging and Testlinks should be disabled after successful testing.

      Cheers Rolf

      (addicted to the Perl Programming Language)

      > those without accounts can't use it even if they wanted to.

      Hmm , actually only those who don't have JS enabled.

      The monastery should have a general JS file.

      Though I'm not sure about the best way to make it a voluntary feature, maybe with cookies?

      update

      Please note that this approach fixes ALL links, not only monastery markup but also plain links. Both within posts and chatterbox.

      Cheers Rolf

      (addicted to the Perl Programming Language)