source: branches/bibliolocean/src/genaeres_rtf.sh @ 214

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

prepare usage by other than fp

  • Property svn:executable set to *
  • Property svn:keywords set to Id URL
File size: 8.2 KB
Line 
1#! /bin/sh
2#+
3#
4# ===============
5# genaeres_rtf.sh
6# ===============
7#
8# SYNOPSIS
9# ========
10#
11# ::
12#
13#   genaeres_rtf.sh
14#
15# DESCRIPTION
16# ===========
17#
18# aeres 2007-2012 pour inclusion dans document word
19#
20# EXAMPLES
21# ========
22#
23# ::
24#
25#   genaeres_rtf.sh
26#
27# SEE ALSO
28# ========
29#
30# genbib.sh
31#
32# genaeres.sh
33#
34# TODO
35# ====
36#
37# log
38#
39# EVOLUTIONS
40# ==========
41#
42# - fplod 20120628T101424Z cratos (Linux)
43#
44#   * creation
45#
46#-
47set -u
48command=$(basename ${0})
49#
50system=$(uname)
51case "${system}" in
52   AIX|IRIX64)
53      echo "${command} : www : no specific posix checking"
54   ;;
55   *)
56      set -o posix
57   ;;
58esac
59#
60usage=" Usage : ${command}"
61#
62# test if bibtool available
63tool=bibtool
64type ${tool} 1> /dev/null 2>&1
65status=${?}
66if [ ${status} -ne 0 ]
67then
68   echo "${command} : eee : ${tool} unavailable" >&2
69   exit 1
70fi
71unset tool
72unset status
73#
74# default
75# n.a.
76#
77hostname=$(hostname)
78tmpdir=${PROJECT_LOG}/aeres2007_2012rtf/
79dirwww=${PROJECT_OD}/aeres2007_2012rtf/
80rm -rf ${tmpdir} 2> /dev/null
81mkdir -p ${tmpdir}
82rm -rf ${dirwww} 2> /dev/null
83mkdir -p ${dirwww}
84#
85. define_teams_aeres2007_2012.sh
86. define_phybiocar_theme.sh
87. jabref_rtf.sh
88#
89# define bibliography reference file
90biblioref_orig=${PROJECT_ID}/biblioref.bib
91biblioreffull=${tmpdir}/all.bib
92cp ${biblioref_orig} ${biblioreffull}
93#
94list_year="2007 2008 2009 2010 2011 2012"
95#
96# pour V.8.b 3- Articles de vulgarisation  (presse en général
97# loop on teams to build bibliography reference file
98aerestype="PV"
99iteam=1
100nbteam=${#list_team_bibtool[@]}
101while [ ${iteam} -le ${nbteam} ]
102do
103    echo "team grep = ${list_team_bibtool[${iteam}]}"
104    biblioref_team=${tmpdir}/${list_team_title[${iteam}]}.bib
105    bibtool_command="bibtool -- 'select={aeresteam \"${list_team_bibtool[${iteam}]}\"}' ${biblioreffull} -o ${PROJECT_LOG}/team.bib"
106    eval ${bibtool_command}
107    nbatteam=$(grep -c @ ${PROJECT_LOG}/team.bib)
108    if [ ${nbatteam} -ge 2 ]
109    then
110        echo "iii : $((${nbatteam} - 1)) ref for aeresteam ${list_team_title[${iteam}]}"
111        for iyear in ${list_year}
112        do
113           # select year
114           rm  ${PROJECT_LOG}/teamyear.bib 2> /dev/null
115           bibtool_command="bibtool -- 'select={year \"${iyear}\"}' ${PROJECT_LOG}/team.bib -o ${PROJECT_LOG}/teamyear.bib"
116           eval ${bibtool_command}
117           # test if empty
118           nbatteamyear=$(grep -c @ ${PROJECT_LOG}/teamyear.bib)
119           if [ ${nbatteamyear} -ge 2 ]
120           then
121               echo "iii : $((${nbatteamyear} - 1)) ref for aeresteam ${list_team_title[${iteam}]} and year ${iyear}"
122               # select aerestype
123               rm ${PROJECT_LOG}/teamyearPV.bib 2> /dev/null
124               bibtool_command="bibtool -- 'select={aerestype \"${aerestype}\"}' ${PROJECT_LOG}/teamyear.bib -o ${PROJECT_LOG}/teamyeartype.bib"
125               eval ${bibtool_command}
126               # test if empty
127               nbatteamyeartype=$(grep -c @ ${PROJECT_LOG}/teamyeartype.bib)
128               if [ ${nbatteamyeartype} -ge 2 ]
129               then
130                   echo "iii : $((${nbatteamyeartype} - 1)) ref for aeresteam ${list_team_title[${iteam}]} and year ${iyear} and aerestype ${aerestype}"
131                   output_title=${list_team_title[${iteam}]}_${iyear}_${aerestype}
132                   rm ${dirwww}/${output_title}.rtf 2> /dev/null
133                   jabref_rtf ./jabref.preferences.xml ${PROJECT_LOG}/teamyeartype.bib ${dirwww}/${output_title}.rtf
134                   # ++ test si ok
135                   read a
136               else
137                   echo "www : no ref for aeresteam ${list_team_title[${iteam}]} and year ${iyear} and aerestype ${aerestype}"
138               fi
139               unset nbatteamyeartype
140           else
141               echo "www : no ref for aeresteam ${list_team_title[${iteam}]} and year ${iyear}"
142           fi
143           unset nbatteamyear
144       done # end of year loop
145    else
146       echo "www : no ref for aeresteam ${list_team_title[${iteam}]}"
147    fi
148    iteam=$(( ${iteam} + 1 ))
149done # end of team loop
150#
151# write a bibtex file for each year of the list
152for iyear in ${list_year}
153do
154   # select year
155   bibtool_command="bibtool -- 'select={year \"${iyear}\"}' ${biblioreffull} -o ${PROJECT_LOG}/1.bib"
156   eval ${bibtool_command}
157   wc -l ${PROJECT_LOG}/1.bib
158   # remove unpublished reference (some of then will be joined later
159   bibtool -- 'select.non={@unpublished}' ${PROJECT_LOG}/1.bib -o ${PROJECT_LOG}/_${iyear}.bib
160   wc -l ${PROJECT_LOG}/_${iyear}.bib
161   rm ${PROJECT_LOG}/1.bib
162done
163#
164# artificial header of jabref file to enforce encoding
165{
166echo "% This file was articifialy created for JabRef ${JABREF_VERSION}."
167echo "% Encoding: ISO8859_1"
168echo " "
169} > ${tmpdir}/header_jabref
170#
171cp ${tmpdir}/header_jabref ${biblioref}
172for iyear in ${list_year}
173do
174   cat ${biblioref} ${PROJECT_LOG}/_${iyear}.bib  > ${PROJECT_LOG}/1.bib
175   cp ${PROJECT_LOG}/1.bib ${biblioref}
176   wc -l ${biblioref}
177   rm ${PROJECT_LOG}/1.bib
178done
179cat ${biblioref} ${PROJECT_LOG}/_unpublished.bib > ${PROJECT_LOG}/1.bib
180cp ${PROJECT_LOG}/1.bib ${biblioref}
181wc -l ${biblioref}
182rm ${PROJECT_LOG}/1.bib
183
184#
185#
186list_format="html simplehtml tablerefs locean_tablerefs locean_tablerefsabsbibsort locean_listrefs"
187#+++list_format="" #+++
188for format in ${list_format}
189do
190   echo "format export jabref ${format}"
191   # generation one HTML file style ${format}
192   rm ${biblioref}.${format}.jabref.html 2> /dev/null
193   java -jar ${JABREF_DIR}/JabRef-${JABREF_VERSION}.jar -n true \
194   -p ${PROJECT}/../branches/bibliolocean/src/jabref.preferences.xml \
195   --output ${dirwww}/${output_title}.${format}.jabref.html,${format} \
196   ${biblioref}
197   jabref_status=${?}
198   if [ ${jabref_status} -ne 0 ]
199   then
200      echo "${command} : eee : pb with jabref export ${format}"
201      exit 1
202   fi
203done
204
205# loop on teams to build bibliography reference file
206iteam=1
207nbteam=${#list_team_bibtool[@]}
208#+++nbteam=0
209while [ ${iteam} -le ${nbteam} ]
210do
211   echo "team title = ${list_team_title[${iteam}]}"
212   echo "team grep = ${list_team_bibtool[${iteam}]}"
213   biblioref_team=${tmpdir}/${list_team_title[${iteam}]}.bib
214   bibtool_command="bibtool -- 'select={aeresteam \"${list_team_bibtool[${iteam}]}\"}' ${biblioref} -o ${PROJECT_LOG}/1.bib"
215   eval ${bibtool_command}
216   # test if no file found ++
217   cat ${tmpdir}/header_jabref ${PROJECT_LOG}/1.bib > ${biblioref_team}
218   format=locean_tablerefsabsbibsort
219   # generation one HTML file style ${format}
220   rm ${biblioref}.${format}.jabref.html 2> /dev/null
221   java -jar ${JABREF_DIR}/JabRef-${JABREF_VERSION}.jar -n true \
222      -p ./jabref.preferences.xml \
223      --output ${dirwww}/${output_title}_${list_team_title[${iteam}]}.${format}.jabref.html,${format} \
224      ${biblioref_team}
225   jabref_status=${?}
226   if [ ${jabref_status} -ne 0 ]
227   then
228      echo "${command} : eee : pb with jabref export ${format}"
229      exit 1
230   fi
231#++ else
232#++ echo "${command} : iii : no reference for team ${team}"
233#++ fi
234   iteam=$(( ${iteam} + 1 ))
235done
236
237. define_authors.sh
238#
239# loop on authors to build bibliography reference file
240iauthor=1
241nbauthor=${#list_author_bibtool[@]}
242#++nbauthor=0 #+++
243while [ ${iauthor} -le ${nbauthor} ]
244do
245   rm ${PROJECT_LOG}/1.bib 2> /dev/null
246   echo "author title = ${list_author_title[iauthor]}"
247   echo "author grep = ${list_author_bibtool[iauthor]}"
248   biblioref_author=${tmpdir}/${list_author_file[iauthor]}.bib
249   bibtool_command="bibtool -- 'select={author \"${list_author_bibtool[iauthor]}\"}' ${biblioref} -o ${PROJECT_LOG}/1.bib"
250   eval ${bibtool_command}
251   # test if no file found ++
252   cat ${tmpdir}/header_jabref ${PROJECT_LOG}/1.bib > ${biblioref_author}
253   format=locean_tablerefsabsbibsort
254   # generation one HTML file style ${format}
255   rm ${biblioref}.${format}.jabref.html 2> /dev/null
256   java -jar ${JABREF_DIR}/JabRef-${JABREF_VERSION}.jar -n true \
257      -p ${PROJECT}/../branches/bibliolocean/src/jabref.preferences.xml \
258      --output ${dirwww}/${output_title}_${list_author_file[iauthor]}.${format}.jabref.html,${format} \
259      ${biblioref_author}
260   jabref_status=${?}
261   if [ ${jabref_status} -ne 0 ]
262   then
263      echo "${command} : eee : pb with jabref export ${format}"
264      exit 1
265   fi
266#++ else
267#++ echo "${command} : iii : no reference for author ${team}"
268#++ fi
269   iauthor=$(( ${iauthor} + 1 ))
270done
271echo "fin auteurs"
272
273#++rm ${biblioref} 2> /dev/null
274#++rm ${tmpdir}/header_jabref 2> /dev/null
275
276exit 0
Note: See TracBrowser for help on using the repository browser.