Skip to content

zerg000000/epublib-clj

Repository files navigation

epublib-clj

Build Status Dependency Status

A Clojure library which wrap the epublib to convert clojure map to epub.

Install

Include this line in your project.clj

Clojars Project

Usage

This library do only one thing -- convert clojure map to a epub.

An simple example

(use 'epublib-clj.core)
(use 'epublib-clj.resource)

(def data {
  :meta {
    :titles ["Welcome to Hello World"]  ; mandatory
    :authors [{:first-name "Peter" :last-name "Pan"}] ; mandatory
    :dates [{:value "2015-10-10" "publication"}
            {:value "2016-12-10" "creation"}]
  }
  :cover-image {
    :src "http://example.com/example.png" 
    :type :uri 
    :href "cover.png"}
  :sections [
    {:title "Chapter 1" :href "chapt1.html" :type :text :src "First Chapter"}
    {:title "Chapter 2" :href "chapt2.html" :type :text :src "Second"}
    {:title "Chapter 3" :href "chapt3.html" :type :text :src "The End"}
  ]
})

(-> data fetch-resources to-book (write "my.epub"))

A more advance example

{
  :meta {
    :titles ["Welcome to Hello World"]  ; mandatory
    :authors [{:first-name "Peter" :last-name "Pan"}] ; mandatory
    :dates [{:value "2015-10-10" "publication"}
            {:value "2016-12-10" "creation"}]
  }
  :cover-image {
    :src "http://example.com/example.png" 
    :type :uri 
    :href "cover.png"}
  :resources [
    {:href "dog1.png" :type :file :src "doc/dog1.png"}
    {:href "dog2.png" :type :file :src "doc/dog2.png"}
    {:href "dog3.png" :type :file :src "doc/dog3.png"}
  ]
  :sections [
    {:title "Chapter 1" :href "chapt1.html" :type :file :src "doc/index.html"}
    {:title "Chapter 2" :href "chapt2.html" :type :uri :src "http://example.com/chapter2.html"
     :resources [
      {:href "dog1ch2.png" :type :file :src "doc/dog1ch2.png"}
     ]
    }
    {:title "Chapter 3" :href "chapt3.html" :type :text :src "The End"
     :sections [
       {:title "Chapter 3-?" :href "chapt3_99.html" :type :text :src "The Begin of other heros"}
     ]}
  ]
}

An complete example full.book.example.edn which includes all the possible options.

Section / Resource / Cover Image

Actually, Section/Resources/Cover Image are both a resource, which means they all share the same properties

{:href "dog3.png" :type :file :src "doc/dog3.png"}

:href is the location of the resource in the epub. :src is the location of the resource exists in the running machine :type is how the program should handle the :src

License

Copyright © 2016 Algo Technologies Limited

Distributed under the Eclipse Public License, the same as Clojure.

About

clojure wrapper for epublib java library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published