[Openstack-docs] Fwd: [Openstack] script to build epubs from openstack documentation

Tom Fifield tom at openstack.org
Thu Jan 2 10:14:33 UTC 2014


Not sure if anyone saw this on the general list.


-------- Original Message --------
Subject: [Openstack] script to build epubs from openstack documentation
Date: Tue, 31 Dec 2013 03:19:03 +0200
From: Cristian Falcas <cristi.falcas at gmail.com>
To: openstack <openstack at lists.openstack.org>

Hi all,

I made a small script that builds epubs from openstack documentation pages.

The most annoying problem is that the TOC is not always correctly
build (because how calibre is searching for headers and how the
openstack pages are build)

Anyway, it's readable and looks to have the correct order of pages.

You will need calibre installed and wget. Also you will have to fix
any new lines added by gmail :(.


#!/bin/bash

# sudo python -c "import sys; py3 = sys.version_info[0] > 2; u =
__import__('urllib.request' if py3 else 'urllib', fromlist=1);
exec(u.urlopen('http://status.calibre-ebook.com/linux_installer').read());
main()"

make_ebook() {
  mkdir -p ./$dir
  wget --directory-prefix=$dir --recursive --no-clobber
--page-requisites --html-extension --convert-links --domains
docs.openstack.org --no-parent -R *.pdf -nH --cut-dirs=2 $site
  [[ -f ./common/css/custom.css ]] && extra_path="common";
css="./$dir/$extra_path/css/custom.css"
  [[ -f ./content/index.html ]] && extra_path="content";
index="./$dir/$extra_path/index.html"

  echo '
body #content {margin-top: 0px;}
#header {display:none;}
#leftnavigation {display:none;}
#content {margin: 0px 0px 0px 0px;}
#toolbar {display:none;}
#legal {display:none;}' >> $css

  /opt/calibre/ebook-convert $index ./$dir.epub
--minimum-line-height=0 --smarten-punctuation --level1-toc="//h:h1"
--level2-toc="//h:h2" --level3-toc="//h:h3" --chapter="//*[name()='h1'
or name()='h2' or name()='h3']" --input-profile=default
--output-profile=nook --use-auto-toc --title=$dir --authors=openstack
}

site="http://docs.openstack.org/trunk/openstack-ops/content/section_yk2_jpr_lj.html"
dir=openstack_ops
make_ebook

site="http://docs.openstack.org/trunk/config-reference/content/config_overview.html"
dir=openstack_conf
make_ebook

site="http://docs.openstack.org/admin-guide-cloud/content/ch_getting-started-with-openstack.html"
dir=openstack_admin_guide
make_ebook

site="http://docs.openstack.org/high-availability-guide/content/ch-intro.html"
dir=openstack_high_availability
make_ebook




Best regards,
Cristian Falcas

_______________________________________________
Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
Post to     : openstack at lists.openstack.org
Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack





More information about the Openstack-docs mailing list