epub metadata: support multiple authors (#3624)

crengine may now give us multiple authors (if multiple <dc:creator>
in epub metadata) separated by \n.
Deal with that where needed.
Limit the number of authors displayed in coverbrowser views.

Bumped base/crengine: multiple <dc:creator> + fix mobi images order
Bumped base: util.runInSubProcess(): give child its own process group
pull/3627/head
poire-z 6 years ago committed by GitHub
parent 35df1749b2
commit ba389c9a00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1 @@
Subproject commit 9fb7d4ae04d3869579c16a2dc504a69b99e6295b
Subproject commit 65856a78437abed39f38c733c1ad03b2b2d90d70

@ -266,10 +266,11 @@ function BookStatusWidget:genBookInfoGroup()
}
-- author
local text_author = TextWidget:new{
local text_author = TextBoxWidget:new{
text = self.props.authors,
face = self.small_font_face,
padding = Size.padding.default
width = width,
alignment = "center",
}
table.insert(book_meta_info_group,
CenterContainer:new{

@ -145,12 +145,19 @@ function KeyValueItem:init()
}
end
-- self.value may contain some control characters (\n \t...) that would
-- be rendered as a square. Replace them with a shorter and nicer '|'.
-- (Let self.value untouched, as with Hold, the original value can be
-- displayed correctly in TextViewer.)
local tvalue = tostring(self.value)
tvalue = tvalue:gsub("[\n\t]", "|")
local frame_padding = Size.padding.default
local frame_internal_width = self.width - frame_padding * 2
local key_w = frame_internal_width / 2
local value_w = frame_internal_width / 2
local key_w_rendered = RenderText:sizeUtf8Text(0, frame_internal_width, self.tface, self.key).x
local value_w_rendered = RenderText:sizeUtf8Text(0, frame_internal_width, self.cface, self.value).x
local value_w_rendered = RenderText:sizeUtf8Text(0, frame_internal_width, self.cface, tvalue).x
local space_w_rendered = RenderText:sizeUtf8Text(0, frame_internal_width, self.cface, " ").x
if key_w_rendered > key_w or value_w_rendered > value_w then
-- truncate key or value so they fit in one row
@ -158,10 +165,10 @@ function KeyValueItem:init()
if key_w_rendered >= value_w_rendered then
key_w = frame_internal_width - value_w_rendered
self.show_key = RenderText:truncateTextByWidth(self.key, self.tface, frame_internal_width - value_w_rendered)
self.show_value = self.value
self.show_value = tvalue
else
key_w = key_w_rendered + space_w_rendered
self.show_value = RenderText:truncateTextByWidth(self.value, self.cface, frame_internal_width - key_w_rendered,
self.show_value = RenderText:truncateTextByWidth(tvalue, self.cface, frame_internal_width - key_w_rendered,
false, false, true)
self.show_key = self.key
end
@ -182,14 +189,14 @@ function KeyValueItem:init()
key_w = key_w_rendered + space_w_rendered
end
self.show_key = self.key
self.show_value = self.value
self.show_value = tvalue
end
else
if self.value_align == "right" then
key_w = frame_internal_width - value_w_rendered
end
self.show_key = self.key
self.show_value = self.value
self.show_value = tvalue
end
self[1] = FrameContainer:new{

@ -399,6 +399,16 @@ function ListMenuItem:update()
else
title = bookinfo.title and bookinfo.title or filename_without_suffix
authors = bookinfo.authors
-- If multiple authors (crengine separates them with \n), we
-- can display them on multiple lines, but limit to 2, and
-- append "et al." to the 2nd if there are more
if authors and authors:find("\n") then
authors = util.splitToArray(authors, "\n")
if #authors > 2 then
authors = { authors[1], T(_("%1 et al."), authors[2]) }
end
authors = table.concat(authors, "\n")
end
end
-- add Series metadata if requested
if bookinfo.series then

@ -23,8 +23,10 @@ local VerticalSpan = require("ui/widget/verticalspan")
local WidgetContainer = require("ui/widget/container/widgetcontainer")
local lfs = require("libs/libkoreader-lfs")
local logger = require("logger")
local util = require("util")
local _ = require("gettext")
local Screen = Device.screen
local T = require("ffi/util").template
local getMenuText = require("util").getMenuText
local BookInfoManager = require("bookinfomanager")
@ -136,6 +138,16 @@ function FakeCover:init()
-- Also replace underscores with spaces
title = title:gsub("_", " ")
end
-- If multiple authors (crengine separates them with \n), we
-- can display them on multiple lines, but limit to 3, and
-- append "et al." on a 4th line if there are more
if authors and authors:find("\n") then
authors = util.splitToArray(authors, "\n")
if #authors > 3 then
authors = { authors[1], authors[2], T(_("%1 et al."), authors[3]) }
end
authors = table.concat(authors, "\n")
end
-- We build the VerticalGroup widget with decreasing font sizes till
-- the widget fits into available height

Loading…
Cancel
Save