text: 
  /*
   * Federated Wiki : Changes Plugin
   *
   * Licensed under the MIT license.
   * https://github.com/fedwiki/wiki-plugin-changes/blob/master/LICENSE.txt
   */
  
  (function() {
    var constructor, escape, listItemHtml, pageBundle;
  
    escape = function(line) {
      return line.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
    };
  
    listItemHtml = function(slug, page) {
      return "<li>\n  <a class=\"internal\" href=\"#\" title=\"local\" data-page-name=\"" + slug + "\" data-site=\"local\">\n    " + (escape(page.title)) + "\n  </a>\n  <button class=\"delete\">✕</button>\n</li>";
    };
  
    pageBundle = function() {
      var bundle, i, j, length, ref, slug;
      bundle = {};
      length = localStorage.length;
      for (i = j = 0, ref = length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
        slug = localStorage.key(i);
        bundle[slug] = JSON.parse(localStorage.getItem(slug));
      }
      return bundle;
    };
  
    constructor = function($, dependencies) {
      var bind, emit, localStorage;
      if (dependencies == null) {
        dependencies = {};
      }
      localStorage = dependencies.localStorage || window.localStorage;
      emit = function($div, item) {
        var i, j, page, ref, slug, ul;
        if (localStorage.length === 0) {
          $div.append('<ul><p><i>no local changes</i></p></ul>');
          return;
        }
        $div.append(ul = $('<ul />'));
        for (i = j = 0, ref = localStorage.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
          slug = localStorage.key(i);
          page = JSON.parse(localStorage.getItem(slug));
          ul.append(listItemHtml(slug, page));
        }
        if (localStorage.length > 0) {
          if (item.submit != null) {
            return ul.append("<button class=\"submit\">Submit Changes</button>");
          } else {
            return $div.append("<p> Click <i>Export Changes</i> to retrieve changed pages as json.\nSave the json as a file to be drop-imported elsewhere.</p>\n<ul><button class=\"export\">Export Changes</button></ul>");
          }
        }
      };
      bind = function($div, item) {
        $div.on('click', '.delete', function() {
          var slug;
          slug = $(this).siblings('a.internal').data('pageName');
          localStorage.removeItem(slug);
          return emit($div.empty(), item);
        });
        $div.on('click', '.submit', function() {
          return $.ajax({
            type: 'PUT',
            url: "/submit",
            data: {
              'bundle': JSON.stringify(pageBundle())
            },
            success: function(citation, textStatus, jqXHR) {
              var before, beforeElement, itemElement, pageElement;
              wiki.log("ajax submit success", citation, textStatus, jqXHR);
              if (!(citation.type && citation.site)) {
                throw new Exception("Incomplete Submission");
              }
              pageElement = $div.parents('.page:first');
              itemElement = $("<div />", {
                "class": "item " + citation.type
              }).data('item', citation).attr('data-id', citation.id);
              itemElement.data('pageElement', pageElement);
              pageElement.find(".story").append(itemElement);
              wiki.doPlugin(itemElement, citation);
              beforeElement = itemElement.prev('.item');
              before = wiki.getItem(beforeElement);
              return wiki.pageHandler.put(pageElement, {
                item: citation,
                id: citation.id,
                type: "add",
                after: before != null ? before.id : void 0
              });
            },
            error: function(xhr, type, msg) {
              return wiki.log("ajax error callback", type, msg);
            }
          });
        });
        $div.on('click', '.export', function() {
          return location.href = "data:application/json," + encodeURIComponent(JSON.stringify(pageBundle()));
        });
        return $div.dblclick(function() {
          var bundle, count;
          bundle = pageBundle();
          count = _.size(bundle);
          return wiki.dialog("JSON bundle for " + count + " pages", $('<pre/>').text(JSON.stringify(bundle, null, 2)));
        });
      };
      return {
        emit: emit,
        bind: bind
      };
    };
  
    wiki.registerPlugin('changes', constructor);
  
    if (typeof module !== "undefined" && module !== null) {
      module.exports = constructor;
    }
  
  }).call(this);
  
  //# sourceMappingURL=changes.js.map
  