summaryrefslogtreecommitdiff
path: root/contents/articles/compile.sh
diff options
context:
space:
mode:
Diffstat (limited to 'contents/articles/compile.sh')
-rwxr-xr-xcontents/articles/compile.sh84
1 files changed, 78 insertions, 6 deletions
diff --git a/contents/articles/compile.sh b/contents/articles/compile.sh
index b2005af..01a6511 100755
--- a/contents/articles/compile.sh
+++ b/contents/articles/compile.sh
@@ -4,12 +4,33 @@
echo "#### STARTING TO COMPILE ARTICLES. Press a key to proceed..."
read
+rm index*
+echo "" > index.txt
+
+LANGS=("en" "es")
+for lng in ${LANGS[@]}; do
+ echo "" > index.$lng.txt
+ rm -rf ../../data/pages/$lng/article/*
+ cd ../../data/pages/$lng/article/
+ ln -s ../../../../contents/articles/index.$lng.txt index.txt
+ cd -
+done
+
+
+
+echo "" > index.es.txt
+
+
+
for i in `ls -d */`; do
echo "*** $i"
+ FOLDER=$i
YEAR=`echo $i | cut -d '-' -f1`
cd $i
LANGORIG=`cat index | grep langorig | cut -d "@" -f 4 | cut -d "_" -f 3`
echo $LANGORIG
+ TITLEORIG=`cat index | grep titleorig | cut -d "_" -f3`
+ echo $TITLEORIG
if [[ -f $LANGORIG.txt ]]
then
@@ -26,15 +47,24 @@ for i in `ls -d */`; do
fi
# Creates the index file
- echo "Regenerate the index file for $i in $LANG"
+ echo "Regenerate the index functionle for $i in $LANG"
INDEX="../../../data/pages/$LANG/article/$i/index.txt"
+
head -n1 $LANG.txt > $INDEX
echo "" >> $INDEX
+ TITLELANG=`head -n1 $LANG.txt | sed s/\#\ //`
cat index >> $INDEX
cat $LANG.notes | sed s/\*/\ \ \*/ >> $INDEX
echo "" >> $INDEX
echo "~~NOTOC~~" >> $INDEX
sed -i "s/\*YEAR\*/$YEAR/g" $INDEX
+ LINES=`wc -l $LANG.txt`
+ if [[ $LINES > 2 ]]; then
+ # If the files contains more than one line, we consider the original article is complete and not pending
+ echo "{{tag>available}}" >> $INDEX
+ else
+ echo "{{tag>pending}}" >> $INDEX
+ fi
# Creates the link to the text in the specific language
cd ../../../data/pages/$LANG/article/$i
@@ -43,12 +73,29 @@ for i in `ls -d */`; do
ln -s ../../../../../contents/articles/$i$LANG.txt text.txt
fi
+ if [[ ! -f notes.txt ]]
+ then
+ ln -s ../../../../../contents/articles/$i$LANG.notes notes.txt
+ fi
cd -
+
+ if [[ $TITLELANG == $TITLEORIG ]]
+ then
+ echo "* [[$LANG:article:$FOLDER:index|$YEAR - $TITLELANG]]" >> ../index.$LANG.txt
+
+ else
+ echo "* [[$LANG:article:$FOLDER:index|$YEAR - $TITLELANG]] (*$TITLEORIG*)" >> ../index.$LANG.txt
+ fi
+
+
done
+ #echo "* $YEAR - $TITLEORIG" >> ../index.txt
+ echo "* [[$LANGORIG:article:$FOLDER:index|$YEAR - $TITLEORIG]]" >> ../index.txt
+
+ # Creates the article directory
else
echo "La version en el idioma original NO esta procesada, entonces marcamos como pendiente y creamos un index"
- # Creates the article directory
if [[ ! -d ../../../data/pages/$LANGORIG/article/$i ]]
then
echo "Create the article directory for $i in $LANGORIG"
@@ -61,7 +108,7 @@ for i in `ls -d */`; do
INDEX="../../../data/pages/$LANGORIG/article/$i/index.txt"
echo $INDEX
- TITLEORIG=`cat index | grep titleorig | cut -d "_" -f3`
+ # TITLEORIG=`cat index | grep titleorig | cut -d "_" -f3`
echo "# $TITLEORIG" > $INDEX
echo "" >> $INDEX
cat index >> $INDEX
@@ -69,11 +116,36 @@ for i in `ls -d */`; do
echo "" >> $INDEX
echo "~~NOTOC~~" >> $INDEX
sed -i "s/\*YEAR\*/$YEAR/g" $INDEX
- echo "{{tag>pending}}" >> $INDEX
- fi
-
+ echo "{{tag>missing}}" >> $INDEX
+ echo "* **[[$LANGORIG:article:$FOLDER:index|$YEAR - $TITLEORIG]]**" >> ../index.txt
+ fi
cd ..
echo ""
done
+
+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
+
+ done
+done