WP Nasa/ADS Query Importer

Import any ADS query you can perform on an ADS server in your WordPress website.

Author:Matthias Bissinger and Giovanni Di Milia for the ADS (profile at wordpress.org)
WordPress version required:4.7
WordPress version tested:5.4.13
Plugin version:1.0
Added to WordPress repository:28-09-2011
Last updated:27-06-2023
Rating, %:100
Rated by:1
Plugin URI:http://wordpress.org/extend/plugins/wp-nasaad...
Total downloads:2 271
Active installs:10+
plugin download
Click to start download

The SAO/NASA Astrophysics Data System (ADS) (NASA ADS) is a digital library portal for researchers in astronomy and physics. Complex literature searches can be performed such that compiling a list of relevant papers for a specific topic can be done easily. This plugin provides an interface to the NASA ADS API in order to include lists of records in your posts using shortcodes.

With this plugin you are able to
– easily include simple ADS queries without having to learn the NASA ADS API.
– include complex ADS queries by providing the full GET method URL (see the Shortcodes section below).
– customize the format and the displayed information of the returned list of records at the shortcode level if needed.

Note: this code is not backward compatible with version 0.3 and older.

Shortcodes

The shortcode wp_nasaads_query_importer can be used to query the NASA ADS and output the returned list of records. It can be inserted into any post with or without providing enclosed content:
[wp_nasaads_query_importer attributes]
or
[wp_nasaads_query_importer attributes] format [/wp_nasaads_query_importer]

Here, attributes are the shortcode’s attributes and it is mandatory to either provide
– at least one of the query attributes described below,
– the library attribute (and combined optionally with query attributes),
– or the query attribute.

In case of enclosed content the format is used to format the list of the records. See the Format section below.

Please note that for all of the following query attributes the NASA ADS search syntax is applied, i.e., the shortcode’s attribute values are submitted unaltered to the API (with the exception of author and title as described below). This enables more complex searches, for instance when combined with logical operators like AND, OR, or NOT (read the search syntax for details).

  • author: search for certain author(s). In case a single author is given the name of the author, i.e., the attribute’s value will be submitted with surrounding double quotes (e.g., Hawking, S. will be submitted as "Hawking, S."). Technically, a value is considered to be a single author if the string contains no AND, OR, double quotes or parentheses. If you need to include double quotes in the author field, please use single quotes around the attribute’s value (see the examples below).
  • aff: search for author’s affiliations which contain the given string.
  • bibstem: search for articles published in specific journal(s) given by the acronym(s) of the journal(s).
  • year: search for articles published in a certain year given in the format YYYY. Articles within a certain period can be searched by YYYY-YYYY or YYYY TO YYYY.
  • title: search for articles whose title contains the given string. The title will be submitted with surrounding double quotes under the same conditions as described for the author attribute.
  • property: filter the records on specific properties like refereed. Read the Properties section of the search syntax for a list of all available properties.

Showing the records within an ADS user library is supported by the

  • library attribute: the ID of the user-library.

For more complex ADS searches, which are not supported by using the attributes of the shortcode, you may specify the
query attribute: the GET method’s URL to the API without the base path, i.e., https://api.adsabs.harvard.edu/v1/ is added automatically to the URL.

Finally,the following optional attributes can be used to control the output:
sort: sort the list of records. The value has to be in the format field+direction where field is the record field name to sort on and direction is either desc or asc. The default is date desc,bibcode desc.
max_rec: the maximum number of records to show. The default is set to 25.
max_authors: the maximum number of authors to print, which is set to 3 by default. The remaining number of authors are appended to the printed author list.
notify_empty_list: overrides the global plugin option “Notify empty list”. Possible values are true or false. The default is true.
show_num_rec: overrides the global plugin option “Show number of records”. Allowed values are never, always, or depends (read the description in the plugin’s settings page for details). The default is set to depends.

Format

How the list of records is formatted and inserted into your post can be defined in the plugin option “Content template” for all shortcodes. In case a shortcode is inserted into a post with enclosed content, i.e., [wp_nasaads_query_importer] ... [/wp_nasaads_query_importer] then the content within the shortcode tags is used as the template and, thus, overrides the plugin’s global option.

The template is applied to each record in the list and may contain HTML entities to style the output. The data of the record is inserted by the following placeholders: %author, %affil, %title, %year, %month, %bibstem, %pub, %page, %volume, and %adsurl. See the NASA ADS search syntax for the definition of the record’s fields with the exception of %year and %month which are derived from date, and %adsurl which is derived from bibcode.

Ultimate full control over the output and field records can be gained by new WordPress filters added by the plugin (see the WordPress filter section below).

WordPress filter

This plugins adds a few filters to WordPress, which can be used by third party plugins to further control the output and fetched record fields.

apply_filters( 'wp_nasaads_query_importer-record_mapping', array $mapping )

Defines which record fields are fetched from NASA ADS and on which placeholders they are mapped. The keys of the associative array $mapping are the placeholder names (without the leading %) and their values the API fields names. The default definition can be found in the source code. (Source code)

apply_filters( 'wp_nasaads_query_importer-API_value', mixed $value, string $field )

Filters the $value of a fetched API $field before it is inserted into the record’s data. (Source code)

apply_filters( 'nasa_das_query-format_[placeholder]', mixed $current_value, mixed $original_value, array $atts )

The final value returned by this filter will be the replacement for the placeholder (without the leading %). The $original_value is that returned by the NASA ADS API while $current_value is the value already modified by filter functions of higher priority. The shortcode attributes are passed as the associative array $atts. See the source code of the author filter for an example. (Source code)

Requirements

The plugin needs your personalized NASA ADS API token in order to fetch records from the database and, thus, to work correctly! You need to register an account at NASA ADS or login and generate your token in the account settings.

Examples

Show a list of refereed papers with Stephen Hawking among the list of authors:
[wp_nasaads_query_importer author=”Hawking, S.” property=”refereed”]

Same as before but where Hawking was first author:
[wp_nasaads_query_importer author=”^Hawking, S.” property=”refereed”]

List all articles by Ejnar Hertzsprung published in the Astronomische Nachrichten:
[wp_nasaads_query_importer author=”Hertzsprung, E.” bibstem=”AN”]

List all articles by Ejnar Hertzsprung and Henry Norris Russell. Note that the author string is surrounded by single quotes while the author names are surrounded by double quotes in order to preserve their last and first names. Also the search by both authors is logically combined by AND due to the space between their names:
[wp_nasaads_query_importer author='”Hertzsprung, E.” “Russell, H.N.”‘]

Load a user ADS library and filter the list of papers on a year range and exclude a certain journal:
[wp_nasaads_query_importer library=”GdEguHJfSGCrYKKqJM-5XA” year=”1911-1914″ bibstem=”(-SciAm)” max_rec=40]

Same as before but only show the title by customizing the record template:
<ul>
[wp_nasaads_query_importer library="GdEguHJfSGCrYKKqJM-5XA" year="1911-1914" bibstem="(-SciAm)" max_rec=40]
<li><a href="%adsurl">%title</a></li>
[/wp_nasaads_query_importer]
</ul>


FAQ
ChangeLog