Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chinese evernote support and create note in specific Notebook #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions plugin/evervim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ endif
"
" initialize {{{
" 作業用フォルダの位置"
if !exists('g:evervim_host')
let g:evervim_host = 'www.evernote.com'
endif

if !exists('g:evervim_workdir')
let g:evervim_workdir = $HOME . '/.evervim'
endif
Expand Down
19 changes: 10 additions & 9 deletions plugin/py/evernoteapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ class EvernoteAPI(object):
#}}}
#### constractuor.

def __init__(self, devtokens): # {{{
def __init__(self, devtokens, host): # {{{
""" initialize """
self.devtokens = devtokens
self.userstore_uri = "https://" + host + "/edam/user"
self.notestore_uribase = "https://" + host + "/edam/note/"

self.__setUserStore()
self.__versioncheck()
Expand All @@ -45,9 +47,9 @@ def createNote(self, note): # {{{
return self.__getNoteStore().createNote(authToken, note)
#}}}

def newNote(self): # {{{
def newNote(self, notebookGuid = None): # {{{
""" return Types.Note() """
return Types.Note()
return Types.Note(notebookGuid = notebookGuid)
#}}}

def updateNote(self, note): # {{{
Expand Down Expand Up @@ -158,7 +160,7 @@ def auth(self): # {{{

def __setUserStore(self): # {{{
""" setup userStore. """
userStoreHttpClient = THttpClient.THttpClient(USERSTORE_URI)
userStoreHttpClient = THttpClient.THttpClient(self.userstore_uri)
userStoreProtocol = TBinaryProtocol.TBinaryProtocol(userStoreHttpClient)
self.userStore = UserStore.Client(userStoreProtocol)
#}}}
Expand Down Expand Up @@ -219,11 +221,10 @@ def __init__(self):
CONSUMER_SECRET = '960305afca85b6b0'

#EVERNOTE_HOST = "sandbox.evernote.com"
EVERNOTE_HOST = "www.evernote.com"
USERSTORE_URI = "https://" + EVERNOTE_HOST + "/edam/user"
CONSUMER_SECRET = '960305afca85b6b0'

NOTESTORE_URIBASE = "https://" + EVERNOTE_HOST + "/edam/note/"
#EVERNOTE_HOST = "www.evernote.com"
#EVERNOTE_HOST = "app.yinxiang.com"
#USERSTORE_URI = "https://" + EVERNOTE_HOST + "/edam/user"
#NOTESTORE_URIBASE = "https://" + EVERNOTE_HOST + "/edam/note/"

AUTH_REFRESH_LATE = 0.6
# }}}
Expand Down
3 changes: 2 additions & 1 deletion plugin/py/evervim_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self):
if EvervimPref._instance is not None:
raise RuntimeError("EvervimPref must be one object!!!")

self.host = None
self.workdir = None
self.devtoken = None
self.sortnotebooks = None
Expand Down Expand Up @@ -55,7 +56,7 @@ def setAPI(self):
if EvervimPref.getInstance().devtoken is None:
raise AttributeError("devtoken must be set!!")

self.api = EvernoteAPI(pref.devtoken)
self.api = EvernoteAPI(pref.devtoken, pref.host)

def note2buffer(self, note):
""" return strings array for buffer from note. """
Expand Down
4 changes: 3 additions & 1 deletion plugin/py/evervimmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def getInstance(self):

""" prefs from vim option """
def setPref(self): # {{{
self.pref.host = vim.eval("g:evervim_host")
self.pref.workdir = vim.eval("g:evervim_workdir")
self.pref.devtoken = vim.eval("g:evervim_devtoken")
self.pref.sortnotebooks = vim.eval("g:evervim_sortnotebooks")
Expand Down Expand Up @@ -229,7 +230,8 @@ def searchByQueryPrevpage(self): # {{{

def createNote(self): # {{{
try:
Evervimmer.currentnote = Evervimmer.editor.api.newNote()
notebookGuid = self.currentNotebook.guid if hasattr(self, "currentNotebook") else None
Evervimmer.currentnote = Evervimmer.editor.api.newNote(notebookGuid)
self.checkNote()
createdNote = Evervimmer.editor.api.createNote(Evervimmer.currentnote)
Evervimmer.currentnote = createdNote
Expand Down