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

support yinxiang note(chinese local version of evernote) #33

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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# evervim.vim

## description:
edit evernote on vim.
edit evernote on vim. support [chinese yinxiang note](https://www.yinxiang.com/).

## requires:
* python
Expand Down
3 changes: 3 additions & 0 deletions doc/evervim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ and set g:evervim_devtoken, evervim will initialize on start VIM.
vimrc example:
let g:evervim_devtoken='S=s999:U=9ee99c9:E=999d9999c99:C=99a99a99999:P=9cd:A=en-devtoken:H=cd99999de9999c99b999d99d999cb9f9'

if you are using chinese yinxiang note(https://www.yinxiang.com/), please add:
let g:evervim_yinxiang=1

Initialize is not yet, set g:evervim_devtoken and do
>
:EvervimSetup
Expand Down
10 changes: 7 additions & 3 deletions plugin/evervim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,19 @@ if !exists('g:evervim_sorttags') " (name) (asc|desc)
let g:evervim_sorttags= 'name asc'
endif

if !exists('g:evervim_xmlindent') "
if !exists('g:evervim_xmlindent')
let g:evervim_xmlindent= ' '
endif
" use markdown when edit content(default = 1 means use markdown)
if !exists('g:evervim_usemarkdown') "
if !exists('g:evervim_usemarkdown')
let g:evervim_usemarkdown= 1
endif

if !exists('g:evervim_asyncupdate') "
if !exists('g:evervim_yinxiang')
let g:evervim_yinxiang = 0
endif

if !exists('g:evervim_asyncupdate')
let g:evervim_asyncupdate = 0
endif

Expand Down
9 changes: 6 additions & 3 deletions plugin/py/evernoteapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ class EvernoteAPI(object):
#}}}
#### constractuor.

def __init__(self, devtokens): # {{{
def __init__(self, devtokens, is_yinxiang=False): # {{{
""" initialize """
self.devtokens = devtokens
self.is_yinxiang = is_yinxiang

self.__setUserStore()
self.__versioncheck()
Expand Down Expand Up @@ -158,7 +159,8 @@ def auth(self): # {{{

def __setUserStore(self): # {{{
""" setup userStore. """
userStoreHttpClient = THttpClient.THttpClient(USERSTORE_URI)
host = YINXIANG_HOST if self.is_yinxiang == '1' else EVERNOTE_HOST
userStoreHttpClient = THttpClient.THttpClient(USERSTORE_URI_FORMAT % host)
userStoreProtocol = TBinaryProtocol.TBinaryProtocol(userStoreHttpClient)
self.userStore = UserStore.Client(userStoreProtocol)
#}}}
Expand Down Expand Up @@ -220,7 +222,8 @@ def __init__(self):

#EVERNOTE_HOST = "sandbox.evernote.com"
EVERNOTE_HOST = "www.evernote.com"
USERSTORE_URI = "https://" + EVERNOTE_HOST + "/edam/user"
YINXIANG_HOST = "app.yinxiang.com"
USERSTORE_URI_FORMAT = "https://%s/edam/user"
CONSUMER_SECRET = '960305afca85b6b0'

NOTESTORE_URIBASE = "https://" + EVERNOTE_HOST + "/edam/note/"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont know how to change NOTESTORE_URIBASE, so i left it unchanged.

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 @@ -24,6 +24,7 @@ def __init__(self):
self.usemarkdown = None
self.encoding = None
self.asyncupdate = None
self.is_yinxiang = None
self.enscriptpath = None

@classmethod
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.is_yinxiang)

def note2buffer(self, note):
""" return strings array for buffer from note. """
Expand Down
1 change: 1 addition & 0 deletions plugin/py/evervimmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def setPref(self): # {{{
self.pref.xmlindent = vim.eval("g:evervim_xmlindent")
self.pref.usemarkdown = vim.eval("g:evervim_usemarkdown")
self.pref.asyncupdate = vim.eval("g:evervim_asyncupdate")
self.pref.is_yinxiang = vim.eval("g:evervim_yinxiang")
self.pref.encoding = vim.eval('&enc')
self.pref.enscriptpath = None
# }}}
Expand Down