EBook
Rick Murray (539) 13862 posts |
A little app I threw together today is a (very VERY) simple reader for EPUB ebooks. It works by stripping out the text from the EPUB structure (if it can figure out the filenames, sometimes Calibre creates ridiculous names), and then showing you the result. It doesn’t currently try to parse the formatting. Make sure SparkFS is running. Then run !EBook. Drag an EPUB file to the EBook icon (doesn’t matter what the filetype is, it’ll set it to &DDC (Zip) to see if SparkFS can open it; and when done it’ll set it to &AAE as this seems to be what MuView expects EPUB files to be). The file, if it passes basic checks, will be stripped and combined according to the details in the manifest: When it is done, a big scrolling window will open containing the text of the entire book. I plan on making something better, but it works for now: (you can pick from a variety of colour themes, the one shown is PseudoSepia) Not bad for something I “just decided to have a crack at writing at half two this afternoon”. :-)
|
nemo (145) 2571 posts |
Yeah don’t do that Rick. SparkFS will happily allow access to any ZIP format file without changing its type if you use the SparkFS prefix – take your full pathname, change all the colons into #, and then use the filename “SparkFS#yourfilename_with_colons_replaced:$”. ie if your filename is So you can detect if it’s a zip by using XOS_File,5 on the resulting filename – if you get an error, it isn’t, otherwise it’ll be a directory. |
Stuart Painting (5389) 714 posts |
Page 17 of the SparkFS manual. |
Clive Semmens (2335) 3276 posts |
:D Thanks for the plug, Rick – I think I’ve seen that text somewhere before… :D |
Steve Pampling (1551) 8182 posts |
You read a manual? :) |
Stuart Painting (5389) 714 posts |
Well, I do have a lot of free time these days… |
Andrew Rawnsley (492) 1445 posts |
Stupid thought, but would it make sense to output (or export) to (very simple) HTML so that some formatting could be retained (alignment, bold, italic) and possibly any embedded pictures (if ebooks have such things) could be linked via tags? |
nemo (145) 2571 posts |
And then you can just use the built-in HTML renderer that any decent OS…I’ll get my coat. Horrible evil thought: Convert it into a Draw Text Area and… (really, really, don’t do that. Uggh) |
Rick Murray (539) 13862 posts |
Loads of enhancements today:
Here’s a picture: Some books:
|
Rick Murray (539) 13862 posts |
:-) Thanks for the suggestions. Works nicely, so no need to fritz with the filetypes.
EPUB is actually a restricted form of XHTML/CSS (most implementations do not tolerate markup errors, that’s why tools like Calibre are important).
Sure, if that HTML renderer can cope with rendering page by page, with user-defined text size, spacing, margins etc – and not as a big scrolling window of text. The underlying technology is very similar, the method of presentation differs somewhat.
I ought to add that as an Easter Egg, and call it “nemo mode”. ;-) |
Andrew Rawnsley (492) 1445 posts |
I get that the presentation differs. I was just thinking for RISC OS, since your program just concatenates things together, a similar (but more elaborate, for hopefully not much work) could be achieved by feeding the HTML to NetSurf. Note, I’m not suggesting that this would suffice as an ebook reader, but rather that it’d give a prettier view of the content in line with what your program was doing. Then you went and added nicer fonts, bold, italic etc anyway, so my idea is probably somewhat redundant, unless there are pictures in ebooks. |
Clive Semmens (2335) 3276 posts |
All Clive’s books, including Birgom’s Diary which isn’t otherwise available yet, are free to friends – and I regard all of you as friends. http://clive.semmens.org.uk/000-books_r3U.html – that’s a thrown-together page, the links to the books just download a pdf BANG to wherever your downloads go with no warning or anything. But that’s pdfs of the printed version of the books. I don’t have the ebooks, and they don’t exist for some of the titles. |
Clive Semmens (2335) 3276 posts |
Is “nemo mode” a bad omen? |
nemo (145) 2571 posts |
No, an edom omen. |
Clive Semmens (2335) 3276 posts |
That’s roughly what I had in dnim, sey. |
Paul Sprangers (346) 525 posts |
‘demo omen’, considering the number of unreleased pearls. |
Rick Murray (539) 13862 posts |
Some more enhancements to finish the day:
|
nemo (145) 2571 posts |
O demon me. |
Willard Goosey (5119) 257 posts |
ebook002b seems broken… I drop no-explanations/epub onto the icon and it opens the smallest possible RO window (all the border window buttons) and does nothing else. Sparkfs is running. ebook002 works with the same epub file. RO 5.24, ARMv7 Pi2, sparkfs 1.45 |
Rick Murray (539) 13862 posts |
Thanks for the report. I’ll take a look later on. Do other books work? Is it only No Explanations? |
Rick Murray (539) 13862 posts |
http://heyrick.ddns.net/files/ebook003.zip Weird. So I added a function to look at the input filename, scan backwards from the end looking for a ‘.’ (to get the leafname), and to then copy that to a buffer following the word "Examining ". Only it didn’t work. How it failed? Well, it failed in that reading the manifest worked, reading the number of objects to process worked. But it completely skipped over the loop to do the actual reading of the objects. It sounds to me like a stray memory access mucking with stuff, but absolutely nothing stood out. The filename isn’t touched. The counters are correct. The loop counter isn’t relevant as that’s set on entry to the loop… My ‘fix’ was to create a local string, copy the filename global into that, and then poke around the local copy, not the global one. And, behold! It works. Tested with:
|
nemo (145) 2571 posts |
There ought to be a word for the period of time between that hackneyed claim and the “Ohhhhhhhhh” that will at some point follow. You don’t notice the bugs until they bite. Here’s an interesting thing I found the other day: Every copy of VirtualAcorn/VirtualRPC that has ever shipped contains a HostFS of course, and its HostFS has an unfortunate little bug: If you dismount a drive all your other drives get unshared. If you don’t use HostFS or Access or never dismount a drive then you wouldn’t notice. You’d correctly guess that it’s emitting a Service_DiscDismounted with too short a filename, and it is – “HostFS::”, but the why is interesting: It does try to append the disc name, but in between it has done a Service_NetFS for dubious reasons, and it treats that service number as the name pointer… which means it actually appends whatever it finds at address &00000055 – normally a zero. This is fortunate, because if it does manage to copy anything as intended it stiffs the machine completely. Moral: “Working” is not proof of correctness. |
Clive Semmens (2335) 3276 posts |
There are several, but they’re not repeatable. |
Doug Webb (190) 1181 posts |
Hi Rick, Firstly thanks for yet another useful application. I have tried it with one epub document I have and it works but I have tried it with others from Gutenberg, using the epub without images option, and I get issues with errors like “File is either not EPUB or damaged” or “can’t read manifest/ too many manifests”. This is using some of the example files you have highlighted. This is with SparkFS 1.45, RISC OS 5.35 (24th Aug 18) on an ARMX6. |
Martin Avison (27) 1498 posts |
Really?!! Do you know something we don’t? |