|
|
@ -7,9 +7,9 @@ local DataStorage = require("datastorage")
|
|
|
|
local DocSettings = require("docsettings")
|
|
|
|
local DocSettings = require("docsettings")
|
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
local Screen = require("device").screen
|
|
|
|
local Screen = require("device").screen
|
|
|
|
|
|
|
|
local logger = require("logger")
|
|
|
|
local util = require("ffi/util")
|
|
|
|
local util = require("ffi/util")
|
|
|
|
local Device = require("device")
|
|
|
|
local Device = require("device")
|
|
|
|
local DEBUG = require("dbg")
|
|
|
|
|
|
|
|
local JoplinClient = require("JoplinClient")
|
|
|
|
local JoplinClient = require("JoplinClient")
|
|
|
|
local T = require("ffi/util").template
|
|
|
|
local T = require("ffi/util").template
|
|
|
|
local _ = require("gettext")
|
|
|
|
local _ = require("gettext")
|
|
|
@ -405,6 +405,7 @@ function EvernoteExporter:doLogin(username, password)
|
|
|
|
domain = self.evernote_domain,
|
|
|
|
domain = self.evernote_domain,
|
|
|
|
username = username,
|
|
|
|
username = username,
|
|
|
|
password = password,
|
|
|
|
password = password,
|
|
|
|
|
|
|
|
logger = logger.dbg,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self.evernote_username = username
|
|
|
|
self.evernote_username = username
|
|
|
|
local ok, token = pcall(oauth.getToken, oauth)
|
|
|
|
local ok, token = pcall(oauth.getToken, oauth)
|
|
|
@ -486,7 +487,7 @@ function EvernoteExporter:updateHistoryClippings(clippings, new_clippings)
|
|
|
|
or clippings[title][chapter_index][note_index].time ~= note.time
|
|
|
|
or clippings[title][chapter_index][note_index].time ~= note.time
|
|
|
|
or clippings[title][chapter_index][note_index].text ~= note.text
|
|
|
|
or clippings[title][chapter_index][note_index].text ~= note.text
|
|
|
|
or clippings[title][chapter_index][note_index].note ~= note.note then
|
|
|
|
or clippings[title][chapter_index][note_index].note ~= note.note then
|
|
|
|
DEBUG("found new notes in history", booknotes.title)
|
|
|
|
logger.dbg("found new notes in history", booknotes.title)
|
|
|
|
clippings[title] = booknotes
|
|
|
|
clippings[title] = booknotes
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -500,7 +501,7 @@ function EvernoteExporter:updateMyClippings(clippings, new_clippings)
|
|
|
|
-- since appending is the only way to modify notes in My Clippings
|
|
|
|
-- since appending is the only way to modify notes in My Clippings
|
|
|
|
for title, booknotes in pairs(new_clippings) do
|
|
|
|
for title, booknotes in pairs(new_clippings) do
|
|
|
|
if clippings[title] == nil or #clippings[title] < #booknotes then
|
|
|
|
if clippings[title] == nil or #clippings[title] < #booknotes then
|
|
|
|
DEBUG("found new notes in MyClipping", booknotes.title)
|
|
|
|
logger.dbg("found new notes in MyClipping", booknotes.title)
|
|
|
|
clippings[title] = booknotes
|
|
|
|
clippings[title] = booknotes
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -539,7 +540,7 @@ function EvernoteExporter:exportAllNotes()
|
|
|
|
clippings[title] = nil
|
|
|
|
clippings[title] = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
--DEBUG("clippings", clippings)
|
|
|
|
--logger.dbg("clippings", clippings)
|
|
|
|
self:exportClippings(clippings)
|
|
|
|
self:exportClippings(clippings)
|
|
|
|
self.config:saveSetting("clippings", clippings)
|
|
|
|
self.config:saveSetting("clippings", clippings)
|
|
|
|
self.config:flush()
|
|
|
|
self.config:flush()
|
|
|
@ -606,11 +607,11 @@ function EvernoteExporter:exportClippings(clippings)
|
|
|
|
NetworkMgr:promptWifiOn()
|
|
|
|
NetworkMgr:promptWifiOn()
|
|
|
|
return
|
|
|
|
return
|
|
|
|
elseif not ok and err then
|
|
|
|
elseif not ok and err then
|
|
|
|
DEBUG("Error occurs when exporting book:", title, err)
|
|
|
|
logger.dbg("Error while exporting book", title, err)
|
|
|
|
error_count = error_count + 1
|
|
|
|
error_count = error_count + 1
|
|
|
|
error_title = title
|
|
|
|
error_title = title
|
|
|
|
elseif ok then
|
|
|
|
elseif ok then
|
|
|
|
DEBUG("Exported notes in book:", title)
|
|
|
|
logger.dbg("Exported notes in book:", title)
|
|
|
|
export_count = export_count + 1
|
|
|
|
export_count = export_count + 1
|
|
|
|
export_title = title
|
|
|
|
export_title = title
|
|
|
|
booknotes.exported[exported_stamp] = true
|
|
|
|
booknotes.exported[exported_stamp] = true
|
|
|
@ -648,7 +649,7 @@ function EvernoteExporter:exportBooknotesToEvernote(client, title, booknotes)
|
|
|
|
booknotes = booknotes,
|
|
|
|
booknotes = booknotes,
|
|
|
|
notemarks = self.notemarks,
|
|
|
|
notemarks = self.notemarks,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
--DEBUG("content", content)
|
|
|
|
--logger.dbg("content", content)
|
|
|
|
local note_guid = client:findNoteByTitle(title, self.notebook_guid)
|
|
|
|
local note_guid = client:findNoteByTitle(title, self.notebook_guid)
|
|
|
|
local resources = {}
|
|
|
|
local resources = {}
|
|
|
|
for _, chapter in ipairs(booknotes) do
|
|
|
|
for _, chapter in ipairs(booknotes) do
|
|
|
@ -674,7 +675,7 @@ function EvernoteExporter:exportBooknotesToHTML(title, booknotes)
|
|
|
|
booknotes = booknotes,
|
|
|
|
booknotes = booknotes,
|
|
|
|
notemarks = self.notemarks,
|
|
|
|
notemarks = self.notemarks,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
--DEBUG("content", content)
|
|
|
|
--logger.dbg("content", content)
|
|
|
|
local html = io.open(self.clipping_dir .. "/" .. title .. ".html", "w")
|
|
|
|
local html = io.open(self.clipping_dir .. "/" .. title .. ".html", "w")
|
|
|
|
if html then
|
|
|
|
if html then
|
|
|
|
html:write(content)
|
|
|
|
html:write(content)
|
|
|
|