hyrax-doi 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12db48742cfe4714f719f444954e9cfdf217a6ad9e66edc941a19043ebfc68c6
|
4
|
+
data.tar.gz: 1a3a56a08ec0c8f41217133e810bb307e690eb78cdc122a6871ca1d068bbc13e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40c3448c22706056a7d385fe078ce0f4257baed5eab6acb664b7b2ce7d10c3d05c45c9fe15925e8c675fdfe357fb5b318cd120b3621fb6759f9c4b994122f5ce
|
7
|
+
data.tar.gz: ee71b4f0ba50177bddf6c96698dad279b52fac0b71bb11d37c0f967157170ad09f36f681c3f4c494e93357f4cb99329b706988f6a336eebc5215824941b1b666
|
data/README.md
CHANGED
@@ -10,6 +10,27 @@ Jump in: [![Slack Status](http://slack.samvera.org/badge.svg)](http://slack.samv
|
|
10
10
|
|
11
11
|
Hyrax-doi is a Hyrax plugin that provides tools for working with DOIs including model attributes, minting, and fetching descriptive metadata.
|
12
12
|
|
13
|
+
## Features
|
14
|
+
### DOI Creation and Updating
|
15
|
+
DOIs are created and updated when a work of a DOI-enabled work type is saved. This happens in a background job using the [external identifier interface](https://github.com/samvera/hyrax/pull/4458) provided by Hyrax.
|
16
|
+
|
17
|
+
>Note: At this point only functionality for registering DOIs wtih DataCite is implemented but other registrars should be also be possible.
|
18
|
+
|
19
|
+
#### Draft DOI Creation (DataCite)
|
20
|
+
The deposit form has a button for creating a draft DOI without requiring submitting the form. This is useful if you need to know the DOI and embed it in the uploaded file(s).
|
21
|
+
|
22
|
+
#### DOI Status Support (DataCite)
|
23
|
+
The uploader is allowed to choose the DOI status (draft, registered, findable) they want for the work when it becomes public. If findable is chosen the DOI will remain as registered until the work become public.
|
24
|
+
|
25
|
+
#### Form Validation (DataCite)
|
26
|
+
Hyrax-doi will provide defaults or placeholders for fields which Hyrax doesn't require but which are mandatory for DataCite. In this case the uploader will be notified of the missing fields and given the opportunity of filling them in before submittign or of continuing with the defaults.
|
27
|
+
|
28
|
+
### Form autofilling
|
29
|
+
When submitting a work with an existing DOI (like a scholarly article), the uploader can fill in the DOI and click a button to autofill the deposit form with metadata from the DOI. This is not limited to DataCite and works with DOIs from a variety of registrars (DataCite, CrossRef, JaLC, ISTIC, , etc.)
|
30
|
+
|
31
|
+
### Metadata Crosswalking
|
32
|
+
DOI submission and form autofilling happens by crosswalking the work's metadata with DataCite's schema through the [bolognese gem](https://github.com/datacite/bolognese) which enables crosswalking with a number of metadata formats besides those required by DOI registars including RIS, BibTeX, Crosscite, and Schema.org.
|
33
|
+
|
13
34
|
## Compatibilty
|
14
35
|
Hyrax-doi is compatible with Hyrax 2.9+ and tested with a [Hyrax 2.9.0 test application](https://github.com/ubiquitypress/hyrax_test_app) that mirrors the generated app used by Hyrax internally for testing.
|
15
36
|
|
@@ -25,21 +46,49 @@ And then execute:
|
|
25
46
|
$ bundle
|
26
47
|
```
|
27
48
|
|
28
|
-
|
29
|
-
```
|
30
|
-
|
49
|
+
Then run the install generator
|
50
|
+
```
|
51
|
+
rails g hyrax:doi:install
|
52
|
+
```
|
53
|
+
Use the `--datacite` flag if working with DataCite DOIs:
|
54
|
+
```
|
55
|
+
rails g hyrax:doi:install --datacite
|
31
56
|
```
|
32
57
|
|
33
58
|
## Usage
|
34
59
|
|
35
|
-
###
|
60
|
+
### Enable DOI functionality for a work type
|
36
61
|
Run the generator to add DOI support to a given work type:
|
37
62
|
```
|
38
63
|
rails g hyrax:doi:add_to_work_type MyWorkType
|
39
64
|
```
|
65
|
+
Add the `--datacite` flag if creating DataCite DOIs:
|
66
|
+
```
|
67
|
+
rails g hyrax:doi:add_to_work_type MyWorkType --datacite
|
68
|
+
```
|
69
|
+
|
70
|
+
### Configuration
|
71
|
+
After the install generator is run, Hyrax-doi can be configured in the `config/initializers/hyrax-doi.rb` initializer.
|
72
|
+
|
73
|
+
If your application does not already set `host` in `default_url_options`, you will need to configure it for creating full urls to work show pages to be registered with DOIs.
|
74
|
+
|
75
|
+
DataCite credentials can either be set in environment variables (DATACITE_PREFIX, DATACITE_USERNAME, and DATACITE_PASSWORD) or set in the initializer. Hyrax-doi defaults to using DataCite's test environment but can be switched to the production environment by setting the mode:
|
76
|
+
```
|
77
|
+
Hyrax::DOI::DataCiteRegistrar.mode = :production
|
78
|
+
```
|
79
|
+
|
80
|
+
### Using with Hyku
|
81
|
+
Hyrax-doi is currently implemented for a single-tenant Hyrax application with configuration shared application wide. Work to support per tenant configuration is under way and will live in its own engine or be contributed directly to Hyku.
|
40
82
|
|
41
83
|
## Development
|
42
84
|
|
85
|
+
### Setting up Development Environment
|
86
|
+
After checking out the code, initialize the internal hyrax test application:
|
87
|
+
```
|
88
|
+
git submodule init
|
89
|
+
git submodule update
|
90
|
+
```
|
91
|
+
|
43
92
|
### Running Rake Tasks and Generators
|
44
93
|
When working on this engine rake tasks from Hyku can be run by prepending the `app` namespace (e.g. `rake app:db:migrate`). Generators provided by rails or other gems/engines can be run like normal from this engine's root (e.g. `rails g job UbiquityExporter`).
|
45
94
|
|
@@ -74,11 +74,10 @@ module Bolognese
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def read_hyrax_work_publication_year(meta)
|
77
|
-
# FIXME: better parsing of free text dates...maybe using EDTF?
|
78
77
|
date = meta.fetch("date_created", nil)&.first
|
79
78
|
date ||= meta.fetch("date_uploaded", nil)
|
80
|
-
Date.
|
81
|
-
rescue
|
79
|
+
Date.edtf(date.to_s).year
|
80
|
+
rescue StandardError
|
82
81
|
Time.zone.today.year
|
83
82
|
end
|
84
83
|
|
@@ -92,6 +91,7 @@ module Bolognese
|
|
92
91
|
|
93
92
|
def read_hyrax_work_publisher(meta)
|
94
93
|
# Fallback to ':unav' since this is a required field for datacite
|
94
|
+
# TODO: Should this default to application_name?
|
95
95
|
parse_attributes(meta.fetch("publisher")).to_s.strip.presence || ":unav"
|
96
96
|
end
|
97
97
|
end
|
@@ -18,7 +18,7 @@ module Bolognese
|
|
18
18
|
'contributor' => contributors&.pluck("name"),
|
19
19
|
'publisher' => Array(publisher),
|
20
20
|
'date_created' => Array(publication_year),
|
21
|
-
'description' =>
|
21
|
+
'description' => build_hyrax_work_description,
|
22
22
|
'keyword' => subjects&.pluck("subject")
|
23
23
|
}
|
24
24
|
hyrax_work_class = determine_hyrax_work_class
|
@@ -45,6 +45,11 @@ module Bolognese
|
|
45
45
|
def build_hyrax_work_doi
|
46
46
|
Array(doi&.sub('https://doi.org/', ''))
|
47
47
|
end
|
48
|
+
|
49
|
+
def build_hyrax_work_description
|
50
|
+
return nil if descriptions.blank?
|
51
|
+
descriptions.pluck("description").map { |d| Array(d).join("\n") }
|
52
|
+
end
|
48
53
|
end
|
49
54
|
end
|
50
55
|
end
|
@@ -1,20 +1,31 @@
|
|
1
|
+
<%# TODO: determine these from actual DataCite data instead of the intention field stored in fedora %>
|
2
|
+
<% disable_do_not_mint = @curation_concern.doi_status_when_public != nil %>
|
3
|
+
<% disable_draft = @curation_concern.doi_status_when_public.in?(['registered','findable']) %>
|
4
|
+
|
1
5
|
<div>
|
2
|
-
<%#
|
3
|
-
<%=
|
6
|
+
<%# Render DOI input as a single field even though it is stored as multivalued %>
|
7
|
+
<%= f.input :doi, input_html: { value: @curation_concern.doi.first,
|
8
|
+
name: "#{f.object.model_name.param_key}[doi][]",
|
9
|
+
style: "max-width: 40em" } %>
|
4
10
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
<%# Only show an actionable button if the work doesn't have a DOI already %>
|
12
|
+
<% if @curation_concern.doi.blank? %>
|
13
|
+
<%= link_to "Create draft DOI",
|
14
|
+
Hyrax::DOI::Engine.routes.url_helpers.create_draft_doi_path,
|
15
|
+
remote: true,
|
16
|
+
method: :get,
|
17
|
+
data: {
|
18
|
+
disable_with: "Creating draft DOI...",
|
19
|
+
params: {
|
20
|
+
curation_concern: @curation_concern.class.name.underscore,
|
21
|
+
attribute: 'doi'
|
22
|
+
}
|
23
|
+
},
|
24
|
+
class: 'btn btn-default',
|
25
|
+
id: 'doi-create-draft-btn' %>
|
26
|
+
<% else %>
|
27
|
+
<div id='doi-create-draft-btn' class='btn btn-default' disabled>Create draft DOI</div>
|
28
|
+
<% end %>
|
18
29
|
|
19
30
|
<%= link_to "Autofill form",
|
20
31
|
Hyrax::DOI::Engine.routes.url_helpers.autofill_path,
|
@@ -35,11 +46,11 @@
|
|
35
46
|
|
36
47
|
<div class="form-group" style="margin-left: 20px">
|
37
48
|
<label class="radio" style="font-weight: normal">
|
38
|
-
<%= f.radio_button :doi_status_when_public, '', style: 'margin-top: 0px;' %>
|
49
|
+
<%= f.radio_button :doi_status_when_public, '', disabled: disable_do_not_mint, style: 'margin-top: 0px;' %>
|
39
50
|
Do not mint
|
40
51
|
</label>
|
41
52
|
<label class="radio" style="font-weight: normal">
|
42
|
-
<%= f.radio_button :doi_status_when_public, 'draft', style: 'margin-top: 0px;' %>
|
53
|
+
<%= f.radio_button :doi_status_when_public, 'draft', disabled: disable_draft, style: 'margin-top: 0px;' %>
|
43
54
|
Draft
|
44
55
|
</label>
|
45
56
|
<label class="radio" style="font-weight: normal">
|
@@ -70,4 +81,29 @@
|
|
70
81
|
$("#doi-autofill-btn").on("ajax:error", function(e, xhr, status, error) {
|
71
82
|
alert(xhr.responseText);
|
72
83
|
});
|
84
|
+
|
85
|
+
// Force the user to confirm using fallback defaults when DataCite mandatory fields
|
86
|
+
// not filled in on the deposit form. This only applies when the DOI is set to become
|
87
|
+
// registered or findable. Let drafts be drafts.
|
88
|
+
document.getElementById('with_files_submit').addEventListener("click", function(event){
|
89
|
+
if (["findable", "registered"].indexOf(document.querySelector('input[name="generic_work[doi_status_when_public]"]:checked').value) < 0)
|
90
|
+
return;
|
91
|
+
|
92
|
+
const empty_fields = [];
|
93
|
+
if (document.querySelector('.generic_work_title .form-control').value == "")
|
94
|
+
empty_fields.push("Title")
|
95
|
+
if (document.querySelector('.generic_work_creator .form-control').value == "")
|
96
|
+
empty_fields.push("Creator")
|
97
|
+
if (document.querySelector('.generic_work_publisher .form-control').value == "")
|
98
|
+
empty_fields.push("Publisher")
|
99
|
+
if (document.querySelector('.generic_work_date_created .form-control').value == "")
|
100
|
+
empty_fields.push("Date Created")
|
101
|
+
if (empty_fields.length == 0)
|
102
|
+
return;
|
103
|
+
|
104
|
+
if(!window.confirm("DataCite DOI mandatory fields ("+ empty_fields.join(', ') +") are missing. Placeholder values will be submitted to DataCite instead. Do you want to proceed?")){
|
105
|
+
event.preventDefault();
|
106
|
+
event.stopImmediatePropagation();
|
107
|
+
}
|
108
|
+
}, false);
|
73
109
|
</script>
|
data/lib/hyrax/doi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyrax-doi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Colvard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|