ebookor

grab content from web to make ebook such as *.epub,it needs a uri and auto grab all related resource then let user choose which will go into ebook. it can set basic information for ebook such as cover,title,author and so on.

Usage no npm install needed!

<script type="module">
  import ebookor from 'https://cdn.skypack.dev/ebookor';
</script>

README

ebookor

auto grab content from web including related resource such as css,image,links and so on to make ebook for epub.

Install

npm install ebookor

Quick start

var ebookor=require('ebookor');

// optional
// ebookor.useLanguage({
//   var message={
//     'rendder file failed':'渲染文件失败',
//     'is loading':'正在下载',
//   	'all resource is loaded':'所有资源文件已下载完',
//   	'epub maked success':'epub文件已生成',
//   	'is copying related files':'正在操作相关文件',
//   	'is reading config and edit opt and ncx':'读取配置编辑epub配置文件',
//   	'lack of base information about downloaded resources':'没找到下载的资源文件',
//   	'we need some time to pack files into epub,plaease wait for a momenet':'正在生成电子书,稍等片刻'
//   };
// });

// optional
// for example you are grabing cur url,and thr url page include other url page,we need tell progama wether grap the other url page,defualt is like this: url=http://javascript.ruanyifeng.com/advanced/fsm.html,nextUrl=http://javascript.ruanyifeng.com/advanced/ecmascript6.html,then return true,if nextUrl=http://javascript.ruanyifeng.com/test/a.html,return false
// ebookor.setRule(function(url,nextUrl){
//   return true;
// });

var monitor=ebookor.start({
  uri:'uri'//set one available resource uri,http or https is ok
});

// monintor progress
monitor.on('message',function(msg){
  console.log(msg.type);//update,error,loaded,finished
  switch (msg.type) {
    case 'update':
      console.log(msg.name+' is loading');
      break;
    case 'loaded':
      console.log('all is loaded');
      var htmls=ebookor.getHtmlList();//we can preview all htmls loaded
      ebookor.epubConfig(config);//we can set basic information for making epub.
      ebookor.makeEpub();//start to make epub using htmls loaded
      break;
    case 'finished':
      console.log(monitor.file+'can be downloaded');
      break;
    case 'error':
      console.log(monitor.msg);
      break;
    default:
      console.log(monitor.msg);
  }
});

tips

if you have problem with it ,let me know,my email: cuc_ygh@163.com,thanks!