Daniel-KM / Omeka-S-module-Reference

Module for Omeka S to add glossary pages with the alphabetical indexes of specified classes and properties.
Other
3 stars 1 forks source link
glossary index omeka-s-module omekas-s

Reference (module for Omeka S)

New versions of this module and support for Omeka S version 3.0 and above are available on GitLab, which seems to respect users and privacy better than the previous repository.

Reference is a module for Omeka S that allows to serve a glossary (an alphabetized index) of links to records or to searches for all resources classes (item types) and properties (metadata fields) of all resources of an Omeka S instance. The references can be aggregated, for example to get all dates from "dcterms:date" and "dcterms:issued" together.

These lists can be displayed in any page via a helper or a block. References can be limited by site or any other pool, and ordered alphabetically or by count.

The references are available via the api too, for example /api/references?metadata=dcterms:subject to get the list of all subjects, or /api/references?metadata=foaf:Person to get the list of all resources with class "Person". Another format for the query is provided by the module Api Info.

This Omeka S module is a rewrite and an improvement of the Reference plugin for Omeka.

Installation

See general end user documentation for installing a module.

This module requires the module [Common], that should be installed first.

Download the last release Reference.zip from the list of releases, and uncompress it in the modules directory.

If the module was installed from the source, rename the name of the folder of the module to Reference.

Then install it like any other Omeka module and follow the config instructions.

Note for an upgrade from Omeka Classic

The default slugs use the full term, with the vocabulary prefix, so the default route for subjects is now reference/dcterms:subject instead of references/subject. It can be changed in the site settings form and pages can be created with any slug.

Furthermore, the base route has been changed to singular reference instead of references. To keep or to create an alias for old plural routes, simply add/update it directly in your local.config.php, via a copy of the route part of the file config/module.config.php. Any word can be used, like lexicon, glossary, etc.

Anyway, it is recommended to use site page blocks, with any slug, so it’s not necessary to modify the config.

Usage

The site settings allows to select the terms to display. The config is the same for the main site pages or in the block form for pages. It is recommended to use site pages when possible.

Automatic site pages

The module adds pages for selected resource classes and properties at https://www.example.com/s/my-site/reference. Available pages and options can be set in the site settings. Options are:

Lists

A block allows to display the lists in any page. Furthermore,

These contents can be displayed anywere via the view helper references():

// With default values.
echo $this->references()->displayListForTerm('dcterms:subject', $query, $options);
// Get the lists.
print_r($this->references()->list('dcterms:subject', $query, $options));
// Get the count.
echo $this->references()->count('dcterms:subject', $query, $options);
// Get the initials (here to get the list of years from iso 8601 values or numeric timestamp).
print_r($this->references()->initials('dcterms:created', $query, ['initial' => 4]));
// Get the list of resources related to all subjects.
print_r($references->list('dcterms:subject', null, ['list_by_max' => 1024]));

The references are available via the api in /api/references too. Arguments are the same than above: the search query + a metadata array for the list of fields to get, and an array of options to use (see below). The same feature is available via the module Api Info too on /api/infos/references.

Tree view

The tree of references can be build with the block page "Reference tree". The references should be formatted like:

Europe
- France
-- Paris
- United Kingdom
-- England
--- London
Asia
- Japan

So:

Via the helper:

echo $this->references()->displayTree(
    // A dash list as a text or as an array of value/level.
    $referenceLevels,
    ['site_id' => 1],
    [
        'term' => $term,
        'type' => 'properties',
        'resource_name' => 'items',
        'query_type' => 'eq',
        'link_to_single' => true,
        'custom_url' => false,
        'total' => true,
        'expanded' => true,
        'strip' => true,
        'total' => true,
        'raw' => false,
    ]
);

All arguments are optional and the default ones are set in the config page or in the block, but they can be overridden in the theme.

For order, the sort can be ['total' => 'DESC'] too.

For query, it is the standard query used in the api of Omeka, or the arguments taken from the url of an advanced search, converted into an array with parse_str. The conversion is automatically done inside the user interface (page blocks).

Api to get references and facets

To get the results via api, use a standard query and append the options you need, for example /api/references?metadata[subjects]=dcterms:subject to get the list of all subjects, or /api/references?metadata[people]=foaf:Person to get the list of all resources with class "Person". You can add multiple metadata together: /api/references?medatadata[subjects]=dcterms:subject&medatadata[creators]=dcterms:creator You can use the special metadata o:title too, but some options won't be available for it since it is managed differently inside Omeka. The metadata can be a property term, or o:item_set, o:resource_class, and o:resource_template too. If no metadata is set, you will get the totals of references for properties.

The query from the url can be simplified with text=my-text in most of the cases, so the references are filtered by this text in any property. If one or multiple fields are specified, the references are returned for these fields. The fields can be a comma separated list of an array, for example: /api/references?text=example&metadata[subjects]=dcterms:subject allows to get all references for the specified text in the specified field.

To get the facets for the search result page, you can use this query: /api/references?text=xxx&site_id=1&option[resource_name]=items&option[sort_by]=total&option[sort_order]=desc&option[filters][languages][]=fra&option[filters][languages][]=null&option[filters][languages]=&option[lang]=1&metadata[subjects]=dcterms:subject Note: if you use the filters for the language, it may be needed to add an empty language &option[filters][languages][]=null or, for string format, &option[filters][languages]=fra,null because many metadata have no language (date, names, etc.). The empty language can be an empty string too (deprecated).

To get more information about results, in particular the list of resources associated to each reference (list_by_max), use options. Options can be appended to the query. If you don't want to mix them, you can use the keys query and option.

Options are the same than the view helper:

A standard resource query can be appended to the query. The property argument supports some more types for the properties: sw/nsw for "starts with" or not, ew/new for "ends with" or not, in/nin for "in list" or not, res/nres for "has resource" or not.

Don't confuse the filters and the query: the query limits the resource to search, generally a site or an item set, and the filters limits the returned list of references.

For the filters and the metadata, they can be written in various ways to simplify url request, for example:

To get results for aggregated metadata, use an array for the fields:

Important: The response is for all sites by default. Add argument site_id={##} or site_slug={slug} to get data for a site.

Note about linked resources

When you want to fetch all datatypes, the data types resource, resource:item, resource:itemset, etc. are returned. It is recommended to replace all types resource by the specific one in order to clarify the results. The modules Bulk Edit or Bulk Check allows to do it automatically.

TODO

Warning

Use it at your own risk.

It’s always recommended to backup your files and your databases and to check your archives regularly so you can roll back if needed.

Troubleshooting

See online issues on the module issues page on GitLab.

License

This module is published under the CeCILL v2.1 license, compatible with GNU/GPL and approved by FSF and OSI.

In consideration of access to the source code and the rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software’s author, the holder of the economic rights, and the successive licensors only have limited liability.

In this respect, the risks associated with loading, using, modifying and/or developing or reproducing the software by the user are brought to the user’s attention, given its Free Software status, which may make it complicated to use, with the result that its use is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the suitability of the software as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions of security. This Agreement may be freely reproduced and published, provided it is not altered, and that no provisions are either added or removed herefrom.

The module uses a jQuery library for the tree view, released under the MIT licence.

Copyright

This module is inspired from earlier work done by William Mayo (see pobocks on GitLab) in Subject Browse, with some ideas from Metadata Browser and Category Browse, that have been upgraded for Omeka 2.x too (Subject Browse (2.x), Metadata Browser (2.x), and Category Browse (2.x)). They are no longer maintained. Upgrade and improvements were made for Jane Addams Digital Edition. Performance fixes were made for Article 19.