diff options
author | Franco Iacomella <franco@reevo.org> | 2024-03-08 14:27:11 -0300 |
---|---|---|
committer | Franco Iacomella <franco@reevo.org> | 2024-03-08 14:27:11 -0300 |
commit | 8c2d8064a31e2ad90e4152fadc10c119feabffd4 (patch) | |
tree | d12821d84455fa8c91e1486d506de55abc7895de | |
parent | f687ca0b48ceefa7fff334cfbc34e5fd60f67edc (diff) |
Book processing is functional
-rwxr-xr-x | platform/bin/contents_compile.sh | 149 |
1 files changed, 117 insertions, 32 deletions
diff --git a/platform/bin/contents_compile.sh b/platform/bin/contents_compile.sh index a46f78d..0952fa6 100755 --- a/platform/bin/contents_compile.sh +++ b/platform/bin/contents_compile.sh @@ -11,6 +11,7 @@ cd ../../content/$COLLECTION/contents/$TYPE AUTHOR=`cat ../../conf/local.php | grep author | cut -d "'" -f4` SITE=`cat ../../conf/local.php | grep title | cut -d "'" -f4` CODENAME=`cat ../../conf/local.php | grep codename | cut -d "'" -f4` +UNIVERSE=`cat ../../conf/local.php | grep universe | cut -d "'" -f4` BASEURL=`cat ../../../../platform/www/conf/farm.ini | grep basedomain | cut -d '"' -f 2` @@ -46,6 +47,15 @@ for i in `ls -d */`; do TITLEORIG=`cat index | grep titleorig | cut -d "_" -f3` # echo $TITLEORIG + # echo "************************" + # echo "LANGORIG: $LANGORIG" + # echo "TYPE: $TYPE" + # echo "i: $i" + # echo "************************" + # echo "************************" + # read + + if [[ -f $LANGORIG.txt ]] then echo "The version in the original language is already processed" @@ -60,8 +70,13 @@ for i in `ls -d */`; do mkdir ../../../data/pages/$LANG/$TYPE/$i fi + TAGS=() + TAGLIST="" + EXTRATAGS="" + + # Creates the index file - echo "Regenerate the index functionle for $i in $LANG" + echo "Regenerate the index for $i in $LANG" INDEX="../../../data/pages/$LANG/$TYPE/$i/index.txt" TITLE_MD=`head -n1 $LANG.txt` TITLE=`echo $TITLE_MD | sed s/\#\ //` @@ -69,29 +84,45 @@ for i in `ls -d */`; do echo "" >> $INDEX TITLELANG=`head -n1 $LANG.txt | sed s/\#\ //` cat index >> $INDEX - cat $LANG.notes >> $INDEX - sed -i "s/\*YEAR\*/$YEAR/g" $INDEX - if grep "LANG_authors" $INDEX + if [[ -f LANG.notes ]] + then + cat $LANG.notes >> $INDEX + fi + + + if [[ $TYPE != "book" ]] + then + sed -i "s/\*YEAR\*/$YEAR/g" $INDEX + fi + + if [ $(grep -c "LANG_authors" $INDEX) -eq 1 ] + # if grep "LANG_authors" $INDEX then sed -i "s/LANG_authors@#:\*\*/LANG_authors\@\#:\*\* $AUTHOR;/g" $INDEX - AUTHORS=`grep "LANG_authors" $INDEX | cut -d '*' -f6 | sed s/\;/\ and/g | sed s/^\ //` + AUTHORS=`grep "LANG_authors" $INDEX | cut -d '*' -f6 | sed s/\;/\ and/g | sed s/^\ // | sed s/:\ //` else # only main author AUTHORS=$AUTHOR fi - if grep "LANG_publicationdate" $INDEX + if [ $(grep -c "LANG_publicationdate" $INDEX) -eq 1 ] + # if grep "LANG_publicationdate" $INDEX then PUBDATE=`grep "LANG_publicationdate" $INDEX | cut -d '*' -f6 | sed s/\;/\ and/g | sed s/^\ //` else # Use year if full date is not defined PUBDATE=$YEAR fi + if [[ $TYPE == "book" ]] + then + YEAR=$PUBDATE + fi + if grep "LANG_translators" $INDEX then - TRANSLATORS=`grep "LANG_translators" $INDEX | cut -d '*' -f6 | sed s/\;/\ and/g | sed s/^\ //` + TRANSLATORS=`grep "LANG_translators" $INDEX | cut -d '*' -f6 | sed s/\;/\ and/g | sed s/^\ // | sed s/:\ //` else # no translators TRANSLATORS="" @@ -99,16 +130,19 @@ for i in `ls -d */`; do KEY=`echo $FOLDER | sed 's/\///'` # http://illich.acerv.uz/en:$TYPE:1900-testing:index URL="https://$CODENAME.$BASEURL/$LANG/$TYPE/$KEY:index" + URLDATE=`date +"%Y-%m-%d"` echo "" >> $INDEX - echo "@ARTICLE{$SITE-$KEY-$LANG, + echo "@ARTICLE{$UNIVERSE-$CODENAME-$KEY-$LANG, author = {$AUTHORS}, title = {$TITLE}, year = {$YEAR}, date = {$PUBDATE}, origdate = {$PUBDATE}, language = {$LANG}, + origlanguage = {$LANGORIG}, translator = {$TRANSLATORS}, - url = {$URL} + url = {$URL}, + urldate = {$URLDATE} }" > $LANG.bib echo "Generated $LANG.bib" cat $LANG.bib >> ../index.$LANG.bib @@ -122,11 +156,29 @@ for i in `ls -d */`; do LINES=`wc -l $LANG.txt` if [[ $LINES > 2 ]]; then # If the files contains more than one line, we consider the original $TYPE is complete and not pending - echo "{{tag>available}}" >> $INDEX + TAGS=("${TAGS[@]}" available) else - echo "{{tag>pending}}" >> $INDEX + TAGS=("${TAGS[@]}" pending) fi + for j in "${TAGS[@]}" + do + if [ -z "$TAGLIST" ] + then + TAGLIST="$j" + else + TAGLIST="$TAGLIST $j" + fi + done + + # Add tags in the tags file in the object folder + if [[ -f tags ]] + then + EXTRATAGS=`cat tags | awk '{print}' ORS=' '` + fi + echo "{{tag>$TAGLIST $EXTRATAGS}}" >> $INDEX + + # Creates the link to the text in the specific language cd ../../../data/pages/$LANG/$TYPE/$i if [[ ! -f text.txt ]] @@ -164,6 +216,12 @@ for i in `ls -d */`; do else echo "La version en el idioma original NO esta procesada, entonces marcamos como pendiente y creamos un index" + echo "LANGORIG: $LANGORIG" + echo "TYPE: $TYPE" + echo "i: $i" + + read + if [[ ! -d ../../../data/pages/$LANGORIG/$TYPE/$i ]] then echo "Create the $TYPE directory for $i in $LANGORIG" @@ -186,7 +244,23 @@ for i in `ls -d */`; do sed -i "s/\*YEAR\*/$YEAR/g" $INDEX sed -i "s/LANG_authors@#:\*\*/LANG_authors\@\#:\*\* $AUTHOR;/g" $INDEX - echo "{{tag>missing}}" >> $INDEX + TAGS=("${TAGS[@]}" available) + for j in "${TAGS[@]}" + do + if [ -z "$TAGLIST" ] + then + TAGLIST="$j" + else + TAGLIST="$TAGLIST $j" + fi + done + # Add tags in the tags file in the object folder + if [[ -f tags ]] + then + EXTRATAGS=`cat tags | awk '{print}' ORS=' '` + fi + echo "{{tag>$TAGLIST $EXTRATAGS}}" >> $INDEX + echo "* **[[$LANGORIG:$TYPE:$FOLDER:index|$YEAR - $TITLEORIG]]**" >> ../index.txt fi @@ -199,24 +273,35 @@ echo "Running decades... " IFS=$'\n' -for file in `ls index*.txt`; do - mv $file $file.old - echo "***** $file" - for name in `cat $file.old`; do - YEAR=`echo $name | cut -d ':' -f 3 | cut -d '-' -f 1` - DECADE=${YEAR:0:3} - #echo "YEAR: $YEAR" - #echo "DECADE: $DECADE" - - if [[ $DECADE_PRE != $DECADE ]]; then - echo "" >> $file - echo '### '$DECADE'0' >> $file - echo "" >> $file - fi - echo $name >> $file - DECADE_PRE=$DECADE - echo "" >> $file +case $TYPE in + book) + for file in `ls index*.txt`; do + sort -n -t '|' -k2 -o $file $file + sed -i 's/$/\n/' $file + done + ;; + *) + for file in `ls index*.txt`; do + mv $file $file.old + echo "***** $file" + for name in `cat $file.old`; do + YEAR=`echo $name | cut -d ':' -f 3 | cut -d '-' -f 1` + DECADE=${YEAR:0:3} + #echo "YEAR: $YEAR" + #echo "DECADE: $DECADE" + + if [[ $DECADE_PRE != $DECADE ]]; then + echo "" >> $file + echo '### '$DECADE'0' >> $file + echo "" >> $file + fi + echo $name >> $file + DECADE_PRE=$DECADE + echo "" >> $file + + done + done + rm *.old - done -done -rm *.old + ;; +esac |