use new amb nip

This commit is contained in:
@s.roertgen 2025-10-27 22:13:35 +01:00
parent 5e16129e4c
commit 8dc0744041
3 changed files with 1004 additions and 460 deletions

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,6 @@ import (
"github.com/stretchr/testify/assert"
)
func TestNostrToAmbEvent(t *testing.T) {
assert := assert.New(t)
sk := nostr.GeneratePrivateKey()
@ -38,7 +37,6 @@ func TestNostrToAmbEvent(t *testing.T) {
}
// Helper function to create a test event with a specific tag
func createTestEvent(tags nostr.Tags) *nostr.Event {
sk := nostr.GeneratePrivateKey()
@ -85,7 +83,10 @@ func TestNostrToAMB_About(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"about", "http://w3id.org/kim/schulfaecher/s1009", "Französisch", "de"},
{"about:id", "http://w3id.org/kim/schulfaecher/s1009"},
{"about:prefLabel", "Französisch"},
{"about:inLanguage", "de"},
{"about:type", "Concept"},
}
event := createTestEvent(tags)
@ -99,6 +100,7 @@ func TestNostrToAMB_About(t *testing.T) {
assert.Equal("http://w3id.org/kim/schulfaecher/s1009", amb.About[0].ID)
assert.Equal("Französisch", amb.About[0].PrefLabel)
assert.Equal("de", amb.About[0].InLanguage)
assert.Equal("Concept", amb.About[0].Type)
}
func TestNostrToAMB_Keywords(t *testing.T) {
@ -106,7 +108,9 @@ func TestNostrToAMB_Keywords(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"keywords", "Französisch", "Niveau A2", "Sprache"},
{"t", "Französisch"},
{"t", "Niveau A2"},
{"t", "Sprache"},
}
event := createTestEvent(tags)
@ -164,8 +168,12 @@ func TestNostrToAMB_Creator(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"creator", "http://author1.org", "Autorin 1", "Person"},
{"creator", "http://author2.org", "Autorin 2", "Person"},
{"creator:id", "http://author1.org"},
{"creator:name", "Autorin 1"},
{"creator:type", "Person"},
{"creator:id", "http://author2.org"},
{"creator:name", "Autorin 2"},
{"creator:type", "Person"},
}
event := createTestEvent(tags)
@ -190,8 +198,12 @@ func TestNostrToAMB_Contributor(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"contributor", "http://author1.org", "Autorin 1", "Person"},
{"contributor", "http://author2.org", "Autorin 2", "Person"},
{"contributor:id", "http://author1.org"},
{"contributor:name", "Autorin 1"},
{"contributor:type", "Person"},
{"contributor:id", "http://author2.org"},
{"contributor:name", "Autorin 2"},
{"contributor:type", "Person"},
}
event := createTestEvent(tags)
@ -237,8 +249,12 @@ func TestNostrToAMB_Publisher(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"publisher", "http://publisher1.org", "Publisher 1", "Person"},
{"publisher", "http://publisher2.org", "Publisher 2", "Organization"},
{"publisher:id", "http://publisher1.org"},
{"publisher:name", "Publisher 1"},
{"publisher:type", "Person"},
{"publisher:id", "http://publisher2.org"},
{"publisher:name", "Publisher 2"},
{"publisher:type", "Organization"},
}
event := createTestEvent(tags)
@ -263,8 +279,12 @@ func TestNostrToAMB_Funder(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"funder", "http://funder1.org", "Funder 1", "Person"},
{"funder", "http://funder2.org", "Funder 2", "Organization"},
{"funder:id", "http://funder1.org"},
{"funder:name", "Funder 1"},
{"funder:type", "Person"},
{"funder:id", "http://funder2.org"},
{"funder:name", "Funder 2"},
{"funder:type", "Organization"},
}
event := createTestEvent(tags)
@ -320,7 +340,8 @@ func TestNostrToAMB_License(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"license", "https://creativecommons.org/publicdomain/zero/1.0/", "CC-0"},
{"license:id", "https://creativecommons.org/publicdomain/zero/1.0/"},
{"license:name", "CC-0"},
}
event := createTestEvent(tags)
@ -339,7 +360,10 @@ func TestNostrToAMB_ConditionsOfAccess(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"conditionsOfAccess", "http://w3id.org/kim/conditionsOfAccess/no_login", "Kein Login", "de"},
{"conditionsOfAccess:id", "http://w3id.org/kim/conditionsOfAccess/no_login"},
{"conditionsOfAccess:prefLabel", "Kein Login"},
{"conditionsOfAccess:inLanguage", "de"},
{"conditionsOfAccess:type", "Concept"},
}
event := createTestEvent(tags)
@ -359,8 +383,12 @@ func TestNostrToAMB_LearningResourceType(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"learningResourceType", "http://w3id.org/openeduhub/vocabs/new_lrt/video", "Video", "de"},
{"learningResourceType", "http://w3id.org/openeduhub/vocabs/new_lrt/tutorial", "Tutorial", "en"},
{"learningResourceType:id", "http://w3id.org/openeduhub/vocabs/new_lrt/video"},
{"learningResourceType:prefLabel", "Video"},
{"learningResourceType:inLanguage", "de"},
{"learningResourceType:id", "http://w3id.org/openeduhub/vocabs/new_lrt/tutorial"},
{"learningResourceType:prefLabel", "Tutorial"},
{"learningResourceType:inLanguage", "en"},
}
event := createTestEvent(tags)
@ -385,8 +413,12 @@ func TestNostrToAMB_Audience(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"audience", "http://purl.org/dcx/lrmi-vocabs/educationalAudienceRole/student", "Schüler:in", "de"},
{"audience", "http://purl.org/dcx/lrmi-vocabs/educationalAudienceRole/teacher", "Lehrer:in", "de"},
{"audience:id", "http://purl.org/dcx/lrmi-vocabs/educationalAudienceRole/student"},
{"audience:prefLabel", "Schüler:in"},
{"audience:inLanguage", "de"},
{"audience:id", "http://purl.org/dcx/lrmi-vocabs/educationalAudienceRole/teacher"},
{"audience:prefLabel", "Lehrer:in"},
{"audience:inLanguage", "de"},
}
event := createTestEvent(tags)
@ -411,8 +443,12 @@ func TestNostrToAMB_Teaches(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"teaches", "http://awesome-skills.org/1", "Zuhören", "de"},
{"teaches", "http://awesome-skills.org/2", "Sprechen", "de"},
{"teaches:id", "http://awesome-skills.org/1"},
{"teaches:prefLabel", "Zuhören"},
{"teaches:inLanguage", "de"},
{"teaches:id", "http://awesome-skills.org/2"},
{"teaches:prefLabel", "Sprechen"},
{"teaches:inLanguage", "de"},
}
event := createTestEvent(tags)
@ -437,8 +473,12 @@ func TestNostrToAMB_Assesses(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"assesses", "http://awesome-skills.org/1", "Hörverständnis", "de"},
{"assesses", "http://awesome-skills.org/2", "Grammatik", "de"},
{"assesses:id", "http://awesome-skills.org/1"},
{"assesses:prefLabel", "Hörverständnis"},
{"assesses:inLanguage", "de"},
{"assesses:id", "http://awesome-skills.org/2"},
{"assesses:prefLabel", "Grammatik"},
{"assesses:inLanguage", "de"},
}
event := createTestEvent(tags)
@ -463,8 +503,12 @@ func TestNostrToAMB_CompetencyRequired(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"competencyRequired", "http://awesome-skills.org/1", "Basisvokabular", "de"},
{"competencyRequired", "http://awesome-skills.org/2", "Grundkenntnisse", "de"},
{"competencyRequired:id", "http://awesome-skills.org/1"},
{"competencyRequired:prefLabel", "Basisvokabular"},
{"competencyRequired:inLanguage", "de"},
{"competencyRequired:id", "http://awesome-skills.org/2"},
{"competencyRequired:prefLabel", "Grundkenntnisse"},
{"competencyRequired:inLanguage", "de"},
}
event := createTestEvent(tags)
@ -489,8 +533,12 @@ func TestNostrToAMB_EducationalLevel(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"educationalLevel", "https://w3id.org/kim/educationalLevel/level_2", "Sekundarstufe 1", "de"},
{"educationalLevel", "https://w3id.org/kim/educationalLevel/level_3", "Sekundarstufe 2", "de"},
{"educationalLevel:id", "https://w3id.org/kim/educationalLevel/level_2"},
{"educationalLevel:prefLabel", "Sekundarstufe 1"},
{"educationalLevel:inLanguage", "de"},
{"educationalLevel:id", "https://w3id.org/kim/educationalLevel/level_3"},
{"educationalLevel:prefLabel", "Sekundarstufe 2"},
{"educationalLevel:inLanguage", "de"},
}
event := createTestEvent(tags)
@ -515,7 +563,9 @@ func TestNostrToAMB_InteractivityType(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"interactivityType", "http://purl.org/dcx/lrmi-vocabs/interactivityType/active", "aktiv", "de"},
{"interactivityType:id", "http://purl.org/dcx/lrmi-vocabs/interactivityType/active"},
{"interactivityType:prefLabel", "aktiv"},
{"interactivityType:inLanguage", "de"},
}
event := createTestEvent(tags)
@ -535,7 +585,8 @@ func TestNostrToAMB_IsBasedOn(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"isBasedOn", "http://an-awesome-resource.org", "Französisch I"},
{"isBasedOn:id", "http://an-awesome-resource.org"},
{"isBasedOn:name", "Französisch I"},
}
event := createTestEvent(tags)
@ -554,7 +605,9 @@ func TestNostrToAMB_IsPartOf(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"isPartOf", "http://whole.org", "Whole", "PresentationDigitalDocument"},
{"isPartOf:id", "http://whole.org"},
{"isPartOf:name", "Whole"},
{"isPartOf:type", "PresentationDigitalDocument"},
}
event := createTestEvent(tags)
@ -574,8 +627,12 @@ func TestNostrToAMB_HasPart(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"hasPart", "http://part1.org", "Part 1", "LearningResource"},
{"hasPart", "http://part2.org", "Part 2", "LearningResource"},
{"hasPart:id", "http://part1.org"},
{"hasPart:name", "Part 1"},
{"hasPart:type", "LearningResource"},
{"hasPart:id", "http://part2.org"},
{"hasPart:name", "Part 2"},
{"hasPart:type", "LearningResource"},
}
event := createTestEvent(tags)
@ -616,7 +673,13 @@ func TestNostrToAMB_Trailer(t *testing.T) {
tags := nostr.Tags{
{"d", "test-resource-id"},
{"trailer", "https://example.com/video.mp4", "Video", "video/mp4", "10MB", "abc123", "https://example.com/embed", "1Mbps"},
{"trailer:contentUrl", "https://example.com/video.mp4"},
{"trailer:type", "VideoObject"},
{"trailer:encodingFormat", "video/mp4"},
{"trailer:contentSize", "10MB"},
{"trailer:sha256", "abc123"},
{"trailer:embedUrl", "https://example.com/embed"},
{"trailer:bitrate", "1Mbps"},
}
event := createTestEvent(tags)
@ -627,11 +690,10 @@ func TestNostrToAMB_Trailer(t *testing.T) {
assert.Equal(1, len(amb.Trailer))
assert.Equal("https://example.com/video.mp4", amb.Trailer[0].ContentUrl)
assert.Equal("Video", amb.Trailer[0].Type)
assert.Equal("VideoObject", amb.Trailer[0].Type)
assert.Equal("video/mp4", amb.Trailer[0].EncodingFormat)
assert.Equal("10MB", amb.Trailer[0].ContentSize)
assert.Equal("abc123", amb.Trailer[0].Sha256)
assert.Equal("https://example.com/embed", amb.Trailer[0].EmbedUrl)
assert.Equal("1Mbps", amb.Trailer[0].Bitrate)
}

View file

@ -77,17 +77,17 @@ type Audience struct {
// Teaches represents what the content teaches
type Teaches struct {
ControlledVocabulary
ControlledVocabulary
}
// Assesses represents what the content assesses
type Assesses struct {
ControlledVocabulary
ControlledVocabulary
}
// CompetencyRequired represents required competencies
type CompetencyRequired struct {
ControlledVocabulary
ControlledVocabulary
}
// EducationalLevel represents the educational level
@ -102,7 +102,7 @@ type InteractivityType struct {
// IsBasedOn represents a reference to source material
type IsBasedOn struct {
ID string `json:"id"`
ID string `json:"id"`
Type string `json:"type,omitempty"`
Name string `json:"name"`
Creator *Creator `json:"creator,omitempty"`
@ -135,6 +135,41 @@ type License struct {
Name string `json:"name,omitempty"`
}
// MainEntityProvider represents the provider of a web page
type MainEntityProvider struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
}
// MainEntityOfPage represents meta-metadata about web pages
type MainEntityOfPage struct {
ID string `json:"id"`
Type string `json:"type"`
Provider *MainEntityProvider `json:"provider,omitempty"`
DateCreated string `json:"dateCreated,omitempty"`
DateModified string `json:"dateModified,omitempty"`
}
// Encoding represents a media encoding (MediaObject)
type Encoding struct {
Type string `json:"type"`
ContentUrl string `json:"contentUrl,omitempty"`
EmbedUrl string `json:"embedUrl,omitempty"`
EncodingFormat string `json:"encodingFormat,omitempty"`
ContentSize string `json:"contentSize,omitempty"`
Sha256 string `json:"sha256,omitempty"`
Bitrate string `json:"bitrate,omitempty"`
}
// Caption represents a caption/subtitle file (MediaObject)
type Caption struct {
ID string `json:"id"`
Type string `json:"type"`
EncodingFormat string `json:"encodingFormat,omitempty"`
InLanguage string `json:"inLanguage,omitempty"`
}
// NostrMetadata contains Nostr-specific metadata
type NostrMetadata struct {
EventID string `json:"eventID"`
@ -190,9 +225,12 @@ type AMBMetadata struct {
HasPart []*HasPart `json:"hasPart,omitempty"`
// Technical
Duration string `json:"duration,omitempty"`
// TODO Encoding ``
// TODO Caption
Duration string `json:"duration,omitempty"`
Encoding []*Encoding `json:"encoding,omitempty"`
Caption []*Caption `json:"caption,omitempty"`
// Meta-Metadata
MainEntityOfPage []*MainEntityOfPage `json:"mainEntityOfPage,omitempty"`
// Nostr integration
NostrMetadata `json:",inline"`