zizia 4.5.4.alpha.01 → 4.6.0.alpha.01

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -9
  3. data/app/assets/stylesheets/zizia/_field_guide.scss +10 -0
  4. data/app/assets/stylesheets/zizia/zizia.scss +1 -0
  5. data/app/config/zizia/usage.yml +39 -0
  6. data/app/controllers/zizia/csv_import_details_controller.rb +3 -0
  7. data/app/controllers/zizia/metadata_details_controller.rb +3 -0
  8. data/app/helpers/zizia/metadata_details_helper.rb +22 -0
  9. data/app/lib/zizia/metadata_details.rb +45 -13
  10. data/app/lib/zizia/metadata_usage.rb +3 -3
  11. data/app/views/zizia/metadata_details/show.html.erb +21 -10
  12. data/lib/zizia/version.rb +1 -1
  13. data/spec/controllers/metadata_details_spec.rb +18 -2
  14. data/spec/dummy/app/assets/stylesheets/application.css +1 -0
  15. data/spec/dummy/app/models/ability.rb +2 -0
  16. data/spec/dummy/public/assets/.sprockets-manifest-6a791b26afc0064d45ad6c9c7834c971.json +1 -1
  17. data/spec/dummy/public/assets/application-2ccde71ce94afc831e097399d88f233e622dcde6c13b1e55328492cbd74652e1.css +20020 -0
  18. data/spec/dummy/public/assets/application-2ccde71ce94afc831e097399d88f233e622dcde6c13b1e55328492cbd74652e1.css.gz +0 -0
  19. data/spec/dummy/public/assets/application-c2d24435e1dfeb4513665fe5fcf77c4d82a771af39242801a0de2c9d11420110.css +20026 -0
  20. data/spec/dummy/public/assets/application-c2d24435e1dfeb4513665fe5fcf77c4d82a771af39242801a0de2c9d11420110.css.gz +0 -0
  21. data/spec/dummy/public/assets/application-cd56066ec179de033c8cb72c47bce15d0bb303f8ae84e40b1f9bb458c69f1984.js +91589 -0
  22. data/spec/dummy/public/assets/application-cd56066ec179de033c8cb72c47bce15d0bb303f8ae84e40b1f9bb458c69f1984.js.gz +0 -0
  23. data/spec/dummy/public/assets/browse_everything-9a6b1be24c1637c3d3f401209ba92f08bdfb31283b7535e3fc00767f7fd33f30.css +12766 -0
  24. data/spec/dummy/public/assets/browse_everything-9a6b1be24c1637c3d3f401209ba92f08bdfb31283b7535e3fc00767f7fd33f30.css.gz +0 -0
  25. data/spec/dummy/public/assets/zizia/application-1a6b5ed6492ec1d1f55182cb261f6a41ca34efc8f0718afdb8c69691de071e87.css +60 -0
  26. data/spec/dummy/public/assets/zizia/application-1a6b5ed6492ec1d1f55182cb261f6a41ca34efc8f0718afdb8c69691de071e87.css.gz +0 -0
  27. data/spec/dummy/public/assets/zizia/application-a0041cb295da9e33e213c36cdb7974af70df2bdf636cdca13f10122ac35a78ec.css +54 -0
  28. data/spec/dummy/public/assets/zizia/application-a0041cb295da9e33e213c36cdb7974af70df2bdf636cdca13f10122ac35a78ec.css.gz +0 -0
  29. data/spec/dummy/spec/system/csv_import_details_page_spec.rb +18 -1
  30. data/spec/dummy/spec/system/import_from_csv_spec.rb +1 -2
  31. data/spec/dummy/spec/system/metadata_details_page_spec.rb +16 -2
  32. metadata +17 -4
  33. data/app/config/usage.yml +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cda0b48e918b9f663e1cbdc458b425bf597825c3ef52b524ce148013c89fc6c
4
- data.tar.gz: c8d37b6d969ac9dfc70ca683f3c02ecda50e1957eb724eed113a93627e2979f5
3
+ metadata.gz: e474d50c1f6b1d4e15cc79ef9546a5f747c61e03cd6d85426ce6580c8c019f22
4
+ data.tar.gz: f9da12668c3657384042f5e202814094720ec63b22608d1165fa08c306d633e5
5
5
  SHA512:
