Skip to content

Commit

Permalink
Merge pull request #18 from GetDKAN/composer-restore
Browse files Browse the repository at this point in the history
Refactor dependencies
  • Loading branch information
janette authored Feb 25, 2020
2 parents 5760baa + 8c26efc commit 891e5b0
Show file tree
Hide file tree
Showing 762 changed files with 1,417 additions and 101,037 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# About this module
# DKAN Science Metadata

This module adds Science Metadata related paragraph bundles to the DKAN dataset content type, and Dkan Sci Search index logic.

## Metadata Paragraph Bundles
- Science Author: Includes Author ID, Author ID Type (ORCID, Google Scholar, ResearcherID, Scopus Author ID, USDA), Author Name, and Is Organization fields. Validates ORCID IDs and retrieve biography information to populate name field.
More documentation coming soon...

## Submodules
### DKAN Sci search (modules/dkan_sci_search)
- Provides solr index that allows for file attachment indexing. At present, the metadata source content type is the only node type
having files indexed. These attachments are associated with dataset content nodes via entityreferences.

### DKAN Sci Author (modules/dkan_sci_author)

- Provides a child paragraph bundle for adding authors. Includes Author ID, Author ID Type (ORCID, Google Scholar, ResearcherID, Scopus Author ID, USDA), Author Name, and Is Organization fields. Validates ORCID IDs and retrieve biography information to populate name field. ORCID IDs

### DKAN Sci Citation (modules/dkan_sci_citation)

- Support for DOI-based citations. Adds a citation bundle that allows adding via either a free text field or a DOI. If DOI is used, the full citation is retrieved from CrossRef and displayed properly on the dataset page. See module README for details.

This module is the result of a joint partnership between [CivicActions](https://civicactions.com) and the [US Department of Agriculture](https://usda.gov), as part of the development of the [Ag Data Commons](https://data.nal.usda.gov/).
7 changes: 0 additions & 7 deletions autoload.php

This file was deleted.

96 changes: 0 additions & 96 deletions circle.yml

This file was deleted.

1 change: 0 additions & 1 deletion composer.json

This file was deleted.

67 changes: 0 additions & 67 deletions dkan-module-init.sh

This file was deleted.

1 change: 0 additions & 1 deletion dkan_sci_metadata.info
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies[] = paragraphs_defaults
dependencies[] = strongarm
dependencies[] = taxonomy
dependencies[] = text
dependencies[] = usda_content_types
features[ctools][] = field_group:field_group:1
features[ctools][] = strongarm:strongarm:1
features[features_api][] = api:2
Expand Down
47 changes: 47 additions & 0 deletions dkan_sci_metadata.module
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,50 @@ function dkan_sci_metadata_field_formatter_view($entity_type, $entity, $field, $
}
return $element;
}

function dkan_sci_metadata_preprocess_node(&$variables) {
// Grab our citation paragraphs, and place in the main node table.
if ($variables['type'] === 'dataset' && $variables['view_mode'] === 'full') {
dkan_sci_metadata_metadata_table($variables);
}
}

function dkan_sci_metadata_metadata_table(&$variables) {
if (!empty($variables['content']['field_metadata_extended']['#items'])) {
foreach($variables['content']['field_metadata_extended']['#items'] as $delta => $field_metadata_extended_item) {
// Load what we assume to be the main science metadata item, and make
// sure it's the right bundle.
$extended_metadata = paragraphs_item_load($field_metadata_extended_item['value']);
// Get our list of science fields and sort according to display.
$metadata_fields = array();
foreach(field_info_instances('paragraphs_item', $extended_metadata->bundle) as $field) {
$metadata_fields[$field['display']['default']['weight']] = $field;
}
ksort($metadata_fields);
$rows = array();
foreach($metadata_fields as $field_info) {
dkan_sci_metadata_table_add_field($rows, $field_info, $extended_metadata);
}
// Replace the whole extended metadata field with our table.
$field_instance = field_info_instance('node', 'field_metadata_extended', 'dataset');
$extended_metadata_table = array(
'#theme' => 'table',
'#header' => array(t('Field'), t('Value')),
'#rows' => $rows,
'#weight' => $field_instance['display']['default']['weight'],
'#attributes' => array('class' => array('extended-metadata')),
);
$variables['content']['field_metadata_extended'][$delta]['entity']['paragraphs_item'][$extended_metadata->item_id] = $extended_metadata_table;
}
}
}

function dkan_sci_metadata_table_add_field(&$rows, $field_info, $extended_metadata) {
if (!empty($extended_metadata->{$field_info['field_name']})) {
$row_value = field_view_field('paragraphs_item', $extended_metadata, $field_info['field_name'], 'full');
$row = array();
$row[] = array('data' => $field_info['label'], 'class' => array('field-label'));
$row[] = array('data' => $row_value, 'class' => array('field-content'));
$rows[] = $row;
}
}
1 change: 1 addition & 0 deletions modules/dkan_sci_citation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
includes/vendor
26 changes: 24 additions & 2 deletions modules/dkan_sci_citation/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# DKAN Science Citations

Add citations via DOI, Bibtex or free text.

## Installation

You must install some dependencies with [Composer](https://getcomposer.org/) for this module to work. Please run

```
composer install
```

from the dkan_sci_citation root folder (probably _sites/all/modules/contrib/dkan_sci_metadata/modules/dkan_sci_citation_ in your site docroot) before using.

## Adding additional styles
- Add item name as indicated by `.csl` file to form options array in `dkan_sci_citation_form()`
- Add `.csl` file to `./includes/vendor/citation-style-language/styles-distribution`

This module supports citation rendering in many common styles. We are working on a better way to change the list of available styles, but currently we recommend:

- Create a fork of https://github.com/citation-style-language/styles-distribution.git
- Remove all csl files except the ones you want to use
- Update this module's composer.json to pull the styles-distribution library from your fork.

## Attribution

The citation styling tools used in this module come from [CitationStyles.org](http://citationstyles.org/).
39 changes: 39 additions & 0 deletions modules/dkan_sci_citation/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"require": {
"audiolabs/bibtexparser": "dev-master",
"citation-style-language/locales": "1.*",
"citation-style-language/styles-distribution": "1.*",
"renanbr/crossref-client": "dev-master",
"seboettg/citeproc-php": "2.1.1",
"topfloor/composer-cleanup-vcs-dirs": "^1.0"
},
"repositories": [
{
"type": "package",
"package": {
"version": "1.0.0",
"name": "citation-style-language/locales",
"source": {
"url": "https://github.com/citation-style-language/locales.git",
"type": "git",
"reference": "master"
}
}
},
{
"type": "package",
"package": {
"version": "1.0.0",
"name": "citation-style-language/styles-distribution",
"source": {
"url": "https://github.com/getdkan/styles-distribution.git",
"type": "git",
"reference": "dkan-sci"
}
}
}
],
"config": {
"vendor-dir": "includes/vendor"
}
}
Loading

0 comments on commit 891e5b0

Please sign in to comment.