joins calibre metadata search and calibre wireless connections into a single plugin search metadata changes: - search directly into calibre metadata files. - search can be performed on more than one library (configurable from a menu) - device scans now find all calibre libraries under a given root - search options can be configured from a menu. (case sensitive, find by title, author and path) - removed legacy global variables. - *option* to search from the reader - *option* to generate a cache of books for faster searches. calibre wireless connection changes: - keep track of books in a library (includes prunning books from calibre metadata if the file was deleted locally) - remove files on device from calibre - support password protected connections - FM integration: if we're in the inbox dir it will be updated each time a book is added or deleted. - disconnect when requested by calibre, available on newer calibre versions (+4.17) - remove unused opcodes. - better report of client name, version and device id - free disk space checks for all calibre versions - bump supported extensions to match what KOReader can handle. Users can override this with their own list of extensions (or from calibre, by configuring the wireless device).
138 lines
3.8 KiB
Lua
138 lines
3.8 KiB
Lua
describe("defaults module", function()
|
|
local Defaults, DataStorage
|
|
setup(function()
|
|
require("commonrequire")
|
|
Defaults = require("apps/filemanager/filemanagersetdefaults")
|
|
DataStorage = require("datastorage")
|
|
end)
|
|
|
|
it("should load all defaults from defaults.lua", function()
|
|
Defaults:init()
|
|
assert.is_same(98, #Defaults.defaults_name)
|
|
end)
|
|
|
|
it("should save changes to defaults.persistent.lua", function()
|
|
local persistent_filename = DataStorage:getDataDir() .. "/defaults.persistent.lua"
|
|
os.remove(persistent_filename)
|
|
|
|
-- To see indices and help updating this when new settings are added:
|
|
-- for i=1, 98 do print(i.." ".. Defaults.defaults_name[i]) end
|
|
|
|
-- not in persistent but checked in defaults
|
|
Defaults.changed[20] = true
|
|
Defaults.changed[50] = true
|
|
Defaults.changed[56] = true
|
|
Defaults.changed[85] = true
|
|
Defaults:saveSettings()
|
|
assert.is_same(98, #Defaults.defaults_name)
|
|
assert.is_same("DTAP_ZONE_BACKWARD", Defaults.defaults_name[85])
|
|
assert.is_same("DCREREADER_CONFIG_WORD_SPACING_LARGE", Defaults.defaults_name[50])
|
|
assert.is_same("DCREREADER_CONFIG_H_MARGIN_SIZES_XXX_LARGE", Defaults.defaults_name[20])
|
|
local fd = io.open(persistent_filename, "r")
|
|
assert.Equals(
|
|
[[-- For configuration changes that persists between updates
|
|
DCREREADER_CONFIG_WORD_SPACING_LARGE = {
|
|
[1] = 100,
|
|
[2] = 90
|
|
}
|
|
DTAP_ZONE_BACKWARD = {
|
|
["y"] = 0,
|
|
["x"] = 0,
|
|
["h"] = 1,
|
|
["w"] = 0.25
|
|
}
|
|
DCREREADER_CONFIG_H_MARGIN_SIZES_XXX_LARGE = {
|
|
[1] = 50,
|
|
[2] = 50
|
|
}
|
|
DDOUBLE_TAP_ZONE_PREV_CHAPTER = {
|
|
["y"] = 0,
|
|
["x"] = 0,
|
|
["h"] = 0.25,
|
|
["w"] = 0.25
|
|
}
|
|
]],
|
|
fd:read("*a"))
|
|
fd:close()
|
|
|
|
-- in persistent
|
|
Defaults:init()
|
|
Defaults.changed[56] = true
|
|
Defaults.defaults_value[56] = {
|
|
y = 0,
|
|
x = 0,
|
|
h = 0.25,
|
|
w = 0.75
|
|
}
|
|
Defaults.changed[85] = true
|
|
Defaults.defaults_value[85] = {
|
|
y = 10,
|
|
x = 10.125,
|
|
h = 20.25,
|
|
w = 20.75
|
|
}
|
|
Defaults:saveSettings()
|
|
fd = io.open(persistent_filename)
|
|
assert.Equals(
|
|
[[-- For configuration changes that persists between updates
|
|
DCREREADER_CONFIG_WORD_SPACING_LARGE = {
|
|
[2] = 90,
|
|
[1] = 100
|
|
}
|
|
DDOUBLE_TAP_ZONE_PREV_CHAPTER = {
|
|
["y"] = 0,
|
|
["x"] = 0,
|
|
["h"] = 0.25,
|
|
["w"] = 0.75
|
|
}
|
|
DCREREADER_CONFIG_H_MARGIN_SIZES_XXX_LARGE = {
|
|
[2] = 50,
|
|
[1] = 50
|
|
}
|
|
DTAP_ZONE_BACKWARD = {
|
|
["y"] = 10,
|
|
["x"] = 10.125,
|
|
["h"] = 20.25,
|
|
["w"] = 20.75
|
|
}
|
|
]],
|
|
fd:read("*a"))
|
|
fd:close()
|
|
os.remove(persistent_filename)
|
|
end)
|
|
|
|
it("should delete entry from defaults.persistent.lua if value is reverted back to default", function()
|
|
local persistent_filename = DataStorage:getDataDir() .. "/defaults.persistent.lua"
|
|
local fd = io.open(persistent_filename, "w")
|
|
fd:write(
|
|
[[-- For configuration changes that persists between updates
|
|
DCREREADER_CONFIG_H_MARGIN_SIZES_LARGE = {
|
|
[1] = 15,
|
|
[2] = 15
|
|
}
|
|
DCREREADER_VIEW_MODE = "page"
|
|
DHINTCOUNT = 2
|
|
]])
|
|
fd:close()
|
|
|
|
-- in persistent
|
|
Defaults:init()
|
|
Defaults.changed[57] = true
|
|
Defaults.defaults_value[57] = 1
|
|
Defaults:saveSettings()
|
|
fd = io.open(persistent_filename)
|
|
assert.Equals(
|
|
[[-- For configuration changes that persists between updates
|
|
DCREREADER_VIEW_MODE = "page"
|
|
DCREREADER_CONFIG_H_MARGIN_SIZES_LARGE = {
|
|
[2] = 15,
|
|
[1] = 15
|
|
}
|
|
DGLOBAL_CACHE_FREE_PROPORTION = 1
|
|
DHINTCOUNT = 2
|
|
]],
|
|
fd:read("*a"))
|
|
fd:close()
|
|
os.remove(persistent_filename)
|
|
end)
|
|
end)
|