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

Intity Epubreader #2

Closed
dunxd opened this issue Mar 10, 2024 · 83 comments
Closed

Intity Epubreader #2

dunxd opened this issue Mar 10, 2024 · 83 comments

Comments

@dunxd
Copy link

dunxd commented Mar 10, 2024

I really like the look of the inity epub reader. I've taken a chance and made it the epubreader for HA-COPS.

Really nice table of contents, and bookmarks and notes! However, where does it store the bookmarks and notes? Looks like Local Storage in the browser. Very cool, but how persistant?

@mikespub
Copy link
Member

Hi @dunxd glad you like it :-)

I used the fork from intity as starting point because its distribution was kept up to date, but the original is still the epub.js reader from futurepress

Right now the "integration" with COPS is limited to 1 template + 1 zipfs.php file, with the actual functionality provided by the epubjs-reader package, so any changes would need to come from the upstream repos. I haven't explored all its capabilities, but from what I can see local storage is what you use by default.

For annotations there's an option to share them with hypothes.is. Calibre has its own annotations table, but I haven't seen any example of integrating them with epubjs-reader. And I don't know if anything is available for bookmarks.

@mikespub
Copy link
Member

Maybe one more remark:

COPS has always taken a "read-only" approach for the Calibre database, and it has no custom database of its own. If we want to save/restore bookmarks and/or annotations with epubjs-reader (beyond local storage in the browser), it would need to be:

  1. with a third-party service like hypothes.is
  2. using the Calibre annotations table (with updates?)
  3. using the EPUB file annotations (?)
  4. using e-reader specific annotations from Kindle, Kobo etc.
  5. using a COPS database to handle that
  6. ...

From PHP design perspective, I'm not a fan of any of those myself, except maybe options 1 or 2 - what do you think?

@dunxd
Copy link
Author

dunxd commented Mar 11, 2024 via email

@mikespub
Copy link
Member

Hi @dunxd I'm afraid the screenshot didn't make it via email.

Some settings you can change in the epubjs-reader interface itself, like:

But I haven't tried most of those out, so if there's a particular configuration that works well for you let me know :-)

@dunxd
Copy link
Author

dunxd commented Mar 12, 2024

Screenshot_20240312_133612_Chrome

Here is the screenshot. Every page looks like this on a mobile phone.

Changing the width in the Intity settings from 800 to 100 doesn't change it, nor does changing the font size to 50%. This is when viewing the book with Chrome on a Samsung Android 14 phone.

@mikespub
Copy link
Member

Huh - that's definitely not what we're looking for here :-(

I'm not familiar with CSS but there seem to be some hard-coded calculations in main.css of the intity epubjs-reader like
https://github.com/intity/epubjs-reader/blob/e9e7b8adb4246b9893ce1c71d3e4972b5862a1f2/dist/css/main.css#L58

If you do find a work-around, it might be worth sending a PR to https://github.com/intity/epubjs-reader

Otherwise you might be better off with Monocle for mobile viewing...

@dunxd
Copy link
Author

dunxd commented Mar 12, 2024 via email

@marioscube
Copy link

I really like the new epub-reader over monocle.

Tomorrow I can test it with iOS ipadOS if you want.

What I would really like in this epubreader is the ability to set the font-size (to larger) if possible.

@mikespub
Copy link
Member

That'd be great, thanks. You're supposed to be able to change the font size via the settings in the sidebar on the left

@marioscube
Copy link

marioscube commented Mar 13, 2024

Thank you! I found the font setting in the sidebar. Just what I needed.

Then on to my findings with iPhone and iPad.

  1. I can confirm the issue of @dunxd on my iPhone 13 in portrait mode with all webkit browsers.
  2. On the iPhone in Safari in landscape mode it works (sort of). The viewing area for the book is to narrow for the screen. It can be used for a quick look at a book, not really for reading.
  3. On an iPad it works (again sort of) in portrait and landscape mode. To be able to use the settings and then read again I had to juggle the iPad between landscape (I use this) and portrait mode. In landscape the setting options would sometimes disappear off the screen.
  4. The viewing rectangle is not wide enough for comfortable reading on the iPhone in landscape mode. On the iPad it's OK, but could be slightly wider to optimally use the screen size. I have that same observation with a regular browser on my desktop.

@mikespub
Copy link
Member

Thanks for the feedback - I guess my hope of finding a decent replacement for monocle isn't quite realized yet...

If anyone knows of other potential candidates please let me know.

Pre-conditions would be:

  1. stand-alone package that requires minimal customization of html template and/or javascript to integrate
  2. actively maintained or updated on a regular basis in the last x years
  3. allows setting the initial book path in template/script and retrieve individual epub file components (for larger epub files)
  4. visually attractive & functional for both large screens, mobile devices and e-readers
  5. (bonus) possibility of loading/saving bookmarks, annotations etc.

Note: that last part seems to be a dead end so far, as apparently every viewer uses its own variation on the EPUB CFI standard - see comments and links at futurepress/epub.js#1358

@marioscube
Copy link

marioscube commented Mar 13, 2024

@mikespub

Take a look at ../cops/vendor/mikespub/epubjs-reader/dist/css/main.css
On the bottom of this file remove /* */ around the code below /* For iPhone portrait layouts only */ and /* For iPhone landscape layouts only */, remove the cookies from Safari on my iPhone and ..... it works! (on iPhone) :-)

