GithubHelp home page GithubHelp logo

vaporbook / bookgluttonepub Goto Github PK

View Code? Open in Web Editor NEW
67.0 5.0 16.0 2.5 MB

BookGlutton core epub read/write class in PHP. This standalone PHP class for the Epub (OEBPS 2.0) format has been battle-tested with over 20 publishers, including O'Reilly Media. Use it to do conversions from HTML, OPS filesystem manipulation, or direct zip container manipulation.

Home Page: http://www.bookglutton.com/api/convert

PHP 100.00%

bookgluttonepub's Introduction

BookGluttonEpub

Copyright (c) 2011, Aaron Miller

Licensed under the MIT license.

Core class for the BookGlutton publishing and social reading platform. Includes OPS virtualization, zip container manipulation, and more, in a single convenient class library. Zip container and file finder helper classes included.

DEPS

Requires epubcheck, zip, tidy, java, PHP mods for zip, dom_document, simple_xml, xpath, possibly others...

API documentation

Coming soon - There are many helpful convenience methods, and helpful comments, in the code. Please browse the main class file for more info on how to use this library.

TODO

1.Clean up the code! Production-tested but messy.
2.Add some test scripts and test epub/OPS content

Usage Examples:

Please see the test.php script for the simplest possible example of usage. More involved test scripts will be added when I get time. Do look through the main class file at some of the methods available. There is much useful there.


1. Open an epub from a file:


  $epub = new BookGluttonEpub();

  $epub->open($epub_filename);


2. Load an OPS structure into a virtualized Epub:


  $epub = new BookGluttonEpub();
  
  $epub->loadOPS($path_to_ops);


3. Open a remote epub by URL and echo its ISBN:


  $epub = new BookGluttonEpub();
  
  $epub->openRemote($href);

  $epub->setPretty(true);
    
  echo $epub->getIsbn();
  
  
4. Open an epub as a virtual zip epub and unzip its contents into an OPS structure:
  
  
  $epub = new BookGluttonZipEpub();
    
  $epub->ingestZipData($zipdata, $book->getPackagePath());
    
  print_r($epub->getMetaPairs());
  
  
  
5. Load remote, modify and save local to OPS:


  $epub = new BookGluttonEpub();

  $epub->openRemote($href);

  $epub->setTitle($book->getTitle());
  
  $epub->setAuthor($book->getAuthor());

  $epub->setDescription($book->getDescription());

  $epub->setRights($book->getRights());

  $epub->writeOPS();
  
  
6. Create a new virtual OPS, then load an HTML conversion source, then save locally as OPS:
  
  
  $epub = new BookGluttonEpub();
  
  $epub->create(array(
              'title'=>$book->getTitle(),
              'author'=>$book->getAuthor(),
              'language'=>$book->getLanguage(),
              'desc'=>$book->getDescription(),
              'rights'=>$book->getRights()
      
    ));

  $epub->loadSource($zipped_html_or_html);

  $epub->moveOps($ops_repo_root, $unique_package_directory_id);
  

  
  
  

bookgluttonepub's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

bookgluttonepub's Issues

Class 'uuidGen' not found

PHP Fatal error: Uncaught Error: Class 'uuidGen' not found in /var/www/html/boek/BookGluttonEpub.php:2208

Edit Metadata

How can I edit the metadata with BookGluttonEpub?
The example of point 5. (Load remote, modify and save local to OPS) doesn't work for me.

Error message for undefined variable when ncx not found

Notice: Undefined variable: path in BookGluttonZipEpub.php on line 62

It appears that on that line it should be:
$this->log('ncx '.$this->opfroot . '/' . $this->ncxpath.' not located');
instead of
$this->log('ncx '.$path . '/' . $this->ncxpath.' not located');

getFlatNav returning empty result

This function returns an empty value.

public function getFlatNav()
{
// returns all navpoints in document order, flat structure
return $this->ncx->getElementsByTagName('navPoint');
}

Using the files dated November 1, 2011 on the included H. G. Wells book.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.