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

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

consolidate tools

  • Property svn:executable set to *
  • Property svn:keywords set to Id URL
File size: 9.8 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# critere aeresteam vs loceanteam
29#
30# ++ phybiocar theme
31#
32# on ne voit pas les notes des unpublished dans le pdf plain
33#
34# EVOLUTIONS
35# ==========
36#
37# $Id$
38#
39# $URL$
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#++rm ${biblioref} 2> /dev/null
334#++rm ${tmpdir}/header_jabref 2> /dev/null
335
336exit 0
Note: See TracBrowser for help on using the repository browser.