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

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.

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

Replies are listed 'Best First'.
Re^3: Proposal - Update shortcuts pointing to cpan.org to link to mcpan.org # Nodelet Hack
by LanX (Saint) on Jun 03, 2014 at 13:11 UTC
    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)

Re^3: Proposal - Update shortcuts pointing to cpan.org to link to mcpan.org
by LanX (Saint) on Jun 03, 2014 at 14:19 UTC
    > 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)