6
- metadata.gz: 4db9363bed73c42c1ca18da5222ed3af388b3db5a5cde376b72b580963acdb1ccfa62ba840d0e247584cf83a3b8e880b82e38f83cc4658d572cb0b1cd03de7f8
7
- data.tar.gz: b734026aa43137f6b24a657884b7d945eb4f69930ef96dcf1e20dea4e4dce7663c062a2bfb9a800764047deae9b2349cbdfa1943d7986e3c38461e991837bba0
6
+ metadata.gz: 9d602fbc263f0bc0dd8d231c93c6897e275ee195c2e19f00287c7d83af05810aac2f46551de43b21cc20f6f9918cfa826bafafce3fe175f371296284940d7fc9
7
+ data.tar.gz: 5b3ff29ac96a0cc5c1f820fa4c6cb184dc4c78f07f11fc078309e2b01258a197ae84d77b75cd07ca5a1a4b6febae356b312971c532a2d486cd6da71c84ab9602
data/README.md CHANGED
@@ -78,15 +78,7 @@ helper Zizia::Engine.helpers
78
78
  can :manage, Zizia::CsvImport if current_user.admin?
79
79
  ```
80
80
 
81
- 4. Add documentation and sample csv files to your project at
82
-
83
- `app/assets/csv/import_manifest.csv`
84
-
85
- and
86
-
87
- `app/assets/markdown/importer_guide.md`
88
-
89
- 5. Add links to `/csv_imports/new` and `/importer_documentation/csv` in the Hyrax dashboard
81
+ 4. Add links to `/csv_imports/new` and `/importer_documentation/csv` in the Hyrax dashboard
90
82
 
91
83
  The `spec/dummy` folder in this application is a complete Hyrax application with Zizia installed.
92
84
  You can use that as an example for adding this to your current Hyrax application or copy that
@@ -0,0 +1,10 @@
1
+ .system-field { display: none; }
2
+ .field-guide-intro {
3
+ margin-top: 1em;
4
+ margin-bottom: 1em;
5
+ font-size: large;
6
+ }
7
+ .delimiter {
8
+ font-weight: 800;
9
+ font-family: monospace;
10
+ }
@@ -1,4 +1,5 @@
1
1
  @import 'file_upload';
2
+ @import 'field_guide';
2
3
 
3
4
  .btn {
4
5
  white-space:normal !important;
@@ -0,0 +1,39 @@
1
+ ---
2
+ # Metadata usage hints
3
+ # attribute: usage
4
+
5
+ arkivo_checksum: "-- system field - not directly editable --"
6
+ based_near: "A place name related to the work, such as its site of publication, or the city, state, or country the work contents are about. This field is a URI. The URIs should be GeoNames identifiers. You can look these up at GeoNames (http://www.geonames.org/). Example: http://www.geonames.org/4500546/"
7
+ bibliographic_citation: "Used to store the preferred bibliographic citation."
8
+ contributor: "A person or group you want to recognize for playing a role in the creation of the work, but not the primary role. Example: Smith, Mary"
9
+ create_date: "-- system field - not directly editable --"
10
+ creator: "The person or group responsible for the work. Usually this is the author, artist, or other person or people responsible for creating the content. Example: Leffler, Warren K., photographer."
11
+ date_created: "The date the work was created. Typically entered using ISO 8601 format; however, and local convention can be supported. Example: 1964-08-21 (also '1964', 'Aug. 22 '64', '19th C.' or '8/22/1964') NOTE: the system treats this field as a string and does not attempt to interpret the value entered."
12
+ date_modified: "-- system field - not directly editable --"
13
+ date_uploaded: "-- system field - not directly editable --"
14
+ depositor: "-- system field - not directly editable --"
15
+ description: "Free-text notes about the work, such as abstracts of a paper or citation information for a journal article. Example: Photograph shows half-length portrait of Hamer seated at a table."
16
+ has_model: "-- system field - not directly editable --"
17
+ head: "-- system field - not directly editable --"
18
+ identifier: "A unique handle identifying the work. An example would be a DOI for a journal article, or an ISBN or OCLC number for a book. Example: LC-U9-12470B-17"
19
+ import_url: "-- system field - not directly editable --"
20
+ keywords: "Words or phrases you select to describe what the work is about. Example: New Orleans or Music "
21
+ label: "-- system field - not directly editable --"
22
+ language: "The language of the source content being described. Example: English"
23
+ license: "Licensing and distribution information governing access to the work. This field is a URI. You can choose rights statements from this vocabulary (https://github.com/curationexperts/tenejo/blob/master/config/authorities/licenses.yml). Example: http://creativecommons.org/licenses/by/3.0/us/"
24
+ modified_date: "-- system field - not directly editable --"
25
+ on_behalf_of: "-- system field - not directly editable --"
26
+ owner: "-- system field - not directly editable --"
27
+ proxy_depositor: "-- system field - not directly editable --"
28
+ publisher: "The person or group making the work available. Generally this is the institution. Example: Library of Congress"
29
+ related_url: "A link to a website or other specific content (audio, video, PDF document) related to the work such as the URL of a research project from which the work was derived. Example: https://www.loc.gov/free-to-use/african-american-women-changemakers/"
30
+ relative_path: "-- system field - not directly editable --"
31
+ resource_type: "Pre-defined categories to describe the type of content. You must choose from one of the types listed here (https://github.com/curationexperts/tenejo/blob/master/config/authorities/resource_types.yml) Examples: Image, Article, or Dataset"
32
+ rights_statement: "This field is a URI. You can choose rights statements from this vocabulary (https://github.com/curationexperts/tenejo/blob/master/config/authorities/rights_statements.yml). Example: http://rightsstatements.org/vocab/UND/1.0/"
33
+ source: "A related resource from which the described resource is derived. Example: Library of Congress Online Catalog (976,247)"
34
+ state: "-- system field - not directly editable --"
35
+ subject: "Headings or index terms describing what the work is about. These should conform to an existing vocabulary, like LCSH. Example: Hamer, Fannie Lou--Public appearances--New Jersey--Atlantic City."
36
+ tail: "-- system field - not directly editable --"
37
+ title: "A name to aid in identifying a work. Example: [Fannie Lou Hamer, Mississippi Freedom Democratic Party delegate, at the Democratic National Convention, Atlantic City, New Jersey, August 1964] / [WKL]."
38
+ visibility: "The desired visiblity setting for the work and it's files. You can use 'open', 'registered', or 'restricted'. Example: 'open'"
39
+ files: "The file(s) you want to attach to your work. Must match the filenames you have uploaded to the server. Example: 01267_150px.jpg. You can attach multiple files to a work by providing multiple filenames separated by the separator configured for your application."
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
  module Zizia
3
3
  class CsvImportDetailsController < ApplicationController
4
+ load_and_authorize_resource
5
+ with_themed_layout 'dashboard'
6
+
4
7
  def index
5
8
  @csv_import_details = Zizia::CsvImportDetail.order(:id).page csv_import_detail_params[:page]
6
9
  end
@@ -4,6 +4,9 @@ module Zizia
4
4
  def show
5
5
  @details = MetadataDetails.instance.details(work_attributes:
6
6
  WorkAttributes.instance)
7
+
8
+ @delimiter = Zizia::HyraxBasicMetadataMapper.new.delimiter
9
+
7
10
  respond_to do |format|
8
11
  format.html
9
12
  format.json { render json: @details.to_json }
@@ -5,5 +5,27 @@ module Zizia
5
5
  return 'missing' if value == 'not configured'
6
6
  return 'missing' if value.match?(/translation missing/)
7
7
  end
8
+
9
+ def system_field(detail)
10
+ return "" if detail.nil?
11
+ return "non-system-field" unless detail[:usage]
12
+ return "system-field" if detail[:usage].match?("system field")
13
+ "non-system-field"
14
+ end
15
+
16
+ def hide_system_field(detail)
17
+ return "" if detail.nil?
18
+ return "" unless detail[:usage]
19
+ # rubocop: disable Rails/OutputSafety
20
+ return "style='display: none'".html_safe if detail[:usage].match?("system field")
21
+ # rubocop: enable Rails/OutputSafety
22
+ ""
23
+ end
24
+
25
+ def true_false_to_yes_no(value)
26
+ return "" if value.nil?
27
+ return "yes" if value == "true"
28
+ "no"
29
+ end
8
30
  end
9
31
  end
@@ -7,19 +7,9 @@ module Zizia
7
7
 
8
8
  def details(work_attributes:)
9
9
  validators = work_attributes.validators
10
- work_attributes.properties.sort.map do |p|
11
- Hash[
12
- attribute: p[0],
13
- predicate: p[1].predicate.to_s,
14
- multiple: p[1].try(:multiple?).to_s,
15
- type: type_to_s(p[1].type),
16
- validator: validator_to_string(validator: validators[p[0].to_sym][0]),
17
- label: I18n.t("simple_form.labels.defaults.#{p[0]}"),
18
- csv_header: csv_header(p[0]),
19
- required_on_form: required_on_form_to_s(p[0]),
20
- usage: MetadataUsage.instance.usage[p[0]]
21
- ]
22
- end
10
+ detail_list = work_attributes.properties.sort.map { |p| definition_hash_for(p, validators) }
11
+ detail_list << visibility_definition
12
+ detail_list << file_definition
23
13
  end
24
14
 
25
15
  def to_csv(work_attributes:)
@@ -64,5 +54,47 @@ module Zizia
64
54
  'No validation present in the model.'
65
55
  end
66
56
  end
57
+
58
+ def definition_hash_for(field_properties, validators)
59
+ Hash[
60
+ attribute: field_properties[0],
61
+ predicate: field_properties[1].predicate.to_s,
62
+ multiple: field_properties[1].try(:multiple?).to_s,
63
+ type: type_to_s(field_properties[1].type),
64
+ validator: validator_to_string(validator: validators[field_properties[0].to_sym][0]),
65
+ label: I18n.t("simple_form.labels.defaults.#{field_properties[0]}"),
66
+ csv_header: csv_header(field_properties[0]),
67
+ required_on_form: required_on_form_to_s(field_properties[0]),
68
+ usage: MetadataUsage.instance.usage[field_properties[0]]
69
+ ]
70
+ end
71
+
72
+ def file_definition
73
+ {
74
+ attribute: 'files',
75
+ predicate: 'n/a',
76
+ multiple: 'true',
77
+ type: 'String',
78
+ validator: 'Required, must name a file on the server',
79
+ label: 'Items (listed at bottom of page)',
80
+ csv_header: 'files',
81
+ required_on_form: 'true',
82
+ usage: MetadataUsage.instance.usage['files']
83
+ }
84
+ end
85
+
86
+ def visibility_definition
87
+ {
88
+ attribute: 'visibility',
89
+ predicate: 'n/a',
90
+ multiple: 'false',
91
+ type: 'String',
92
+ validator: 'Required, must exist in the application\'s controlled vocabulary for visiblity levels.',
93
+ label: 'Visibility',
94
+ csv_header: 'visibility',
95
+ required_on_form: 'true',
96
+ usage: MetadataUsage.instance.usage['visibility']
97
+ }
98
+ end
67
99
  end
68
100
  end
@@ -11,12 +11,12 @@ module Zizia
11
11
  private
12
12
 
13
13
  def default_location
14
- File.join(File.dirname(__FILE__), '../../config/usage.yml')
14
+ File.join(File.dirname(__FILE__), '../../config/zizia/usage.yml')
15
15
  end
16
16
 
17
17
  def config
18
- return default_location unless File.exist?(Rails.root.join("config", "usage.yml"))
19
- Rails.root.join("config", "usage.yml")
18
+ return default_location unless File.exist?(Rails.root.join("config", "zizia", "usage.yml"))
19
+ Rails.root.join("config", "zizia", "usage.yml")
20
20
  end
21
21
  end
22
22
  end
@@ -1,14 +1,25 @@
1
+ <h2>Metadata Field Guide</h2>
2
+ <div class="field-guide-intro">
3
+ <p>
4
+ This is a dynamically generated guide to the metadata used in this application.
5
+ Many fields are multi-valued. To include multiple values in a single CSV cell,
6
+ separate them with the delimiter that has been configured for this application:
7
+ <span class="delimiter"><%= @delimiter %></span>
8
+ </p>
9
+ <p>
10
+ Example: <span class="delimiter">Value 1<%= @delimiter %>Value 2</span>
11
+ </p>
12
+ </div>
13
+
1
14
  <% content_for :title, 'Importer Field Guide' %>
2
15
  <div class="guide-container">
3
16
  <a class="btn btn-primary" href="/importer_documentation/profile">Download as CSV</a>
4
- <dl>
17
+ <div class="metadata-field-guide">
5
18
  <% @details.each do |detail| %>
6
- <h2>
7
- <dt>
19
+ <div class="metadata-field <%= system_field(detail) %>" <%= hide_system_field(detail) %>>
20
+ <h2 class="field-label">
8
21
  <%= detail[:attribute] %>
9
- </dt>
10
- </h2>
11
- <dd>
22
+ </h2>
12
23
  <div>
13
24
  <b>Predicate:</b>
14
25
  <a href="<%= detail[:predicate] %>"><%= detail[:predicate] %></a>
@@ -22,8 +33,8 @@
22
33
  <%= detail[:validator] %>
23
34
  </div>
24
35
  <div>
25
- <b>Multiple:</b>
26
- <%= detail[:multiple] %>
36
+ <b>Multiple values accepted:</b>
37
+ <%= true_false_to_yes_no(detail[:multiple]) %>
27
38
  </div>
28
39
  <div>
29
40
  <b>Edit Form Label:</b>
@@ -43,7 +54,7 @@
43
54
  <b>Usage:</b>
44
55
  <%= detail[:usage] %>
45
56
  </div>
46
- </dd>
57
+ </div>
47
58
  <% end %>
48
- </dl>
59
+ </div>
49
60
  </div>
data/lib/zizia/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zizia
4
- VERSION = '4.5.4.alpha.01'
4
+ VERSION = '4.6.0.alpha.01'
5
5
  end
@@ -54,11 +54,27 @@ RSpec.describe Zizia::MetadataDetailsController, type: :controller do
54
54
  expect(first_row).to include('required_on_form')
55
55
  end
56
56
 
57
- it 'includes usage' do
57
+ it 'includes `usage`' do
58
58
  get :profile
59
59
  profile_table = CSV.parse(response.body, headers: :first_row)
60
60
  title_definition = profile_table.find { |r| r.field('attribute') == 'title' }
61
- expect(title_definition.field('usage')).to include 'name of the resource being described' # match text extracted from ./config/emory/usage.yml
61
+ expect(title_definition.field('usage')).to include 'name to aid in identifying a work' # match text extracted from ./config/emory/usage.yml
62
+ end
63
+
64
+ it 'includes `files`' do
65
+ get :profile
66
+ profile_table = CSV.parse(response.body, headers: :first_row)
67
+ files_definition = profile_table.find { |r| r.field('attribute') == 'files' }
68
+ expect(files_definition.field('csv_header')).to eq('files')
69
+ expect(files_definition.field('validator')).to match(/Required/)
70
+ end
71
+
72
+ it 'includes `visibility`' do
73
+ get :profile
74
+ profile_table = CSV.parse(response.body, headers: :first_row)
75
+ visibility_definition = profile_table.find { |r| r.field('attribute') == 'visibility' }
76
+ expect(visibility_definition.field('csv_header')).to eq('visibility')
77
+ expect(visibility_definition.field('validator')).to match(/Required/)
62
78
  end
63
79
 
64
80
  it 'includes a date in the filename' do
@@ -13,4 +13,5 @@
13
13
  *= require_tree .
14
14
  *= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
15
15
  *= require_self
16
+ *= require zizia/application
16
17
  */
@@ -8,6 +8,8 @@ class Ability
8
8
  # Define any customized permissions here.
9
9
  def custom_permissions
10
10
  can :manage, Zizia::CsvImport if current_user.admin?
11
+ can :manage, Zizia::CsvImportDetail if current_user.admin?
12
+
11
13
  # Limits deleting objects to a the admin user
12
14
  #
13
15
  # if current_user.admin?