* Add comments to a few functions
* Fix bug associated with arxiv catalog.
See comments in genItemTableFromCatalog. Basically, though, the bug
was related to the checking of the acquisition urls. Arxiv only has
PDFs available to download, and the block wasn't catching these with
its existing logic. By adding another clause to look for PDF link
types, and fixing href values that were missing the PDF suffix, we can
successfully download PDFs from Arxiv.
andheaders.location:match("^http[^s]")then-- Page is redirecting
UIManager:show(InfoMessage:new{
text=T(_("Insecure HTTPS → HTTP downgrade attempted by redirect from:\n\n'%1'\n\nto\n\n'%2'.\n\nPlease inform the server administrator that many clients disallow this because it could be a downgrade attack."),BD.url(item_url),BD.url(headers.location)),
text=T(_("Insecure HTTPS → HTTP downgrade attempted by redirect from:\n\n'%1'\n\nto\n\n'%2'.\n\nPlease inform the server administrator that many clients disallow this because it could be a downgrade attack."),
BD.url(item_url),
BD.url(headers.location)),
icon="notice-warning",
})
elseifcode==401then
elseifcode==401then-- Not authorized
UIManager:show(InfoMessage:new{
text=T(_("Authentication required for catalog. Please add a username and password.")),
})
elseifcode==403then
elseifcode==403then-- Authorization attemp failed
UIManager:show(InfoMessage:new{
text=T(_("Failed to authenticate. Please check your username and password.")),
})
elseifcode==404then
elseifcode==404then-- Page not found
UIManager:show(InfoMessage:new{
text=T(_("Catalog not found.")),
})
elseifcode==406then
elseifcode==406then-- Server cannot fulfil our request
UIManager:show(InfoMessage:new{
text=T(_("Cannot get catalog. Server refuses to serve uncompressed content.")),
})
else
-- This block handles all other requests and supplies the user with a generic
-- error message and no more information than the code.
UIManager:show(InfoMessage:new{
text=T(_("Cannot get catalog. Server response code %1."),code),
})
@ -448,7 +492,10 @@ function OPDSBrowser:genItemTableFromCatalog(catalog, item_url, username, passwo
orlink.rel=="http://opds-spec.org/sort/new")then
item.url=build_href(link.href)
end
iflink.relthen
-- Some catalogs do not use the rel attribute to denote
-- a publication. Arxiv uses title. Specifically, it uses
-- a title attribute that contains pdf. (title="pdf")
iflink.relorlink.titlethen
iflink.rel:match(self.acquisition_rel)then
table.insert(item.acquisitions,{
type=link.type,
@ -459,6 +506,23 @@ function OPDSBrowser:genItemTableFromCatalog(catalog, item_url, username, passwo
elseiflink.rel==self.image_relthen
item.image=build_href(link.href)
end
-- This statement grabs the catalog items that are
-- indicated by title="pdf" or whose type is
-- "application/pdf"
iflink.title=="pdf"orlink.type=="application/pdf"
andlink.rel~="subsection"then
-- Check for the presence of the pdf suffix and add it
-- if it's missing.
localhref=link.href
localfiletype=util.getFileNameSuffix(link.href)
iffiletype~="pdf"then
href=href..".pdf"
end
table.insert(item.acquisitions,{
type=link.title,
href=build_href(href),
})
end
end
end
end
@ -631,6 +695,7 @@ function OPDSBrowser:showDownloads(item)