Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/sqlite.sh130
1 files changed, 69 insertions, 61 deletions
diff --git a/engines/sqlite.sh b/engines/sqlite.sh
index af7afdd..b10d6c3 100644
--- a/engines/sqlite.sh
+++ b/engines/sqlite.sh
@@ -1,5 +1,5 @@
-base_SQL="SELECT title,author,journal,year,token,doi,arxiv,citeref,prauth FROM bibliography"
-base_SQL_noprauth="SELECT title,author,journal,year,token,doi,arxiv,citeref FROM bibliography"
+base_SQL="SELECT title,author,journal,year,token,doi,arxiv,citeref,prauth,bibtex FROM bibliography"
+base_SQL_noprauth="SELECT title,author,journal,year,token,doi,arxiv,citeref,bibtex FROM bibliography"
# add quotes
function SQL_addquotes {
@@ -23,32 +23,36 @@ function generate_SQL_alpha {
exists_citeref=0
# sift through aux file
- grep -h "$aux_cmd" $aux | while read -r citeref; do
- eval "citeref=\${citeref#$aux_cmd}"
- citeref="${citeref%\}}"
+ grep -h "$aux_cmd" $aux | while read -r citerefs; do
+ eval "citerefs=\${citerefs#$aux_cmd}"
+ citerefs="${citerefs%\}}"
- # replace the citeref with a ref_map if there is any
- if [ -n "$ref_map" ]; then
- citeref=$(map_citeref "$citeref")
- fi
+ # can be a comma separated list
+ for citeref in $(echo -n "$citerefs" | tr ',' '\n'); do
- # Only query the db if there is no matching extra entry
- foundit=0
- if [ ${#extra} -gt 0 ]; then
- for entry in "${extra[@]}"; do
- ref="${entry#*:}"
- ref="${ref%%:*}"
- if [ "$ref" = "$citeref" ]; then
- foundit=1
- break
- fi
- done
- fi
-
- if [ "$foundit" = 0 ]; then
- echo -n "$citeref' OR citeref='"
- exists_citeref=1
- fi
+ # replace the citeref with a ref_map if there is any
+ if [ -n "$ref_map" ]; then
+ citeref=$(map_citeref "$citeref")
+ fi
+
+ # Only query the db if there is no matching extra entry
+ foundit=0
+ if [ ${#extra} -gt 0 ]; then
+ for entry in "${extra[@]}"; do
+ ref="${entry#*:}"
+ ref="${ref%%:*}"
+ if [ "$ref" = "$citeref" ]; then
+ foundit=1
+ break
+ fi
+ done
+ fi
+
+ if [ "$foundit" = 0 ]; then
+ echo -n "$citeref' OR citeref='"
+ exists_citeref=1
+ fi
+ done
done
# if there are no citerefs close '
@@ -70,46 +74,50 @@ function fetch_BBlog_entries_appearance {
citeref_list=""
# sift through aux file
- grep -h "$aux_cmd" $aux | while read -r citeref; do
- eval "citeref=\${citeref#$aux_cmd}"
- citeref="${citeref%\}}"
+ grep -h "$aux_cmd" $aux | while read -r citerefs; do
+ eval "citerefs=\${citerefs#$aux_cmd}"
+ citerefs="${citerefs%\}}"
- # replace the citeref with a ref_map if there is any
- if [ -n "$ref_map" ]; then
- citeref=$(map_citeref "$citeref")
- fi
+ # can be a comma separated list
+ for citeref in $(echo -n "$citerefs" | tr ',' '\n'); do
- # check whether the reference was already cited
- citeref_list="$citeref_list;"
- if $(echo "$citeref_list" | grep -q ";$citeref;"); then
- # remove trailing ';'
- citeref_list="${citeref_list%;}"
- else
- citeref_list="$citeref_list$citeref"
-
- # Only query the db if there is no matching extra entry
- foundit=0
- if [ ${#extra} -gt 0 ]; then
- for entry in "${extra[@]}"; do
- ref="${entry#*:}"
- ref="${ref%%:*}"
- if [ "$ref" = "$citeref" ]; then
- foundit=1
- break
- fi
- done
+ # replace the citeref with a ref_map if there is any
+ if [ -n "$ref_map" ]; then
+ citeref=$(map_citeref "$citeref")
fi
-
- if [ "$foundit" = 0 ]; then
- SQL="$base_SQL_noprauth WHERE citeref='$citeref'"
- sqlite3 -line "$db" "$SQL" | SQL_addquotes
+
+ # check whether the reference was already cited
+ citeref_list="$citeref_list;"
+ if $(echo "$citeref_list" | grep -q ";$citeref;"); then
+ # remove trailing ';'
+ citeref_list="${citeref_list%;}"
else
- echo "citeref=$citeref"
- fi
+ citeref_list="$citeref_list$citeref"
- # add an empty line
- echo ""
- fi
+ # Only query the db if there is no matching extra entry
+ foundit=0
+ if [ ${#extra} -gt 0 ]; then
+ for entry in "${extra[@]}"; do
+ ref="${entry#*:}"
+ ref="${ref%%:*}"
+ if [ "$ref" = "$citeref" ]; then
+ foundit=1
+ break
+ fi
+ done
+ fi
+
+ if [ "$foundit" = 0 ]; then
+ SQL="$base_SQL_noprauth WHERE citeref='$citeref'"
+ sqlite3 -line "$db" "$SQL" | SQL_addquotes
+ else
+ echo "citeref=$citeref"
+ fi
+
+ # add an empty line
+ echo ""
+ fi
+ done
done
}