Content bundle making script: Difference between revisions

From OLPC
Jump to navigation Jump to search
m (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...)
 
Line 2: Line 2:


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]].
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]].

At the end of running the script (it is quiet and may take several minutes as it downloads files) you should have a '''bundlename.xol''' file in the directory you ran the script on, ready to go on the XO.

=== Improvements ===

These are things I know should be fixed in the script - if you have the time and inclination, please do them.

* test the script on several index-type sites and try out the .xol files generated on your XO, and see if they work. Post results to the [[Talk:Content bundle making script|talk page]].
* make the library.info file generation less horribly hackish... right now it just appends all the needed information to the file, but the implementation is very brittle in that the library.info format and default values are hard-coded into the script right now.
* make the script clean up after itself. It leaves a bunch of cruft hanging around that isn't the .xol file.
* if this is sufficiently useful, consider asking for [[Project hosting]] for the script - please cc me in on the request if you do this!


== usage ==
== usage ==

Revision as of 16:36, 14 May 2008

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.

At the end of running the script (it is quiet and may take several minutes as it downloads files) you should have a bundlename.xol file in the directory you ran the script on, ready to go on the XO.

Improvements

These are things I know should be fixed in the script - if you have the time and inclination, please do them.

  • test the script on several index-type sites and try out the .xol files generated on your XO, and see if they work. Post results to the talk page.
  • make the library.info file generation less horribly hackish... right now it just appends all the needed information to the file, but the implementation is very brittle in that the library.info format and default values are hard-coded into the script right now.
  • make the script clean up after itself. It leaves a bunch of cruft hanging around that isn't the .xol file.
  • if this is sufficiently useful, consider asking for Project hosting for the script - please cc me in on the request if you do this!

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