Not 100% perfect, but now it is usable.

@dunxd
See if this works on Android.

@dunxd
Copy link
Author

dunxd commented Mar 13, 2024

Hmm - that's some interesting CSS going on. Not only in the CSS files, but I think there are some styles that are written in via the CSS at least to generate the columns that are displayed when the viewport is over a certain width.

Lines 58 and 59 of /cops/vendor/mikespub/epubjs-reader/dist/css/main.css calculate how tall and wide the container for the book should be by subtracting some figures from the rendered width. I think these are set rather high so I adjusted them as follows:

	width: calc(100% - 50px);
	height: calc(100% - 90px);

I just made this change using the inspector in Chrome, and then resized the browser window to see the effect at different sizes. At first glance that seems to work ok for smaller screens. On larger screens it starts to render the page in multiple columns so it looks like a book, and then on a wide screen it starts to look a bit too wide, which I guess is why they made them so large. I also don't know what it will look like when changing the font size and width setting in the reader's menu.

With much fiddling it might be possible to get this working better using @media directives in the CSS to have different sets of these values for different screen sizes. I may find some time this weekend to look at this deeper, but if you try the above changes to main.css and let me know what you see that would help me know if I am onto the right thing.

@dunxd
Copy link
Author

dunxd commented Mar 13, 2024

If I fork Intity's epubjs-reader how do I then get my fork of this repo to use it so I can test changes I make. I have still not figured out composer.

I fear that I will eat up a lot of time just preparing to experiment - any pointers?

@mikespub
Copy link
Member

mikespub commented Mar 14, 2024

Hi @dunxd

here's a short description: https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository

What I tend to do for minor tweaks in libraries is

  1. first change the files directly in the vendor/ directory of the main project until I'm satisfied,
  2. then fork the library repo (*), create a new branch and apply/commit the same changes there.
  3. update the composer.json file of the main project to use your forked branch of the library (as described above)
  4. and try out the applied changes by running composer update again
  5. submit your forked branch as PR to the library maintainer (*)

(*) you'll need to fork from https://github.com/mikespub-org/intity-epubjs-reader if you want to update the package, since https://github.com/intity/epubjs-reader doesn't have a composer package definition

In this case, once you've done step 5 I can merge it into my fork too, and have it required in future COPS versions

@marioscube
Copy link

@dunxd @mikespub

I player around with some of the settings in ../cops/vendor/mikespub/epubjs-reader/dist/css/main.css and I like for webbrowser (firefox), iPad and iPhone:

change
#viewer : width: calc(100% - 416px);
#viewer : height: calc(100% - 116px);
.arrow span : font-size: 64px;
#divider : height: calc(100% - 116px);

to
#viewer : width: calc(100% - 100px);
#viewer : height: calc(100% - 100px);
.arrow span : font-size: 24px;
#divider : height: calc(100% - 100px);

