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

Last change on this file since 250 was 250, checked in by pinsard, 12 years ago

produce a RTF file for each team during aeres period

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