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 | #- |
---|
47 | set -u |
---|
48 | command=$(basename ${0}) |
---|
49 | # |
---|
50 | system=$(uname) |
---|
51 | case "${system}" in |
---|
52 | AIX|IRIX64) |
---|
53 | echo "${command} : www : no specific posix checking" |
---|
54 | ;; |
---|
55 | *) |
---|
56 | set -o posix |
---|
57 | ;; |
---|
58 | esac |
---|
59 | # |
---|
60 | usage=" Usage : ${command}" |
---|
61 | # |
---|
62 | # test if bibtool available |
---|
63 | tool=bibtool |
---|
64 | type ${tool} 1> /dev/null 2>&1 |
---|
65 | status=${?} |
---|
66 | if [ ${status} -ne 0 ] |
---|
67 | then |
---|
68 | echo "${command} : eee : ${tool} unavailable" >&2 |
---|
69 | exit 1 |
---|
70 | fi |
---|
71 | unset tool |
---|
72 | unset status |
---|
73 | # |
---|
74 | # default |
---|
75 | # n.a. |
---|
76 | # |
---|
77 | hostname=$(hostname) |
---|
78 | tmpdir=${PROJECT_LOG}/aeres2007_2012rtf/ |
---|
79 | dirwww=${PROJECT_OD}/aeres2007_2012rtf/ |
---|
80 | rm -rf ${tmpdir} 2> /dev/null |
---|
81 | mkdir -p ${tmpdir} |
---|
82 | rm -rf ${dirwww} 2> /dev/null |
---|
83 | mkdir -p ${dirwww} |
---|
84 | # |
---|
85 | . define_teams_aeres2007_2012.sh |
---|
86 | . define_phybiocar_theme.sh |
---|
87 | . jabref_rtf.sh |
---|
88 | # |
---|
89 | # define bibliography reference file |
---|
90 | biblioref_orig=${PROJECT_ID}/biblioref.bib |
---|
91 | biblioreffull=${tmpdir}/all.bib |
---|
92 | cp ${biblioref_orig} ${biblioreffull} |
---|
93 | # |
---|
94 | list_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 |
---|
98 | aerestype="PV" |
---|
99 | iteam=1 |
---|
100 | nbteam=${#list_team_bibtool[@]} |
---|
101 | while [ ${iteam} -le ${nbteam} ] |
---|
102 | do |
---|
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 )) |
---|
149 | done # end of team loop |
---|
150 | # |
---|
151 | # write a bibtex file for each year of the list |
---|
152 | for iyear in ${list_year} |
---|
153 | do |
---|
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 |
---|
162 | done |
---|
163 | # |
---|
164 | # artificial header of jabref file to enforce encoding |
---|
165 | { |
---|
166 | echo "% This file was articifialy created for JabRef ${JABREF_VERSION}." |
---|
167 | echo "% Encoding: ISO8859_1" |
---|
168 | echo " " |
---|
169 | } > ${tmpdir}/header_jabref |
---|
170 | # |
---|
171 | cp ${tmpdir}/header_jabref ${biblioref} |
---|
172 | for iyear in ${list_year} |
---|
173 | do |
---|
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 |
---|
178 | done |
---|
179 | cat ${biblioref} ${PROJECT_LOG}/_unpublished.bib > ${PROJECT_LOG}/1.bib |
---|
180 | cp ${PROJECT_LOG}/1.bib ${biblioref} |
---|
181 | wc -l ${biblioref} |
---|
182 | rm ${PROJECT_LOG}/1.bib |
---|
183 | |
---|
184 | # |
---|
185 | # |
---|
186 | list_format="html simplehtml tablerefs locean_tablerefs locean_tablerefsabsbibsort locean_listrefs" |
---|
187 | #+++list_format="" #+++ |
---|
188 | for format in ${list_format} |
---|
189 | do |
---|
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 |
---|
203 | done |
---|
204 | |
---|
205 | # loop on teams to build bibliography reference file |
---|
206 | iteam=1 |
---|
207 | nbteam=${#list_team_bibtool[@]} |
---|
208 | #+++nbteam=0 |
---|
209 | while [ ${iteam} -le ${nbteam} ] |
---|
210 | do |
---|
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 )) |
---|
235 | done |
---|
236 | |
---|
237 | . define_authors.sh |
---|
238 | # |
---|
239 | # loop on authors to build bibliography reference file |
---|
240 | iauthor=1 |
---|
241 | nbauthor=${#list_author_bibtool[@]} |
---|
242 | #++nbauthor=0 #+++ |
---|
243 | while [ ${iauthor} -le ${nbauthor} ] |
---|
244 | do |
---|
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 )) |
---|
270 | done |
---|
271 | echo "fin auteurs" |
---|
272 | |
---|
273 | #++rm ${biblioref} 2> /dev/null |
---|
274 | #++rm ${tmpdir}/header_jabref 2> /dev/null |
---|
275 | |
---|
276 | exit 0 |
---|