The latest changes in https://github.com/intity/epubjs-reader make it look slightly nicer.

On a very wide screen (I have a 3840x1600 monitor) it's perhaps a bit to much to comfortably read a book. ;-)

@dunxd
Copy link
Author

dunxd commented Mar 17, 2024

I've created a PR on https://github.com/mikespub-org/intity-epubjs-reader which changes the CSS to detect screens with the same or smaller width as an iPhone X, and makes the viewer wider (100% - 60px) and the page turn arrows smaller. Thanks @marioscube for the suggestion - I've made it wider than you suggested. I've tested on my Samsung Galaxy A53 and it works great. Would be good to get feedback.

Here is the css:

@media only screen and (max-width: 812px){ /* This should catch smart phones with a screen width of, or narrower than, an iPhone X */
    #viewer {
        width: calc(100% - 60px);
    }
    .arrow span {
        font-size: 24px;
    }
}

I didn't notice any difference for the height settings or the divider, so I took them out.

Would love to hear how it works with your own phones. I'm not sure whether the same width is detected if the phone is in portrait or landscape mode. The rule could be further modified to detect that, but I wanted to start simple and get it right for the most common use case first.

@dunxd
Copy link
Author

dunxd commented Mar 17, 2024

I've done some more tweaking to my PR. If you want to try it locally, it is now:

@media only screen and (max-width: 812px){ /* This should catch smart phones with a screen width of, or narrower than, an iPhone X */
    #viewer {
        width: calc(100% - 60px);
        height: calc(100% - 60px);
        margin-top: 45px;
        box-shadow: 0 0 5px rgba(0,0,0,.12), 0 5px 5px rgba(0,0,0,.24);
    }
    .arrow span {
        font-size: 24px;
    }
}

This reduces the wasted space at the bottom of the screen, and looks better in landscape mode too. This only applies to smaller screens, so no change for iPads etc.

@marioscube
Copy link

@dunxd

Your second "tweak" is definitely better.

It works well on both an iPhone 6s and iPhone 13 in portrait mode.
Sometimes the "hamburger" icon disappears if the book title is to long. But with some switching between landscape and portrait mode that can be overcome.

On the iPhone 13 a margin-top of 30px looks slightly better. as does a width pf -80px. But that's a personal preference.

In landscape mode this PR works as well on both the iPhone's.

The divider only needs to be adjusted is you change something with height and there are 2 columns.

@dunxd
Copy link
Author

dunxd commented Mar 17, 2024

Thanks for feedback.

I'm not seeing the hamburger icon disappearing for any screen width in Chrome browser or Safari on a Mac, so perhaps I don't quite understand what you mean. The book title isn't displaying for me at all so I am not sure what would cause this to disappear. Could you share a screenshot?

I've put the divider back in so it handles the height setting for smaller screen. You will only see this if you reduced the page width setting to narrow enough that it splits into columns on the phone screen - e.g. set it to 200.

100%-80px works does indeed look better with the visible page turn buttons.

I tweaked the top margin so the top menu appears more vertically centered, but that, as you say, is very subjective.

@media only screen and (max-width: 812px){ /* This should catch smart phones with a screen width of, or narrower than, an iPhone X */
    #viewer {
        width: calc(100% - 65px);
        height: calc(100% - 60px);
        margin-top: 40px;
        box-shadow: 0 0 5px rgba(0,0,0,.12), 0 5px 5px rgba(0,0,0,.24);
    }
    .arrow span {
        font-size: 24px;
    }
    #divider {
        margin-top: 40px;
        height: calc(100% - 60px);
    }
}

Some ideas for further improvement:

  • Drop the visible page buttons for invisible ones over the left and right of the text - you can tap anywhere in the 100 px right or left to turn pages. This allows more screen width for the words on the page.
  • Rethink the top menu - the folder icon invites uploading a file to open - that isn't really necessary for COPS so the icon could be dropped. The bookmark and fullscreen buttons are useful, but could they be incorporated into the hamburger menu instead, allowing more book display.
  • Maybe it would be nice to display the book title and author at the top, with truncation for very long strings.

@mikespub
Copy link
Member

