class EnClient::GetNoteCommand

Attributes

guid[RW]

Public Instance Methods

exec_impl() click to toggle source
# File usr/lib/evernote-mode/enclient.rb, line 727
def exec_impl
  check_auth
  note = DBUtils.get_note dm, @guid
  if note && note.contentFile && (FileTest.readable? note.contentFile)
    reply = GetNoteReply.new
    reply.note = note
    shell.reply self, reply
  else
    server_task do
      note = sm.note_store.getNote sm.auth_token, @guid, true, false, false, false
      note.editMode = Formatter.get_edit_mode note.attributes.sourceApplication
      content = format_content note.content, note.editMode
      DBUtils.set_note_and_content dm, note, content
      reply = GetNoteReply.new
      reply.note = note
      shell.reply self, reply
    end
  end
end

Private Instance Methods

format_content(content, edit_mode) click to toggle source
# File usr/lib/evernote-mode/enclient.rb, line 749
def format_content(content, edit_mode)
  result = nil
  content.gsub! %r{(?:\r\n)|\n|\r}, "\n"
  if edit_mode == "TEXT"
    content =~ %r|<en-note[^>]*>(.*)</en-note>|m
    content = $1
    content.gsub! %r{<br.*?/>}m, "\n"
    content.gsub! %r{&nbsp;}m, " "
    result = CGI.unescapeHTML content
  else
    result = content
  end
end