Skip to content

Commit 2cc47f7

Browse files
committed
Added missing conformsTo in JSON-LD
Re-add non-schema.org properties to Event JSON-LD serialization. They are part of the bioschemas profile.
1 parent 1e7e63e commit 2cc47f7

5 files changed

Lines changed: 31 additions & 4 deletions

File tree

lib/bioschemas/course_generator.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ def self.type
44
'Course'
55
end
66

7+
def self.bioschemas_profile
8+
'https://bioschemas.org/profiles/Course/0.9-DRAFT-2020_12_08'
9+
end
10+
711
property :name, :title
812
property :alternateName, :subtitle
913
property :url, :url

lib/bioschemas/course_instance_generator.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ def self.type
44
'CourseInstance'
55
end
66

7+
def self.bioschemas_profile
8+
'https://bioschemas.org/profiles/Course/0.9-DRAFT-2020_12_08'
9+
end
10+
711
property :startDate, :start
812
property :endDate, :end
913
property :organizer, -> (event) { { '@type' => 'Organization', name: event.organizer } if event.organizer.present? }

lib/bioschemas/event_generator.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ def self.type
44
'Event'
55
end
66

7+
def self.bioschemas_profile
8+
'https://bioschemas.org/profiles/Event/0.2-DRAFT-2019_06_14'
9+
end
10+
711
property :name, :title
812
property :alternateName, :subtitle
913
property :url, :url
@@ -25,17 +29,17 @@ def self.type
2529
}.compact
2630
}, condition: -> (event) { event.venue.present? || event.city.present? || event.county.present? ||
2731
event.country.present? || event.postcode.present? }
28-
# property :hostInstitution, :host_institutions # Does not seem to be a valid Schema/Bioschemas property
29-
# property :contact, :contact
32+
property :hostInstitution, :host_institutions
33+
property :contact, :contact
3034
property :funder, -> (event) {
3135
event.sponsors.map { |sponsor| { '@type' => 'Organization', 'name' => sponsor } }
3236
}
3337
property :audience, -> (event) {
3438
event.target_audience.map { |audience| { '@type' => 'Audience', 'audienceType' => audience } }
3539
}
3640
property :maximumAttendeeCapacity, :capacity
37-
# property :event_types, event.event_types
38-
# property :eligibility, event.eligibility
41+
property :event_types, :event_types
42+
property :eligibility, :eligibility
3943
property :about, -> (event) {
4044
event.scientific_topics.map { |t| term(t) }
4145
}

lib/bioschemas/generator.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ def self.type
66
'Thing'
77
end
88

9+
def self.bioschemas_profile
10+
nil
11+
end
12+
913
def initialize(resource)
1014
@resource = resource
1115
end
@@ -17,6 +21,13 @@ def generate
1721
'@type' => self.class.type
1822
}
1923

24+
if self.class.bioschemas_profile
25+
template['dct:conformsTo'] = {
26+
'@type' => 'CreativeWork',
27+
'@id' => self.class.bioschemas_profile
28+
}
29+
end
30+
2031
properties.each do |prop, opts|
2132
attr_or_proc = opts[:attr]
2233
condition = opts[:condition]

lib/bioschemas/learning_resource_generator.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ def self.type
44
'LearningResource'
55
end
66

7+
def self.bioschemas_profile
8+
'https://bioschemas.org/profiles/TrainingMaterial/1.0-RELEASE'
9+
end
10+
711
property :name, :title
812
property :url, :url
913
property :description, :description

0 commit comments

Comments
 (0)