1#!/bin/bash 2 3# This script creates a single html file of all the .bib files 4# passed in the year_names array below. Make sure there is a 5# corresponding entry in the year_numbers array as well. Why 6# not just name the bib files 2009.bib etc? For some reason 7# multibib can't handle filenames with numbers in them. 8 9# This script requires bibtex2html (see associated Makefile and 10# libmesh_html rule) 11if [ "x`which bibtex2html`" == "x" ]; then 12 echo "bibtex2html is required to create the website!"; 13 exit 1; 14fi 15 16# Process command line arguments. 17# https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash 18count_only=false 19while [[ $# -ge 1 ]] 20do 21 key="$1" 22 case $key in 23 -c|--count-only) 24 count_only=true 25 shift # past argument 26 ;; 27 *) 28 # unknown option 29 shift 30 ;; 31 esac 32done 33 34# Declare array of year names and numbers. Zero-based indexing! 35year_names=( libmesh preprints twenty nineteen eighteen seventeen sixteen fifteen fourteen thirteen twelve eleven ten nine eight seven six five four ) 36year_numbers=( 'Please use the following citation to reference libMesh' 'Preprints' 2020 2019 2018 2017 2016 2015 2014 2013 2012 2011 2010 2009 2008 2007 2006 2005 2004 ) 37link_names=( 'skip me' 'Preprints' 'Articles' ) 38# The short_numbers are used for making Python strings of the years. 39short_numbers=( 'na' 'na' \'\\\'20\' \'\\\'19\' \'\\\'18\' \'\\\'17\' \'\\\'16\' \'\\\'15\' \'\\\'14\' \'\\\'13\' \'\\\'12\' \'\\\'11\' \'\\\'10\' \'\\\'09\' \'\\\'08\' \'\\\'07\' \'\\\'06\' \'\\\'05\' \'\\\'04\') 40 41# Stores strings to be output in reverse 42output_strings=() 43 44# Length of the arrays 45N=${#year_names[@]} 46 47# Remove previous file, if it exists 48if [ -f master.html ]; then 49 rm master.html 50fi 51 52for ((i=0; i < $N ; i++)) 53do 54 # Store the bibtex2html output in $output_filename so we can comb through it later. 55 input_filename=${year_names[$i]}.bib 56 output_filename=${year_names[$i]}.b2h 57 make libmesh_html SOURCE=$input_filename &> $output_filename 58 59 # This strips the number of entries from the bibtex2thml 60 # output. There is probably a better, cleaner way to do this with 61 # perl, but I have not bothered to look it up yet. 62 n_entries=`cat $output_filename | grep -m 1 "entries)" | cut -d"(" -f 2 | cut -d" " -f 1` 63 output_strings+=("${short_numbers[$i]}, $n_entries,") 64 65 # Clean up the temporary file. 66 rm $output_filename 67 68 # Add header 69 # echo "<h2>${year_numbers[$i]}</h2>" >> master.html 70 71 # Ben added links to some of these headers so they can 72 # be accessed from the left navigation pane on the actual 73 # site... 74 if [ $i -gt 0 ]; then 75 if [ $i -lt 4 ]; then 76 echo "<a name=\"${link_names[$i]}\"></a>" >> master.html 77 fi 78 fi 79 80 echo "<h2>${year_numbers[$i]}</h2>" >> master.html 81 82 # Combine 83 cat ${year_names[$i]}.html >> master.html 84done 85 86# Create publications.html 87if [ "$count_only" = false ] ; then 88 # The name of the final file that we will produce 89 final_file=../html/src/publications.html 90 91 if [ -f $final_file ]; then 92 rm $final_file 93 fi 94 95 # Inject all the references 96 cat master.html >> $final_file 97 98 # bibtex2html unhelpfully inserts trailing whitespace, so kill that off 99 perl -pli -e 's/\s+$//' $final_file 100fi 101 102# Print the citation count results by year, in reverse, and we don't 103# care about the first two categories. 104for ((i=$[$N-1]; i > 1 ; i--)) 105do 106 echo ${output_strings[$i]} 107done 108