Skip to content

Commit 0fa98d0

Browse files
Merge branch 'Sudashiii:master' into master
2 parents 529cad1 + 3f26a9f commit 0fa98d0

31 files changed

Lines changed: 2632 additions & 1589 deletions

README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,25 +187,31 @@ Basic setup flow:
187187

188188
1. Install the plugin in KOReader like any other plugin.
189189
2. Open `Settings -> More tools -> Sake`.
190-
3. Set the public URL of your Sake web app.
191-
4. Log in with the same username and password you use in the web app.
192-
5. Choose `Login and fetch device key`.
193-
6. Use the sync actions to pull books, push progress, or check for plugin updates.
190+
3. Open `Setup`.
191+
4. Set the public URL of your Sake web app in `Server URL`.
192+
5. Optionally rename the device in `Device Name`.
193+
6. Choose `Pair Device` and log in with the same username and password you use in the web app.
194+
7. Use the actions in `Sync`, `Library Import/Export`, and `Maintenance` as needed.
194195

195196
The login step exchanges your password for a device API key and clears the password from the device afterward.
196197

197198
You can also export ebooks from the devices home folder back to the web app, including sidecar data such as progress and notes. Great if you have a pre-existing library on your device!
198199

199-
KOReader plugin releases are tracked in the database and the artifacts are served through S3-compatible storage. If the KOReader plugin is updated and you start the app, the new version will be uploaded to S3 so you can use the updater plugin to easily update the core plugin without needing to manually mvoe the files to your KOReader device.
200+
KOReader plugin releases are tracked in the database and the artifacts are served through S3-compatible storage. If the KOReader plugin is updated and you start the app, the new version will be uploaded to S3 so you can use the updater plugin to easily update the core plugin without needing to manually move the files to your KOReader device.
200201

201202
### Concrete Usage
202203
- The Plugin can be found under "Settings" --> "More tools" --> "Sake"
203-
- Books are are downloaded when pressing "Sync Books now" or when setting the device to sleep
204-
- The progress gets automatically uploaded when putting the device to sleep and you are currently in the book (dont exit the book!)
205-
- If you use multiple devices, the progress needs to be manually downloadede with the "Sync progress now" button. (I had problems getting background sync to work, but im still working on it!)
206-
- Pressing "Export Existing Library" tries to upload every book and progress sidecar to the WebApp. This takes a while and the E-Reader is not usable before finishing!
207-
- Before using it you need to set the API URL (base url like, sake.yourdomain.com) and login to fetch the API Key. Your password will be removed from the device after logging in.
208-
- You can optionally change the auto generated device name. The device name will show up in the WebApp in the API-Key list and on the Book Detail you ("Downloaded on device x)
204+
- `Setup` contains `Server URL`, `Device Name`, and `Pair Device` / `Refresh Device Key`
205+
- `Sync` contains `Download New Books`, `Pull Progress From Other Devices`, and `Upload Current Book Progress`
206+
- Books are downloaded when pressing `Download New Books` or when setting the device to sleep
207+
- Progress is automatically uploaded when putting the device to sleep while a book is still open
208+
- If you use multiple devices, use `Pull Progress From Other Devices` to fetch newer progress from another reader
209+
- `Library Import/Export -> Import or Export Existing Library` uploads books already on the device, along with sidecar data such as progress and notes
210+
- Library import/export can take a while, and the device may be unusable until the process finishes
211+
- `Maintenance -> Check for Plugin Updates` checks for new plugin releases
212+
- `Maintenance -> Advanced -> Remote Log Shipping` toggles shipping KOReader logs back to Sake
213+
- Before using the plugin you need to set the server URL and pair the device. Your password is removed from the device after pairing succeeds.
214+
- You can optionally change the auto-generated device name. The device name shows up in the web app for device-specific downloads and API keys.
209215

210216
## Search providers and downloads
211217

koreaderPlugins/sake.koplugin/_meta.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ return {
44
fullname = _("Sake"),
55
description = _([[Svelte and Koreader Ecosystem - Syncs your books and progress.]]),
66
author = "Sascha Lorenz",
7-
version = "0.7.2",
7+
version = "0.9.2",
88
}

koreaderPlugins/sake.koplugin/controllers/library_export.lua

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
local ConfirmBox = require("ui/widget/confirmbox")
12
local InfoMessage = require("ui/widget/infomessage")
23
local UIManager = require("ui/uimanager")
34
local logger = require("core/log")
@@ -63,7 +64,7 @@ function LibraryExport:showError(message)
6364
})
6465
end
6566

