generated from imfing/hextra-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper scripts to import bibliography
- Loading branch information
1 parent
4915020
commit 3e4bc62
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |