source: branches/bibliolocean/src/genaeres.sh @ 354

Last change on this file since 354 was 354, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo

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