mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #1766 from houqp/houqp-master
fix #1764 & bump koreader-base
This commit is contained in:
4
Makefile
4
Makefile
@@ -124,6 +124,10 @@ clean:
|
||||
$(Q:@=@echo 'MAKE -C base clean'; &> /dev/null) \
|
||||
$(MAKE) -C $(KOR_BASE) clean
|
||||
|
||||
dist-clean: clean
|
||||
rm -rf $(INSTALL_DIR)
|
||||
$(MAKE) -C $(KOR_BASE) dist-clean
|
||||
|
||||
# Don't bundle launchpad on touch devices..
|
||||
ifeq ($(TARGET), kindle-legacy)
|
||||
KINDLE_LEGACY_LAUNCHER:=launchpad
|
||||
|
||||
11
README.md
11
README.md
@@ -108,18 +108,17 @@ Koreader on Linux PC. Fedora users can install `SDL` and `SDL-devel` package.
|
||||
Ubuntu users probably need to install `libsdl2-dev` package:
|
||||
|
||||
Getting the source
|
||||
========
|
||||
==================
|
||||
|
||||
```
|
||||
git clone https://github.com/koreader/koreader.git
|
||||
cd koreader
|
||||
make fetchthirdparty
|
||||
cd koreader && make fetchthirdparty
|
||||
```
|
||||
|
||||
Building & Running & Testing
|
||||
========
|
||||
Building, Running and Testing
|
||||
=============================
|
||||
|
||||
For real reader devices
|
||||
For EReader devices (kindle, kobo, pocketbook)
|
||||
---------------------
|
||||
|
||||
To build installable package for Kindle:
|
||||
|
||||
2
base
2
base
Submodule base updated: 9a2503bacc...059c1f5cba
@@ -11,6 +11,7 @@ local FileChooser = require("ui/widget/filechooser")
|
||||
local TextWidget = require("ui/widget/textwidget")
|
||||
local Blitbuffer = require("ffi/blitbuffer")
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local docsettings = require("docsettings")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Screen = require("device").screen
|
||||
local Geom = require("ui/geometry")
|
||||
@@ -277,18 +278,35 @@ function FileManager:pasteHere(file)
|
||||
end
|
||||
|
||||
function FileManager:deleteFile(file)
|
||||
local ok, err
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
DEBUG("File to remove", util.realpath(file))
|
||||
local rm = util.execute(self.rm_bin, "-rf", util.realpath(file))
|
||||
DEBUG("rm status", rm)
|
||||
if rm == 0 then
|
||||
local file_abs_path = util.realpath(file)
|
||||
if file_abs_path == nil then
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("Successfully deleted\n") .. file,
|
||||
text = util.template(_("File %1 not found"), file),
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
local is_doc = DocumentRegistry:getProvider(file_abs_path)
|
||||
ok, err = os.remove(file_abs_path)
|
||||
if err == nil then
|
||||
if is_doc ~= nil then
|
||||
-- also delete history/settings for documents
|
||||
local sidecar_dir = docsettings:getSidecarDir(file_abs_path)
|
||||
if lfs.attributes(sidecar_dir, "mode") == "directory" then
|
||||
util.purgeDir(sidecar_dir)
|
||||
end
|
||||
local legacy_history_file = docsettings:getHistoryPath(file)
|
||||
ok, err = os.remove(legacy_history_file)
|
||||
end
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = util.template(_("Successfully deleted %1"), file),
|
||||
timeout = 2,
|
||||
})
|
||||
else
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("An error occurred while trying to delete\n") .. file,
|
||||
text = util.template(_("An error occurred while trying to delete %1"), file),
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,7 +41,7 @@ function FileSearcher:readDir()
|
||||
local fullpath = d.."/"..f
|
||||
local attributes = lfs.attributes(fullpath)
|
||||
if attributes.mode == "directory" and f ~= "." and f~=".." then
|
||||
table.insert(new_dirs, d.."/"..f)
|
||||
table.insert(new_dirs, fullpath)
|
||||
elseif attributes.mode == "file" and DocumentRegistry:getProvider(fullpath) then
|
||||
table.insert(self.files, {name = f, path = fullpath, attr = attributes})
|
||||
end
|
||||
|
||||
@@ -6,6 +6,10 @@ local DocSettings = {}
|
||||
|
||||
local history_dir = DataStorage:getDataDir() .. "/history/"
|
||||
|
||||
function DocSettings:getSidecarDir(doc_path)
|
||||
return doc_path:match("(.*)%.")..".sdr"
|
||||
end
|
||||
|
||||
function DocSettings:getHistoryPath(fullpath)
|
||||
return history_dir .. "[" .. fullpath:gsub("(.*/)([^/]+)","%1] %2"):gsub("/","#") .. ".lua"
|
||||
end
|
||||
@@ -34,7 +38,7 @@ function DocSettings:open(docfile)
|
||||
else
|
||||
history_path = self:getHistoryPath(docfile)
|
||||
|
||||
local sidecar = docfile:match("(.*)%.")..".sdr"
|
||||
local sidecar = self:getSidecarDir(docfile)
|
||||
if lfs.attributes(sidecar, "mode") ~= "directory" then
|
||||
lfs.mkdir(sidecar)
|
||||
end
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
TITLE: koreader
|
||||
TITLE: KOReader
|
||||
|
||||
CONTAINS: KUAL files for installation in /mnt/us/extensions/
|
||||
CONTAINS: KUAL files for installation in /mnt/us/extensions/
|
||||
|
||||
REF: Main KUAL thread http://www.mobileread.com/forums/showthread.php?t=203326
|
||||
|
||||
UPSTREAM SOURCE: https://github.com/koreader/koreader
|
||||
|
||||
SUPPORTS:
|
||||
DX No
|
||||
K3 No
|
||||
K4 No
|
||||
SUPPORTS:
|
||||
DX Yes
|
||||
K3 Yes
|
||||
K4 Yes
|
||||
Touch Yes
|
||||
PW Yes
|
||||
Voyage Yes
|
||||
|
||||
REQUIRES: koreader
|
||||
|
||||
ARCHIVAL LINK:
|
||||
ARCHIVAL LINK:
|
||||
|
||||
ORIGINAL AUTHOR: koreader development team
|
||||
ORIGINAL AUTHOR: KOReader development team
|
||||
|
||||
NOTES: this is the successor of KindlePDFviewer for devices with touch input support. Support for keyboard input is to be done, use the legacy KindlePDFviewer or Librerator for this. Report issues and bugs on github.
|
||||
NOTES: this is the successor of KindlePDFviewer for devices with touch input
|
||||
support. Support for keyboard input is to be done, use the legacy
|
||||
KindlePDFviewer or Librerator for this. Report issues and bugs on github.
|
||||
|
||||
10
spec/unit/docsettings_spec.lua
Normal file
10
spec/unit/docsettings_spec.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
require("commonrequire")
|
||||
local doc = require("docsettings")
|
||||
|
||||
describe("docsettings module", function()
|
||||
it("should generate sidecar directory path", function()
|
||||
assert.Equals("../../foo.sdr", doc:getSidecarDir("../../foo.pdf"))
|
||||
assert.Equals("/foo/bar.sdr", doc:getSidecarDir("/foo/bar.pdf"))
|
||||
assert.Equals("baz.sdr", doc:getSidecarDir("baz.pdf"))
|
||||
end)
|
||||
end)
|
||||
@@ -1,7 +1,10 @@
|
||||
require("commonrequire")
|
||||
local FileManager = require("apps/filemanager/filemanager")
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local docsettings = require("docsettings")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Screen = require("device").screen
|
||||
local util = require("ffi/util")
|
||||
local DEBUG = require("dbg")
|
||||
|
||||
describe("FileManager module", function()
|
||||
@@ -15,4 +18,85 @@ describe("FileManager module", function()
|
||||
UIManager:scheduleIn(1, function() UIManager:close(filemanager) end)
|
||||
UIManager:run()
|
||||
end)
|
||||
it("should show error on non-existent file", function()
|
||||
local filemanager = FileManager:new{
|
||||
dimen = Screen:getSize(),
|
||||
root_path = "../../test",
|
||||
}
|
||||
local old_show = UIManager.show
|
||||
local tmp_fn = "/abc/123/test/foo.bar.baz.tmp.epub.pdf"
|
||||
UIManager.show = function(self, w)
|
||||
assert.Equals(w.text, "File "..tmp_fn.." not found")
|
||||
end
|
||||
assert.is_nil(lfs.attributes(tmp_fn))
|
||||
filemanager:deleteFile(tmp_fn)
|
||||
UIManager.show = old_show
|
||||
end)
|
||||
it("should not delete settings for non-document file", function()
|
||||
local filemanager = FileManager:new{
|
||||
dimen = Screen:getSize(),
|
||||
root_path = "../../test",
|
||||
}
|
||||
|
||||
local tmp_fn = "../../test/2col.test.tmp.sh"
|
||||
util.copyFile("../../test/2col.pdf", tmp_fn)
|
||||
|
||||
local tmp_sidecar = docsettings:getSidecarDir(util.realpath(tmp_fn))
|
||||
lfs.mkdir(tmp_sidecar)
|
||||
local tmp_history = docsettings:getHistoryPath(tmp_fn)
|
||||
local tmpfp = io.open(tmp_history, "w")
|
||||
tmpfp:write("{}")
|
||||
tmpfp:close()
|
||||
local old_show = UIManager.show
|
||||
|
||||
-- make sure file exists
|
||||
assert.is_not_nil(lfs.attributes(tmp_fn))
|
||||
assert.is_not_nil(lfs.attributes(tmp_sidecar))
|
||||
assert.is_not_nil(lfs.attributes(tmp_history))
|
||||
|
||||
UIManager.show = function(self, w)
|
||||
assert.Equals(w.text, "Successfully deleted "..tmp_fn)
|
||||
end
|
||||
filemanager:deleteFile(tmp_fn)
|
||||
UIManager.show = old_show
|
||||
|
||||
-- make sure history file exists
|
||||
assert.is_nil(lfs.attributes(tmp_fn))
|
||||
assert.is_not_nil(lfs.attributes(tmp_sidecar))
|
||||
assert.is_not_nil(lfs.attributes(tmp_history))
|
||||
os.remove(tmp_sidecar)
|
||||
os.remove(tmp_history)
|
||||
end)
|
||||
it("should delete document with its settings", function()
|
||||
local filemanager = FileManager:new{
|
||||
dimen = Screen:getSize(),
|
||||
root_path = "../../test",
|
||||
}
|
||||
|
||||
local tmp_fn = "../../test/2col.test.tmp.pdf"
|
||||
util.copyFile("../../test/2col.pdf", tmp_fn)
|
||||
|
||||
local tmp_sidecar = docsettings:getSidecarDir(util.realpath(tmp_fn))
|
||||
lfs.mkdir(tmp_sidecar)
|
||||
local tmp_history = docsettings:getHistoryPath(tmp_fn)
|
||||
local tmpfp = io.open(tmp_history, "w")
|
||||
tmpfp:write("{}")
|
||||
tmpfp:close()
|
||||
local old_show = UIManager.show
|
||||
|
||||
-- make sure file exists
|
||||
assert.is_not_nil(lfs.attributes(tmp_fn))
|
||||
assert.is_not_nil(lfs.attributes(tmp_sidecar))
|
||||
assert.is_not_nil(lfs.attributes(tmp_history))
|
||||
|
||||
UIManager.show = function(self, w)
|
||||
assert.Equals(w.text, "Successfully deleted "..tmp_fn)
|
||||
end
|
||||
filemanager:deleteFile(tmp_fn)
|
||||
UIManager.show = old_show
|
||||
|
||||
assert.is_nil(lfs.attributes(tmp_fn))
|
||||
assert.is_nil(lfs.attributes(tmp_sidecar))
|
||||
assert.is_nil(lfs.attributes(tmp_history))
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user