2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00
koreader/frontend/apps/filemanager/filemanagerutil.lua
poire-z 17656778b1 Book information: refactored and additional features
- Factored out duplicate code from filemanager.lua and filemanagerhistory.lua
to new filemanagerbookinfo.lua (and other common code to filemanagerutil.lua).
- Uses sidecar files' new doc_props and doc_pages settings, or fallback to
old 'stats' settings, or to opening document.
- Shows filename, filetype and directory.
- Shows description (Hold to see whole truncated text), keywords, and
cover image (tap to extract image from document and display it if available).
- Book information now available from reader menu, to display info about
the currently opened book.
- Convert possibly HTML description to plain text via added
util.htmlToPlainTextIfHtml() (for simple HTML conversion).
2017-07-14 16:46:38 +02:00

35 lines
892 B
Lua

--[[--
This module contains miscellaneous helper functions for FileManager
]]
local Device = require("device")
local filemanagerutil = {}
function filemanagerutil.getDefaultDir()
if Device:isKindle() then
return "/mnt/us/documents"
elseif Device:isKobo() then
return "/mnt/onboard"
elseif Device:isAndroid() then
return "/sdcard"
else
return "."
end
end
function filemanagerutil.abbreviate(path)
local home_dir_name = G_reader_settings:readSetting("home_dir_display_name")
if home_dir_name ~= nil then
local home_dir = G_reader_settings:readSetting("home_dir") or filemanagerutil.getDefaultDir()
local len = home_dir:len()
local start = path:sub(1, len)
if start == home_dir then
return home_dir_name .. path:sub(len+1)
end
end
return path
end
return filemanagerutil