css_tweaks: Add generic setting for smaller inpage footnotes #13613
Conversation
8f31e29 to
4c2ab7e
Compare
4c2ab7e to
2379025
Compare
|
very happy with the removal of all the duplicate settings, although the I do find the names unrelated to this PR but, shouldn't that |
2379025 to
09f0dc6
Compare
|
I've rebased out the footnote extension changes, let's keep that discussion in #13554. Just means I'll need to rebase whichever one of these is merged first. |
|
If we can, I'd be all for getting rid of the "smaller" stuff, as it is redundant with choosing a font size (80%) in the "In-page footnote font size" submenu. But please have a look at (no time myself to re-read all that - and this PR - this evening):
These font size items works with each their own id - styletweaks are not dynamic, they are just stored as IDs to static bits of CSS. Having a SpinWidget would need a lot more work to pick the right ID or need some more dynamic CSS spitting, not worth the effort (and I like these menu items, easier that having to play with a SpinWidget). |
|
Pushed an alternative that allows getting rid of "smaller" while keeping all current behavior/combinations in #13639. Not sure if it's worth it though or if this simplification is enough. |
| conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_") end, | ||
| global_conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_classic_classnames") end, | ||
| title = _("In-page classic classname footnotes (smaller)"), | ||
| id = "smaller_footnote-inpage", |
There was a problem hiding this comment.
We may sort all the settings in settings.reader.lua, so it would be nice if this one started the same as the other.
I think we start with footnote_inpage_ when targetting elements to be a footnote, and inpage_footnote_ when adjusting a matched element, so this one could be named inpage_footnote_smaller.
|
Looks like you'd be migrating only global tweaks. |
|
I personally hate both those screenshots, but hate the left one a lot less, does it really need to use word “force”? |
|
All the style tweaks are about forcing things, so indeed that seems redundant at best. |
Forget about how it looks. But what does it do? ;-) I'm not quite sure what this is trying to say. What's the same hint with different values?
|
|
Sorry, I should have elaborated a bit more. I pushed the left version without the wording change. I just moved the "smaller footnotes" hint, which is Into the footnote size submenu. This keeps the same behavior that's in master right now if you select one of the duplicated "smaller" in-page footnote options. (i.e. within footnotes, relative font-sizes work) I wanted to find some wording that distinguishes this from the footnote font-size tweaks, which override the size of each (block) element in the footnote to e.g. This has always been confusing in my opinion. If you select the smaller footnotes, what do the footnote font-size hints do? Maybe "override" would be a wording that's more consistent with other tweaks? In any case, I just split out the duplicated "smaller" part from the footnotes and moved it to the submenu for now (and specified that it's 80%, because all the other size options also specify the size).
This doesn't quite get rid of it. I don't think it's possible without fundamentally changing behavior as you were worried about and I think it's valuable to have a tweak that just changes the size at the top level of the footnote (or some way to scale the font-size of a whole block in This should at least be less cluttered than the duplicated "smaller" footnote hints and correctly does conflicts to make it clear that the font-size tweaks override the "smaller" variant.
|
| -- Global settings, https://github.com/koreader/koreader/pull/4945 & https://github.com/koreader/koreader/pull/5655 | ||
| -- Limit the check to the most recent update. ReaderUI calls this one unconditionally to update docsettings, too. | ||
| if last_migration_date < 20191129 then | ||
| logger.info("Performing one-time migration for 20191129") | ||
|
|
||
| local SettingsMigration = require("ui/data/settings_migration") | ||
| SettingsMigration:migrateSettings(G_reader_settings) |
There was a problem hiding this comment.
This one has not been used since 2019 - not sure why. May be it existed before we introduced onetimemigration, which is where migration stuff has been happening :) @NiLuJe ?
So, dunno if it's a good idea to ressurect/reuse that one, which did/would do other stuff.
There was a problem hiding this comment.
No strong feeling about it, but it probably couldn't hurt to keep the old one as-is, and just add another specific method in SettingsMigration for that one ;).
There was a problem hiding this comment.
onetimemigration also handles global settings. It was introduced by you in April 2021.
settings_migration has had minor stuff added after 2019, but given that it's driven since Apr 2021 by your PR with a last_migration_date < 2019 condition, it has had no effect and use.
I'd be for keeping everything in onetime_migration.
| -- base hint | ||
| -- | ||
| -- | n | t | f | | ||
| -- ---+---+---+---+ | ||
| -- small n | n | t | f | | ||
| -- hint t | t | t | t | | ||
| -- f | f | t | f | |
There was a problem hiding this comment.
What do n, t and f stand for ? I really can't say :/ so it needs a comment.
Some minutes later: Oh, nil, true and false ! you may as well write them fully :)
Some minutes later: what does hint means ? What's the last unamed line, the resut ?
There was a problem hiding this comment.
I hope it's clearer now. The two input dimensions are the tweak setting for e.g. classname footnotes and smaller classname footnotes, the fields are the result after the migration.
I found it helpful to write down all the cases especially because the meaning differs a bit between global and per-book settings.
There was a problem hiding this comment.
Oh, "base hint" written on 2 lines :)
"hint" feels like not the best word, I would just use "note".
There was a problem hiding this comment.
I changed it to hopefully be unambiguous and also make it clear that this is per footnote type. (diff above is outdated though)
For some reason my brain keeps replacing "tweak" with "hint", but I think I fixed that in all comments (probably because of -cr-hint)...
| id = "inpage_footnote_font-size_smaller", | ||
| conflicts_with = function(id) return util.stringStartsWith(id, "inpage_footnote_font-size_") end, | ||
| title = _("Smaller footnotes (80%)"), | ||
| description = _([[ | ||
| Decrease size of in-page footnotes.]]), | ||
| css = [[ | ||
| body[name="notes"] > section { | ||
| -cr-only-if: fb2-document; | ||
| font-size: 0.75rem; | ||
| } | ||
| body[name="comments"] > section { | ||
| -cr-only-if: fb2-document; | ||
| font-size: 0.85rem; | ||
| } | ||
| *, autoBoxing { | ||
| -cr-hint: late; | ||
| -cr-only-if: -fb2-document inpage-footnote; | ||
| font-size: 0.8rem !important; | ||
| } | ||
| ]], | ||
| separator = true, | ||
| }, |
There was a problem hiding this comment.
OK, what I disliked in the other PR, I'm ok with having it only in this "somehow legacy" tweak.
May be it could have a more verbose description, mentionning it's limited (no inheritance, so possibly no effect - the reasong why you qualitied the others with "force" all along).
There was a problem hiding this comment.
I'm honestly not 100% sure if I like this better or if it's better to keep the fb2 footnote size tweak separate. My main concern was cleaning up the top-level footnote menu and I got a bit carried away.
As you noted, it prevents some combinations like having larger epub and smaller fb2.
Any preference on your side for reducing menu items vs keeping fb2 size separate? (as in master, or also moving it inside font size)
There was a problem hiding this comment.
Dunno, not sure I get what the options are :).
I don't mint not reducing menu stuff for FB2 and having them separated (FB2 is useful to user from a few countries only, 98% of users won't ever hear about FB2).
I'd rather not have the font size % duplicated in the FB2 submenu.
There was a problem hiding this comment.
I reverted the changes to fb2, incorporating that into the migration would have been tricky anyway.
It now just removes the "smaller" top-level variants and moves them to the footnote font-size submenu.
|
Ok, I prefer this one.
Initially, we only had the pairs "normal" and "smaller", which were not "forcing": no inheritance to sub elements (because otherwise it would have killed any superscript in the footnote), so possibly having no effect if there's nested block elements and the publisher sets a font size on the sub element. Later, I added support for The 2nd behaviour is probably the best, and could be the only one. But as you are keeping this 1st behaviour (that I'm willing to call legacy) buried inside the "Footnote font size" submenu, I'm quite fine with this PR. No idea if the migration will handle all cases, or prevent some combinations (smaller FB2 but normal EPUB ? probably rarely used), so trusting you. |
| id = "footnote-inpage_epub", | ||
| conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_") end, | ||
| global_conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_epub") end, | ||
| global_conflicts_with = false, |
There was a problem hiding this comment.
by the way, is it intentional that this lets you set multiple of these footnote tweaks as global defaults, even if they conflict? You can do that on master and I've preserved the behavior, but I always found it strange. As soon as you then adjust them in book-specific settings you can only keep one, so it's very inconsistent.
There was a problem hiding this comment.
I don't remember.
But I guess one could set EPUB + Wikipedia to have inpage footnotes whenever he opens a publisher EPUB and a Wikipedia Saved as EPUB - there may be no need to prevent that.
(Not using that myself, I have my own patch which sets tweaks depending on some condition - mostly just because I don't like having a black star in my menu items :))
There was a problem hiding this comment.
Indeed, the question is what you mean by conflict exactly. Setting all the footnote classes as default is very reasonable for example.
There was a problem hiding this comment.
I mean conflicts as in conflicts_with in css_tweaks.lua. I find it weird that I can set all inpage footnote tweaks as default, so once I open a book they are all enabled at the same time. But if I only have one of them as default then I can't enable multiple of them for a single book.
I agree it's fine in practice because each book probably only uses one of the types and having the others on doesn't hurt (and if it does you can adjust from there). I just found it weird when testing this stuff that there are some configurations that you can only reach through global defaults and not by adjusting per-book settings.
I tested many different combinations, but this obviously limits possibilities compared to what's in As you say, probably rarely used though and the newer footnote font-size tweaks already work the same way and affect all footnotes, so this is probably better anyway. |
|
Fine with the latest comments and changes. Remaining, from my previous review comments:
|
|
I don't think that's quite correct. |
|
Oh, you mean it's alright, and the correct place, to have per-book (docsettings) settings migration ? |
| conflicts_with = function(id) return util.stringStartsWith(id, "inpage_footnote_font-size_") end, | ||
| title = _("Smaller footnotes (80%)"), | ||
| description = _([[ | ||
| Decrease size of in-page footnotes. This may have limited/no effect, e.g. if it's overwritten by publisher styles.]]), |
There was a problem hiding this comment.
| Decrease size of in-page footnotes. This may have limited/no effect, e.g. if it's overwritten by publisher styles.]]), | |
| Decrease size of in-page footnotes. This may have no effect if it's overwritten by publisher styles.]]), |
But how can !important have no effect? Do you mean something like 'may have no apparent effect'?
There was a problem hiding this comment.
It will find the footnote container and apply it.
But if the publisher has set a font-size on a sub-block of that container, this font-size will not be overridden by ours (set on the parent, not inherited).
So, may have no apparent effect.
The other (added at a later date) tweaks use * { -cr-only-if: inside-inpage-footnote } and will match ALL children and will override their font-size.
That's why I mentionned previously this one could be considered legacy and this could be mentionned - but @moben seems to want to be soft about it :)
There was a problem hiding this comment.
I'm not trying to be soft about it, I'm just bad at writing these descriptions 😄
There was a problem hiding this comment.
I made the wording stronger, maybe it's better now?
| DEFAULT_GLOBAL_STYLE_TWEAKS["footnote-inpage_epub_smaller"] = true | ||
| DEFAULT_GLOBAL_STYLE_TWEAKS["footnote-inpage_epub"] = true | ||
| DEFAULT_GLOBAL_STYLE_TWEAKS["footnote-inpage_fb2"] = true | ||
| DEFAULT_GLOBAL_STYLE_TWEAKS["inpage_footnote_font-size_smaller"] = true |
There was a problem hiding this comment.
Another thing that could be done is switching this default to inpage_footnote_font-size_80.
That would apply to new installs, whereas existing users get the "legacy" tweak inpage_footnote_font-size_smaller via the migration.
Maybe a good idea if it's strongly recommended to use the newer tweaks as @poire-z suggests. Then we'd also be more likely to get reports if these newer tweaks are worse in some situation. After some time one could migrate everyone from the legacy tweak (if wanted).
There was a problem hiding this comment.
I think there might be enough changes here to maybe wait for a release and see if there's any feedback before also changing the default.
| conflicts_with = function(id) return util.stringStartsWith(id, "inpage_footnote_font-size_") end, | ||
| title = _("Smaller footnotes (80%, legacy)"), | ||
| description = _([[ | ||
| Decrease size of in-page footnotes. This may have limited/no apparent effect, e.g. if it's overwritten by publisher styles. The "footnote font size" style tweaks are recommended instead.]]), |
There was a problem hiding this comment.
| Decrease size of in-page footnotes. This may have limited/no apparent effect, e.g. if it's overwritten by publisher styles. The "footnote font size" style tweaks are recommended instead.]]), | |
| Decrease size of in-page footnotes. This may have no effect if it's overwritten by publisher styles. The "footnote font size" style tweaks are recommended instead.]]), |
|
"This branch has conflicts that must be resolved". Letting you handle this. |
d2e0a68 to
6ed2ee6
Compare
|
|
||
| -- Date at which the last migration snippet was added | ||
| local CURRENT_MIGRATION_DATE = 20250405 | ||
| local CURRENT_MIGRATION_DATE = 20250417 |
There was a problem hiding this comment.
Can you update this date to the day you'll do it :)
…er#13613) Replaces the 3 '... (smaller)' tweaks.




When fixing the "smaller" versions of in-page footnotes for #13554 I got annoyed by the duplication. Also, the in-page footnote menu is getting quite big.
I couldn't find any context for why it's set up this way but here is an alternative.
css_tweaks: Generalize smaller inpage footnotesintroduces a singleSmaller in-page footnotestweak that affects all enabled footnotes.I believe a possible downside of this is that it has to be
-cr-hint: lateand needs to be manually sorted by priority relative to other tweaks. But if that were a problem then it would also apply to all the fixup tweaks?Screenshot
(also has the changes from #13554 but that is unrelated, I'll just rebase if one of them is merged)

This change is