epub-press icon indicating copy to clipboard operation
epub-press copied to clipboard

Feature Request: combine epub-press and epub-press-client to one command line

Open TangMonk opened this issue 5 years ago • 2 comments

I wanna to make my own website to epub

for example:

$ ls
gyzkx-000.htm   gyzkx-12.htm  gyzkx-25.htm  gyzkx-38.htm  gyzkx-51.htm  gyzkx-64.htm  gyzkx-77.htm  gyzkx-90.htm
gyzkx-000.htm1  gyzkx-13.htm  gyzkx-26.htm  gyzkx-39.htm  gyzkx-52.htm  gyzkx-65.htm  gyzkx-78.htm  gyzkx-91.htm
gyzkx-01.htm    gyzkx-14.htm  gyzkx-27.htm  gyzkx-40.htm  gyzkx-53.htm  gyzkx-66.htm  gyzkx-79.htm  gyzkx-92.htm
gyzkx-02.htm    gyzkx-15.htm  gyzkx-28.htm  gyzkx-41.htm  gyzkx-54.htm  gyzkx-67.htm  gyzkx-80.htm  gyzkx-93.htm
gyzkx-03.htm    gyzkx-16.htm  gyzkx-29.htm  gyzkx-42.htm  gyzkx-55.htm  gyzkx-68.htm  gyzkx-81.htm  gyzkx-94.htm
gyzkx-04.htm    gyzkx-17.htm  gyzkx-30.htm  gyzkx-43.htm  gyzkx-56.htm  gyzkx-69.htm  gyzkx-82.htm  gyzkx-95.htm        gyzkx-05.htm    gyzkx-18.htm  gyzkx-31.htm  gyzkx-44.htm  gyzkx-57.htm  gyzkx-70.htm  gyzkx-83.htm  gyzkx-96.htm
gyzkx-06.htm    gyzkx-19.htm  gyzkx-32.htm  gyzkx-45.htm  gyzkx-58.htm  gyzkx-71.htm  gyzkx-84.htm  index.php
gyzkx-07.htm    gyzkx-20.htm  gyzkx-33.htm  gyzkx-46.htm  gyzkx-59.htm  gyzkx-72.htm  gyzkx-85.htm
gyzkx-08.htm    gyzkx-21.htm  gyzkx-34.htm  gyzkx-47.htm  gyzkx-60.htm  gyzkx-73.htm  gyzkx-86.htm
gyzkx-09.htm    gyzkx-22.htm  gyzkx-35.htm  gyzkx-48.htm  gyzkx-61.htm  gyzkx-74.htm  gyzkx-87.htm
gyzkx-10.htm    gyzkx-23.htm  gyzkx-36.htm  gyzkx-49.htm  gyzkx-62.htm  gyzkx-75.htm  gyzkx-88.htm
gyzkx-11.htm    gyzkx-24.htm  gyzkx-37.htm  gyzkx-50.htm  gyzkx-63.htm  gyzkx-76.htm  gyzkx-89.htm

so maybe we can:

$ epub-press .

it will auto detect html files in the direcotry and combine them to epub file.

I can do this with epub-press server and epub-press-client, but it is not convient.

TangMonk avatar Feb 25 '20 06:02 TangMonk

You could do this using just the server by running https://www.npmjs.com/package/http-server in your directory. Then you can POST to the server with a list of URLS referring to your local web server. Then you wouldn't need the client.

curl --X POST 'http://localhost:3000/api/v1/books' \
-D '{
    "title": "My Site",
    "description": "test",
    "filetype": "epub",
    "urls": [
        "http://localhost:3000/gyzkx-000.htm",
        "http://localhost:3000/gyzkx-000.html",
        "http://localhost:3000/gyzkx-01.htm",
         ...etc
    ]
}'

wrobbins avatar May 17 '20 17:05 wrobbins

^ I like that above solution!

Combining these things wouldn't be super hard... the server code is pretty disconnected from the core logic. That being said, I'm not sure I'd want to have a package that's a server, a client for that server and a cli.

I would see this being broken down into: epub-press-server, epub-press-js, epub-press-core, epub-press-cli.

The quick and dirty solution would just be to add a script:

node scripts/bundleDirectory.js .
# PSEUDO-ish CODE

const Book = require('../lib/book');
const BookServices = require('../lib/book-services');
const fs = require('fs');

fs.readAllFiles(args[0]).then((files) => {
    const json = { sections: files.map(file => { html: file.text() }) };
    const book = Book.fromJSON(json);

    BookServices.publish(book); // outputs to ebooks
});

I'll keep this in mind, but not sure the effort saved by formally releasing a CLI would be a huge gain.

haroldtreen avatar May 21 '20 01:05 haroldtreen