define(['jquery'], function ($) {
    var publishNotebook = function() {
        var anacondacloudid = IPython.notebook.metadata.anacondaCloudID,
            notebookName = IPython.notebook.notebook_name,
            nbj = IPython.notebook.toJSON(),
            interval;

        if (!IPython.notebook) return;
        $.ajax({
            url: "/ac-publish",
            method: 'POST',
            dataType: 'json',
            contentType: 'application/json; charset=utf-8',
            processData: false,
            data: JSON.stringify({
                name: notebookName,
                content: nbj
            })
        }).done(function(data) {
            IPython.notification_area.get_widget("notebook").
                set_message("Your notebook has been uploaded.", 4000);
        }).fail(function(jqXHR, textStatus) {
            var msg = '';
            if (jqXHR.status == 401) {
                msg = 'You must login though anaconda client.';
            } else {
                msg = 'There has been a problem. Try again.';
            }
            IPython.notification_area.get_widget("notebook").
                danger(msg, 4000);
        }).always(function(data, textStatus) {
            clearInterval(interval);
        });
        interval = uploadingNotification();
    };

    var uploadingNotification = function() {
        var index = 0,
            pattern = ['-', '\\', '|', '/'],
            _updateString = function(i) {
                IPython.notification_area.
                    get_widget('notebook').
                    warning('Uploading ' + pattern[i]);
            }
        _updateString(index);
        return setInterval(function() {
            index+=1;
            if (index > 3) { index = 0 };
            _updateString(index);
        }, 250);
    };

    var updateUploadLink = function(anacondaCloudID) {
        if (!IPython.notebook) return;
        if (!anacondaCloudID) {
            anacondaCloudID = IPython.notebook.metadata.anacondaCloudID;
        } else {
            IPython.notebook.metadata.anacondaCloudId = anacondaCloudID;
        }
        if (!anacondaCloudID) {
            return;
        }
        var toolbar = IPython.toolbar.element;
        var link = toolbar.find("a#nbviewer");
        if (!link.length) {
            link = $('<a id="nbviewer" target="_blank"/>');
            toolbar.append(
                $('<span id="nbviewer_span"/>').append(link)
            );
        }
        link.attr("href", "http://notebooks.anaconda.org/" + anacondaCloudID);
        link.text("http://notebooks.anaconda.org/" + anacondaCloudID);
    };

    var publishButton = function() {
        if (!IPython.toolbar) {
            $([IPython.events]).on("app_initialized.NotebookApp", publishButton);
            return;
        }
        if ($("#publish_notebook").length === 0) {
            IPython.toolbar.add_buttons_group([
                {
                    'label'   : 'Publish your notebook into Anaconda.org',
                    'icon'    : 'fa-cloud-upload',
                    'callback': publishNotebook,
                    'id'      : 'publish_notebook'
                },
            ]);
        }
        updateUploadLink();
    };

    var load_ipython_extension = function () {
        publishButton();
    };

    return {
        load_ipython_extension : load_ipython_extension,
    };
});

@@ -777,32 +777,72 @@
 oaded.%22, 4000);%0A
+            updateUploadLink(data.url);%0A
         %7D).fail(
@@ -1888,34 +1888,35 @@
 on(anacondaCloud
-ID
+URL
 ) %7B%0A        if (
@@ -1960,34 +1960,35 @@
  (!anacondaCloud
-ID
+URL
 ) %7B%0A            
@@ -2000,18 +2000,19 @@
 ndaCloud
-ID
+URL
  = IPyth
@@ -2037,34 +2037,35 @@
 ta.anacondaCloud
-ID
+URL
 ;%0A        %7D else
@@ -2122,10 +2122,11 @@
 loud
-Id
+URL
  = a
@@ -2137,18 +2137,19 @@
 ndaCloud
-ID
+URL
 ;%0A      
@@ -2178,18 +2178,19 @@
 ndaCloud
-ID
+URL
 ) %7B%0A    
@@ -2540,41 +2540,8 @@
 ef%22,
- %22http://notebooks.anaconda.org/%22
  + a
@@ -2548,26 +2548,27 @@
 nacondaCloud
-ID
+URL
 );%0A        l
@@ -2580,58 +2580,66 @@
 ext(
-%22http://notebooks.anaconda.org/%22 + anacondaCloudID
+anacondaCloudURL);%0A        IPython.notebook.save_notebook(
 );%0A 

Save notebook and show link