Skip to content

Instantly share code, notes, and snippets.

@robotmedia
Created September 19, 2011 13:51
Show Gist options
  • Save robotmedia/1226536 to your computer and use it in GitHub Desktop.
Save robotmedia/1226536 to your computer and use it in GitHub Desktop.

Revisions

  1. Robot Media revised this gist Sep 21, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion zepuh.sh
    Original file line number Diff line number Diff line change
    @@ -45,7 +45,7 @@ fi
    initial=$PWD
    cd $input
    zip -0Xq $initial/$output mimetype
    zip -Xr9Dq $initial/$output * -x zepub.sh *.epub
    zip -Xr9Dq $initial/$output * -x zepub.sh *.epub *.DS_Store
    echo $output
    # Validate
    if [ -f $validator_path ]; then
  2. Robot Media revised this gist Sep 19, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions zepuh.sh
    Original file line number Diff line number Diff line change
    @@ -11,8 +11,8 @@
    #
    # EXAMPLES
    #
    # ./zepub book.epub
    # ./zepub book.epub /my/epub/folder
    # sh zepub book.epub
    # sh zepub book.epub /my/epub/folder

    # Path to EpubCheck (http://code.google.com/p/epubcheck)
    validator_path="/path/to/epubcheck/epubcheck-1.2.jar"
  3. Robot Media created this gist Sep 19, 2011.
    54 changes: 54 additions & 0 deletions zepuh.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    #
    # zepub.sh 0.1
    # Package & Validate ePub Files
    # by @robot_media (http://www.robotmedia.net)
    # thanks to @lizcastro (http://www.elizabethcastro.com/epub/)
    #
    # INSTRUCTIONS
    #
    # Make zepub.sh executable: chmod +x zepub.sh
    # Optional: to validate the resulting ePub files change the validator_path variable below.
    #
    # EXAMPLES
    #
    # ./zepub book.epub
    # ./zepub book.epub /my/epub/folder

    # Path to EpubCheck (http://code.google.com/p/epubcheck)
    validator_path="/path/to/epubcheck/epubcheck-1.2.jar"

    function usage () {
    cat <<EOF
    Usage: zepub output [input]
    EOF
    }


    # Output argument
    if [ -z "$1" ]; then
    usage
    exit 0
    fi
    output=$1

    # Remove existing output
    rm -f $output

    # Input argument
    if [ -n "$2" ]; then
    input=$2
    else
    input="."
    fi

    # Package
    initial=$PWD
    cd $input
    zip -0Xq $initial/$output mimetype
    zip -Xr9Dq $initial/$output * -x zepub.sh *.epub
    echo $output
    # Validate
    if [ -f $validator_path ]; then
    cd $initial
    java -jar $validator_path $output
    fi