Thanks for testing this out :-)

Regarding the book title, this was actually moved to a new metadata panel by @intity last week I believe - which might explain the confusion.

I've merged the pull request and added a new tag so that you can update the package via composer if you want...

@marioscube
Copy link

@dunxd

See picture from my iPhone in portrait.
No "hamburger" menu icon. Title is to wide.

image0

And at the bottom it does not look to nice.

@intity
Copy link

intity commented Mar 18, 2024

I think I need to clarify some details regarding the epubjs-reader fork. This is actually an experimental project for me to learn some concepts of JavaScript application development. To use this reader on a mobile device, you need to thoroughly develop style sheets and implement the additional sidebarreflow function to automatically rebuild the page layout (see sidebarreflow). In addition, the epub.js library is poorly developed, which will require additional effort to maintain.
Thanks

@mikespub
Copy link
Member

Thanks for the feedback @intity - it's good to know what you're aiming for :-)

As mentioned above #2 we are looking for a possible alternative for the very old Monocle-based epub reader that was included with COPS, and an epub.js based reader seemed like a good fit.

The reason I started epubjs-reader from your fork was because it was kept up to date and you seemed to actively work on it, as opposed to the original epubjs-reader repo from futurepress.

One of the challenges for COPS is that it's targeted not just for large screens, so if mobile devices or old e-readers are not on your roadmap at all, we may need to start from another fork or find some other starting point...

@marioscube
Copy link

As a user of COPS I must say that the new epub viewer based on epub.js is much, much better than monocle.

It works very well with my iPhone(s) and iPad(s). Maybe not for really reading an epub. I have epub-reader apps for that. But to just view an epub to see if I want to start reading it, it just works. It's a good addendum to COPS.

@dunxd dunxd changed the title Inity Epubreader Intity Epubreader Mar 21, 2024
@dunxd
Copy link
Author

dunxd commented Mar 21, 2024

I am with @marioscube on this - @intity has made great improvements on the futurepress epubreader, and I believe with some tweaks we can get it working well for our use case. However, we haven't been able to test it against many different devices so there could well be snags waiting to bite us.

What I get from this discussion is that the fork made by @intity is only being developed by them, and we should not hold any expectation about future development. That is fair enough.

Would it make sense to make the @mikespub fork from the @intity one instead a fork from the futurepress version, and incorporate intity's changes which we like (of course with full acknowledgement and thanks).?This would allow us to incorporate any improvements to futurepress version in future (if they happen) or even contribute PRs to futurepress. That stops the version we use being dependant on continued maintenance by intity.

Is that reasonable?

@intity
Copy link

intity commented Mar 21, 2024

@dunxd, the problem is that the developer from Futurepress does not maintain the main epub.js library well (for example, the metadata is not fully extracted).

I think the main question should be posed like this: who will maintain the epub.js library in accordance with the EPUB 3 specification?

@mikespub
Copy link
Member

As I see it we have 2 separate steps here:

  1. maintain/update epub.js itself, which gets imported into whichever epubjs-reader we use - is there a more recent fork from epub.js that you could require in the @intity repo package.json instead of "epubjs": "^0.3.93"?

  2. maintain/update epubjs-reader to better suit the needs of COPS users - I'm already forking the @mikespub repo from the @intity repo to import as PHP package into COPS, but if minor tweaks in .css or .js are needed for COPS users, I'd prefer that they be merged into the @intity repo at some point, since I'm a total loss at either stylesheets or javascript ;-)

@dunxd
Copy link
Author

dunxd commented Mar 23, 2024

Is adopting intity's epubreader.js without taking on the upstream epub.js reader any worse than sticking with monocle? It's not like monocle is more actively maintained. The last update was 7 years ago, and there are no forks with updates in the last five.

In my opinion, the Intity refer is a cool improvement on the current browser based reader. I also note that in my opinion the browser based reader isn't a core function of COPS. As @marioscube said it is a nice addendum.

Would it be so bad if we just adopted @mikespub fork of Intity, tweaked it for mobile phones (I think we are 90% there already) and accepted there will be no upstream development of Intity or epub.js ever.

