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

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

handle phybiocar theme

  • Property svn:executable set to *
  • Property svn:keywords set to Id URL
File size: 14.2 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 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#-
59set -u
60command=$(basename ${0})
61#
62system=$(uname)
63case "${system}" in
64   AIX|IRIX64)
65      echo "${command} : www : no specific posix checking"
66   ;;
67   *)
68      set -o posix
69   ;;
70esac
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#
78log_date=$(date -u +"%Y%m%dT%H%M%SZ")
79log=${PROJECT_LOG}/$(basename ${command} .sh).log.${log_date}
80#
81usage=" Usage : ${command}"
82#
83# test if bibtool available
84tool=bibtool
85type ${tool} 1> /dev/null 2>&1
86status=${?}
87if [ ${status} -ne 0 ]
88then
89   echo "${command} : eee : ${tool} unavailable" >&2
90   exit 1
91fi
92unset tool
93unset status
94#
95# test if bib2bib available
96tool=bib2bib
97type ${tool} 1> /dev/null 2>&1
98status=${?}
99if [ ${status} -ne 0 ]
100then
101   echo "${command} : eee : ${tool} unavailable" >&2
102   exit 1
103fi
104unset tool
105unset status
106#
107# default
108# n.a.
109#
110tmpdir=${PROJECT_LOG}/gtbiblio/aeres2007_2012/
111dirwww=${PROJECT_OD}/public_html/gtbiblio/aeres2007_2012/
112rm -rf ${tmpdir} 2> /dev/null
113mkdir -p ${tmpdir}
114rm -rf ${dirwww} 2> /dev/null
115mkdir -p ${dirwww}
116#
117# copy javascript and css for sort table in  output directory
118cp sorttable.js ${dirwww}/
119cp sorttable.css ${dirwww}/
120#
121# define bibliography reference file
122biblioref_orig=${PROJECT_ID}/biblioref.bib
123biblioreffull=${tmpdir}/all.bib
124cp ${biblioref_orig} ${biblioreffull}
125biblioref=${tmpdir}/aeres2007_2012.bib
126bibliocite=${tmpdir}/aeres2007_2012_cite.bib
127#
128bib2bib -oc ${bibliocite} -ob ${biblioref} \
129        -c 'year>=2007 and year<=2012' \
130        ${biblioreffull}
131#
132# ++ usefull artificial header of jabref file to enforce encoding
133jabref_header ${tmpdir}/header_jabref
134#
135# génération du PDF classique
136list_style="plain" #+++
137for style in ${list_style}
138do
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}
154EOF
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
168done
169
170echo "fin 1re passe latex"
171
172# generation one RTF file style harvard
173output_title=aeres2007_2012
174rm ${biblioref}.harvard.jabref.rtf 2> /dev/null
175java -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}
179echo "fin rtf all"
180#
181# generation of HTML
182list_format="html simplehtml tablerefs locean_tablerefs locean_tablerefsabsbibsort locean_listrefs"
183for format in ${list_format}
184do
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
198done
199#
200# loop on teams and years to build bibliography reference file
201list_fteamyear=""
202iteam=1
203nbteam=${#list_team_bibtool[@]}
204while [ ${iteam} -le ${nbteam} ]
205do
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 ))
257done # end of team loop
258unset iteam
259unset nbteam
260unset list_year
261unset fteam
262#
263# define jabref header
264# ++ usefull
265jabref_header ${tmpdir}/header_jabref
266#
267# loop on aerestype
268list_aerestype="ACL ACLN ASCL BRE C-INV C-ACTI C-ATCN C-COM C-AFF DO OR OS PV PAT PT AP"
269for aerestype in ${list_aerestype}
270do
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
297done # end of loop on aerestype
298#
299# loop on authors to build bibliography reference file
300iauthor=1
301nbauthor=${#list_author_bibtool[@]}
302#++nbauthor=0 #+++
303while [ ${iauthor} -le ${nbauthor} ]
304do
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 ))
330done
331echo "fin auteurs"
332
333# phybiocar = team with theme
334fteam=${tmpdir}/phybiocar.bib
335rm ${fteam} 2> /dev/null
336bibtool_command="bibtool -- 'select={aeresteam \"phybiocar\"}' ${biblioreffull} -o ${fteam}"
337eval ${bibtool_command}
338unset bibtool_command
339nbatteam=$(grep -c @ ${fteam})
340if [ ${nbatteam} -ge 2 ]
341then
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
402else
403   echo "www : no ref for aeresteam phybiocar]}"
404fi
405unset list_year
406unset fteam
407#
408# define jabref header
409# ++ usefull
410jabref_header ${tmpdir}/header_jabref
411#
412# loop on aerestype
413list_aerestype="ACL ACLN ASCL BRE C-INV C-ACTI C-ATCN C-COM C-AFF DO OR OS PV PAT PT AP"
414for aerestype in ${list_aerestype}
415do
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
442done # end of loop on aerestype
443#
444#++rm ${biblioref} 2> /dev/null
445#++rm ${tmpdir}/header_jabref 2> /dev/null
446
447exit 0
Note: See TracBrowser for help on using the repository browser.