Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 03-28-2012, 03:42 PM   #1
caleb68864
Member
caleb68864 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Mar 2012
Device: Pandigital Novel
Adding Ability to Read Books Online

I am trying to add some functionality to Calibre.
I would like to add the ability to read books online.
I plan on doing this by extracting an htmlz version of the book inside the book folder and opening it in the web browser.
I have created a php function that extracts the file and opens the page.
I have also created a python script that will extract the file.
However I have not figured out how to make this work with Calibre yet.
When I try running the php page I get the following errors.

http://localhost:9878/static/browse/reader.php
404 Not Found
u'browse/reader.php' not a valid resource type

http://localhost:9878/browse/reader.php
404 Not Found
The path '/browse/reader.php' was not found.

Currently I have not tried running my script in Cailbre the php file I am currently trying to run just prints Hello World

Another avenue I am looking at would be doing something similar to how files are downloaded now.
i.e. http://localhost/get/html/book.htmlz
This would open the extract the book on the server if needed then direct the user to the books index page.

I think this should be possible any help s greatly appreciated.
Thanks,

Last edited by caleb68864; 03-28-2012 at 03:59 PM.
caleb68864 is offline   Reply With Quote
Old 03-28-2012, 10:55 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,924
Karma: 5036099
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You cannot run PHP scripts in the calibre web server. You have to write your code in python, and create endpoints for it. Use the ZIP output format, not HTMLZ, IIRC the ZIP format as designed specifically for this. HTMLZ is designed for ease of editing.
kovidgoyal is online now   Reply With Quote
Old 03-29-2012, 09:11 AM   #3
caleb68864
Member
caleb68864 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Mar 2012
Device: Pandigital Novel
I have a python script written that extracts the file as a zip.
However I am very new to python could you recommend a good resource to learn how to create the endpoints?

Thanks
caleb68864 is offline   Reply With Quote
Old 03-29-2012, 09:36 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,924
Karma: 5036099
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
There's nothing difficult about it, just look at the browse.py file in the calibre source for examples. Add your endpoints there and run calibre from source (instructions on how to do that are in the user maual under setting up a development environment)
kovidgoyal is online now   Reply With Quote
Old 03-29-2012, 11:24 AM   #5
caleb68864
Member
caleb68864 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Mar 2012
Device: Pandigital Novel
Thanks, I will play around with it and see if I can make this work.

PS Thanks for making a great piece f software.
caleb68864 is offline   Reply With Quote
Old 03-29-2012, 04:25 PM   #6
caleb68864
Member
caleb68864 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Mar 2012
Device: Pandigital Novel
So I've created what I believe to be a small Hello World type Endpoint, but I'm unsure how to call or view it on the server.

I added the following code to \src\calibre\library\server\browse.py

# Read Online {{{
@Endpoint()
def browse_read_online(self, id_):
book = 'The Book You Selected Is: ' + id_
return book
# }}}
caleb68864 is offline   Reply With Quote
Old 03-29-2012, 04:59 PM   #7
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,924
Karma: 5036099
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You need to add a mapping from a URL to your endpoint in the add_routes() function
kovidgoyal is online now   Reply With Quote
Old 03-30-2012, 10:13 AM   #8
caleb68864
Member
caleb68864 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Mar 2012
Device: Pandigital Novel
Removed

Last edited by caleb68864; 03-30-2012 at 04:37 PM. Reason: Deleted
caleb68864 is offline   Reply With Quote
Old 03-30-2012, 05:30 PM   #9
caleb68864
Member
caleb68864 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Mar 2012
Device: Pandigital Novel
I have my endpoint set up and it can read a html file then display it through the server.
The wall I'm running into is how to get the ebook file from the server so that I can export it and display it afterward.
Is there a function that will give the file path of a book on the server based on the id?
caleb68864 is offline   Reply With Quote
Old 03-30-2012, 11:12 PM   #10
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,924
Karma: 5036099
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Look at server/content.py to see how that is done.
kovidgoyal is online now   Reply With Quote
Old 04-01-2012, 07:03 PM   #11
caleb68864
Member
caleb68864 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Mar 2012
Device: Pandigital Novel
Removed

Last edited by caleb68864; 04-01-2012 at 09:36 PM. Reason: Deleted
caleb68864 is offline   Reply With Quote
Old 04-02-2012, 03:56 PM   #12
caleb68864
Member
caleb68864 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Mar 2012
Device: Pandigital Novel
I have two more questions.
I got everything working to extract and display the book.
I would like to modify the summary template so that if the book has an htmlz format it will display the "Read" link and it will display a "Convert" link if it does not.
How would I go about this? I am having trouble understanding how the template works.

The second question is where is the best place to look to be able to convert a book from inside the application?
caleb68864 is offline   Reply With Quote
Old 04-03-2012, 12:13 AM   #13
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,924
Karma: 5036099
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
The template just uses simple python string interpolation, you will need to change code in browse.py to change the nature of the get button.

As for conversions, there is no good place to do it. The content server is designed to be read only at the moment. It should not make changes to the calibre library database. You can run a cnversion into a temporary file if you want, I suggest using simple_worker.py to do it, call the conversion functions in conversion/cli.py with fork_job()
kovidgoyal is online now   Reply With Quote
Old 04-05-2012, 12:58 PM   #14
caleb68864
Member
caleb68864 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Mar 2012
Device: Pandigital Novel
To keep the server read only I am trying to change the details and summary template to only display the Read link if the book is in the proper format.
However "def browse_summary_template(self):" does not currently take an ID variable I feel adding one would break the server in several places.
I need some way to retrieve the ID without changing the number of variables the function takes in is this possible?
caleb68864 is offline   Reply With Quote
Old 04-05-2012, 01:37 PM   #15
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 25,924
Karma: 5036099
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You dont wan to change that function, you want to make your changes in browse_booklist_page(). The ids are available there.
kovidgoyal is online now   Reply With Quote
Reply

Tags
web browser

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
the ability to transfer books between different librarys alansplace Calibre 1 08-01-2010 02:09 PM
Request Ability to read tiff images in ereader aidren enTourage Archive 2 05-15-2010 07:39 PM
Ability to read question zorgon Amazon Kindle 7 02-10-2009 10:27 PM
Adding online metadata using ISBN from CLI EditorJack Calibre 17 01-20-2009 01:47 AM
Sony PRS-505's ability to read letters not found in the English alphabet? ASC Which one should I buy? 9 01-07-2009 02:25 AM


All times are GMT -4. The time now is 02:19 AM.


MobileRead.com is a privately owned, operated and funded community.