Merge pull request #877 from chrox/opds

fix href with two slash
pull/879/head
Paulo Matias 10 years ago
commit c26e5e3116

@ -13,6 +13,7 @@ local UIManager = require("ui/uimanager")
local Font = require("ui/font")
local Screen = require("ui/screen")
local Geom = require("ui/geometry")
local Device = require("ui/device")
local Event = require("ui/event")
local DEBUG = require("dbg")
local _ = require("gettext")
@ -163,9 +164,21 @@ function FileManager:onClose()
return true
end
function FileManager: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 FileManager:showFiles(path)
DEBUG("show home page")
path = path or G_reader_settings:readSetting("lastdir")
path = path or G_reader_settings:readSetting("lastdir") or self:getDefaultDir()
G_reader_settings:saveSetting("lastdir", path)
UIManager:show(FileManager:new{
dimen = Screen:getSize(),

@ -206,6 +206,13 @@ function OPDSBrowser:genItemTableFromURL(item_url, base_url)
local function build_href(href)
if href:match("^http") then
return href
elseif href:match("^//") then
local parsed = url.parse(item_url or base_url)
if parsed and parsed.scheme then
return parsed.scheme .. ":" .. href
else
return "http:" .. href
end
elseif base_url then
return base_url .. "/" .. href
elseif item_url then
@ -302,7 +309,7 @@ end
function OPDSBrowser:downloadFile(title, format, remote_url)
-- download to last opened dir
-- TODO: let the user select where to store the downloaded file?
local lastdir = G_reader_settings:readSetting("lastdir")
local lastdir = G_reader_settings:readSetting("lastdir") or "."
local local_path = lastdir .. "/" .. title .. "." .. string.lower(format)
DEBUG("downloading file", local_path, "from", remote_url)

Loading…
Cancel
Save