/usr/bin/refdbnd is in refdb-clients 1.0.2-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | #!/bin/sh
# refdbnd: creates a new document and sets up a Makefile for use
# with RefDB bibliographies
# Invocation: refdbnd basename doctype|filename pubtype database style encoding fo-driver html-driver xhtml-driver
# or: refdbnd (interactive mode)
# markus@mhoenicka.de 2002-11-26
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>
# user variable defaults
defbasename="refdbtest"
defdoctype="db43x"
defpubtype="book"
defdatabase="refdbtest"
defstyle="J.Biol.Chem."
defencoding="utf-8"
defcssfile=""
xfile=""
encoding=""
cssfile=""
silent="f"
myfo=""
myhtml=""
myxhtml=""
fodriveropt=""
htmldriveropt=""
xhtmldriveropt=""
check_existing_doc() {
if [ -e $basename ]; then
# guess values from existing file
xfile=$basename
if grep "^<!DOCTYPE.*DTD DocBook V3.1//EN" $basename; then
doctype="db31"
pubtype=`grep "DTD DocBook V3.1//EN" $basename | sed 's/^<!DOCTYPE \(.*\) PUBLIC.*/\1/'`
else
if grep "^<!DOCTYPE.*DTD DocBook V4.0//EN" $basename; then
doctype="db40"
pubtype=`grep "DTD DocBook V4.0//EN" $basename | sed 's/^<!DOCTYPE \(.*\) PUBLIC.*/\1/'`
else
if grep "^<!DOCTYPE.*DTD DocBook V4.1//EN" $basename; then
doctype="db41"
pubtype=`grep "DTD DocBook V4.1//EN" $basename | sed 's/^<!DOCTYPE \(.*\) PUBLIC.*/\1/'`
else
if grep "^<!DOCTYPE.*DTD DocBook XML V4.1.2//EN" $basename; then
doctype="db41x"
pubtype=`grep "DTD DocBook XML V4.1.2//EN" $basename | sed 's/^<!DOCTYPE \(.*\) PUBLIC.*/\1/'`
encoding=`grep "^<?xml version=\"1.0\"" $basename | sed 's/^.*encoding=\"\(.*\)\".*/\1/'`
else
if grep "^<!DOCTYPE.*DTD DocBook XML V4.2//EN" $basename; then
doctype="db42x"
pubtype=`grep "DTD DocBook XML V4.2//EN" $basename | sed 's/^<!DOCTYPE \(.*\) PUBLIC.*/\1/'`
encoding=`grep "^<?xml version=\"1.0\"" $basename | sed 's/^.*encoding=\"\(.*\)\".*/\1/'`
else
if grep "^<!DOCTYPE.*DTD DocBook XML V4.2//EN" $basename; then
doctype="db43x"
pubtype=`grep "DTD DocBook XML V4.3//EN" $basename | sed 's/^<!DOCTYPE \(.*\) PUBLIC.*/\1/'`
encoding=`grep "^<?xml version=\"1.0\"" $basename | sed 's/^.*encoding=\"\(.*\)\".*/\1/'`
else
if grep "^<!DOCTYPE.*TEI P4//DTD Main DTD Driver File//EN" $basename; then
doctype="teix"
pubtype=`grep "TEI P4//DTD Main DTD Driver File//EN" $basename | sed 's/^<!DOCTYPE \(.*\) PUBLIC.*/\1/'`
encoding=`grep "^<?xml version=\"1.0\"" $basename | sed 's/^.*encoding=\"\(.*\)\".*/\1/'`
else
if grep "xmlns.*\"http://www.tei-c.org/ns/1.0\"" $basename; then
doctype="tei5x"
pubtype="TEI"
encoding=`grep "^<?xml version=\"1.0\"" $basename | sed 's/^.*encoding=\"\(.*\)\".*/\1/'`
else
if grep "^\{\\rtf1" $basename; then
doctype="rtf"
pubtype="rtf"
encoding=`grep "^\{\\rtf1" $basename | sed 's/^\{\\rtf1\\\([^\\]+\)\\/\1/'`
fi
fi
fi
fi
fi
fi
fi
fi
fi
basename=${xfile%%.*}
fi
}
# if we have at least six command line arguments (cssfile and driver
# files are optional), we'll use them. Otherwise ask interactively
if [ -z "$*" ] || [ "$#" -lt 6 ]; then
# get arguments interactively
clear
echo "I'll be happy to assist you in setting up a new document along with"
echo "a Makefile. First we'll collect a few answers, and only if you"
echo "accept your settings any files will be created. Press Ctrl-C anytime"
echo "to exit."
echo ""
echo "Each question will present a default value which you can accept by"
echo "pressing ENTER"
echo ""
echo "Please enter the basename of your document. This is the name without"
echo "any suffix. For example, if your printed output file is supposed to"
echo "be called refdbtest.pdf, the basename will be 'refdbtest'"
echo "Alternatively, enter the full name of an existing document in this"
echo "directory. I'll try and guess the proper values for this document."
echo "[$defbasename]"
read basename
if [ -z "$basename" ]; then
basename=$defbasename
fi
check_existing_doc
if [ -z $doctype ]; then
echo ""
echo "Please enter the type of the document. Available types are 'db31',"
echo "'db40', and 'db41' for DocBook SGML versions 3.1, 4.0, and 4.1,"
echo "respectively, 'db41x', 'db42x', 'db43x', and 'db50x' for DocBook XML"
echo "versions 4.1.2, 4.2, 4.3, and 5.0, respectively, "
echo "'teix' and 'tei5x' for TEI XML P4 and TEI XML P5, respectively,"
echo "and 'rtf' for Rich Text Format (RTF)."
echo "[$defdoctype]"
read doctype
if [ ! "$doctype" = "rtf" ]; then
echo ""
echo "Please enter the element root which determines the type of the"
echo "publication. Common are 'set', 'book', and 'article' for DocBook"
echo "documents and 'TEI.2' for TEI documents"
# use TEI.2 as default for TEI documents. $defpubtype defaults to 'book'
if [ "$doctype" = "teix" ]; then
defpubtype="TEI.2"
else
if [ "$doctype" = "tei5x" ]; then
defpubtype="TEI"
fi
fi
echo "[$defpubtype]"
read pubtype
else
pubtype="rtf"
fi
fi
echo ""
echo "Please enter the name of the RefDB database where you take your"
echo "references from"
echo "[$defdatabase]"
read database
echo ""
echo "Please enter the bibliography style that your document should use"
echo "Enter 'raw' to use the default formatting of the stock stylesheets"
echo "[$defstyle]"
read style
echo ""
if [ -z $encoding ]; then
echo "Please enter the character encoding that your document should use"
echo "[$defencoding]"
read encoding
echo ""
fi
if [ -z "$style" ]; then
style=$defstyle
fi
# mangle stylename to generate the name of the CSS file
defcssfile=${style%.*}.css
if [ "$doctype" != "rtf" ]; then
echo "Please enter the path or the URL of a custom CSS file for the"
echo "(x)html output. Hit ENTER if you do not use a custom CSS file"
echo "[$defcssfile]"
read cssfile
echo ""
echo "Please enter the path of a custom XSL driver file for the"
echo "printable (fo) output. Hit ENTER to use the default driver file"
read myfo
echo ""
echo "Please enter the path of a custom XSL driver file for the"
echo "html output. Hit ENTER to use the default driver file"
read myhtml
echo ""
echo "Please enter the path of a custom XSL driver file for the"
echo "xhtml output. Hit ENTER to use the default driver file"
read myxhtml
echo ""
fi
# apply defaults to empty strings
if [ -z "$basename" ]; then
basename=$defbasename
fi
if [ -z "$doctype" ]; then
doctype=$defdoctype
fi
if [ -z "$pubtype" ]; then
pubtype=$defpubtype
fi
if [ -z "$database" ]; then
database=$defdatabase
fi
if [ -z "$encoding" ]; then
encoding=$defencoding
fi
if [ -z "$cssfile" ]; then
cssfile=$defcssfile
fi
if [ -n "$myfo" ]; then
fodriveropt=" -a $myfo "
fi
if [ -n "$myhtml" ]; then
htmldriveropt=" -b $myhtml "
fi
if [ -n "$myxhtml" ]; then
xhtmldriveropt=" -c $myxhtml "
fi
echo "You've selected the following values:"
echo "Basename: $basename"
echo "Document type: $doctype"
if [ "$doctype" != "rtf" ]; then
echo "Publication type: $pubtype"
fi
echo "Database: $database"
echo "Bibliography style: $style"
echo "Encoding: $encoding"
if [ "$doctype" != "rtf" ]; then
echo "CSS file: $cssfile"
if [ -n "$myfo" ]; then
echo "Fo driver file: $myfo"
fi
if [ -n "$myhtml" ]; then
echo "HTML driver file: $myhtml"
fi
if [ -n "$myxhtml" ]; then
echo "XHTML driver file: $myxhtml"
fi
fi
echo ""
echo "Is this ok?"
echo "[y]"
read ok
if [ -z "$ok" ]; then
ok="y"
fi
else
# all arguments were specified on the command line
basename=$1
doctype=$2
pubtype=$3
check_existing_doc
database=$4
style=$5
encoding=$6
cssfile=$7
myfo=$8
myhtml=$9
shift
myxhtml=$9
# mangle stylename to generate the name of the CSS file
defcssfile=${style%.*}.css
if [ -z "$cssfile" ]; then
cssfile=$defcssfile
fi
ok="y"
silent="t"
fi
if [ "$silent" = "f" ]; then
if [ "$ok" = "y" ] || [ "$ok" = "Y" ]; then
echo "Fine, so then ..."
echo ""
else
echo "Please try again"
exit 1
fi
fi
# customize a Makefile from the template
if [ "$doctype" = "rtf" ]; then
maketemplate="/usr/share/refdb/examples/Makefile.rtf.template"
else
maketemplate="/usr/share/refdb/examples/Makefile.template"
fi
case "$doctype" in
db31 | db40 | db41) doctypeswitch="db31"
extension="sgml"
htmlstylesheet=".dsl"
xhtmlstylesheet=".dsl"
printstylesheet=".dsl"
makeall="all: pdf ps rtf html"
dist="dist: pdfdist psdist rtfdist htmldist"
transformscript="refdbjade";;
db41x | db42x | db43x) doctypeswitch="db31x"
extension="xml"
htmlstylesheet=".html.xsl"
xhtmlstylesheet=".xhtml.xsl"
printstylesheet=".fo.xsl"
makeall="all: pdf rtf html"
dist="dist: pdfdist rtfdist htmldist"
transformscript="refdbxml";;
db50x ) doctypeswitch="db50x"
extension="xml"
htmlstylesheet=".html.xsl"
xhtmlstylesheet=".xhtml.xsl"
printstylesheet=".fo.xsl"
makeall="all: pdf rtf html"
dist="dist: pdfdist rtfdist htmldist"
transformscript="refdbxml";;
teix ) doctypeswitch="teix"
extension="xml"
htmlstylesheet=".html.xsl"
xhtmlstylesheet=".html.xsl"
printstylesheet=".fo.xsl"
makeall="all: pdf rtf html"
dist="dist: pdfdist rtfdist htmldist"
transformscript="refdbxml";;
tei5x ) doctypeswitch="tei5x"
extension="xml"
htmlstylesheet=".html.xsl"
xhtmlstylesheet=".html.xsl"
printstylesheet=".fo.xsl"
makeall="all: pdf rtf html"
dist="dist: pdfdist rtfdist htmldist"
transformscript="refdbxml";;
rtf ) doctypeswitch="rtf"
extension="rtf"
makeall="all: rtf"
dist="dist: rtfdist"
transformscript="refdbrtf";;
esac
# substitute values
sed "s%<doctypeswitch>%$doctypeswitch%" < $maketemplate | sed "s%<pubtype>%$pubtype%" | sed "s%<basename>%$basename%" | sed "s%<extension>%$extension%" | sed "s%<style>%$style%" | sed "s%<htmlstylesheet>%$htmlstylesheet%" | sed "s%<xhtmlstylesheet>%$xhtmlstylesheet%" | sed "s%<printstylesheet>%$printstylesheet%" | sed "s%<database>%$database%" | sed "s%all: pdf rtf html%$makeall%" | sed "s%dist: pdfdist rtfdist htmldist%$dist%" | sed "s%<transformscript>%$transformscript%" | sed "s%<encoding>%$encoding%" | sed "s%<cssfile>%$cssfile%" | sed "s%<fodriveropt>%$fodriveropt%" | sed "s%<htmldriveropt>%$htmldriveropt%" | sed "s%<xhtmldriveropt>%$xhtmldriveropt%" > Makefile
if [ "$silent" = "f" ]; then
echo "Makefile created."
echo ""
fi
encodingstring=" encoding=\"$encoding\""
# create an empty short-style document
if [ -z $xfile ]; then
case "$doctype" in
db31 ) printf "<!DOCTYPE $pubtype PUBLIC \"-//OASIS//DTD DocBook V3.1//EN\" [\n<!ENTITY bibliography SYSTEM \"$basename.bib.$extension\">\n]>\n<$pubtype>\n<!-- include the bibliography at the chapter level by inserting the entity &bibliography; -->\n</$pubtype>\n" > $basename.short.$extension;;
db40 ) printf "<!DOCTYPE $pubtype PUBLIC \"-//OASIS//DTD DocBook V4.0//EN\" [\n<!ENTITY bibliography SYSTEM \"$basename.bib.$extension\">\n]>\n<$pubtype>\n<!-- include the bibliography at the chapter level by inserting the entity &bibliography; -->\n</$pubtype>\n" > $basename.short.$extension;;
db41 ) printf "<!DOCTYPE $pubtype PUBLIC \"-//OASIS//DTD DocBook V4.1//EN\" [\n<!ENTITY bibliography SYSTEM \"$basename.bib.$extension\">\n]>\n<$pubtype>\n<!-- include the bibliography at the chapter level by inserting the entity &bibliography; -->\n</$pubtype>\n" > $basename.short.$extension;;
db41x) printf "<?xml version=\"1.0\"$encodingstring?>\n<!DOCTYPE $pubtype PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\" [\n<!ENTITY bibliography SYSTEM \"$basename.bib.$extension\">\n]>\n<$pubtype>\n<!-- include the bibliography at the chapter level by inserting the entity &bibliography; -->\n</$pubtype>\n" > $basename.short.$extension;;
db42x) printf "<?xml version=\"1.0\"$encodingstring?>\n<!DOCTYPE $pubtype PUBLIC \"-//OASIS//DTD DocBook XML V4.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd\" [\n<!ENTITY bibliography SYSTEM \"$basename.bib.$extension\">\n]>\n<$pubtype>\n<!-- include the bibliography at the chapter level by inserting the entity &bibliography; -->\n</$pubtype>\n" > $basename.short.$extension;;
db43x) printf "<?xml version=\"1.0\"$encodingstring?>\n<!DOCTYPE $pubtype PUBLIC \"-//OASIS//DTD DocBook XML V4.3//EN\" \"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd\" [\n<!ENTITY bibliography SYSTEM \"$basename.bib.$extension\">\n]>\n<$pubtype>\n<!-- include the bibliography at the chapter level by inserting the entity &bibliography; -->\n</$pubtype>\n" > $basename.short.$extension;;
db50x) printf "<?xml version=\"1.0\"$encodingstring?>\n<$pubtype xmlns=\"http://docbook.org/ns/docbook\">\n<!-- xinclude the bibliography file $basename.bib.xml at the chapter level -->\n<!-- <xi:include href=\"$basename.bib.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n<xi:fallback>$basename.bib.xml appears to be missing</xi:fallback>\n</xi:include> -->\n</$pubtype>\n" > $basename.short.$extension;;
teix ) printf "<?xml version=\"1.0\"$encodingstring?>\n<!DOCTYPE TEI.2 PUBLIC \"-//TEI P4//DTD Main DTD Driver File//EN\" \"http://www.tei-c.org/P4X/DTD/tei2.dtd\" [\n<!ENTITY % TEI.general 'INCLUDE'>\n<!ENTITY % TEI.names.dates 'INCLUDE'>\n<!ENTITY % TEI.linking 'INCLUDE'>\n<!ENTITY % TEI.XML 'INCLUDE'>\n<!ENTITY bibliography SYSTEM \"$basename.bib.$extension\">\n]>\n<$pubtype>\n<!-- include the bibliography at the chapter level by inserting the entity &bibliography; -->\n</$pubtype>\n" > $basename.short.$extension;;
tei5x) printf "<?xml version=\"1.0\"$encodingstring?>\n<$pubtype xmlns=\"http://www.tei-c.org/ns/1.0\">\n<!-- xinclude the bibliography file $basename.bib.xml at the chapter level -->\n<!-- <xi:include href=\"$basename.bib.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n<xi:fallback>$basename.bib.xml appears to be missing</xi:fallback>\n</xi:include> -->\n</$pubtype>\n" > $basename.short.$extension;;
# must use quadruple backslashes. One is eaten by the shell, the
# other one by the echo command due to the -e switch (which we
# need for inserting newlines)
# also, use ansi as default encoding for the time being instead
# of $encoding
rtf) printf "{\\\\rtf1\\\\ansi\n\\\\deff1\n{\\\\fonttbl\n{\\\\f0\\\\froman\\\\fcharset0\\\\fprq2 Times New Roman;}\n{\\\\f1\\\\froman\\\\fcharset0\\\\fprq2 Times New Roman;}\n{\\\\f2\\\\fswiss\\\\fcharset0\\\\fprq2 Lucida Sans Unicode;}}\n}\n" > $basename.$extension;;
esac
# create the full-style document
if [ "$doctype" != "rtf" ]; then
cp $basename.short.$extension $basename.$extension
if [ "$silent" = "f" ]; then
echo "Documents $basename.short.$extension and $basename.$extension created."
fi
else
if [ "$silent" = "f" ]; then
echo "Document $basename.$extension created."
fi
fi
else
if [ "$silent" = "f" ]; then
echo "Your existing document is called $xfile."
fi
fi
if [ "$silent" = "f" ]; then
echo ""
if [ "$doctype" = "rtf" ]; then
echo "After editing this file you can type \"make\" to generate $basename.refdb.$extension"
else
echo "After editing this file you can use the following commands to create"
echo "formatted output:"
echo "make pdf to create a Portable Document Format (PDF) file ($basename.pdf)"
if [ "$doctype" = "db41x" ] || [ "$doctype" = "db42x" ] || [ "$doctype" = "db43x" ] || [ "$doctype" = "db50x" ]; then
echo "make html to create HTML output ($basename.html)"
echo "make xhtml to create XHTML output ($basename.xhtml)"
else
echo "make html to create HTML output (${pubtype}1.html)"
fi
if [ "$extension" = "sgml" ]; then
echo "make rtf to create a Rich Text Format (RTF) file ($basename.rtf)"
echo "make ps to create a Postscript file ($basename.ps)"
fi
echo "make all to create all available output formats"
fi
fi
exit 0
|