66-
function LibraryExport:start()
67+
function LibraryExport:startExport()
6768
logger.info("[Sake] Existing-library export started.")
6869

6970
self.popup = InfoMessage:new{
@@ -104,6 +105,20 @@ function LibraryExport:start()
104105
end)
105106
end
106107

108+
function LibraryExport:start()
109+
UIManager:show(ConfirmBox:new{
110+
text = _(
111+
"Importing or exporting an existing library can take a while.\n"
112+
.. "Your device may be unusable until the process finishes.\n\n"
113+
.. "Do you want to continue?"
114+
),
115+
ok_text = _("Continue"),
116+
ok_callback = function()
117+
self:startExport()
118+
end,
119+
})
120+
end
121+
107122
function LibraryExport:startQueue(books, index, summary)
108123
closePopup(self)
109124

koreaderPlugins/sake.koplugin/controllers/progress_sync.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ function ProgressSync:syncCurrentBookProgress(opts)
5959
local ok_snapshot, snapshot_or_err = self.engine:prepareCurrentDocumentProgressSnapshot()
6060
if not ok_snapshot then
6161
if snapshot_or_err == "No document open" then
62+
if opts and opts.no_remote_fallback then
63+
logger.info(LOG_PREFIX .. "No document open. Skipping upload because remote fallback is disabled.")
64+
return true, { no_document = true }
65+
end
6266
logger.info(LOG_PREFIX .. "No document open. Running remote progress download sync.")
6367
return self:syncNewProgressForDevice(opts)
6468
end
@@ -85,6 +89,7 @@ function ProgressSync:syncCurrentBookProgress(opts)
8589
return true, {
8690
deferred = true,
8791
percent_finished = snapshot.percent_finished,
92+
uploaded = false,
8893
}
8994
end
9095

@@ -94,7 +99,10 @@ function ProgressSync:syncCurrentBookProgress(opts)
9499
end
95100

96101
logger.info(LOG_PREFIX .. "Live percent_finished: " .. tostring(percent_finished_or_err))
97-
return true
102+
return true, {
103+
uploaded = true,
104+
percent_finished = percent_finished_or_err,
105+
}
98106
end
99107

100108
function ProgressSync:syncNewProgressForDevice(opts)

koreaderPlugins/sake.koplugin/core/settings.lua

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,33 @@ end
4545

4646
function Settings.validateRequired(settings)
4747
local missing = {}
48-
if not settings.api_url or settings.api_url == "" then table.insert(missing, "API URL") end
48+
if not settings.api_url or settings.api_url == "" then table.insert(missing, "Server URL") end
4949
if not settings.device_name or settings.device_name == "" then table.insert(missing, "Device Name") end
5050
local has_api_key = settings.api_key and settings.api_key ~= ""
51-
if not has_api_key then
52-
if not settings.api_user or settings.api_user == "" then table.insert(missing, "Login Username") end
53-
if not settings.api_pass or settings.api_pass == "" then table.insert(missing, "Login Password") end
51+
local has_pairing_credentials = settings.api_user and settings.api_user ~= ""
52+
and settings.api_pass and settings.api_pass ~= ""
53+
if not has_api_key and not has_pairing_credentials then
54+
table.insert(missing, "Device Key")
5455
end
5556
if #missing > 0 then
5657
return false, table.concat(missing, ", ")
5758
end
5859
return true
5960
end
6061

62+
function Settings.validatePairingSetup(settings)
63+
local missing = {}
64+
if not settings.api_url or settings.api_url == "" then table.insert(missing, "Server URL") end
65+
if not settings.device_name or settings.device_name == "" then table.insert(missing, "Device Name") end
66+
if #missing > 0 then
67+
return false, table.concat(missing, ", ")
68+
end
69+
return true
70+
end
71+
6172
function Settings.validatePairingRequired(settings)
6273
local missing = {}
63-
if not settings.api_url or settings.api_url == "" then table.insert(missing, "API URL") end
74+
if not settings.api_url or settings.api_url == "" then table.insert(missing, "Server URL") end
6475
if not settings.api_user or settings.api_user == "" then table.insert(missing, "Login Username") end
6576
if not settings.api_pass or settings.api_pass == "" then table.insert(missing, "Login Password") end
6677
if not settings.device_name or settings.device_name == "" then table.insert(missing, "Device Name") end

0 commit comments

Comments
 (0)