blob: 01a651120ba097b7deccdabae8bfe6245d59ffbb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
#!/usr/bin/env bash
# Article compilers
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
echo "la version en el idioma original esta procesada"
for j in `ls *.txt`; do
LANG=`echo $j | cut -d '.' -f1`
echo "**** $LANG"
# Creates the article directory
if [[ ! -d ../../../data/pages/$LANG/article/$i ]]
then
echo "Create the article directory for $i in $LANG"
mkdir ../../../data/pages/$LANG/article/$i
fi
# Creates the index file
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
if [[ ! -f text.txt ]]
then
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"
if [[ ! -d ../../../data/pages/$LANGORIG/article/$i ]]
then
echo "Create the article directory for $i in $LANGORIG"
mkdir ../../../data/pages/$LANGORIG/article/$i
fi
# Creates the index file
echo "Creates the index file for $i in $LANGORIG"
INDEX="../../../data/pages/$LANGORIG/article/$i/index.txt"
echo $INDEX
# TITLEORIG=`cat index | grep titleorig | cut -d "_" -f3`
echo "# $TITLEORIG" > $INDEX
echo "" >> $INDEX
cat index >> $INDEX
cat $LANGORIG.notes | sed s/\*/\ \ \*/ >> $INDEX
echo "" >> $INDEX
echo "~~NOTOC~~" >> $INDEX
sed -i "s/\*YEAR\*/$YEAR/g" $INDEX
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
|