Local URL Shortener

If I have a URL shortener script installed in a subfolder of my status.net installation. How can I get status.net to make links out of the shortened URLS?

Specifically, I have yourls installed in a subfolder of my status.net installation. yourls is returning shortened URLs of the form a/1 where a is the name of the subfolder containing the URL shortener. However, status.net does not recognize a/1 as a URL and is not making it into a hyperlink.

Can you point me to the code I need to change to trick status.net into thinking that a/* should be a hyperlink?

Thanks!

Comments

  • I'm also interested in this. :)
  • If you add the code at the bottom to util.php then it will recognize a/ as a hyperlink, but the link comes across as http://a/ So now I have to figure out how to prevent the http:// from being pre-pended...

    This code belongs on util.php lines 664 through 667. I include the lines above and below so you can see where the change goes:

    '(?:(?:mailto|aim|tel|xmpp):)'.
    '|'.
    '(?:(?:a/))'.
    ')'.

  • The http:// seems to be getting added in File_redirection.php in _canonUrl. Changing the default_scheme causes a "Can't linkify url" error in comon_linkify in util.php.

    The quest continues...
  • So it works now! Yippie!

    I had to take out quite a few safety checks. Here's what I did:
    1. The change above to the regex on lines 664-667 in util.php
    '(?:(?:mailto|aim|tel|xmpp):)'.
    '|'.
    '(?:(?:a/))'.
    ')'.
    2. Change util.php lines 788-792 to:
    } else {
    //throw new ServerException("Can't linkify url '$longurl_data'");
    $canon = "../$url";
    $longurl = "../$url";
    }
    3. Comment out File_redirection.php line 252:
    //if (empty($p['scheme'])) return false;
    4. Comment out File_redirection.php line 258:
    //if (empty($p['host'])) return false;
  • @riegel thats great, do you have an account on gitorious, you could get your code merged in
    @brionv was going to write a built in url shortener, we need one for sure.


    http://gitorious.org/statusnet/mainline/commits/master
  • @aric Right now it's a hack. I just stripped out safety checks that may cause other things to go badly for me... I'll let my users play (meaning test) with this and see if they complain about other errors.

    Also, for anyone else who stumbles on this post the plugin to integrate status.net with yourls is here: http://github.com/rthees/yourls-status-net

    I'm not sure if you'd want to write your own URL shortener or just implement support for existing shorteners and make them part of the status.net distro.
  • Also, I forgot... I had to change the default parameter for default_scheme in _canonUrl on line 230 of File_redirection.php:

    function _canonUrl($in_url, $default_scheme = '../') {
  • Any way to make status.net work with YOURLs? My main domain is a URL shortener (http://gunn.in) and added a subdomain for my Status.net install. It is my ultimate goal to make them play nicely together.

    Thanks,
    ~Full Mag~
    http://blast.gunn.in
  • @fullmag look in the plugins directory, there are plugins for different types of shorteners, you may be able to use one of the already written ones, or modify one for your needs.


    heres and example of how you would enable it in your config.php http://lists.status.net/pipermail/statusnet-dev/2009-November/002717.html
  • I found this plugin that has already been written to be able to use YOURLs with Status.net.

    http://github.com/rthees/yourls-status-net

    I am trying it out now. I'll post back to let you know if it worked.

    Thanks,
    ~Full Mag~
    http://blast.gunn.in
  • I tried that rthees/yours-statustnet, but it's 2 years old.
    it has
    require_once INSTALLDIR.'/plugins/UrlShortener/UrlShortenerPlugin.php';

    but there is no UrlShortener/blah blah, in current SN.

    I'm going to see if I can hack it and make it work by looking at the tight, ptit, simpleurl plugins, and what I know of my yourls installation.

    tonybaldwin@tonybaldwin.me/status
    tony@free-haven.org
  • Okay, I forked from rhtees, fixed the plugin, and now have it working.
    New pluging (I changed one whole line) in https://github.com/tonybaldwin/yourls-status-net
    It works with sn v. 1.0.1, pulled from gitorious today, and yourls v. 1.5
  • Washington power brokers and the fashion elite have something in common. They are all watching the fashion choices of Michele Obama, as evidenced by the number of articles that cover every detail of her wardrobe on a daily basis.
    But when it comes to the watch making industry, all eyes are “watching” the choice of timepiece worn by the leader of the free world, as well as his second-in-command.
    He has already made headlines around the world for his less formal approach to White House protocol, and his wardrobe reflects a younger, more casual attitude than that of his predecessor, but President Obama’s most recent choice of a watch is a bit more formal than the rest of his wardrobe. It is even issued by the government, complete with a Secret Service coat of arms.
    This is because when Obama was still a senator; his Secret Service agents presented him with a black dialed chronograph. He later wore at this watch at his inauguration, making it one of the most photographed Watches in US history. The men’s watch was purchased as a gift for his 46th birthday, and came from the employee-only Secret Service store, housed in the agency’s DC headquarters.
    While Obama-watchers cannot purchase the exact same men’s watwch for themselves, a similar model – the JGC 6500 – is available from Jorg Gray, the watch’s manufacturer. Of course, this one won’t have the Secret Service emblem, but who knows; maybe a replica will be released if there is significant demand.
    Prior to receiving the Secret Service watch, Obama wore a TAG Heuer Divers watch, Series 1500.
    Omega has the honor of naming Vice President Joseph Biden as one of their more famous fans. Biden wears an Omega Seamaster watch, with a stainless steel bracelet, featuring a precision quartz movement and water resistance of up to 1,000 feet.http://www.watchesmod.com/
  • *** Above comment is spam. ***
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID