Originally Posted by ilovejedd
Need some (major) help...
I have a modified PHP script (based on FLAG
) that dynamically creates a Stanza catalog for my favorite FanFiction.Net categories. It basically allows me to browse FanFiction.Net in real-time and creates epub-format ebooks on the fly using Calibre for reading in Stanza iPhone. The script currently runs on my Windows PC running XAMPP.
I have a shared Linux hosting account on 1and1 and I wish to upload the script there. My current dilemma is the epub creation part. I'm currently researching what methods I can use to create epub files using utilities/etc already installed or are user-installable on the shared account. The Linux host has Perl, Python and PHP installed and the operating system is CentOS, iirc.
Options I'm considering:
- Install Calibre on Linux Host
- no changes to the PHP script required
- no idea how to do this or if it's even feasible
- BookGlutton API
- seems like this might be the easiest to implement
- dependent on another website
- don't know how I'm supposed to handle the post request
- seems like the dependencies should already be installed or are user-installable (no admin rights required)
- don't know a thing about docbook
- don't know a thing about xslt
- Code my own PHP script to create epubs
- I might be able to finish this in 2 years if I'm lucky
Right now, I'm thinking using the BookGlutton API might be the best option for me (unless, of course, it's possible to install Calibre or at least html2epub on a shared host). I'm just not sure how I'm supposed to handle the post requests via PHP. Currently, I have an epub.php script that calls html2epub and returns the epub file. I guess I could modify this to send a post request to BookGlutton instead. I just don't know how, particularly the part where you upload the html file.
Anyway, not really looking for a discussion on the merits of the different methods. Just asking for help on the how
. If you know of another way to do this (preferably something even an inexperienced coder can do), please post it here.
I created my own script similar to FLAG some time ago to create .oeb files for my EB-1150 from stories on portkey.org and fanfiction.net. I have updated it to output .epub using a class to zip up the data. If you have customized FLAG, this is pretty easy to integrate as an output method.
Usage as follows:
$tstamp = time(); // timestamp for zip entries
$epub = new ZipCreate();
$prev_encoding = $epub->ztype;
$epub->ztype = 'store';
$epub->add_file('application/epub+zip', 'mimetype', $tstamp);
$epub->ztype = $prev_encoding;
// add container
$epub->add_file($container, 'META-INF/container.xml', $tstamp);
// add opf
$epub->add_file($opf, 'OEBPS/content.opf', $tstamp);
// add toc
$epub->add_file($toc, 'OEBPS/toc.ncx', $tstamp);
// add your xhtml and CSS and pictures and fonts here
// finish it up and download
$output_file = $epub->build_zip();
$output_name = $story['title'] . '.epub';
$output_mime = 'application/epub+zip';
header('Content-Length: '. strlen($output_file));
header('Content-Disposition: attachment; filename="' . $output_name . '"');