1 | #! /bin/sh -x |
---|
2 | #+ |
---|
3 | # |
---|
4 | # =========== |
---|
5 | # genaeres.sh |
---|
6 | # =========== |
---|
7 | # |
---|
8 | # SYNOPSIS |
---|
9 | # ======== |
---|
10 | # |
---|
11 | # ``./genaeres.sh`` |
---|
12 | # |
---|
13 | # DESCRIPTION |
---|
14 | # =========== |
---|
15 | # |
---|
16 | # aeres 2007-2012 |
---|
17 | # |
---|
18 | # SEE ALSO |
---|
19 | # ======== |
---|
20 | # |
---|
21 | # genbib.sh |
---|
22 | # |
---|
23 | # TODO |
---|
24 | # ==== |
---|
25 | # |
---|
26 | # integrer dans trunk superbib |
---|
27 | # |
---|
28 | # on ne voit pas les notes des unpublished dans le pdf plain |
---|
29 | # |
---|
30 | # EVOLUTIONS |
---|
31 | # ========== |
---|
32 | # |
---|
33 | # $Id$ |
---|
34 | # |
---|
35 | # $URL$ |
---|
36 | # |
---|
37 | # - fplod 20120706T101813Z cratos (Linux) |
---|
38 | # |
---|
39 | # * add phybiocar theme (bouzin mais ça marche) |
---|
40 | # |
---|
41 | # - fplod 20120705T101524Z cratos (Linux) |
---|
42 | # |
---|
43 | # * nouvelle technique de sélection avec bib2bib |
---|
44 | # donc les unpublished avec des champs year sont maintenant sélectionnés |
---|
45 | # thanks to http://www.lri.fr/~filliatr/bibtex2html/doc/manual.html#htoc14 |
---|
46 | # * intégration de genaeres_rtf.sh |
---|
47 | # |
---|
48 | # - fplod 20120419T121614Z cratos (Linux) |
---|
49 | # |
---|
50 | # * add copy of sorttable.js in dirwww |
---|
51 | # * add copy of sorttable.css in dirwww |
---|
52 | # |
---|
53 | # - fplod 20120406 |
---|
54 | # |
---|
55 | # * creation sans répéter certaines fonctionalités de genbib.sh |
---|
56 | # comme les vérif. de bases, les tutuelles |
---|
57 | # |
---|
58 | #- |
---|
59 | set -u |
---|
60 | command=$(basename ${0}) |
---|
61 | # |
---|
62 | system=$(uname) |
---|
63 | case "${system}" in |
---|
64 | AIX|IRIX64) |
---|
65 | echo "${command} : www : no specific posix checking" |
---|
66 | ;; |
---|
67 | *) |
---|
68 | set -o posix |
---|
69 | ;; |
---|
70 | esac |
---|
71 | # |
---|
72 | . define_teams_aeres2007_2012.sh |
---|
73 | . define_phybiocar_theme.sh |
---|
74 | . jabref_rtf.sh |
---|
75 | . jabref_header.sh |
---|
76 | . define_authors.sh |
---|
77 | # |
---|
78 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
79 | log=${PROJECT_LOG}/$(basename ${command} .sh).log.${log_date} |
---|
80 | # |
---|
81 | usage=" Usage : ${command}" |
---|
82 | # |
---|
83 | # test if bibtool available |
---|
84 | tool=bibtool |
---|
85 | type ${tool} 1> /dev/null 2>&1 |
---|
86 | status=${?} |
---|
87 | if [ ${status} -ne 0 ] |
---|
88 | then |
---|
89 | echo "${command} : eee : ${tool} unavailable" >&2 |
---|
90 | exit 1 |
---|
91 | fi |
---|
92 | unset tool |
---|
93 | unset status |
---|
94 | # |
---|
95 | # test if bib2bib available |
---|
96 | tool=bib2bib |
---|
97 | type ${tool} 1> /dev/null 2>&1 |
---|
98 | status=${?} |
---|
99 | if [ ${status} -ne 0 ] |
---|
100 | then |
---|
101 | echo "${command} : eee : ${tool} unavailable" >&2 |
---|
102 | exit 1 |
---|
103 | fi |
---|
104 | unset tool |
---|
105 | unset status |
---|
106 | # |
---|
107 | # default |
---|
108 | # n.a. |
---|
109 | # |
---|
110 | tmpdir=${PROJECT_LOG}/gtbiblio/aeres2007_2012/ |
---|
111 | dirwww=${PROJECT_OD}/public_html/gtbiblio/aeres2007_2012/ |
---|
112 | rm -rf ${tmpdir} 2> /dev/null |
---|
113 | mkdir -p ${tmpdir} |
---|
114 | rm -rf ${dirwww} 2> /dev/null |
---|
115 | mkdir -p ${dirwww} |
---|
116 | # |
---|
117 | # copy javascript and css for sort table in output directory |
---|
118 | cp sorttable.js ${dirwww}/ |
---|
119 | cp sorttable.css ${dirwww}/ |
---|
120 | # |
---|
121 | # define bibliography reference file |
---|
122 | biblioref_orig=${PROJECT_ID}/biblioref.bib |
---|
123 | biblioreffull=${tmpdir}/all.bib |
---|
124 | cp ${biblioref_orig} ${biblioreffull} |
---|
125 | biblioref=${tmpdir}/aeres2007_2012.bib |
---|
126 | bibliocite=${tmpdir}/aeres2007_2012_cite.bib |
---|
127 | # |
---|
128 | bib2bib -oc ${bibliocite} -ob ${biblioref} \ |
---|
129 | -c 'year>=2007 and year<=2012' \ |
---|
130 | ${biblioreffull} |
---|
131 | # |
---|
132 | # ++ usefull artificial header of jabref file to enforce encoding |
---|
133 | jabref_header ${tmpdir}/header_jabref |
---|
134 | # |
---|
135 | # génération du PDF classique |
---|
136 | list_style="plain" #+++ |
---|
137 | for style in ${list_style} |
---|
138 | do |
---|
139 | rm ${dirwww}/$(basename ${biblioref}.${style}.log .log).* 2> /dev/null |
---|
140 | # generation of latex file |
---|
141 | cat << EOF > ${biblioref}.${style}.tex |
---|
142 | \documentclass[a4paper]{article} |
---|
143 | %++\usepackage[frenchb]{babel} |
---|
144 | \usepackage[latin1]{inputenc} |
---|
145 | \begin{document} |
---|
146 | % force to include all entry of the bibliography |
---|
147 | \nocite{*} |
---|
148 | |
---|
149 | % bibliography |
---|
150 | \bibliographystyle{${style}} |
---|
151 | |
---|
152 | \bibliography{${biblioref}} |
---|
153 | \end{document} |
---|
154 | EOF |
---|
155 | # |
---|
156 | # processing bibliography with pdflatex (${dirwww}/${biblioref}.${style}.pdf) |
---|
157 | rm ${dirwww}/$(basename ${biblioref}.${style}.log .log).* 2> /dev/null |
---|
158 | pdflatex -output-directory ${dirwww} ${biblioref}.${style}.tex |
---|
159 | bibtex ${dirwww}/$(basename ${biblioref}.${style}) |
---|
160 | #++ warnings |
---|
161 | pdflatex -output-directory ${dirwww} ${biblioref}.${style}.tex |
---|
162 | pdflatex -output-directory ${dirwww} ${biblioref}.${style}.tex |
---|
163 | # |
---|
164 | # remove temporary latex files |
---|
165 | rm ${dirwww}/$(basename ${biblioref}.${style}.bbl) ${dirwww}/$(basename ${biblioref}.${style}.blg) ${dirwww}/$(basename ${biblioref}.${style}.log) ${dirwww}/$(basename ${biblioref}.${style}.aux) 2> /dev/null |
---|
166 | # |
---|
167 | #++rm ${biblioref}.${style}.tex 2> /dev/null |
---|
168 | done |
---|
169 | |
---|
170 | echo "fin 1re passe latex" |
---|
171 | |
---|
172 | # generation one RTF file style harvard |
---|
173 | output_title=aeres2007_2012 |
---|
174 | rm ${biblioref}.harvard.jabref.rtf 2> /dev/null |
---|
175 | java -jar ${JABREF_DIR}/JabRef-${JABREF_VERSION}.jar -n true \ |
---|
176 | -p ${PROJECT}/../branches/bibliolocean/src/jabref.preferences.xml \ |
---|
177 | --output ${dirwww}/${output_title}.harvard.jabref.rtf,harvard \ |
---|
178 | ${biblioref} |
---|
179 | echo "fin rtf all" |
---|
180 | # |
---|
181 | # generation of HTML |
---|
182 | list_format="html simplehtml tablerefs locean_tablerefs locean_tablerefsabsbibsort locean_listrefs" |
---|
183 | for format in ${list_format} |
---|
184 | do |
---|
185 | echo "format export jabref ${format}" |
---|
186 | # generation one HTML file style ${format} |
---|
187 | rm ${biblioref}.${format}.jabref.html 2> /dev/null |
---|
188 | java -jar ${JABREF_DIR}/JabRef-${JABREF_VERSION}.jar -n true \ |
---|
189 | -p ${PROJECT}/../branches/bibliolocean/src/jabref.preferences.xml \ |
---|
190 | --output ${dirwww}/${output_title}.${format}.jabref.html,${format} \ |
---|
191 | ${biblioref} |
---|
192 | jabref_status=${?} |
---|
193 | if [ ${jabref_status} -ne 0 ] |
---|
194 | then |
---|
195 | echo "${command} : eee : pb with jabref export ${format}" |
---|
196 | exit 1 |
---|
197 | fi |
---|
198 | done |
---|
199 | # |
---|
200 | # loop on teams and years to build bibliography reference file |
---|
201 | list_fteamyear="" |
---|
202 | iteam=1 |
---|
203 | nbteam=${#list_team_bibtool[@]} |
---|
204 | while [ ${iteam} -le ${nbteam} ] |
---|
205 | do |
---|
206 | echo "${LINENO} : iii: team = ${list_team_bibtool[${iteam}]}" |
---|
207 | fteam=${tmpdir}/${list_team_title[${iteam}]}.bib |
---|
208 | rm ${fteam} 2> /dev/null |
---|
209 | bibtool_command="bibtool -- 'select={aeresteam \"${list_team_bibtool[${iteam}]}\"}' ${biblioreffull} -o ${fteam}" |
---|
210 | eval ${bibtool_command} |
---|
211 | unset bibtool_command |
---|
212 | nbatteam=$(grep -c @ ${fteam}) |
---|
213 | if [ ${nbatteam} -ge 2 ] |
---|
214 | then |
---|
215 | echo "iii : $((${nbatteam} - 1)) ref for aeresteam ${list_team_title[${iteam}]}" |
---|
216 | # generation one HTML file style ${format} |
---|
217 | format=locean_tablerefsabsbibsort |
---|
218 | rm ${biblioref}.${format}.jabref.html 2> /dev/null |
---|
219 | java -jar ${JABREF_DIR}/JabRef-${JABREF_VERSION}.jar -n true \ |
---|
220 | -p ${PROJECT}/../branches/bibliolocean/src/jabref.preferences.xml \ |
---|
221 | --output ${dirwww}/${output_title}_${list_team_title[iteam]}.${format}.jabref.html,${format} \ |
---|
222 | ${fteam} |
---|
223 | jabref_status=${?} |
---|
224 | if [ ${jabref_status} -ne 0 ] |
---|
225 | then |
---|
226 | echo "${command} : eee : pb with jabref export ${format}" |
---|
227 | exit 1 |
---|
228 | fi |
---|
229 | # loop on years |
---|
230 | list_year=$(seq 2007 2012) |
---|
231 | for iyear in ${list_year} |
---|
232 | do |
---|
233 | echo "${LINENO} : iii: year = ${iyear}" |
---|
234 | fteamyear=${tmpdir}/$(basename ${fteam} .bib)_${iyear}.bib |
---|
235 | rm ${fteamyear} 2> /dev/null |
---|
236 | bibtool_command="bibtool -- 'select={year \"${iyear}\"}' ${fteam} -o ${fteamyear}" |
---|
237 | eval ${bibtool_command} |
---|
238 | unset bibtool_command |
---|
239 | # test if empty |
---|
240 | nbatteamyear=$(grep -c @ ${fteamyear}) |
---|
241 | if [ ${nbatteamyear} -ge 2 ] |
---|
242 | then |
---|
243 | echo "iii : $((${nbatteamyear} - 1)) ref for aeresteam ${list_team_title[${iteam}]} and year ${iyear}" |
---|
244 | list_fteamyear="${list_fteamyear} ${fteamyear}" |
---|
245 | else |
---|
246 | echo "www : no ref for aeresteam ${list_team_title[${iteam}]} and year ${iyear}" |
---|
247 | fi |
---|
248 | unset nbatteamyear |
---|
249 | done # end of year loop |
---|
250 | unset iyear |
---|
251 | else |
---|
252 | echo "www : no ref for aeresteam ${list_team_title[${iteam}]}" |
---|
253 | fi |
---|
254 | unset nbatteam |
---|
255 | unset nbatteamyear |
---|
256 | iteam=$(( ${iteam} + 1 )) |
---|
257 | done # end of team loop |
---|
258 | unset iteam |
---|
259 | unset nbteam |
---|
260 | unset list_year |
---|
261 | unset fteam |
---|
262 | # |
---|
263 | # define jabref header |
---|
264 | # ++ usefull |
---|
265 | jabref_header ${tmpdir}/header_jabref |
---|
266 | # |
---|
267 | # loop on aerestype |
---|
268 | list_aerestype="ACL ACLN ASCL BRE C-INV C-ACTI C-ATCN C-COM C-AFF DO OR OS PV PAT PT AP" |
---|
269 | for aerestype in ${list_aerestype} |
---|
270 | do |
---|
271 | echo "${LINENO} : iii: aerestype = ${aerestype}" |
---|
272 | for fteamyear in ${list_fteamyear} |
---|
273 | do |
---|
274 | echo "${LINENO} : iii: fteamyear = ${fteamyear}" |
---|
275 | #++ add header |
---|
276 | fteamyeartype=${tmpdir}/$(basename ${fteamyear} .bib)_${aerestype}.bib |
---|
277 | rm ${fteamyeartype} 2> /dev/null |
---|
278 | bibtool_command="bibtool -- 'select={aerestype \"${aerestype}\"}' ${fteamyear} -o ${fteamyeartype}" |
---|
279 | eval ${bibtool_command} |
---|
280 | unset bibtool_command |
---|
281 | # test if empty |
---|
282 | nbatteamyeartype=$(grep -c @ ${fteamyeartype}) |
---|
283 | if [ ${nbatteamyeartype} -ge 2 ] |
---|
284 | then |
---|
285 | echo "iii : $((${nbatteamyeartype} - 1)) ref type ${aerestype} in ${fteamyear}" |
---|
286 | ofteamyeartype=${dirwww}/$(basename ${fteamyeartype} .bib).rtf |
---|
287 | rm ${ofteamyeartype} 2> /dev/null |
---|
288 | jabref_rtf \ |
---|
289 | ${PROJECT}/../branches/bibliolocean/src/jabref.preferences.xml \ |
---|
290 | ${fteamyeartype} ${ofteamyeartype} |
---|
291 | # ++ test si ok |
---|
292 | else |
---|
293 | echo "www : no ref type ${aerestype} in ${fteamyear}" |
---|
294 | fi |
---|
295 | unset nbatteamyeartype |
---|
296 | done # end of loop on fteamyear |
---|
297 | done # end of loop on aerestype |
---|
298 | # |
---|
299 | # loop on authors to build bibliography reference file |
---|
300 | iauthor=1 |
---|
301 | nbauthor=${#list_author_bibtool[@]} |
---|
302 | #++nbauthor=0 #+++ |
---|
303 | while [ ${iauthor} -le ${nbauthor} ] |
---|
304 | do |
---|
305 | rm ${tmpdir}/tmp1.bib 2> /dev/null |
---|
306 | echo "author title = ${list_author_title[iauthor]}" |
---|
307 | echo "author grep = ${list_author_bibtool[iauthor]}" |
---|
308 | biblioref_author=${tmpdir}/${list_author_file[iauthor]}.bib |
---|
309 | bibtool_command="bibtool -- 'select={author \"${list_author_bibtool[iauthor]}\"}' ${biblioref} -o ${tmpdir}/tmp1.bib" |
---|
310 | eval ${bibtool_command} |
---|
311 | # test if no file found ++ |
---|
312 | cat ${tmpdir}/header_jabref ${tmpdir}/tmp1.bib > ${biblioref_author} |
---|
313 | format=locean_tablerefsabsbibsort |
---|
314 | # generation one HTML file style ${format} |
---|
315 | rm ${biblioref}.${format}.jabref.html 2> /dev/null |
---|
316 | java -jar ${JABREF_DIR}/JabRef-${JABREF_VERSION}.jar -n true \ |
---|
317 | -p ${PROJECT}/../branches/bibliolocean/src/jabref.preferences.xml \ |
---|
318 | --output ${dirwww}/${output_title}_${list_author_file[iauthor]}.${format}.jabref.html,${format} \ |
---|
319 | ${biblioref_author} |
---|
320 | jabref_status=${?} |
---|
321 | if [ ${jabref_status} -ne 0 ] |
---|
322 | then |
---|
323 | echo "${command} : eee : pb with jabref export ${format}" |
---|
324 | exit 1 |
---|
325 | fi |
---|
326 | #++ else |
---|
327 | #++ echo "${command} : iii : no reference for author ${team}" |
---|
328 | #++ fi |
---|
329 | iauthor=$(( ${iauthor} + 1 )) |
---|
330 | done |
---|
331 | echo "fin auteurs" |
---|
332 | |
---|
333 | # phybiocar = team with theme |
---|
334 | fteam=${tmpdir}/phybiocar.bib |
---|
335 | rm ${fteam} 2> /dev/null |
---|
336 | bibtool_command="bibtool -- 'select={aeresteam \"phybiocar\"}' ${biblioreffull} -o ${fteam}" |
---|
337 | eval ${bibtool_command} |
---|
338 | unset bibtool_command |
---|
339 | nbatteam=$(grep -c @ ${fteam}) |
---|
340 | if [ ${nbatteam} -ge 2 ] |
---|
341 | then |
---|
342 | echo "iii : $((${nbatteam} - 1)) ref for aeresteam phybiocar}" |
---|
343 | # generation one HTML file style ${format} |
---|
344 | format=locean_tablerefsabsbibsort |
---|
345 | rm ${biblioref}.${format}.jabref.html 2> /dev/null |
---|
346 | java -jar ${JABREF_DIR}/JabRef-${JABREF_VERSION}.jar -n true \ |
---|
347 | -p ${PROJECT}/../branches/bibliolocean/src/jabref.preferences.xml \ |
---|
348 | --output ${dirwww}/${output_title}_phybiocar.${format}.jabref.html,${format} \ |
---|
349 | ${fteam} |
---|
350 | jabref_status=${?} |
---|
351 | if [ ${jabref_status} -ne 0 ] |
---|
352 | then |
---|
353 | echo "${command} : eee : pb with jabref export ${format}" |
---|
354 | exit 1 |
---|
355 | fi |
---|
356 | # loop on themes |
---|
357 | list_theme="1 2 3" |
---|
358 | list_fteamtheme="" |
---|
359 | for theme in ${list_theme} |
---|
360 | do |
---|
361 | echo "${LINENO} : iii: theme = ${theme}" |
---|
362 | fteamtheme=${tmpdir}/$(basename ${fteam} .bib)_${theme}.bib |
---|
363 | rm ${fteamtheme} 2> /dev/null |
---|
364 | bibtool_command="bibtool -- 'select={phybiocartheme \"${theme}\"}' ${fteam} -o ${fteamtheme}" |
---|
365 | eval ${bibtool_command} |
---|
366 | unset bibtool_command |
---|
367 | # test if empty |
---|
368 | nbatteamtheme=$(grep -c @ ${fteamtheme}) |
---|
369 | if [ ${nbatteamtheme} -ge 2 ] |
---|
370 | then |
---|
371 | echo "iii : $((${nbatteamtheme} - 1)) ref for aeresteam phybiocar and theme ${theme}" |
---|
372 | list_fteamtheme="${list_fteamtheme} ${fteamtheme}" |
---|
373 | else |
---|
374 | echo "www : no ref for aeresteam phybiocar and theme ${theme}" |
---|
375 | fi |
---|
376 | unset nbatteamtheme |
---|
377 | # loop on years |
---|
378 | list_fteamthemeyear="" |
---|
379 | list_year=$(seq 2007 2012) |
---|
380 | for iyear in ${list_year} |
---|
381 | do |
---|
382 | echo "${LINENO} : iii: year = ${iyear}" |
---|
383 | fteamthemeyear=${tmpdir}/$(basename ${fteam} .bib)_${theme}_${iyear}.bib |
---|
384 | rm ${fteamthemeyear} 2> /dev/null |
---|
385 | bibtool_command="bibtool -- 'select={year \"${iyear}\"}' ${fteamtheme} -o ${fteamthemeyear}" |
---|
386 | eval ${bibtool_command} |
---|
387 | unset bibtool_command |
---|
388 | # test if empty |
---|
389 | nbatteamthemeyear=$(grep -c @ ${fteamthemeyear}) |
---|
390 | if [ ${nbatteamthemeyear} -ge 2 ] |
---|
391 | then |
---|
392 | echo "iii : $((${nbatteamthemeyear} - 1)) ref for aeresteam phybiocar and theme ${theme} and year ${iyear}" |
---|
393 | list_fteamthemeyear="${list_fteamthemeyear} ${fteamthemeyear}" |
---|
394 | else |
---|
395 | echo "www : no ref for aeresteam phybiocar and theme ${theme} and year ${iyear}" |
---|
396 | fi |
---|
397 | read a |
---|
398 | unset nbatteamthemeyear |
---|
399 | done # end of year loop |
---|
400 | done # end of them loop |
---|
401 | unset iyear |
---|
402 | else |
---|
403 | echo "www : no ref for aeresteam phybiocar]}" |
---|
404 | fi |
---|
405 | unset list_year |
---|
406 | unset fteam |
---|
407 | # |
---|
408 | # define jabref header |
---|
409 | # ++ usefull |
---|
410 | jabref_header ${tmpdir}/header_jabref |
---|
411 | # |
---|
412 | # loop on aerestype |
---|
413 | list_aerestype="ACL ACLN ASCL BRE C-INV C-ACTI C-ATCN C-COM C-AFF DO OR OS PV PAT PT AP" |
---|
414 | for aerestype in ${list_aerestype} |
---|
415 | do |
---|
416 | echo "${LINENO} : iii: aerestype = ${aerestype}" |
---|
417 | for fteamthemeyear in ${list_fteamthemeyear} |
---|
418 | do |
---|
419 | echo "${LINENO} : iii: fteamthemeyear = ${fteamthemeyear}" |
---|
420 | #++ add header |
---|
421 | fteamthemeyeartype=${tmpdir}/$(basename ${fteamthemeyear} .bib)_${aerestype}.bib |
---|
422 | rm ${fteamthemeyeartype} 2> /dev/null |
---|
423 | bibtool_command="bibtool -- 'select={aerestype \"${aerestype}\"}' ${fteamthemeyear} -o ${fteamthemeyeartype}" |
---|
424 | eval ${bibtool_command} |
---|
425 | unset bibtool_command |
---|
426 | # test if empty |
---|
427 | nbatteamthemeyeartype=$(grep -c @ ${fteamthemeyeartype}) |
---|
428 | if [ ${nbatteamthemeyeartype} -ge 2 ] |
---|
429 | then |
---|
430 | echo "iii : $((${nbatteamthemeyeartype} - 1)) ref type ${aerestype} in ${fteamthemeyear}" |
---|
431 | ofteamthemeyeartype=${dirwww}/$(basename ${fteamthemeyeartype} .bib).rtf |
---|
432 | rm ${ofteamthemeyeartype} 2> /dev/null |
---|
433 | jabref_rtf \ |
---|
434 | ${PROJECT}/../branches/bibliolocean/src/jabref.preferences.xml \ |
---|
435 | ${fteamthemeyeartype} ${ofteamthemeyeartype} |
---|
436 | # ++ test si ok |
---|
437 | else |
---|
438 | echo "www : no ref type ${aerestype} in ${fteamthemeyear}" |
---|
439 | fi |
---|
440 | unset nbatteamthemeyeartype |
---|
441 | done # end of loop on fteamthemeyear |
---|
442 | done # end of loop on aerestype |
---|
443 | # |
---|
444 | #++rm ${biblioref} 2> /dev/null |
---|
445 | #++rm ${tmpdir}/header_jabref 2> /dev/null |
---|
446 | |
---|
447 | exit 0 |
---|