| Title: | A Shiny Web Portal and Abstract Enricher for Zotero Libraries |
|---|---|
| Description: | Provides automated pipelines to fetch Zotero group libraries, generate APA citations, and harvest citation counts and missing abstracts from external metadata APIs (Crossref, OpenAlex, and Europe PMC). |
| Authors: | Thomas Petzoldt [aut, cre] (ORCID: <https://orcid.org/0000-0002-4951-6468>) |
| Maintainer: | Thomas Petzoldt <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.5.9 |
| Built: | 2026-09-30 12:35:32 UTC |
| Source: | https://github.com/tpetzoldt/biblioview |
Debugging utility to query external APIs directly for a specific DOI and print abstract availability and character length.
check_doi_abstracts(doi, email_contact = Sys.getenv("POLITE_EMAIL"))check_doi_abstracts(doi, email_contact = Sys.getenv("POLITE_EMAIL"))
doi |
Character string. Raw or clean DOI (e.g., "10.1007/s10452-015-9564-x"). |
email_contact |
Character. Contact email for API headers. |
A named list of retrieved abstracts (or NULL per provider).
# 1. PLOS ONE: "phyloseq: An R Package for Reproducible Interactive Analysis..." check_doi_abstracts("10.1371/journal.pone.0061217") # 2. Journal of Statistical Software: "Data Validation Infrastructure for R" (validate package) check_doi_abstracts("10.18637/jss.v097.i10") # 3. PLOS ONE: "Dose-Response Analysis Using R" (drc package) check_doi_abstracts("10.1371/journal.pone.0146021")# 1. PLOS ONE: "phyloseq: An R Package for Reproducible Interactive Analysis..." check_doi_abstracts("10.1371/journal.pone.0061217") # 2. Journal of Statistical Software: "Data Validation Infrastructure for R" (validate package) check_doi_abstracts("10.18637/jss.v097.i10") # 3. PLOS ONE: "Dose-Response Analysis Using R" (drc package) check_doi_abstracts("10.1371/journal.pone.0146021")
Strips common URL prefixes (including bare 'doi.org/'), leading/trailing whitespace, and verifies that the resulting string follows standard DOI format.
clean_doi_string(raw_doi)clean_doi_string(raw_doi)
raw_doi |
Character string containing a raw DOI or DOI URL. |
Character string containing the clean DOI (e.g., "10.1579/..."),
or NULL if input is invalid or missing the '10.' prefix.
Enrich Missing Abstracts from External Metadata APIs
enrich_missing_abstracts( df, email_contact = Sys.getenv("POLITE_EMAIL"), providers = list(epmc = fetch_abstract_epmc, crossref = fetch_abstract_crossref, openalex = fetch_abstract_openalex) )enrich_missing_abstracts( df, email_contact = Sys.getenv("POLITE_EMAIL"), providers = list(epmc = fetch_abstract_epmc, crossref = fetch_abstract_crossref, openalex = fetch_abstract_openalex) )
df |
A data frame generated by |
email_contact |
Character. Valid email address for polite API pools.
Defaults to the environment variable |
providers |
Named list of provider fetcher functions executed in list order. Defaults to Europe PMC -> OpenAlex -> Crossref. |
Data frame with updated Abstract column where matches were found.
## Not run: # Default usage (Europe PMC -> OpenAlex -> Crossref) df_enriched <- enrich_missing_abstracts(df = my_zotero_df) # Custom provider order: OpenAlex primary, Europe PMC secondary custom_order <- list( openalex = fetch_abstract_openalex, epmc = fetch_abstract_epmc ) df_enriched <- enrich_missing_abstracts( df = my_zotero_df, providers = custom_order ) ## End(Not run)## Not run: # Default usage (Europe PMC -> OpenAlex -> Crossref) df_enriched <- enrich_missing_abstracts(df = my_zotero_df) # Custom provider order: OpenAlex primary, Europe PMC secondary custom_order <- list( openalex = fetch_abstract_openalex, epmc = fetch_abstract_epmc ) df_enriched <- enrich_missing_abstracts( df = my_zotero_df, providers = custom_order ) ## End(Not run)
Inspects a Zotero item's metadata list for a DOI, checking the primary
DOI field first, followed by the extra field if necessary. Automatically
normalizes URL prefixes and validates the '10.' prefix structure.
extract_doi(data)extract_doi(data)
data |
List. The |
Clean character string containing the DOI, or NULL if no valid DOI is found.
Extract 4-Digit Year from Raw Zotero Date Fields safely
extract_zotero_year(date_vec)extract_zotero_year(date_vec)
date_vec |
Character vector or list item containing raw date string(s). |
Character vector of 4-digit years (or NA_character_).
Extract Year from Zotero Date Fields (including BCE / Ancient Dates)
extract_zotero_year_extended(date_vec)extract_zotero_year_extended(date_vec)
date_vec |
Character vector of raw date strings from Zotero. |
Character vector containing year strings (e.g., "2024", "384 BCE", "-0383", or NA).
Fetch Abstract from Crossref
fetch_abstract_crossref(doi, req_template)fetch_abstract_crossref(doi, req_template)
doi |
Clean DOI string. |
req_template |
httr2 base request. |
Character string containing abstract or NULL if not found.
Queries Europe PMC for an article's abstract using its DOI. Requires
resultType = "core" in the query parameters to ensure abstract text is included.
fetch_abstract_epmc(encoded_doi, base_req)fetch_abstract_epmc(encoded_doi, base_req)
encoded_doi |
Character string. Clean or URL-encoded DOI. |
base_req |
An httr2 request object configured with user-agent/headers. |
Character string containing abstract text, or NULL if not found.
Fetch Abstract from OpenAlex
fetch_abstract_openalex(doi, req_template)fetch_abstract_openalex(doi, req_template)
doi |
Clean DOI string. |
req_template |
httr2 base request. |
Character string containing abstract or NULL if not found.
Fetch Abstract from Semantic Scholar
fetch_abstract_semanticscholar(doi, base_req)fetch_abstract_semanticscholar(doi, base_req)
doi |
Clean DOI string. |
base_req |
httr2 base request. |
Character string containing abstract or NULL if not found.
Loops through specified or all collections in a Zotero group library, retrieves their items, formats them into a tabular structure, and appends the collection name.
fetch_all_zotero_data(group_id, api_key, collection_id = NULL)fetch_all_zotero_data(group_id, api_key, collection_id = NULL)
group_id |
Character or numeric. The target Zotero Group ID. |
api_key |
Character. Your secret Zotero Web API v3 key. |
collection_id |
Optional character vector. Unique Zotero collection keys (hashes)
to pull down. If |
A data frame containing structured reference data with columns: Sub_Collection, Authors, Year, Title, DOI, APA_Citation, and Abstract.
Scans a data frame for a DOI column, extracts all valid identifiers, and
queries the OpenAlex API in batches of up to 50 items to retrieve up-to-date
citation metrics (cited_by_count). The results are joined back to the
original data frame under a new citations column.
fetch_citation_counts(df, email_contact = Sys.getenv("POLITE_EMAIL"))fetch_citation_counts(df, email_contact = Sys.getenv("POLITE_EMAIL"))
df |
A data frame containing bibliographic data, typically generated by
|
email_contact |
Character string containing the contact email used to gain entry
to the OpenAlex "Polite Pool." Defaults to the system environment variable
|
A data frame identical to the input, but with an added integer column
named citations containing the citation metrics. Rows with missing or
unmatched DOIs will default to NA.
## Not run: enriched_data <- fetch_citation_counts(raw_data) ## End(Not run)## Not run: enriched_data <- fetch_citation_counts(raw_data) ## End(Not run)
Handles paginated API requests (100 items per page) to retrieve all top-level items from a specific Zotero collection key.
fetch_collection_items(group_id, api_key, collection_key)fetch_collection_items(group_id, api_key, collection_key)
group_id |
Character or numeric. The target Zotero Group ID. |
api_key |
Character. Your secret Zotero Web API v3 key. |
collection_key |
Character. The unique alphanumeric key for the sub-collection. |
A data frame of processed items belonging to the collection.
Takes a vector of DOIs and retrieves their bibliographic data formatted as RIS using Crossref Content Negotiation. Includes robust error handling and automatic retry logic for network rate-limiting.
fetch_ris_from_crossref(dois, email = NULL)fetch_ris_from_crossref(dois, email = NULL)
dois |
Character vector of DOIs. |
email |
Optional email address for Crossref's polite pool (recommended). |
A character vector of RIS formatted entries.
## Not run: ris <- fetch_ris_from_crossref( dois = c("10.1016/j.ecolmodel.2020.109282", "10.1111/gcb.15000"), email = "[email protected]" ) write_ris(ris, "export.ris") ## End(Not run)## Not run: ris <- fetch_ris_from_crossref( dois = c("10.1016/j.ecolmodel.2020.109282", "10.1111/gcb.15000"), email = "[email protected]" ) write_ris(ris, "export.ris") ## End(Not run)
Connects to the Zotero API and retrieves a named vector of all sub-folders (collections) within the specified group library.
fetch_zotero_collections(group_id, api_key)fetch_zotero_collections(group_id, api_key)
group_id |
Character or numeric string containing the Zotero Group ID. |
api_key |
Character string containing the Zotero API access key. |
A named character vector where the values are the unique Zotero
collection hashes (e.g., "A8F3X2Z9") and the names are the human-readable
folder titles (e.g., "Marine Biology"). Returns an empty vector if no
folders exist.
## Not run: folders <- fetch_zotero_collections("1234567", "your_api_key") ## End(Not run)## Not run: folders <- fetch_zotero_collections("1234567", "your_api_key") ## End(Not run)
Scans a data frame for columns matching "doi" or "url" (case-insensitive)
and transforms their string values into active HTML anchor tags (<a href="...">).
It automatically protects existing full URLs inside the DOI column from being
duplicated with the DOI resolver prefix.
format_hyperlinks(df)format_hyperlinks(df)
df |
A data frame containing bibliographic data, typically generated by
|
A data frame with the matched identifier columns transformed into HTML link strings.
## Not run: # Assuming raw_data contains columns named 'DOI' and 'url' clean_df <- format_hyperlinks(raw_data) ## End(Not run)## Not run: # Assuming raw_data contains columns named 'DOI' and 'url' clean_df <- format_hyperlinks(raw_data) ## End(Not run)
Launch the Biblioview Dashboard Locally
launch_dashboard(group = NULL, key = NULL, folder = NULL, title = NULL)launch_dashboard(group = NULL, key = NULL, folder = NULL, title = NULL)
group |
Optional character string containing a default Zotero Group ID. |
key |
Optional character string containing a default Zotero API Key. |
folder |
Optional character string containing a sub-collection (folder) of the group library. |
title |
Optional character string to override the default portal header title. |
Handles hyperlink formatting, JS tooltips, column truncation, and export button configurations uniformly.
render_biblioview_table(df, title = "export", show_buttons = TRUE)render_biblioview_table(df, title = "export", show_buttons = TRUE)
df |
Data frame containing reference entries. |
title |
Character. Export filename prefix. |
show_buttons |
Logical. Include Copy/CSV/Excel export buttons. |
Scans a Zotero group library (or specific collections) for top-level items missing abstracts, fetches them from external APIs, sanitizes formatting, and writes them back to Zotero.
sync_missing_abstracts_to_zotero( group_id, api_key, collections = NULL, force_overwrite = FALSE, email_contact = Sys.getenv("POLITE_EMAIL"), providers = list(epmc = fetch_abstract_epmc, crossref = fetch_abstract_crossref, openalex = fetch_abstract_openalex) )sync_missing_abstracts_to_zotero( group_id, api_key, collections = NULL, force_overwrite = FALSE, email_contact = Sys.getenv("POLITE_EMAIL"), providers = list(epmc = fetch_abstract_epmc, crossref = fetch_abstract_crossref, openalex = fetch_abstract_openalex) )
group_id |
Character or Numeric. The Zotero Group ID. |
api_key |
Character. A Zotero API key with write access to the group. |
collections |
Character vector (optional). One or more Zotero folder/collection names. If NULL (default), scans the entire group library. |
force_overwrite |
Logical. If TRUE, re-fetches and overwrites pre-existing abstracts. Defaults to FALSE. |
email_contact |
Character. Contact email used for polite external API pools.
Defaults to environment variable |
providers |
Named list of provider functions passed to external APIs. |
A named list containing summary statistics of the sync operation and details on any unresolvable items.
Writes a character vector of RIS records to a file.
write_ris(ris_data, file)write_ris(ris_data, file)
ris_data |
Character vector of RIS records (e.g. from |
file |
Path to the destination file. |
The file path invisibly.
Parses Zotero JSON items across articles, books, chapters, reports, and webpages, enforcing APA 7th rules without rich text (no italics or bolding).
zotero_to_apa(item)zotero_to_apa(item)
item |
List. A single raw item element from the Zotero JSON API. |
A single-row data frame with standardized bibliographic columns.