@intity
Copy link

intity commented Apr 7, 2024

@dunxd
Mobile device detection is needed to definition two parameters:

  1. manager
  2. display arrows

@dunxd
Copy link
Author

dunxd commented Apr 7, 2024

Does manager do anything other than force continuous display? That should be up to the user, not based on what class of device they are using.

Similarly, I'm not sure the desirability of visible arrows is any different on a mobile phone than anywhere else. They didn't look bad the way you had them previously, and I think they can be made responsive through simpler mechanisms than JavaScript browser detection.

I'm happy to do some work on this to try out different options - just run out of time this weekend.

@mikespub
Copy link
Member

mikespub commented Apr 7, 2024

Changing the composer.json from

"mikespub/epubjs-reader": "^2024.4",

to

"mikespub/epubjs-reader": "^2024.3",

then running composer update isn't resulting in going back to where I consider things were in a better shape.

FYI, if you want to go back to one particular version, you can specify it directly in composer.jon (without the caret)

"mikespub/epubjs-reader": "2024.3.31",

Or if you want to remain in the 2024.3.* family, you can specify one more level down "^2024.3.5" so it will upgrade/downgrade to the latest 2024.3.* but not go to 2024.4.* - see https://getcomposer.org/doc/articles/versions.md#caret-version-range-

@intity
Copy link

intity commented Apr 8, 2024

Major changes in the theme branch:

  1. Changes in configuration settings (see #L196).
    1.2. Properties for internal use are not saved in local storage (see #L278). These properties are mainly used to pre-configure the reader during initialization and cannot be changed at the user interface level.
    1.3. The properties settings.annotations and settings.bookmarks can take two values: array (default) or false.
    1.4. There are three modes available for settings.arrows:
    • the none mode completely disables the arrows;
    • the content mode (default) adds navigation arrows in the middle of the page on the left prev and on the right next;
    • the toolbar mode adds arrows to the toolbar.

Example 1 (pre-config flow setting):

<script type="text/javascript">
	const path = "https://s3.amazonaws.com/epubjs/books/alice.epub"
	window.onload = (e) => {
		epubreader.main(path, {
			flow: "scrolled",
			spread: {
				mod: "none",
				min: 800
			}
		})
		e.stopPropagation()
	}
</script>

Note that if the flow setting is set to scrolled you must also change spread.mod to none, otherwise it will not work. You also need to understand that these settings are restored from local storage when the page is reloaded.

Example 2 (pre-config arrows setting):

<script type="text/javascript">
	const path = "https://s3.amazonaws.com/epubjs/books/alice.epub"
	window.onload = (e) => {
		epubreader.main(path, {
			arrows: "toolbar"
		})
		e.stopPropagation()
	}
</script>

This will force the toolbar arrows to be enabled for all devices, regardless of userAgent settings.

Example 3 (pre-config annotations and bookmarks settings):

<script type="text/javascript">
	const path = "https://s3.amazonaws.com/epubjs/books/alice.epub"
	window.onload = (e) => {
		epubreader.main(path, {
			bookmarks: false,
			annotations: false
		})
		e.stopPropagation()
	}
</script>

This will completely disable the annotations and bookmarks UI.

Please test on your devices.

@mikespub
Copy link
Member

mikespub commented Apr 9, 2024

New COPS release 2.5.4 using new intity-epubjs-reader tag 2024.4.9

I added the epubjs-reader settings as template variable that can be configured via

$config['cops_epubjs_reader_settings'] = '{
// ...
}';

in your COPS config_local.php file - see config_default.php for details.

That way you can experiment with the different settings via your config_local.php file - but some of them may be cached by the browser

@intity
Copy link

intity commented Apr 9, 2024

@dunxd

Does manager do anything other than force continuous display?

The epubjs library provides only two managers:

  1. The default manager is used for desktop devices;
  2. The continuous manager is used for mobile devices.

For manager (2) to work correctly in paginated mode, you also need to set the snap property to true. I can add a manager to the reader settings. Then you can apply your own mobile device detection feature.

@intity
Copy link

intity commented Apr 9, 2024

In order for me to merge with the master branch, I need to integrate the Storage class as a reader setting. The Storage class provides functions for storing a file from the device's file system in the browser's window.indexedDB. Therefore, when overriding the window.onload event, you need to set settings.openbook to false, otherwise you will get an error.

@mikespub
Copy link
Member

Hi @intity I'm not sure I get your point here.

At this stage in COPS, I'm using template variables to fill in a template that looks like this (not updated here in theme yet):

	<!-- Initialize bookPath and settings -->
	<script>
		// string containing the initial book path - link / to get content from file /{component}
		const bookPath = "{{=it.link}}";
		// js object containing the initial settings (use text for template variable)
		const settings = {{=it.settings}};
		window.onload = (e) => {
			epubreader.main(bookPath, settings);
			e.stopPropagation();
		};
	</script>

Where {{=it.settings} is replaced by the [text string defining the] js array in config_local.php:

$config['cops_epubjs_reader_settings'] = '{
   // ...
}';

By default this will be an empty array, so if on your end you need to change the default handling of settings in epubjs-reader to cover some other issue, that's fine by me :-)

@mikespub
Copy link
Member

BTW I'm thinking of loading the settings directly from a separate .json file instead in javascript, but that would mean another place where configurations are made.

@intity
Copy link

intity commented Apr 11, 2024

@mikespub
I completely moved the settings to index.html. Essentially, settings is a javascript object that overrides the default reader settings. But it is important to understand the specifics of interaction with data that is restored from local storage when the reader is reloaded. That is, what is in the browser’s local storage has higher priority over pre-settings.

If you want to save session data in the server database, then this will require an additional API implementation to upload the settings object in json format to the server. Ideally, the server should provide the application/json API, and epubreader.js should interact with it as a frontend.

@mikespub
Copy link
Member

Thanks @intity

in the COPS use case there's no problem if the browser local storage overrides whichever settings are set initially in the template.

After all, the idea is that COPS serves the books and epubjs-reader html/js/css files to the browser, and then epubjs-reader does its own thing in the browser :-)

