# Gempub adventures, cont. Well, it has been almost a month since my last phlog. At that time I had started up in gemini-space again with a capsule dedicated to ebooks, ereaders, etc. In particular I had been getting into the gpub format, which seem to have lain dormant for some time. This phlog is about gpub and my various projects surrounding it. If that is not in your interest-set, now would be fine to bail out. --- ## Software I have written/coded three gpub readers: 1. `gpr`, a terminal-based reader. This is the most feature-packed of the lot and the one I actually use. It supports gpub as a first-class citizen, but also supports epub/kepub and has some very experimental support for mobi/azw3. If you run it with the flag `-fancy` it will use escape codes to color and format headings, blockquotes, lists, etc. Using the flag `-indent` will indent paragraph text, mostly like a "real book". It can view the cover (in an external image viewer) when one is present, it can show you metadata, it can navigate links, as well as by page, by chapter, and by ToC entry. 2. `gpub-reader`, is a webtech-based reader. It is a single, self-contained html document. It can be run fully offline, but does use javascript and some features from relatively modern HTML/CSS/JS. It supports navigation by chapter, by page, and by ToC. It has a button to view metadata and cover. It is a little glitchy sometimes, but mostly works pretty well. This one only supports gpub. 3. `greader`, a native GUI gpub reader (it does not support other formats). It does not "page", but loads a chapter into a scrolling viewport. It does do headings and such in various sizes. It works okay, but is not as portable as I'd like... even between my two amd64/linux systems the same file will only run on one of them. It uses the `fyne` GUI toolkit. It was mostly nice to work with and the result is okay, but something I would never personally use. It was written mostly to have this sort of options within the "gpub ecosystem". ## Hardware This is my most recent project. I got myself an ESP32S3 and an eink driver-board with a charge controller for the battery and an eink screen (4.26"). I have realized _very_ quickly that I am over my head, and I am moving slowly. This is my very first embedded project. I do not know C++ and my C is not great. tinygo supports the ESP32 as a target, but I would have to write my own SPI driver and graphics library for the screen it seems. So that is out for now. So far I have used a mix of my own coding and some borrowed stuff to get a wifi access point working and serving an HTML form to upload a file. I have the middle of three buttons configured, at present, to toggle this access point on and off. When off, the screen says "Disconnected...", when on it shows the SSID, PW, and IP for the access point. That is it. I don't get a lot of time to have things set out at a table and not be monkeyed with by child or cat. So this will be an ongoing project. My next step is to work out my filesystem. If I use LittleFS it seems like I have to use a smaller partition scheme than my space allows for? Something to do with SPIFFS? But if I use Fat I can use all of my flash? It is confusing and I need to sit down and parse through the incredibly terribly documentation (ha!). Once that works I need to get the file upload to write to flash and then get _something_ from the file up on the screen. Then a single page of word wrapped text. Then a single file, paged by buttons, of word wrapped text. Then I need to work out zip file parsing and how I want to store book state and move from section to section, as well as parsing metadata.txt and index.gmi files. At present my biggest hurdle is to work out how to keep track of pages. Forward I can do dynamically and just write to the screen from any point in the book. So I can store a byte offset in a given file and then seek to it and then fill the screen from there. Paging forward as need be and updating the byte offset. Moving in reverse is a bigger problem and I am not quite sure how to do it...parse in advance and keep an array of page offsets and move between those? Parse the whole book or chapter into a temp file that has lines that are the right width and then use newlines as my marker points? But I still cannot read backward through a file so a dynamic way of doing it that doesn't fill flash or ram seems tricky... but maybe I just don't understand the problem-space enough. ## Books The last of the big projectshas been producing books. I wrote some software (`gpb`) to help me process ebooks similar to how I do with standardebooks. It will clean up the text, split files, make a ToC (`index.gmi`), fill in metadata, etc. But I still go through the book text itself and add markup like headings and blockquotes and the like. I find this gives a much better final result than using a fully automated epub to gpub converter (I wrote one of those a long time ago and there are a bunch floating around geminispace). This way takes longer but produces a very nice final book. So I have created three collections: * Nature Writing * Science Fiction * Western and Frontier Fiction I have a gemini capsule with those, as well as a website. My main gpub page also links to both. I've done some 30+ books, good stuff. Lesser known, but some of it is really great! ## Links to things discussed above For those interested: * `gpr`: https://tildegit.org/sloum/gpr * `gpub-reader`: https://tildegit.org/sloum/gpub-reader * hosted version: https://gpub.colorfield.space/gpub-reader/gpubreader.html * `greader`: https://tildegit.org/sloum/greader * `gpb`: https://tildegit.org/sloum/gpb * Gemini ebook capsule: gemini://zaibatsu.circumlunar.space/~sloum/ * Gpub books (web): https://zaibatsu.circumlunar.space/~sloum/ * My gpub website: https://gpub.colorfield.space/ If you are still here: thanks for listening about my projects!