mirror of
https://github.com/koreader/koreader
synced 2024-11-18 03:25:46 +00:00
chore: fix all luacheck issues
This commit is contained in:
parent
252100891f
commit
d6c48b06f9
@ -6,6 +6,4 @@ source "${CI_DIR}/common.sh"
|
||||
travis_retry make fetchthirdparty
|
||||
make all
|
||||
make testfront
|
||||
set +o pipefail
|
||||
luajit $(which luacheck) --no-color -q frontend | tee ./luacheck.out
|
||||
test $(grep Total ./luacheck.out | awk '{print $2}') -le 17
|
||||
luajit $(which luacheck) --no-color -q frontend
|
||||
|
@ -78,14 +78,14 @@ read_globals = {
|
||||
"DDICT_FONT_SIZE",
|
||||
"FRONTLIGHT_SENSITIVITY_DECREASE",
|
||||
"DALPHA_SORT_CASE_INSENSITIVE",
|
||||
"SEARCH_LIBRARY_PATH",
|
||||
"SEARCH_LIBRARY_PATH2",
|
||||
"SEARCH_CASESENSITIVE",
|
||||
"SEARCH_AUTHORS",
|
||||
"SEARCH_TITLE",
|
||||
"SEARCH_TAGS",
|
||||
"SEARCH_SERIES",
|
||||
"SEARCH_PATH",
|
||||
"SEARCH_LIBRARY_PATH",
|
||||
"SEARCH_LIBRARY_PATH2",
|
||||
"KOBO_LIGHT_ON_START",
|
||||
"NETWORK_PROXY",
|
||||
"DUSE_TURBO_LIB",
|
||||
|
@ -36,8 +36,8 @@ function FileManagerMenu:init()
|
||||
home = {
|
||||
icon = "resources/icons/appbar.home.png",
|
||||
callback = function()
|
||||
if settings_changed then
|
||||
settings_changed = false
|
||||
if SetDefaults.settings_changed then
|
||||
SetDefaults.settings_changed = false
|
||||
UIManager:show(ConfirmBox:new{
|
||||
text = _("You have unsaved default settings. Save them now?"),
|
||||
ok_callback = function()
|
||||
|
@ -12,6 +12,7 @@ local Font = require("ui/font")
|
||||
local DEBUG = require("dbg")
|
||||
local T = require("ffi/util").template
|
||||
local _ = require("gettext")
|
||||
local SetDefaults = require("apps/filemanager/filemanagersetdefaults")
|
||||
|
||||
local calibre = "metadata.calibre"
|
||||
local koreaderfile = "temp/metadata.koreader"
|
||||
@ -75,11 +76,11 @@ function Search:getCalibre()
|
||||
if not self.metafile_1 then
|
||||
self.error = _("SEARCH_LIBRARY_PATH should be defined in DEFAULTS.LUA.")
|
||||
else
|
||||
settings_changed = true
|
||||
SetDefaults.settings_changed = true
|
||||
end
|
||||
else
|
||||
if string.sub(SEARCH_LIBRARY_PATH,string.len(SEARCH_LIBRARY_PATH)) ~= "/" then
|
||||
SEARCH_LIBRARY_PATH = SEARCH_LIBRARY_PATH .. "/"
|
||||
SEARCH_LIBRARY_PATH = SEARCH_LIBRARY_PATH .. "/" -- luacheck: ignore
|
||||
end
|
||||
if io.open(SEARCH_LIBRARY_PATH .. calibre,"r") == nil then
|
||||
if io.open(SEARCH_LIBRARY_PATH .. "." .. calibre,"r") == nil then
|
||||
@ -98,7 +99,7 @@ function Search:getCalibre()
|
||||
elseif self.metafile_1 == nil then
|
||||
self.metafile_1 = findcalibre("/mnt")
|
||||
if self.metafile_1 then
|
||||
settings_changed = true
|
||||
SetDefaults.settings_changed = true
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -106,7 +107,7 @@ function Search:getCalibre()
|
||||
local dummy
|
||||
|
||||
if string.sub(SEARCH_LIBRARY_PATH2,string.len(SEARCH_LIBRARY_PATH2)) ~= "/" then
|
||||
SEARCH_LIBRARY_PATH2 = SEARCH_LIBRARY_PATH2 .. "/"
|
||||
SEARCH_LIBRARY_PATH2 = SEARCH_LIBRARY_PATH2 .. "/" -- luacheck: ignore
|
||||
end
|
||||
if io.open(SEARCH_LIBRARY_PATH2 .. calibre,"r") == nil then
|
||||
if io.open(SEARCH_LIBRARY_PATH2 .. "." .. calibre,"r") ~= nil then
|
||||
@ -152,7 +153,7 @@ function Search:ShowSearch()
|
||||
enabled = true,
|
||||
callback = function()
|
||||
self.search_value = self.search_dialog:getInputText()
|
||||
if not settings_changed and self.search_value == dummy and self.lastsearch == "series" then
|
||||
if not SetDefaults.settings_changed and self.search_value == dummy and self.lastsearch == "series" then
|
||||
self.use_previous_search_results = true
|
||||
else
|
||||
self.use_previous_search_results = false
|
||||
@ -166,7 +167,7 @@ function Search:ShowSearch()
|
||||
enabled = true,
|
||||
callback = function()
|
||||
self.search_value = self.search_dialog:getInputText()
|
||||
if not settings_changed and self.search_value == dummy and self.lastsearch == "tags" then
|
||||
if not SetDefaults.settings_changed and self.search_value == dummy and self.lastsearch == "tags" then
|
||||
self.use_previous_search_results = true
|
||||
else
|
||||
self.use_previous_search_results = false
|
||||
@ -190,7 +191,7 @@ function Search:ShowSearch()
|
||||
enabled = true,
|
||||
callback = function()
|
||||
self.search_value = self.search_dialog:getInputText()
|
||||
if not settings_changed and self.search_value == dummy and self.lastsearch == "find" then
|
||||
if not SetDefaults.settings_changed and self.search_value == dummy and self.lastsearch == "find" then
|
||||
self.use_previous_search_results = true
|
||||
else
|
||||
self.use_previous_search_results = false
|
||||
@ -235,7 +236,6 @@ function Search:find(option)
|
||||
local line
|
||||
local i = 1
|
||||
local upsearch
|
||||
local dummy
|
||||
local firstrun
|
||||
|
||||
-- removes leading and closing characters and converts hex-unicodes
|
||||
@ -269,10 +269,10 @@ function Search:find(option)
|
||||
if s == self.authors then
|
||||
self.data[i][self.authors2] = self.data[i][self.authors2] .. " & " .. ReplaceHexChars(line,8,3)
|
||||
elseif s == self.tags then
|
||||
local dummy = ReplaceHexChars(line,8,3)
|
||||
self.data[i][self.tags2] = self.data[i][self.tags2] .. " & " .. dummy
|
||||
self.data[i][self.tags3] = self.data[i][self.tags3] .. "\t" .. dummy
|
||||
self.browse_tags[dummy] = (self.browse_tags[dummy] or 0) + 1
|
||||
local tags_line = ReplaceHexChars(line,8,3)
|
||||
self.data[i][self.tags2] = self.data[i][self.tags2] .. " & " .. tags_line
|
||||
self.data[i][self.tags3] = self.data[i][self.tags3] .. "\t" .. tags_line
|
||||
self.browse_tags[tags_line] = (self.browse_tags[tags_line] or 0) + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -318,16 +318,24 @@ function Search:find(option)
|
||||
line = g:read()
|
||||
end
|
||||
|
||||
local dummy = ""
|
||||
if option == "find" and SEARCH_AUTHORS then dummy = dummy .. self.data[i][self.authors] .. "\n" end
|
||||
if option == "find" and SEARCH_TITLE then dummy = dummy .. self.data[i][self.title] .. "\n" end
|
||||
if option == "find" and SEARCH_PATH then dummy = dummy .. self.data[i][self.path] .. "\n" end
|
||||
local search_content = ""
|
||||
if option == "find" and SEARCH_AUTHORS then
|
||||
search_content = search_content .. self.data[i][self.authors] .. "\n"
|
||||
end
|
||||
if option == "find" and SEARCH_TITLE then
|
||||
search_content = search_content .. self.data[i][self.title] .. "\n"
|
||||
end
|
||||
if option == "find" and SEARCH_PATH then
|
||||
search_content = search_content .. self.data[i][self.path] .. "\n"
|
||||
end
|
||||
if (option == "series" or SEARCH_SERIES) and self.data[i][self.series] ~= "-" then
|
||||
dummy = dummy .. self.data[i][self.series] .. "\n"
|
||||
search_content = search_content .. self.data[i][self.series] .. "\n"
|
||||
self.browse_series[self.data[i][self.series]] = (self.browse_series[self.data[i][self.series]] or 0) + 1
|
||||
end
|
||||
if option == "tags" or SEARCH_TAGS then dummy = dummy .. self.data[i][self.tags] .. "\n" end
|
||||
if not SEARCH_CASESENSITIVE then dummy = string.upper(dummy) end
|
||||
if option == "tags" or SEARCH_TAGS then
|
||||
search_content = search_content .. self.data[i][self.tags] .. "\n"
|
||||
end
|
||||
if not SEARCH_CASESENSITIVE then search_content = string.upper(search_content) end
|
||||
|
||||
for j in string.gmatch(self.data[i][self.tags3],"\t[^\t]+") do
|
||||
if j~="\t" then
|
||||
@ -336,7 +344,7 @@ function Search:find(option)
|
||||
end
|
||||
if DocumentRegistry:getProvider(self.data[i][self.path]) then
|
||||
if upsearch ~= "" then
|
||||
if string.find(dummy,upsearch,nil,true) then
|
||||
if string.find(search_content,upsearch,nil,true) then
|
||||
i = i + 1
|
||||
end
|
||||
else
|
||||
@ -372,23 +380,23 @@ function Search:find(option)
|
||||
if line == " }, " or line == " }" then
|
||||
-- new calibre data set
|
||||
|
||||
dummy = ""
|
||||
if option == "find" and SEARCH_AUTHORS then dummy = dummy .. self.data[i][self.authors] .. "\n" end
|
||||
if option == "find" and SEARCH_TITLE then dummy = dummy .. self.data[i][self.title] .. "\n" end
|
||||
if option == "find" and SEARCH_PATH then dummy = dummy .. self.data[i][self.path] .. "\n" end
|
||||
local search_content = ""
|
||||
if option == "find" and SEARCH_AUTHORS then search_content = search_content .. self.data[i][self.authors] .. "\n" end
|
||||
if option == "find" and SEARCH_TITLE then search_content = search_content .. self.data[i][self.title] .. "\n" end
|
||||
if option == "find" and SEARCH_PATH then search_content = search_content .. self.data[i][self.path] .. "\n" end
|
||||
if (option == "series" or SEARCH_SERIES) and self.data[i][self.series] ~= "-" then
|
||||
dummy = dummy .. self.data[i][self.series] .. "\n"
|
||||
search_content = search_content .. self.data[i][self.series] .. "\n"
|
||||
self.browse_series[self.data[i][self.series]] = (self.browse_series[self.data[i][self.series]] or 0) + 1
|
||||
end
|
||||
if option == "tags" or SEARCH_TAGS then dummy = dummy .. self.data[i][self.tags] .. "\n" end
|
||||
if not SEARCH_CASESENSITIVE then dummy = string.upper(dummy) end
|
||||
if option == "tags" or SEARCH_TAGS then search_content = search_content .. self.data[i][self.tags] .. "\n" end
|
||||
if not SEARCH_CASESENSITIVE then search_content = string.upper(search_content) end
|
||||
|
||||
for j = 1,9 do
|
||||
g:write(self.data[i][j] .. "\n")
|
||||
end
|
||||
|
||||
if upsearch ~= "" then
|
||||
if string.find(dummy,upsearch,nil,true) then
|
||||
if string.find(search_content,upsearch,nil,true) then
|
||||
i = i + 1
|
||||
end
|
||||
else
|
||||
@ -464,8 +472,7 @@ function Search:find(option)
|
||||
self:browse(option,1)
|
||||
end
|
||||
else
|
||||
dummy = _("No match for") .. " " .. self.search_value
|
||||
UIManager:show(InfoMessage:new{text = dummy})
|
||||
UIManager:show(InfoMessage:new{text = T(_("No match for %1."), self.search_value)})
|
||||
end
|
||||
end
|
||||
|
||||
@ -616,14 +623,14 @@ function Search:browse(option, run, chosen)
|
||||
local i = 1
|
||||
while i <= self.count do
|
||||
if (option == "tags" and self.data[i][self.tags3]:find("\t" .. chosen .. "\t",nil,true)) or (option == "series" and chosen == self.data[i][self.series]) then
|
||||
local dummy = _("Title: ") .. (self.data[i][self.title] or "-") .. "\n \n" ..
|
||||
local entry = _("Title: ") .. (self.data[i][self.title] or "-") .. "\n \n" ..
|
||||
_("Author(s):") .. " " .. (self.data[i][self.authors2] or "-") .. "\n \n" ..
|
||||
_("Tags:") .. " " .. (self.data[i][self.tags2] or "-") .. "\n \n" ..
|
||||
_("Series:") .. " " .. (self.data[i][self.series] or "-")
|
||||
if self.data[i][self.series] ~= "-" then
|
||||
dummy = dummy .. " (" .. tostring(self.data[i][self.series_index]):gsub(".0$","") .. ")"
|
||||
entry = entry .. " (" .. tostring(self.data[i][self.series_index]):gsub(".0$","") .. ")"
|
||||
end
|
||||
dummy = dummy .. "\n \n" .. _("Path: ")
|
||||
entry = entry .. "\n \n" .. _("Path: ")
|
||||
local book = self.data[i][self.path]
|
||||
local text
|
||||
if option == "series" then
|
||||
@ -637,7 +644,7 @@ function Search:browse(option, run, chosen)
|
||||
end
|
||||
table.insert(self.results, {
|
||||
text = text,
|
||||
info = dummy,
|
||||
info = entry,
|
||||
notchecked = true,
|
||||
path = self.data[i][self.path],
|
||||
callback = function()
|
||||
|
@ -24,7 +24,8 @@ local SetDefaults = InputContainer:new{
|
||||
results = {},
|
||||
defaults_menu = {},
|
||||
initialized = false,
|
||||
changed = {}
|
||||
changed = {},
|
||||
settings_changed = false,
|
||||
}
|
||||
|
||||
function SetDefaults:ConfirmEdit()
|
||||
@ -118,7 +119,7 @@ function SetDefaults:init()
|
||||
callback = function()
|
||||
self.defaults_value[i] = true
|
||||
_G[setting_name] = true
|
||||
settings_changed = true
|
||||
self.settings_changed = true
|
||||
self.changed[i] = true
|
||||
self.results[i].text = self:build_setting(i)
|
||||
self:close()
|
||||
@ -132,7 +133,7 @@ function SetDefaults:init()
|
||||
callback = function()
|
||||
self.defaults_value[i] = false
|
||||
_G[setting_name] = false
|
||||
settings_changed = true
|
||||
self.settings_changed = true
|
||||
self.changed[i] = true
|
||||
self.results[i].text = self:build_setting(i)
|
||||
self.defaults_menu:swithItemTable("Defaults", self.results, i)
|
||||
@ -180,7 +181,7 @@ function SetDefaults:init()
|
||||
_G[setting_name] = new_table
|
||||
|
||||
self.defaults_value[i] = _G[setting_name]
|
||||
settings_changed = true
|
||||
self.settings_changed = true
|
||||
self.changed[i] = true
|
||||
|
||||
self.results[i].text = self:build_setting(i)
|
||||
@ -221,7 +222,7 @@ function SetDefaults:init()
|
||||
if _G[setting_name] ~= new_value then
|
||||
_G[setting_name] = new_value
|
||||
self.defaults_value[i] = new_value
|
||||
settings_changed = true
|
||||
self.settings_changed = true
|
||||
self.changed[i] = true
|
||||
self.results[i].text = self:build_setting(i)
|
||||
end
|
||||
@ -338,7 +339,7 @@ function SetDefaults:saveSettings()
|
||||
text = _("Default settings saved."),
|
||||
})
|
||||
end
|
||||
settings_changed = false
|
||||
self.settings_changed = false
|
||||
end
|
||||
|
||||
return SetDefaults
|
||||
|
Loading…
Reference in New Issue
Block a user