-
Notifications
You must be signed in to change notification settings - Fork 16
/
metadata.pl
executable file
·78 lines (70 loc) · 2.3 KB
/
metadata.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env perl
use v5.14;
use YAML::PP qw(LoadFile DumpFile);
use JSON::PP;
use utf8;
binmode( STDOUT, ":utf8" );
my ($about) = LoadFile("about.yml");
my ($contributors) = LoadFile("contributors.yml");
my $authors = [
map {
my @names = split ' ', $_->{name};
$a = {
'family-names' => pop(@names),
'given-names' => join( ' ', @names )
};
$a->{orcid} = $_->{orcid} if $_->{orcid};
$a->{email} = $_->{email} if $_->{email};
$a;
} @{ $contributors->{contributor} }
];
DumpFile(
'CITATION.cff',
{
'cff-version' => '1.2.0',
type => "dataset",
url => $about->{url},
title => $about->{book}{title},
abstract => $about->{book}{description},
license => "CC-BY-4.0",
'repository-code' =>
"https://github.com/pro4bib/handbuch-it-in-bibliotheken",
authors => $authors,
# TODO: version =>
# TODO: keywords =>
# TODO: 'date-released' =>
# TODO: references =>
# TODO: identifiers =>
}
);
DumpFile(
'metadata.yml',
{
'@context' => 'https://schema.org/',
creativeWorkStatus => 'Published',
type => 'LearningResource',
name => $about->{book}{title},
license => 'https://creativecommons.org/licenses/by/4.0/deed.de',
id => $about->{url},
creator => [
map {
my $p = {
type => "Person",
givenName => $_->{'given-names'},
familyName => $_->{'family-names'},
# TODO: affiliation?
};
$p->{id} = "https://orcid.org/" . $_->{orcid} if $_->{orcid};
$p;
} @$authors
],
about => ['https://w3id.org/kim/hochschulfaechersystematik/n262'],
learningResourceType => ['https://w3id.org/kim/hcrt/textbook'],
educationalLevel => ['https://w3id.org/kim/educationalLevel/level_A'],
inLanguage => [ $about->{lang} ],
description => $about->{book}{abstract},
# TODO: datePublished
# TODO: keywords (array)
# TODO: image (Vorschaubild)
}
);