[sword-svn] r122 - trunk

Apache apache at www.crosswire.org
Tue May 8 20:42:50 MST 2007


Author: 
Date: 2007-05-08 20:42:48 -0700 (Tue, 08 May 2007)
New Revision: 122

Modified:
   trunk/genfcmobile.sh
Log:
Added support for MAX_LESSON_WORDS
Need to move completed packages into a target subdirectory so genImages doesn't exponentially take longer.


Modified: trunk/genfcmobile.sh
===================================================================
--- trunk/genfcmobile.sh	2007-05-09 03:11:52 UTC (rev 121)
+++ trunk/genfcmobile.sh	2007-05-09 03:42:48 UTC (rev 122)
@@ -1,7 +1,45 @@
 #!/bin/sh
 
+# prepares a lessons/ directory and packages into a jar for a mobile phone
+genpackage() {
+  # Test syntax.
+  partNumber=""
+  if [ "$#" -eq 0 ]; then
+    echo $"Usage: genpackage [-p partNumber] {lessonSet}"
+    return 1
+  fi
+  if [ "$1" = "-p" ]; then
+    partNumber="."$2
+    shift 2
+  fi
+        
+#yeah, I know, it outputs to $HOME/.flashcards, lame.  FIXME
+  rm -rf ~/.flashcards/lessons/$1/images
+  jar cf lessons.jar lessons
+  echo generating pre-rendered images for \[$1\]
+  java -cp flashcards.jar org.crosswire.flashcards.LessonManager -genImages
+  mv ~/.flashcards/lessons/$1/images lessons/$1/
+  mv lessons res/
+  rm lessons.jar
+  echo LessonSet0=$1$partNumber > res/lessons/lessons.properties
+  echo LessonDescription0=$1$partNumber >> res/lessons/lessons.properties
+  PKGNAME=fc$i$partNumber
+  sed s/##NAME##/${PKGNAME}/ ../micro/bin/MANIFEST.MF > MANIFEST.MF
+  sed s/##NAME##/${PKGNAME}/ ../micro/bin/fc.jad > ${PKGNAME}.jad
+  cd ..
+  ant -Ddest.path=${WORKDIR} -Ddest.name=${PKGNAME} -f build.micro2.xml
+  cd ${WORKDIR}
+  JARSIZE=`ls -l ${PKGNAME}.jar |cut -f5 -d' '`
+  sed -i s/##SIZE##/${JARSIZE}/ ${PKGNAME}.jad
+  cat >> index.html <<!
+  <a href="/fc/${PKGNAME}.jad">$i$partNumber</a><br/>
+!
+}
+
+
 JAVA_HOME=/usr/java/j2sdk1.4.2_05
 WORKDIR=fcMobilePackage.$$
+MAX_LESSON_WORDS=200
 
 echo setting up workspace at $WORKDIR
 mkdir $WORKDIR
@@ -33,34 +71,37 @@
   mkdir -p lessons/$i
   mkdir -p res
   cd lessons.orig/$i
-  jNum=0;
+  jNum=0
+  wCount=0
+  part=1
   for j in *
   do
+    words=`grep wordCount $j|sed s/\[^0-9\]//g`
+    echo processing lesson $j with $words words
+    wCount=$(($wCount+$words))
+    if [ "$wCount" -gt $MAX_LESSON_WORDS ]; then
+      echo "Generating package" $i.$part "with" $(($jNum)) "lessons and" $(($wCount-$words)) "words"
+      cd ../..
+      genpackage -p $part $i
+      part=$(($part+1))
+      wCount=$words
+      jNum=0
+      rm -rf res lessons
+      mkdir -p lessons/$i
+      mkdir -p res
+      cd lessons.orig/$i
+    fi
     cp $j ../../lessons/$i/lesson${jNum}.flash
     jNum=$(($jNum+1))
   done
   cd ../../
-#yeah, I know, it outputs to $HOME/.flashcards, lame.  FIXME
-  rm -rf ~/.flashcards/lessons/$i/images
-  jar cf lessons.jar lessons
-  echo generating pre-rendered images for \[$i\]
-  java -cp flashcards.jar org.crosswire.flashcards.LessonManager -genImages
-  mv ~/.flashcards/lessons/$i/images lessons/$i/
-  mv lessons res/
-  rm lessons.jar
-  echo LessonSet0=$i > res/lessons/lessons.properties
-  echo LessonDescription0=$i >> res/lessons/lessons.properties
-  PKGNAME=fc$i
-  sed s/##NAME##/${PKGNAME}/ ../micro/bin/MANIFEST.MF > MANIFEST.MF
-  sed s/##NAME##/${PKGNAME}/ ../micro/bin/fc.jad > ${PKGNAME}.jad
-  cd ..
-  ant -Ddest.path=${WORKDIR} -Ddest.name=${PKGNAME} -f build.micro2.xml
-  cd ${WORKDIR}
-  JARSIZE=`ls -l ${PKGNAME}.jar |cut -f5 -d' '`
-  sed -i s/##SIZE##/${JARSIZE}/ ${PKGNAME}.jad
-  cat >> index.html <<!
-  <a href="/fc/${PKGNAME}.jad">$i</a><br/>
-!
+  if [ $part -gt 1 ]; then
+    echo "Generating package" $i.$part "with" $(($jNum-1)) "lessons and" $(($wCount)) "words"
+    genpackage -p $part $i
+  else
+    echo "Generating package" $i "with" $(($jNum-1)) "lessons and" $(($wCount)) "words"
+    genpackage $i
+  fi
 done
 cat >> index.html <<!
 </body></html>




More information about the sword-cvs mailing list