 Extension = require 'resource'
 ModalSelector = require 'modal-selector'
 Editor = require 'editor'
+
+Base64 = require 'gist/base64'
 
 module.exports =
 class Gist extends Editor

      true

  save: ->
    # Can't get this to work yet. 500ing
    if @id
      files = {}

        data: JSON.stringify { files }
        error: -> console.error "Saving Gist failed."
        success: (data) =>
          atom.native.writeToPasteboard @url
          console.log 'it worked'
        beforeSend: (req) =>
          req.setRequestHeader 'Authorization', @authorization user, pass
        true

  # basic auth
  authorization: (user, pass) ->
    token = "#{user}:#{pass}"
    hash = Base64.encode token
    "Basic #{hash}"
