New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] DocumentRegistry: add getProviders() and preferred by weight #3651

Merged
merged 1 commit into from Jan 31, 2018

Conversation

Projects
None yet
4 participants
@Frenzie
Member

Frenzie commented Jan 31, 2018

This is step one toward "open with".

References #3345

  • Fix up some mimetypes
  • Add XHTML to supported filetypes
  • Add a few image files to MuPDF
    • ".bmp",
    • ".gif",
    • ".hdp",
    • ".j2k",
    • ".jp2",
    • ".jpeg",
    • ".jpg",
    • ".jpx",
    • ".jxr",
    • ".pam",
    • ".pbm",
    • ".pgm",
    • ".png",
    • ".pnm",
    • ".ppm",
    • ".tif",
    • ".tiff",
    • ".wdp",

@poire-z Any thoughts on this before I start thinking about GUI and settings?

PS Regarding GUI, I was thinking maybe something like this:

screenshot_2018-01-31_18-05-20

@Frenzie Frenzie force-pushed the Frenzie:document-provider-weight branch from 676477e to d46e539 Jan 31, 2018

--- Returns the registered document handlers.
-- @string file
-- @treturn string provider, or nil

This comment has been minimized.

@Frenzie

Frenzie Jan 31, 2018

Member

Whoops, table. :-P

-- @string file
-- @treturn string provider, or nil
function DocumentRegistry:getProvider(file)
local providers = self:getProviders(file)
if #providers >= 1 then

This comment has been minimized.

@Frenzie

Frenzie Jan 31, 2018

Member

This test should probably be in getProviders(), just return nil instead of an empty table.

return provider.provider
-- stick highest weighted provider at the front
if #providers >= 1 and provider.weight > providers[#providers].weight then
table.insert(providers, #providers, provider)

This comment has been minimized.

@poire-z

poire-z Jan 31, 2018

Contributor

Shouldn't the two #providers be 1 if you want to stick it at the front ?

This comment has been minimized.

@Frenzie

Frenzie Jan 31, 2018

Member

Definitely. Kind of a half-finished thought about sorting by weight when I realized that doesn't really matter I suppose.

@@ -6,7 +6,8 @@ local pic = nil
local PicDocument = Document:new{
_document = false,
is_pic = true,
dc_null = DrawContext.new()
dc_null = DrawContext.new(),
provider_name = "Picture Document (MuPDF)",

This comment has been minimized.

@poire-z

poire-z Jan 31, 2018

Contributor

I don't think this one uses MuPDF: it uses some libjpeg/libpng/libgif directly.

@Frenzie Frenzie force-pushed the Frenzie:document-provider-weight branch 2 times, most recently from d591f34 to 0a60c7b Jan 31, 2018

@Frenzie Frenzie added the enhancement label Jan 31, 2018

@Frenzie Frenzie force-pushed the Frenzie:document-provider-weight branch 2 times, most recently from a1a4302 to 9eed3f5 Jan 31, 2018

[feat] DocumentRegistry: add getProviders() and preferred by weight
This is step one toward "open with".

References #3345

* Fix up some mimetypes
* Add XHTML to supported filetypes
* Add a few image files to MuPDF
	* ".bmp",
	* ".gif",
	* ".hdp",
	* ".j2k",
	* ".jp2",
	* ".jpeg",
	* ".jpg",
	* ".jpx",
	* ".jxr",
	* ".pam",
	* ".pbm",
	* ".pgm",
	* ".png",
	* ".pnm",
	* ".ppm",
	* ".tif",
	* ".tiff",
        * ".wdp",

@Frenzie Frenzie force-pushed the Frenzie:document-provider-weight branch from 9eed3f5 to ad3cc46 Jan 31, 2018

@Frenzie Frenzie merged commit d714bd3 into koreader:master Jan 31, 2018

1 check passed

ci/circleci Your tests passed on CircleCI!
Details

@Frenzie Frenzie deleted the Frenzie:document-provider-weight branch Jan 31, 2018

@Frenzie

This comment has been minimized.

Member

Frenzie commented Jan 31, 2018

@poire-z @TnS-hun I realized that MuPDF includes libraries for really neat stuff like JPEG2000 since 1.10 so obviously I had to include that as well. ;-)

@TnS-hun

This comment has been minimized.

Contributor

TnS-hun commented Jan 31, 2018

Time to change the description from "An ebook reader application" to "An ebook reader and image viewer application". :)

@KenMaltby

This comment has been minimized.

KenMaltby commented Jan 31, 2018

As color becomes more important to KOReader, on Android Phones and tablets, and, someday a color eink/epaper, the image viewer function might become a factor. Maybe there could be a "Slideshow" plugin some day?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment