Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: whatkindofausernameisthis on December 13, 2011, 07:17:23 pm

Title: Lua-based Ebook Reader (Does not require ndless)
Post by: whatkindofausernameisthis on December 13, 2011, 07:17:23 pm
Hey everybody. I made this a while ago:
http://ourl.ca/9752

But to be honest, that program sucked. So I've made a new one in the only programming language available at the time--Lua. This is a simple script that will convert a plaintext file into a Lua program that can display the book on your calculator. This is still in a beta stage (there are a few bugs left to squash), but since I won't be able to work on this any more until my college applications are done, I'll release this early.

You need to have luna in the same directory as this program for it to function. Get luna here: http://www.mirari.fr/DC0p (http://www.mirari.fr/DC0p)
Your folder should look like this:
(http://dl.dropbox.com/u/4752797/Nspire%20Ebook%203.png)

Usage:
ebook.exe <book.txt>
It will prompt you for the title of the book

Alternatively, you can just drag and drop a *.txt file onto ebook.exe

Included is a copy of Brandon Sanderson's Free online ebook, Warbreaker

Bugs:

Notes:

Pictures:
(http://dl.dropbox.com/u/4752797/Nspire%20Ebook%201.png)

(http://dl.dropbox.com/u/4752797/Nspire%20Ebook%202.png)

Download:
http://dl.dropbox.com/u/4752797/Nspire%20Ebook%20Reader%202.zip (http://dl.dropbox.com/u/4752797/Nspire%20Ebook%20Reader%202.zip)
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: annoyingcalc on December 13, 2011, 07:27:16 pm
Nice!
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: Yeong on December 13, 2011, 09:51:05 pm
wow. how big will be the file per page?
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: Jim Bauwens on December 14, 2011, 06:54:59 am
Looks good =)
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: Lionel Debroux on December 14, 2011, 07:18:25 am
Interesting project :)

The Nspire's horsepower being somewhat larger than that of the TI-68k series, third-party programs could be even more powerful than Hib-View / uView, or TICT eBook Reader, are on the TI-68k series.
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: Jim Bauwens on December 14, 2011, 08:11:54 am
There is also much more space, so pictures might be possible.
And adding support for styling/different font sizes isn't too hard either :)
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: Hayleia on December 14, 2011, 10:57:35 am
D: I got:


Error: Failed attempt to launch program or document:
Action: <totns.bat>
Params: <"test">

Specifically: Le fichier spédifié est introuvable


        Line#
--->  012: Run,totns.bat "%bookName%"

The current thread will exit.


I dragged and dropped the txt file on the exe with all the needed files in the folder ??? I don't know what the problem is
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: whatkindofausernameisthis on December 14, 2011, 11:51:20 am
There is also much more space, so pictures might be possible.
And adding support for styling/different font sizes isn't too hard either :)

Pictures are definitely a possibility, but I haven't come up with an easy, user-friendly way of getting pictures (like covers, maps, and chapter delimiters) embedded in the correct position in the book.
Styling is limited in Lua for the nspire to only "serif" and "sansserif" fonts. Font sizing is already supported (use +/-) to increase/decrease font size.

wow. how big will be the file per page?

Size depends a lot on how easily the book can be compressed, but a 600 page book (The Three Musketeers) ended up being about 580 KB, so I would say roughly 1 KB per physical page.

D: I got:


Error: Failed attempt to launch program or document:
Action: <totns.bat>
Params: <"test">

Specifically: Le fichier spédifié est introuvable


        Line#
--->  012: Run,totns.bat "%bookName%"

The current thread will exit.


I dragged and dropped the txt file on the exe with all the needed files in the folder ??? I don't know what the problem is

Whoops. Looks I forgot to package one of the files. Should be fixed now. Try downloading it again.
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: Jim Bauwens on December 14, 2011, 01:14:39 pm
Pictures are definitely a possibility, but I haven't come up with an easy, user-friendly way of getting pictures (like covers, maps, and chapter delimiters) embedded in the correct position in the book.
Styling is limited in Lua for the nspire to only "serif" and "sansserif" fonts. Font sizing is already supported (use +/-) to increase/decrease font size.

Well, I think a xml based system should be quite possible. To my experience nspire Lua should be fast enough to do this.
You could make something as simple as <img tree>, where tree would be a reference to a TI.Image variable. Get the width/height of the image, and just behave like the image would a bunch of new lines.

Also, you *could* make your own font with images. To improve the speed though they would have to be black+alpha though.
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: Lionel Debroux on December 14, 2011, 01:26:24 pm
Why not a non-XML, but markup-based, language inspired by the one used by Hib-View and uView ? :)
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: Jim Bauwens on December 14, 2011, 01:36:19 pm
That format doesn't look bad, and will be more easy to add :)
Thanks for the tip Lionel.

(http://www.hibnet.org/ti/hiblib/hibLib-tagsdoc/)
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: ExtendeD on December 14, 2011, 01:48:50 pm
What about adapting this Lua implemention of Markdown? http://luaforge.net/projects/markdown/
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: Reo on December 14, 2011, 02:59:23 pm
Well at this point you might as well write an EPUB reader.
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: cyanophycean314 on December 14, 2011, 04:46:35 pm
I thought you could use gc:setFont('serif','b',x) for bold type font in Lua.
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: Jim Bauwens on December 14, 2011, 05:12:51 pm
Yes, but we are thinking how to store the markup in the file :)
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: cyanophycean314 on December 14, 2011, 05:58:54 pm
Oh. Ok, I misunderstood.  :P
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: whatkindofausernameisthis on January 20, 2012, 12:39:05 am
Now that Ndless 3 is out, I'll be switching over to work on a C-based ebook reader. I'll still update this every so often so that you can still have access to books if TI comes out with a new OS.
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: DJ Omnimaga on January 20, 2012, 12:45:43 am
Cool to hear. And glad you still plan to keep the Lua version up to date. IIRC the new Lua is supposed to add improvements (maybe speed/mem access?) but an Ndless version will definitively be nice too.
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: njaddison on January 24, 2012, 11:15:20 pm
This is so awesome....
my mom took my nook color because i played angry birds on it at school.
Now, I don't need my nook anymore.
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: gfrung4 on May 15, 2012, 10:18:05 pm
This is really old, but I was trying to use this and keep getting "An error was found in the format of this document." on my NSpire.  The ebook.exe works fine, no errors.  The document transfers fine, too.  The problem happens when I try to open it.

The weird thing is I can open your sample book.  It works just fine.  The problem is none of my books seem to work!  Just wondering if anyone else had a similar issue or can offer any suggestions.

Sorry, I realize this was really old,
 - gfrung4
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: BalancedFury on May 15, 2012, 10:22:58 pm
Do we have to type in the books?
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: whatkindofausernameisthis on July 22, 2012, 09:36:48 pm
This is really old, but I was trying to use this and keep getting "An error was found in the format of this document." on my NSpire.  The ebook.exe works fine, no errors.  The document transfers fine, too.  The problem happens when I try to open it.

The weird thing is I can open your sample book.  It works just fine.  The problem is none of my books seem to work!  Just wondering if anyone else had a similar issue or can offer any suggestions.

Sorry, I realize this was really old,
 - gfrung4

Sorry about this. I should have mentioned this in the readme. The Nspire can't handle Unicode characters, so they have to be stripped out of the original file before converting the book. If you have Word or OpenOffice, you can do this easily with the search and replace function. Make sure you replace smart quotes (“...” and ‘...’) with regular "dumb" quotes ("..." and '...'), em dashes with regular dashes (-) and ellipses (…) with three periods (...). There might be additional characters with accents that you have to fix as well. Sorry, I know this can be a big inconvenience, but I didn't encounter it too frequently when using it myself.

N.B.: The OpenOffice regex [^a-z0-9 ?.!-"':;,] (finds characters that aren't a-z, 0-9, or common punctuation, don't know if the same will work in Word) works great in identifying characters that the Nspire won't support.

Do we have to type in the books?

No, the dialogue that pops up just asks for the title.

Also, the Nspire that I used to have I rented from my high school. Now that I'm going off to college I (1) don't have an Nspire to test programs on and (2) won't have time to write and test programs. All the software that I've released is open source and has all the source code included with the release. (I do have to apologize for the messiness of the code.) If any aspiring developer wants to pick up development of this program, you are free to do so. I'm sorry to leave everything in such an unfinished state.
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: blweldon2 on July 23, 2012, 11:33:59 pm
I think this could work as a sort of on-calc readme file creator. You could just type up the readme in a txt document for the zip file and make a converted lua file for opening on-calc. That would be perfect for people like me who don't read the readme, can't figure something out, and then can't find the readme. :P
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: AzNg0d1030 on August 29, 2012, 07:50:35 pm
Can someone download the taming of the shrew from this website and convert it using the prgm? I cannot since 1. I use a Mac 2. Our windows computer runs win32 (pretty old) so the ebook.exe does not work. If you do, please PM the tns file.

http://www.umnet.com/download-ebook/48637-The_Taming_of_the_Shrew#

This is the link. And if you do, can you remove all the stuff in the beginning talking about "Thanks for downloading, and legal issues" and whatnot? Just delete that text up until the book starts, like interpretations, summaries, anything that would be part of a book.

Greatly appreciated!
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: DJ Omnimaga on August 29, 2012, 08:11:12 pm
Done (see PM). By the way make sure ebooks you post are really free though, not freely distributed copies of paid ones. :P
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: AzNg0d1030 on August 29, 2012, 08:13:25 pm
Done (see PM). By the way make sure ebooks you post are really free though, not freely distributed copies of paid ones. :P
Thanks a lot :D :D :D
I'm pretty sure Taming of the Shrew is pretty free. It is Shakespeare after all, and we all know how popular his books and plays are :P
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: xacto on August 29, 2012, 10:15:46 pm
I have been using this for a while and it works great. There's just one thing I absolutely cannot figure out. Since Notepad doesn't support formatting, how did you manage to make the eBook Warbreaker have formatting like it did in your screenshots? I have made other eBooks with this program, but I can't find out how to give it formatting. I keep trying to keep all the words on the screen without having to zoom all the way out.
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: Yeong on August 29, 2012, 10:55:40 pm
I'm kinda confused, but which one do I download?
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: AzNg0d1030 on August 29, 2012, 11:02:03 pm
I'm kinda confused, but which one do I download?
Tthe one on the first post where the link is like dropbox something
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: xacto on September 04, 2012, 11:16:11 pm
Does anyone know how to add paragraph formatting etc. to the eBook when its in text format before copying it to the calculator?
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: AngelFish on September 04, 2012, 11:27:13 pm
Done (see PM). By the way make sure ebooks you post are really free though, not freely distributed copies of paid ones. :P
Thanks a lot :D :D :D
I'm pretty sure Taming of the Shrew is pretty free. It is Shakespeare after all, and we all know how popular his books and plays are :P

As a general rule: Anything published before 1924 is almost certainly public domain, anything after probably isn't.
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: whatkindofausernameisthis on March 05, 2013, 11:56:47 pm
Updated to support 32 bit systems. I don't want to get anyone's hopes up, but I am not continuing to update this. I'm in college now, and I had to return my high school's Nspire. Hopefully the open-source nature of this program will encourage some of you to play around with the project and pick up some computer programming. It's an awesome skill to have.
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: DJ Omnimaga on March 06, 2013, 12:17:35 am
Sorry to hear D:, glad to see one last update and that it's open-source, though. Good luck with college!
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: joeym on February 26, 2014, 11:41:42 pm
Yeah I am glad to see this. I upgraded my Nspire's OS (if you want to call it an upgrade) and all I can use is software that does not require Ndless. Thanks for taking the time to make and share this.
Title: Re: Lua-based Ebook Reader (Does not require ndless)
Post by: joeym on March 24, 2014, 07:53:27 pm
I decided to try this out since I love the idea of an eBook reader. I had a text file and dropped it onto ebook.exe and it spit a file two out (TITLE_OF_eBOOK.lua and TITLE_OF_eBOOK.tns). I transfered that .tns file but I was unable to open it.

Ugghhh!!

So I came back to this thread and read what the author said about text files that contain Unicode characters. I did a google search but did not find a quick way of removing the Unicode characters so I was stuck. I kind of gave up on it. Then I decided to open my original text file up using Notepad++

I discovered a great thing about Notepad++. It has the ability to convert text files to ANSI.

To do that just open your original text file up, prior to converting it using the ebook software, in Notepad++. Then choose:

"Encoding, Convert to ANSI".

Save that converted text file and convert it using the ebook software and BOOM!!! You have a file that you can use on the Nspire.