Skip to content
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

Frenzie
Copy link
Member

@Frenzie 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


--- Returns the registered document handlers.
-- @string file
-- @treturn string provider, or nil
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, table. :-P

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

if #providers >= 1 then
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

@poire-z poire-z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Frenzie Frenzie force-pushed the document-provider-weight branch 2 times, most recently from d591f34 to 0a60c7b Compare January 31, 2018 19:01
@Frenzie Frenzie force-pushed the document-provider-weight branch 2 times, most recently from a1a4302 to 9eed3f5 Compare January 31, 2018 19:17
This is step one toward "open with".

References koreader#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 merged commit d714bd3 into koreader:master Jan 31, 2018
@Frenzie Frenzie deleted the document-provider-weight branch January 31, 2018 19:49
@Frenzie
Copy link
Member Author

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
Copy link
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
Copy link

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants