Compare commits
	
		
			3 Commits
		
	
	
		
			v2.1.3
			...
			70bba87946
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 70bba87946 | |||
| aacbf51475 | |||
| 2136ba3f69 | 
							
								
								
									
										16
									
								
								Changelog
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								Changelog
									
									
									
									
									
								
							@@ -1,3 +1,19 @@
 | 
			
		||||
2.2:
 | 
			
		||||
 | 
			
		||||
  * New: Allow for the value of other entries to be in the 'sed' command of a
 | 
			
		||||
	 filter. (May break existing configurations in cases where sed command
 | 
			
		||||
	 uses a '%'.)
 | 
			
		||||
 | 
			
		||||
2.1.5:
 | 
			
		||||
 | 
			
		||||
  * Fixed: Properly escape entries with a '%'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
2.1.4:
 | 
			
		||||
 | 
			
		||||
  * New: Allow for comma separated list of references in aux_cmd.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
2.1.3:
 | 
			
		||||
 | 
			
		||||
  * Fixed: entries that contain a '%' do not cause a failure.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
## Copyright Ian Jauslin 2015-2019
 | 
			
		||||
## Copyright Ian Jauslin 2015-2023
 | 
			
		||||
## 
 | 
			
		||||
## Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
## you may not use this file except in compliance with the License.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								NOTICE
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								NOTICE
									
									
									
									
									
								
							@@ -1,2 +1,2 @@
 | 
			
		||||
BBlog
 | 
			
		||||
Copyright Ian Jauslin 2015-2019
 | 
			
		||||
Copyright Ian Jauslin 2015-2023
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										41
									
								
								bin/BBlog
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								bin/BBlog
									
									
									
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
## Copyright Ian Jauslin 2015-2019
 | 
			
		||||
## Copyright Ian Jauslin 2015-2023
 | 
			
		||||
## 
 | 
			
		||||
## Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
## you may not use this file except in compliance with the License.
 | 
			
		||||
@@ -15,10 +15,10 @@
 | 
			
		||||
## limitations under the License.
 | 
			
		||||
 | 
			
		||||
# directory containing the engine files
 | 
			
		||||
enginedir=/home/ian/Programs/BBlog2/src/engines
 | 
			
		||||
enginedir=/usr/share/BBlog/engines
 | 
			
		||||
 | 
			
		||||
# version
 | 
			
		||||
version=2.1.3
 | 
			
		||||
version=2.2
 | 
			
		||||
 | 
			
		||||
function print_config {
 | 
			
		||||
  echo "engine: $engine"
 | 
			
		||||
@@ -222,7 +222,8 @@ function replace_format {
 | 
			
		||||
 | 
			
		||||
    # apply filter
 | 
			
		||||
    if [ -n "$filter" ]; then
 | 
			
		||||
      sed_cmd=$(eval "echo \$filter_$filter")
 | 
			
		||||
      # replace '%' inside filter text
 | 
			
		||||
      sed_cmd=$(replace_format $(eval "echo \$filter_$filter"))
 | 
			
		||||
      replacement=$(eval "echo \$$field" | sed -r "$sed_cmd" )
 | 
			
		||||
    else
 | 
			
		||||
      replacement=$(eval "echo \$$field")
 | 
			
		||||
@@ -235,12 +236,13 @@ function replace_format {
 | 
			
		||||
    out="${out//\%$command\%/$replacement}"
 | 
			
		||||
  done
 | 
			
		||||
 | 
			
		||||
  # un-escape '%' in replacement
 | 
			
		||||
  out="${out//::iansays:percent::/\%}"
 | 
			
		||||
 | 
			
		||||
  # finish replacing newlines
 | 
			
		||||
  out="${out//\\n/%}"
 | 
			
		||||
  out=$(echo "$out" | tr "%" "\n")
 | 
			
		||||
 | 
			
		||||
  # un-escape '%' in replacement
 | 
			
		||||
  out="${out//::iansays:percent::/\%}"
 | 
			
		||||
 | 
			
		||||
  echo "$out"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -272,17 +274,20 @@ function inverse_map_citeref {
 | 
			
		||||
 | 
			
		||||
  foundref=0
 | 
			
		||||
  # sift through aux file
 | 
			
		||||
  grep -h "$aux_cmd" $aux | while read -r ref; do
 | 
			
		||||
    eval "ref=\${ref#$aux_cmd}"
 | 
			
		||||
    ref="${ref%\}}"
 | 
			
		||||
    # replace the ref via the ref_map
 | 
			
		||||
    possibleref=$(map_citeref "$ref")
 | 
			
		||||
    # check whether the ref is the right one
 | 
			
		||||
    if [ "$possibleref" = "$newref" ]; then
 | 
			
		||||
      echo "$ref"
 | 
			
		||||
      foundref=1
 | 
			
		||||
      return 1
 | 
			
		||||
    fi
 | 
			
		||||
  grep -h "$aux_cmd" $aux | while read -r refs; do
 | 
			
		||||
    eval "refs=\${refs#$aux_cmd}"
 | 
			
		||||
    refs="${ref%\}}"
 | 
			
		||||
    # can be a comma separated list
 | 
			
		||||
    for ref in $(echo -n "$refs" | tr ',' '\n'); do
 | 
			
		||||
      # replace the ref via the ref_map
 | 
			
		||||
      possibleref=$(map_citeref "$ref")
 | 
			
		||||
      # check whether the ref is the right one
 | 
			
		||||
      if [ "$possibleref" = "$newref" ]; then
 | 
			
		||||
	echo "$ref"
 | 
			
		||||
	foundref=1
 | 
			
		||||
	return 1
 | 
			
		||||
      fi
 | 
			
		||||
    done
 | 
			
		||||
  done && echo "$foundref$newref"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
.Dd $Mdocdate: November 5 2019 $
 | 
			
		||||
.Dt BBLOG 2.1.3
 | 
			
		||||
.Dd $Mdocdate: March 21 2022 $
 | 
			
		||||
.Dt BBLOG 2.2
 | 
			
		||||
.Os
 | 
			
		||||
.Sh NAME
 | 
			
		||||
.Nm BBlog
 | 
			
		||||
@@ -194,6 +194,6 @@ automatically adds a letter (from 'b' to 'z') at the end of non-unique tokens, i
 | 
			
		||||
.Nm
 | 
			
		||||
was written by Ian Jauslin.
 | 
			
		||||
.Sh COPYRIGHT
 | 
			
		||||
copyright Ian Jauslin 2015-2019
 | 
			
		||||
copyright Ian Jauslin 2015-2023
 | 
			
		||||
.Sh SEE ALSO
 | 
			
		||||
.Sx BBlog-sqlite Ns (7)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
.Dd $Mdocdate: Novermber 5 2019 $
 | 
			
		||||
.Dd $Mdocdate: November 5 2019 $
 | 
			
		||||
.Dt BBLOG-sqlite
 | 
			
		||||
.Os
 | 
			
		||||
.Sh DESCRIPTION
 | 
			
		||||
@@ -32,7 +32,7 @@ label of the reference
 | 
			
		||||
.Sh AUTHORS
 | 
			
		||||
The sqlite BBlog engine was written by Ian Jauslin.
 | 
			
		||||
.Sh COPYRIGHT
 | 
			
		||||
copyright Ian Jauslin 2015-2019
 | 
			
		||||
copyright Ian Jauslin 2015-2023
 | 
			
		||||
.Sh SEE ALSO
 | 
			
		||||
.Sx BBlog Ns (1) ,
 | 
			
		||||
.Sx sqlite3 Ns (1)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user