Skip to content

Commit

Permalink
Add helper scripts to import bibliography
Browse files Browse the repository at this point in the history
  • Loading branch information
yarikoptic committed Dec 19, 2024
1 parent 4915020 commit 3e4bc62
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tools/import_doi
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
#
# Provide DOIs to import
#
# Uses "academic" (pip install academic) and bibtool (apt install bibtool)

set -eu

topd=$(dirname "$0")/..
pubdir="$topd/content/publications"
bibs="$pubdir/publications.bib"


echo "Storing BibTeX records into $bibs"
for arg in "$@"; do
doi=$(echo "$arg" | sed -e 's,https*://.*doi\.org/,,g')
if grep -q "$doi" "$bibs" 2>/dev/null; then
echo "DOI $doi already known to $bibs. skipping"
continue
fi
mkdir -p "$pubdir"
touch "$bibs"
if ! curl --silent -L -d "" --header "Accept: application/x-bibtex; charset=utf-8" https://doi.org/$doi | sed -e 's,%2F,/,g' >> "$bibs"; then
echo "ERROR: failed to fetch bibtex for doi $doi"
exit 1
fi
done

bibtool -s -i "$bibs" -o "$bibs"

if [ -e "$bibs" ]; then
echo "Importing"
academic import --compact "$bibs" "$pubdir"
git status "$pubdir"
else
echo "No $bibs, nothing todo"
fi
10 changes: 10 additions & 0 deletions tools/import_doi_all
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
#
# one time use script to import all already existing in plain text publications
#

#
# TODO: ideally for all THOSE added entries we should add a tag "repronim" or alike so we could
# add also related publications and then separate from those which are associated directly with ReproNim
#
grep 'doi:' content/about/publications.md | sed -e 's,.*(https://doi.org/\(.*\)).*,\1,g' | xargs tools/import_doi

0 comments on commit 3e4bc62

Please sign in to comment.