@liascript/exporter 2.6.2--0.10.31 → 2.6.4--0.10.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/export/project.ts +93 -21
- package/src/export/rdf.ts +11 -3
- package/src/index.ts +3 -32
- package/index.html +0 -73
package/package.json
CHANGED
package/src/export/project.ts
CHANGED
|
@@ -4,6 +4,7 @@ import * as IMS from './ims'
|
|
|
4
4
|
import * as SCORM12 from './scorm12'
|
|
5
5
|
import * as SCORM2004 from './scorm2004'
|
|
6
6
|
import * as ANDROID from './android'
|
|
7
|
+
import * as RDF from './rdf'
|
|
7
8
|
|
|
8
9
|
const fs = require('fs-extra')
|
|
9
10
|
const path = require('path')
|
|
@@ -61,6 +62,36 @@ export function storeNext(collection: any, data: any) {
|
|
|
61
62
|
return
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
export function help() {
|
|
66
|
+
console.log('\nProject settings:')
|
|
67
|
+
console.log('')
|
|
68
|
+
console.log(
|
|
69
|
+
'--project-no-meta Disable the generation of meta information for OpenGraph and Twitter-cards.'
|
|
70
|
+
)
|
|
71
|
+
console.log('--project-no-rdf Disable the generation of json-ld.')
|
|
72
|
+
console.log(
|
|
73
|
+
'--project-no-categories Disable the filter for categories/tags.'
|
|
74
|
+
)
|
|
75
|
+
console.log(
|
|
76
|
+
'--project-category-blur Enable this and the categories will be blurred instead of deleted.'
|
|
77
|
+
)
|
|
78
|
+
console.log(
|
|
79
|
+
'--project-generate-scrom12 SCORM12 and pass additional scrom settings.'
|
|
80
|
+
)
|
|
81
|
+
console.log(
|
|
82
|
+
'--project-generate-scrom2004 SCORM2004 and pass additional scrom settings.'
|
|
83
|
+
)
|
|
84
|
+
console.log(
|
|
85
|
+
'--project-generate-ims IMS resources with additional config settings.'
|
|
86
|
+
)
|
|
87
|
+
console.log(
|
|
88
|
+
'--project-generate-pdf PDFs are automatically generated and added to every card.'
|
|
89
|
+
)
|
|
90
|
+
console.log(
|
|
91
|
+
'--project-generate-cache Only generate new files, if they do not exist.'
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
64
95
|
export async function exporter(
|
|
65
96
|
argument: {
|
|
66
97
|
input: string
|
|
@@ -84,21 +115,40 @@ export async function exporter(
|
|
|
84
115
|
|
|
85
116
|
let cards = ''
|
|
86
117
|
const output = argument.output
|
|
118
|
+
const itemList: any[] = []
|
|
87
119
|
|
|
88
120
|
for (let i = 0; i < json.collection.length; i++) {
|
|
89
121
|
let course = json.collection[i]
|
|
90
122
|
|
|
91
123
|
if (course.collection) {
|
|
92
124
|
let subCards = ''
|
|
125
|
+
let subItemList: any[] = []
|
|
93
126
|
|
|
94
127
|
for (let j = 0; j < course.collection.length; j++) {
|
|
128
|
+
let { html, json } = await toCard(argument, course.collection[j], true)
|
|
95
129
|
subCards += `<div class='col-sm-6 col-md-4 col-lg-3 ${
|
|
96
130
|
course.grid ? 'mb-3' : ''
|
|
97
131
|
}'>
|
|
98
|
-
${
|
|
132
|
+
${html}
|
|
99
133
|
</div>`
|
|
134
|
+
|
|
135
|
+
subItemList.push(json)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const itemListElement = {
|
|
139
|
+
'@type': 'ItemList',
|
|
140
|
+
itemListElement: subItemList,
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (course.title) {
|
|
144
|
+
itemListElement['name'] = course.title
|
|
145
|
+
}
|
|
146
|
+
if (course.comment) {
|
|
147
|
+
itemListElement['description'] = course.comment
|
|
100
148
|
}
|
|
101
149
|
|
|
150
|
+
itemList.push(itemListElement)
|
|
151
|
+
|
|
102
152
|
cards += `
|
|
103
153
|
<div class="col-12">
|
|
104
154
|
<div class="card">
|
|
@@ -120,7 +170,10 @@ export async function exporter(
|
|
|
120
170
|
} else if (course.html) {
|
|
121
171
|
cards += "<div class='col-12'>" + course.html + '</div>'
|
|
122
172
|
} else {
|
|
123
|
-
|
|
173
|
+
let { html, json } = await toCard(argument, course)
|
|
174
|
+
cards += "<div class='col'>" + html + '</div>'
|
|
175
|
+
|
|
176
|
+
itemList.push(json)
|
|
124
177
|
}
|
|
125
178
|
}
|
|
126
179
|
|
|
@@ -144,10 +197,21 @@ export async function exporter(
|
|
|
144
197
|
'</select>'
|
|
145
198
|
}
|
|
146
199
|
|
|
200
|
+
const jsonLD = {
|
|
201
|
+
'@context': 'http://schema.org/',
|
|
202
|
+
'@type': 'ItemList',
|
|
203
|
+
itemListElement: itemList,
|
|
204
|
+
}
|
|
205
|
+
|
|
147
206
|
let title = json.title || 'LiaScript Course Index'
|
|
148
207
|
|
|
149
208
|
if (json.title) {
|
|
150
|
-
title = title.replace(
|
|
209
|
+
title = cleanHTML(title).replace(/\s+/g, ' ').trim()
|
|
210
|
+
jsonLD['name'] = title
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (json.comment) {
|
|
214
|
+
jsonLD['description'] = cleanHTML(json.comment).replace(/\s+/g, ' ').trim()
|
|
151
215
|
}
|
|
152
216
|
|
|
153
217
|
const html = `<!DOCTYPE html>
|
|
@@ -155,6 +219,10 @@ export async function exporter(
|
|
|
155
219
|
<head>
|
|
156
220
|
<title>${title}</title>
|
|
157
221
|
|
|
222
|
+
<script type="application/ld+json">
|
|
223
|
+
${JSON.stringify(await RDF.compact(jsonLD), null, 2)}
|
|
224
|
+
</script>
|
|
225
|
+
|
|
158
226
|
${
|
|
159
227
|
json.icon
|
|
160
228
|
? '<link rel="icon" type="image/x-icon" href="' + json.icon + '">'
|
|
@@ -233,7 +301,7 @@ export async function exporter(
|
|
|
233
301
|
</html>
|
|
234
302
|
`
|
|
235
303
|
|
|
236
|
-
helper.writeFile(output + '.html', helper.prettify(html))
|
|
304
|
+
helper.writeFile(output + '.html', helper.prettify(helper.prettify(html)))
|
|
237
305
|
}
|
|
238
306
|
|
|
239
307
|
async function moveFile(oldPath, newPath) {
|
|
@@ -282,7 +350,11 @@ function hash(url: string) {
|
|
|
282
350
|
return value.startsWith('-') ? '0' + value.slice(1) : value
|
|
283
351
|
}
|
|
284
352
|
|
|
285
|
-
async function toCard(
|
|
353
|
+
async function toCard(
|
|
354
|
+
argument: any,
|
|
355
|
+
course: any,
|
|
356
|
+
small: boolean = false
|
|
357
|
+
): Promise<{ html: string; json: any }> {
|
|
286
358
|
// if other parameters are defined for a specific course
|
|
287
359
|
// then they are treated
|
|
288
360
|
|
|
@@ -438,15 +510,20 @@ async function toCard(argument: any, course: any, small: boolean = false) {
|
|
|
438
510
|
execSync('rm -rf tmp')
|
|
439
511
|
}
|
|
440
512
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
513
|
+
argument['rdf-url'] = course.data.lia.readme
|
|
514
|
+
|
|
515
|
+
return {
|
|
516
|
+
html: card(
|
|
517
|
+
small,
|
|
518
|
+
course.data.lia.readme,
|
|
519
|
+
overwrite(course.title, course.data.lia.str_title),
|
|
520
|
+
overwrite(course.comment, course.data.lia.comment),
|
|
521
|
+
tagList,
|
|
522
|
+
downloads,
|
|
523
|
+
overwrite(course.logo, course.data.lia.definition.logo)
|
|
524
|
+
),
|
|
525
|
+
json: await RDF.parse(argument, course.data),
|
|
526
|
+
}
|
|
450
527
|
}
|
|
451
528
|
|
|
452
529
|
function card(
|
|
@@ -463,7 +540,7 @@ function card(
|
|
|
463
540
|
apk?: string
|
|
464
541
|
},
|
|
465
542
|
img_url?: string
|
|
466
|
-
) {
|
|
543
|
+
): string {
|
|
467
544
|
let image = ''
|
|
468
545
|
|
|
469
546
|
if (img_url) {
|
|
@@ -544,10 +621,6 @@ function card(
|
|
|
544
621
|
'">Android APK</a></li>'
|
|
545
622
|
: ''
|
|
546
623
|
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
624
|
</ul>
|
|
552
625
|
</div>
|
|
553
626
|
</div>
|
|
@@ -566,8 +639,7 @@ function card(
|
|
|
566
639
|
${tag_list}
|
|
567
640
|
</div>
|
|
568
641
|
${footer}
|
|
569
|
-
</div
|
|
570
|
-
`
|
|
642
|
+
</div>`
|
|
571
643
|
}
|
|
572
644
|
|
|
573
645
|
function stringToColor(str: string) {
|
package/src/export/rdf.ts
CHANGED
|
@@ -98,11 +98,19 @@ export async function script(
|
|
|
98
98
|
},
|
|
99
99
|
json
|
|
100
100
|
) {
|
|
101
|
+
let doc = await parse(argument, json)
|
|
102
|
+
doc = await jsonld.compact(doc, 'http://schema.org/')
|
|
103
|
+
doc = clean(doc)
|
|
104
|
+
|
|
101
105
|
return `<script type="application/ld+json">
|
|
102
|
-
${JSON.stringify(
|
|
106
|
+
${JSON.stringify(doc, null, 2)}
|
|
103
107
|
</script>`
|
|
104
108
|
}
|
|
105
109
|
|
|
110
|
+
export async function compact(doc: any) {
|
|
111
|
+
return await jsonld.compact(doc, 'http://schema.org/')
|
|
112
|
+
}
|
|
113
|
+
|
|
106
114
|
export async function parse(
|
|
107
115
|
argument: {
|
|
108
116
|
input: string
|
|
@@ -168,9 +176,9 @@ export async function parse(
|
|
|
168
176
|
doc = langInformation(doc, json.lia.definition)
|
|
169
177
|
doc = logoInformation(doc, json.lia.definition, baseURL)
|
|
170
178
|
doc = await licenseInformation(doc, argument, baseURL)
|
|
171
|
-
doc = await jsonld.compact(doc, 'http://schema.org')
|
|
179
|
+
doc = await jsonld.compact(doc, 'http://schema.org/')
|
|
172
180
|
|
|
173
|
-
return doc
|
|
181
|
+
return clean(doc)
|
|
174
182
|
}
|
|
175
183
|
|
|
176
184
|
/**
|
package/src/index.ts
CHANGED
|
@@ -22,7 +22,7 @@ import fetch from 'node-fetch'
|
|
|
22
22
|
|
|
23
23
|
// -------------------------------Main Execution-------------------------------
|
|
24
24
|
if (argv.v || argv.version) {
|
|
25
|
-
console.log('version: 2.6.
|
|
25
|
+
console.log('version: 2.6.4--0.10.31')
|
|
26
26
|
} else if (argv.h || argv.help) {
|
|
27
27
|
help()
|
|
28
28
|
} else if (argv.i || argv.input) {
|
|
@@ -309,37 +309,7 @@ function help() {
|
|
|
309
309
|
'--pdf-omitBackground Hides default white background and allows capturing screenshots with transparency. Defaults to true. '
|
|
310
310
|
)
|
|
311
311
|
|
|
312
|
-
|
|
313
|
-
console.log('')
|
|
314
|
-
console.log(
|
|
315
|
-
'--project-no-meta Disable the generation of meta information for OpenGraph and Twitter-cards.'
|
|
316
|
-
)
|
|
317
|
-
console.log(
|
|
318
|
-
'--project-no-categories Disable the filter for categories/tags.'
|
|
319
|
-
)
|
|
320
|
-
console.log(
|
|
321
|
-
'--project-category-blur Enable this and the categories will be blurred instead of deleted.'
|
|
322
|
-
)
|
|
323
|
-
|
|
324
|
-
console.log(
|
|
325
|
-
'--project-generate-scrom12 SCORM12 and pass additional scrom settings.'
|
|
326
|
-
)
|
|
327
|
-
|
|
328
|
-
console.log(
|
|
329
|
-
'--project-generate-scrom2004 SCORM2004 and pass additional scrom settings.'
|
|
330
|
-
)
|
|
331
|
-
|
|
332
|
-
console.log(
|
|
333
|
-
'--project-generate-ims IMS resources with additional config settings.'
|
|
334
|
-
)
|
|
335
|
-
|
|
336
|
-
console.log(
|
|
337
|
-
'--project-generate-pdf PDFs are automatically generated and added to every card.'
|
|
338
|
-
)
|
|
339
|
-
|
|
340
|
-
console.log(
|
|
341
|
-
'--project-generate-cache Only generate new files, if they do not exist.'
|
|
342
|
-
)
|
|
312
|
+
PROJECT.help()
|
|
343
313
|
|
|
344
314
|
RDF.help()
|
|
345
315
|
}
|
|
@@ -408,6 +378,7 @@ function parseArguments() {
|
|
|
408
378
|
|
|
409
379
|
// project settings
|
|
410
380
|
'project-no-meta': argv['project-no-meta'],
|
|
381
|
+
'project-no-rdf': argv['project-no-rdf'],
|
|
411
382
|
'project-no-categories': argv['project-no-categories'],
|
|
412
383
|
'project-category-blur': argv['project-category-blur'],
|
|
413
384
|
'project-generate-pdf': argv['project-generate-pdf'],
|
package/index.html
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>OER - Kurssammlung</title>
|
|
5
|
-
<link rel="icon" type="image/x-icon" href="https://upload.wikimedia.org/wikipedia/commons/thumb/d/de/Logo_TU_Bergakademie_Freiberg.svg/242px-Logo_TU_Bergakademie_Freiberg.svg.png">
|
|
6
|
-
<meta property="og:type" content="website">
|
|
7
|
-
<meta property="og:title" content="OER-Kurssammlung">
|
|
8
|
-
<meta property="og:description" content="Sammlung der OER Inhalte der Arbeitsgruppe Softwareentwicklung und Robotik (TU Freiberg)">
|
|
9
|
-
<meta property="og:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/8/81/Universitaetsbibliothek_Freiberg_Fassade.jpg/1024px-Universitaetsbibliothek_Freiberg_Fassade.jpg">
|
|
10
|
-
<meta name="twitter:title" content="OER-Kurssammlung">
|
|
11
|
-
<meta name="twitter:description" content="Sammlung der OER Inhalte der Arbeitsgruppe Softwareentwicklung und Robotik (TU Freiberg)">
|
|
12
|
-
<meta name="twitter:image" content="https://upload.wikimedia.org/wikipedia/commons/thumb/8/81/Universitaetsbibliothek_Freiberg_Fassade.jpg/1024px-Universitaetsbibliothek_Freiberg_Fassade.jpg">
|
|
13
|
-
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
|
14
|
-
</head>
|
|
15
|
-
<body>
|
|
16
|
-
<main>
|
|
17
|
-
<div class="container-fluid" style="background-size: cover; background-image: url('https://upload.wikimedia.org/wikipedia/commons/thumb/8/81/Universitaetsbibliothek_Freiberg_Fassade.jpg/1024px-Universitaetsbibliothek_Freiberg_Fassade.jpg'); background-position: center center; background-repeat: no-repeat;">
|
|
18
|
-
<section class="py-5 text-center container">
|
|
19
|
-
<div class="row py-lg-5">
|
|
20
|
-
<div class="col-lg-6 col-md-8 mx-auto">
|
|
21
|
-
<h1 class="fw-light">
|
|
22
|
-
<span style="background-color: rgba(0,106,179,0.75); padding: 5px; color: white">OER - Kurssammlung</span>
|
|
23
|
-
</h1>
|
|
24
|
-
<p class="lead text-muted">
|
|
25
|
-
<span style="color: rgb(0,106,179); background-color: rgba(255,255,255,0.75)">Sammlung der OER Inhalte der Arbeitsgruppe Softwareentwicklung und Robotik (TU Freiberg)</span>
|
|
26
|
-
</p>
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
29
|
-
</section>
|
|
30
|
-
</div>
|
|
31
|
-
<div class="album py-5 bg-light">
|
|
32
|
-
<div class="container">
|
|
33
|
-
<div class="row row-cols-1 row-cols-sm-1 row-cols-md-2 row-cols-xl-3 g-3">
|
|
34
|
-
<div class="col-12">
|
|
35
|
-
<div class="card">
|
|
36
|
-
<div class="card-header">Prozedurale Programmierung</div>
|
|
37
|
-
<div class="card-body">
|
|
38
|
-
<p class="card-text">todo</p>
|
|
39
|
-
<div class="row">
|
|
40
|
-
<div class="col-sm-6 col-md-4 col-lg-3 mb-3">
|
|
41
|
-
<div class="card shadow-sm m-1" style="height: 100%" data-category="">
|
|
42
|
-
<div class="card-img-top" style="background-size: cover; height: 175px; background-image: url('https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/img/LogoCodeExample.png'); background-position: center center; background-repeat: no-repeat;"></div>
|
|
43
|
-
<div class="card-body" style="transform: rotate(0);">
|
|
44
|
-
<a href="https://liascript.github.io/course/?https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/00_Einfuehrung.md" class="link-dark stretched-link"><h6 class="card-title">Einführung</h6></a>
|
|
45
|
-
<p class="card-text">
|
|
46
|
-
<small>Einführung in die Programmierung für Nicht-Informatiker</small>
|
|
47
|
-
</p>
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
</main>
|
|
59
|
-
<footer class="text-muted py-3">
|
|
60
|
-
<div class="container">
|
|
61
|
-
<p class="float-end">
|
|
62
|
-
<a href="#">Back to top</a>
|
|
63
|
-
</p>
|
|
64
|
-
<p>
|
|
65
|
-
Kontakt - Prof. Dr.-Ing. Sebastian Zug -
|
|
66
|
-
<a href="https://tu-freiberg.de/fakult1/inf/professuren/softwaretechnologie-und-robotik">Lehrstuhl für Softwaretechnologie und Robotik</a>
|
|
67
|
-
-
|
|
68
|
-
<a href="mailto:Sebastian.Zug@informatik.tu-freiberg.de">Sebastian.Zug@informatik.tu-freiberg.de</a>
|
|
69
|
-
</p>
|
|
70
|
-
</div>
|
|
71
|
-
</footer>
|
|
72
|
-
</body>
|
|
73
|
-
</html>
|