maul-esel / ahkbook

a free online book about AutoHotkey!
http://maul-esel.github.com/ahkbook/index.html
Other
39 stars 22 forks source link

downloadable version #3

Open maul-esel opened 12 years ago

maul-esel commented 12 years ago

Provide a downloadable version

#!bin/sh

rm hook-temp
rm package.zip

mkdir hook-temp

git clone . hook-temp
cd hook-temp

jekyll
cd _site

zip -ll ../../package.zip *
zip -ll ../../package.zip */*

cd ../..
rm -R -f hook-temp

The CSS location is not offline.

maul-esel commented 12 years ago

Maybe this can be turned in a CHM instead?

brigand commented 12 years ago

I have a working solution. The CSS doesn't get included, but I don't think we need it for off-line use. I may have a way for it to work which I can give a try.

this video shows the process

It uses the following bash script to do the process.

#!/bin/sh

# Location to save ebook
OPATH=`pwd`

# Custom dir to build in
BPATH='/tmp/ahkbook_build'
mkdir $BPATH
cd $BPATH

# clone from GitHub using the read-only uri
# this is the official repo
git clone git://github.com/maul-esel/ahkbook.git
cd ahkbook

# Make the html
# I get A LOT of errors so just hide them
# we still get the success status
jekyll 2> /dev/null
cd _site

# make the ebook
# we get ebook-convert from the calibre package
ebook-convert index.html $OPATH/ahkbook.epub >/dev/null 2>&1

# clean up
# it's pretty much impossible for this to delete the output file
rm -R -f $BPATH

Here are the dependencies for running that. If you have apt-get as your package manager this should work. I've tried it on Ubuntu 10.10 and Linux Mint 12.

#!/bin/sh
sudo apt-get install -y rubygems1.8 ruby1.8-dev python-pygments git calibre
gem install jekyll
PATH=$PATH:/var/lib/gems/1.8/bin/
export PATH

Just as a note, I don't think those last two lines do what I think... It doesn't seem to affect my path.

maul-esel commented 12 years ago

I didn't think of this format, but it is good! Maybe we can look out for other formats, too, and provide multiple versions later...

CSS support is not definitely necessary, but if you'd know a way... I tried replacing the CSS URL with a local one, but this produces an error.

brigand commented 12 years ago

we can convert to any and all of these formats.

A css file can be included when converting via a command line parameter. I'll try it a bit later.

maul-esel commented 12 years ago

Did you try in the meantime? I did, but it failed on my system :(

brigand commented 12 years ago

Yes, I did. The pdf fails but most of the others seem to work.

Should there be a separate branch for binaries? (I can upload a zip when I get a good connection.)

maul-esel commented 12 years ago

Yes, I did. The pdf fails but most of the others seem to work.

Oh really? For me even the epub doesn't work (with css) :(

Should there be a separate branch for binaries?

I would prefer downloads over a branch.

brigand commented 12 years ago

Oh, sorry. I forgot to tell you about the --extra-css option. It takes a stylesheet file name and packs that in the output. Some changes need to be made for the style to work properly.

maul-esel commented 12 years ago

Yeah, I used that option, but I didn't make any changes to the style.

I'm doing some (AutoHotkey) experiments to create a CHM from the index page automatically.

brigand commented 12 years ago

I built it again, and then zipped the folder. It has the scripts too.

http://www.autohotkey.net/~frankie/temp_links/ahkbook-11-24-11.zip (2 MB)

You should see the problem with the epub, it sets the background to gray and ignores the div.content styles. I haven't checked all of them, mostly because I don't know what to open them with! (calibre can probably handle them.)

Let me know what you think.

P.s. What system are you running? Why can't you build them? Feel free to send me a message about it because I think it's important you can do it.

maul-esel commented 12 years ago

Thanks, I sent you a PM.

Btw, it seems your ebooks all contain that liquid error: Liquid error: undefined method join' for "; any AutoHotkey version\nMsgBox Hello, World!\n":String or similar, wherever code appears. That occurs if you're using Liquid 2.3.0 (seems to be a bug). v2.2.2 does it correctly.

Regards maul.esel

P.S.: Assuming you know your content is not entirely up-to-date...

maul-esel commented 12 years ago

I just uploaded a zip with the latest content as html files. The modifications I made:

You as a shell expert, can you tell me if there's a way to automate this text replacement (regex or similar) ?

Edit: The first change seems also to be possible with a jekyll cmd parameter. Edit 2: added the build script Edit 3: automated replacement in build script

Regards maul.esel

maul-esel commented 12 years ago

You can see my CHM experiments here. Currently it doesn't work (fatal navigation error).

Of course it would be best if this could be rewritten in another language (shell script) to make it run on linux - and then we could just build the content (as for the zip file) instead of downloading.

maul-esel commented 12 years ago

About the failed ebook-conversion: I tried the version in your repo and it worked. My version doesn't work with or without command line parameters now.

Bisecting tells me this behaviour starts with this commit. Do you have an idea why?

Regards maul.esel