Content bundle making script

From OLPC
Revision as of 12:33, 14 May 2008 by Mchua (talk | contribs) (New page: == intro == Quick hack of a script that takes an index page on the web and pulls it, and all the pages it references, into a library bundle. Useful for things like Wikislices. == usa...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

intro

Quick hack of a script that takes an index page on the web and pulls it, and all the pages it references, into a library bundle. Useful for things like Wikislices.

usage

Copy the script into a directory on your machine and make it executable. usage is bundlemaker url bundlename languagecode

where

  • url is the url you want to turn into your index page
  • bundlename is the name you want your bundle to have (bundle.xol)
  • languagecode is the 2-letter language code the materials are written in; for instance, en, es, pt

example:

./bundlemaker http://www.nlm.nih.gov/medlineplus/healthtopics.html healthbundle en

script

#!/bin/sh
# usage: bundlemaker <url> <bundlename> <language>
# $1 - url to download from
# $2 - folder name to download to, also name of bundle
# $3 - language code this content is in (en, es, pt, etc.)

# make sure there are 3 arguments
if [ $# -ne 3 ]; then
    echo 1>&2 Usage: bundlemaker URL BUNDLENAME LANGUAGECODE
    exit 127
fi

# get the files from <url>
# place them in a folder called <bundlename> in cwd
# create a log at <bundlename>-log for debugging
wget -rp -nH -l1 -o ${2}-log -P $2 $1

# create the metadata
cd $2
mkdir library
cd library
# note: this is a stupid script! please fix it!
# see http://wiki.laptop.org/go/Sample_library.info_file
echo [Library] >> library.info
echo name = $2 >> library.info
echo global_name = $2 >> library.info
echo long_name = $2 >> library.info
echo library_version = 1 >> library.info
echo host_version = 1 >> library.info
echo l10n = false >> library.info
echo locale = $3 >> library.info

# zip and rename as bundle
cd ../..
zip -9 -rq $2 $2
mv $2.zip $2.xol

# delete extra files
# TODO: implement
exit 0