So if after the initial page load the user wants to change settings in the browser etc. when reading a particular book, and have these settings re-used the next time he/she continues reading it, that's perfectly OK.

And COPS doesn't want or need to know what settings the user changed, so there's no need for a .json API to change/save settings - I was merely thinking to simplify the initial loading of the settings in index.html

@intity
Copy link

intity commented Apr 12, 2024

@mikespub
Are you using the openbook feature for the COPS site?

I renamed the epubjs-reader repository to epubreader-js. Please update the links.

@mikespub
Copy link
Member

No, the open book feature is not relevant in this case, as @marioscube mentioned earlier. I'll have a look at the link later this weekend when I re-package a new version, thanks

@intity
Copy link

intity commented Apr 17, 2024

@marioscube

I just did some testing with Firefox browser, iPhone 6s, iPhone 13, iPad 6th gen.

Please, if you are doing a test, you need to write more detailed information:

  • Device name
  • Operating system version
  • Browser version

Ideally this should be the userAgent string. This data can be obtained by entering navigator.userAgent in the browser console. For an iPad/iPhone mobile device, userAgent data can also be obtained through the enabled Web Inspector option (see Inspecting iOS and iPadOS).

@mikespub
Copy link
Member

That would probably be @marioscube rather than me :-)

@marioscube
Copy link

@intity @mikespub

I will redo my "testing" probably over the weekend with the asked for information added.

To test I will use the latest version of COPS. (not the git clone version)

For devices I have:

  • iPhone 6s (with safari)
  • iPhone 13 (with safari)
  • iPad 6th generation (with safari)
  • iPad pro 1st generation (with safari)
  • macOS with firefox browser.
    No android devices.

Any things I should especially test?

@intity
Copy link

intity commented Apr 18, 2024

@marioscube
Can you get the navigator.userAgent strings for each device?

@marioscube
Copy link

@intity

I am able to give you something like this from my apache logs:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

Is that what you want?

@intity
Copy link

intity commented Apr 18, 2024

@marioscube yes this is what I need.

@marioscube
Copy link

@intity

OK that is easy, I just look at my (apache2) logs.

I could not find "navigator.userAgent" in the firefox console. Maybe I did something wrong. But now that's not needed.

@intity
Copy link

intity commented Apr 18, 2024

I did bundle optimization to reduce loading time. Also, I changed the package type to module (see index.html for current changes).

Please test on your devices.

@marioscube
Copy link

I promised some quick testing and here it is:

Server = Debian 12 Bookworm

Webserver = Apache/2.4.59 (Debian)
PHP = PHP Version 8.2.18
COPS = COPS 2.5.4 - 20240409
standard config_local.php

Device = nucintosh

OS = macOS 10.14.6
Browser = Firefox browser 115.10 (private browsing)
navigator.userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:109.0) Gecko/20100101 Firefox/115.0"

Font size (%) = 150
Layout = Paginated
Review = just works!

Layout = Scrolled
Review = Scrolled per chapter, then NEXT (key, mouse, menu) for next chapter

Device = Apple iPhone 13

OS = iOS 17.4.1
Browser = Safari
navigator.userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 17_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Mobile/15E148 Safari/604.1"

Font size (%) = 150

Orientation = Portrait
Layout = Paginated (starts with)

Review = does not wrork properly for me

  • no arrows on top
  • no arrows to the side
  • browsing through swiping:
    swipe left = nothing or 2 pages at once
    swipe right is nothing or back to start or 2 pages at once
    => this does not work

Orientation = Portrait
Layout = Scrolled
Review = Scrolles continuously through pages and chapters
Works!

Orientation = Landscape
Layout = Paginated
Review = Does not work. No way to navigate the ebook.

  • no arrows on top or to the side
  • swiping does not work for me
  • cannot reach all menu options

Orientation = Landscape
Layout = Scrolled
Review = Does not work properly

  • jumps forward and back with multiple pages while scrolling (swping up/down)
  • top bar of the reader takes to much space on the screen

Device = Apple iPhone 6s

OS = iOS 15.8.2
Browser = Safari
navigator.userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 15_8_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.6 Mobile/15E148 Safari/604.1"

Font size (%) = 150

Orientation = Portrait
Layout = Paginated (starts with)

Review = does not wrork properly for me

  • no arrows on top
  • no arrows to the side
  • browsing through swiping:
    swipe left = nothing or 2 or more pages at once
    swipe right is nothing (sticks on same page) or back to start or 2 pages at once
    => this does not work

Orientation = Portrait
Layout = Scrolled
Review = Scrolles continuously through pages and chapters
Works! (Some hickups caused by slow device?)

Orientation = Landscape
Layout = Paginated
Review = Does not work.

  • no arrows on top or to the side
  • swiping left works sort of
  • swiping left = stays on same page
  • cannot reach all menu options

Orientation = Landscape
Layout = Scrolled
Review = Does not work properly

  • sometimes jumps forward and/or back with multiple pages while scrolling (swping up/down)
  • top bar of the reader takes to much space on the screen

Device = Apple iPad 9.7"

OS = iPadOS 17.4.1
Browser = Safari
navigator.userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Safari/605.1.15"

Font size (%) = 150

Orientation = Portrait
Layout = Paginated 1 column (starts with)

Review = just works

  • no arrows on top
  • arrows to the side (love it)
  • icon for full screen that works
  • no browsing through swiping:

Orientation = Portrait
Layout = Scrolled 1 column
Review = works

  • arrows to the side go to previous/next chapter
  • scrolling through swiping top/down works inside chapter
  • icon for full screen that works

Orientation = Landscape
Layout = Paginated
Review = works

  • no arrows on top
  • arrows to the side
  • swiping does not work
  • icon for full screen that works

Orientation = Landscape
Layout = Scrolled
Review = works

  • arrows to the side go to previous/next chapter
  • scrolling through swiping top/down works inside chapter
  • icon for full screen that works

Device = Apple iPad Pro 1st generation 12"

OS = iPadOS 16.7.7
Browser = Safari
navigator.userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Safari/605.1.15"

Font size (%) = 150

Orientation = Portrait
Layout = Paginated 2 column (starts with)

Review = just works (I personally do not like this mode)

  • no arrows on top
  • arrows to the side (love it)
  • icon for full screen that works
  • no browsing through swiping

Orientation = Portrait
Layout = Scrolled 1 column
Review = works

  • arrows to the side go to previous/next chapter
  • scrolling through swiping top/down works inside chapter
  • icon for full screen that works
  • if I return to paginated mode, then 1 column!

Orientation = Landscape
Layout = Paginated 2 columns
Review = works (best mode)

  • no arrows on top
  • arrows to the side
  • swiping does not work
  • icon for full screen that works

Orientation = Landscape
Layout = Scrolled 1 column
Review = works

  • arrows to the side go to previous/next chapter
  • scrolling through swiping top/down works inside chapter
  • icon for full screen that works

@intity
Copy link

intity commented Apr 20, 2024

@marioscube
Thank you for the detailed report. As I expected, your iPad device is detected as a desktop system in userAgent.

As you noticed, manager=continuous with flow=paginated does not work very well for a mobile device. This problem is also observed for desktop systems in the manager=default mode (for some books). This is a problem with the epubjs library.

@marioscube
Copy link

marioscube commented Apr 20, 2024

@intity

Ah, that was what you were looking for!

Very deep in the Safari settings there is a setting REQUEST DESKTOP WEBSITE ON to which my settings on the iPad's say ON (slider to the right).
On my iPhone's the setting is OFF.
If I set it to ON, I get the desktop website of COPS and the epubreader with arrow to the sides. If these were (a lot) smaller and the usable space on the screen for content was (a lot) larger I would be really happy. Maybe a setting?

@intity
Copy link

intity commented Apr 20, 2024

I think to get maximum performance from the epubreder-js application, you need to move towards component-based assembly. That is, the configuration should be configured not at the application level, but at the webpack or rollup builder configuration level. This way, everything unnecessary will be removed from the final application build. For example, if you disable the openbook feature, then the build system should remove all unnecessary code that the code analyzer spends time on.

@intity
Copy link

intity commented Apr 20, 2024

@marioscube
This would require forcing arrows to be enabled for all devices, but I don't think that's the right solution. I can resize the arrows to adapt to a mobile device. However, changing the default settings requires careful strategy.

@dunxd
Copy link
Author

dunxd commented Apr 21, 2024

I don't agree with using the User Agent string to figure out anything about the device or the browser being used. It's terribly inconsistent, reliant on text parsing, can change with any update and prone to being spoofed for various reasons. Mozilla strongly advise against it.

Better to use other information that is more reliable such as display size (which also works for windowed browsers) and user configurable preferences.

Just because I am reading on a phone doesn't mean I like continuous scrolling as opposed to turning pages.

How are you going to handle ereader browsers should they ever get up to date CSS and JavaScript support? We already found that the User Agent strings for these is not very useful (e.g. no difference across completely different models produced 10+ years apart).

My suggestion is to use display size (easily accessed through CSS media queries) to apply settings likely to work well but override them with user preferences if they are set, and have reasonable fallbacks when neither apply.

@intity
Copy link

intity commented Apr 22, 2024

@dunxd
It is not enough to get just the screen size, you also need to check whether the device supports touch features. This must be done before initializing the reader settings, since the manager cannot be switched without reloading the page.

I also added manager to the settings so that the user can use his own function to detect the device. For example:

<script type="module">
    import { Reader } from "./js/epubreader.min.js"
    const isMobile = () => { /* your code for mobile device detection */ }
    const url = "{{bookPath}}"
    window.onload = (e) => new Reader(url, {
        arrows: isMobile() ? "none" : "content",
        manager: isMobile() ? "continuous" : "default"
    })
</script>

@mikespub
Copy link
Member

I've created a new release 2024.4.23 of this package for composer + updated the COPS template accordingly: mikespub-org/seblucas-cops@2.5.4...2.5.5

Any further tweaks of the arrows/manager/... settings for COPS can be changed in config_local.php if needed.

Thanks to everybody for all the improvements and testing - I'm going to mark this issue closed for now.

Please open any new issues here or better yet, directly at https://github.com/intity/epubreader-js/issues :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants