@liascript/exporter 2.6.1--0.10.31 → 2.6.2--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/index.html ADDED
@@ -0,0 +1,73 @@
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>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liascript/exporter",
3
- "version": "2.6.1--0.10.31",
3
+ "version": "2.6.2--0.10.31",
4
4
  "description": "A generic exporter for LiaScript",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -47,13 +47,13 @@
47
47
  "dependencies": {
48
48
  "@liascript/simple-scorm-packager": "^0.3.0",
49
49
  "archiver": "^5.3.0",
50
- "clean-html": "^1.5.0",
51
50
  "fs-extra": "^9.1.0",
52
51
  "jsonld": "^8.1.1",
53
52
  "minimist": "^1.2.5",
54
53
  "node-fetch": "^2.6.9",
55
54
  "path": "^0.12.7",
56
55
  "puppeteer": "^19.2.2",
56
+ "simply-beautiful": "^0.2.14",
57
57
  "temp": "^0.9.4",
58
58
  "xhr2": "^0.2.1",
59
59
  "yaml": "^2.1.3"
@@ -5,6 +5,7 @@ const temp = require('temp')
5
5
  const fs = require('fs-extra')
6
6
  const path = require('path')
7
7
  const archiver = require('archiver')
8
+ const beautify = require('simply-beautiful')
8
9
 
9
10
  export function tmpDir() {
10
11
  return new Promise((resolve, reject) => {
@@ -51,6 +52,12 @@ export function injectResponsivevoice(key: string, into: string): string {
51
52
  )
52
53
  }
53
54
 
55
+ /**
56
+ * Inject an arbitrary tag directly to the end of the html-head tag.
57
+ * @param element - new tag to be added
58
+ * @param into - old index.html content
59
+ * @returns - new index.html content
60
+ */
54
61
  export function inject(element: string, into: string): string {
55
62
  return into.replace('</head>', element + '</head>')
56
63
  }
@@ -67,15 +74,16 @@ export async function iframe(
67
74
  tmpPath,
68
75
  filename: string,
69
76
  readme: string,
77
+ jsonLD: string,
70
78
  style?: string,
71
79
  index?: string
72
80
  ) {
73
81
  await writeFile(
74
82
  path.join(tmpPath, filename),
75
- `<!DOCTYPE html>
83
+ prettify(`<!DOCTYPE html>
76
84
  <html style="height:100%; overflow: hidden">
77
85
  <head>
78
-
86
+ ${jsonLD}
79
87
  </head>
80
88
  <body style="height:100%; margin: 0px">
81
89
 
@@ -97,7 +105,7 @@ export async function iframe(
97
105
 
98
106
  </body>
99
107
  </html>
100
- `
108
+ `)
101
109
  )
102
110
  }
103
111
 
@@ -203,3 +211,12 @@ async function checkFileExists(fileUrl: string) {
203
211
  return false
204
212
  }
205
213
  }
214
+
215
+ export function prettify(html: string) {
216
+ return beautify.html(html, {
217
+ indent_size: 4,
218
+ space_before_conditional: true,
219
+ jslint_happy: true,
220
+ max_char: 0,
221
+ })
222
+ }
package/src/export/ims.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as helper from './helper'
2
+ import * as RDF from './rdf'
2
3
 
3
4
  const path = require('path')
4
5
  const fs = require('fs-extra')
@@ -67,7 +68,15 @@ export async function exporter(
67
68
  await fs.move(old_, new_)
68
69
  }
69
70
 
70
- await helper.iframe(tmpPath, 'start.html', argument.readme, argument.style)
71
+ const jsonLD = await RDF.script(argument, json)
72
+
73
+ await helper.iframe(
74
+ tmpPath,
75
+ 'start.html',
76
+ argument.readme,
77
+ jsonLD,
78
+ argument.style
79
+ )
71
80
 
72
81
  helper.zip(tmpPath, argument.output)
73
82
  }
@@ -8,7 +8,6 @@ import * as ANDROID from './android'
8
8
  const fs = require('fs-extra')
9
9
  const path = require('path')
10
10
  const { execSync } = require('child_process')
11
- const cleaner = require('clean-html')
12
11
 
13
12
  var Categories: Set<string> = new Set([])
14
13
 
@@ -233,26 +232,8 @@ export async function exporter(
233
232
  </body>
234
233
  </html>
235
234
  `
236
- cleaner.clean(
237
- html,
238
- {
239
- wrap: 0,
240
- 'break-around-tags': [
241
- 'a',
242
- 'head',
243
- 'link',
244
- 'meta',
245
- 'p',
246
- 'script',
247
- 'small',
248
- 'span',
249
- 'title',
250
- ],
251
- },
252
- function (htmlCleaned: string) {
253
- helper.writeFile(output + '.html', htmlCleaned)
254
- }
255
- )
235
+
236
+ helper.writeFile(output + '.html', helper.prettify(html))
256
237
  }
257
238
 
258
239
  async function moveFile(oldPath, newPath) {
package/src/export/rdf.ts CHANGED
@@ -49,6 +49,80 @@ export async function exporter(
49
49
  'rdf-educationalLevel'?: string
50
50
  },
51
51
  json
52
+ ) {
53
+ let doc = parse(argument, json)
54
+
55
+ if (argument['rdf-format'] === 'n-quads') {
56
+ const nquads = await jsonld.toRDF(doc, { format: 'application/n-quads' })
57
+ if (argument['rdf-preview']) {
58
+ console.log(nquads)
59
+ } else {
60
+ fs.writeFile(argument.output + '.nq', nquads, function (err) {
61
+ if (err) console.error(err)
62
+ })
63
+ }
64
+ } else {
65
+ doc = clean(doc)
66
+ if (argument['rdf-preview']) {
67
+ console.log(JSON.stringify(doc, null, 2))
68
+ } else {
69
+ fs.writeFile(
70
+ argument.output + '.jsonld',
71
+ JSON.stringify(doc, null, 2),
72
+ function (err) {
73
+ if (err) console.error(err)
74
+ }
75
+ )
76
+ }
77
+ }
78
+ }
79
+
80
+ export async function script(
81
+ argument: {
82
+ input: string
83
+ readme: string
84
+ output: string
85
+ format: string
86
+ path: string
87
+ key?: string
88
+ style?: string
89
+
90
+ // special cases for RDF
91
+ 'rdf-format'?: string
92
+ 'rdf-preview'?: string
93
+ 'rdf-url'?: string
94
+ 'rdf-type'?: string
95
+ 'rdf-template'?: string
96
+ 'rdf-license'?: string
97
+ 'rdf-educationalLevel'?: string
98
+ },
99
+ json
100
+ ) {
101
+ return `<script type="application/ld+json">
102
+ ${JSON.stringify(await parse(argument, json), null, 2)}
103
+ </script>`
104
+ }
105
+
106
+ export async function parse(
107
+ argument: {
108
+ input: string
109
+ readme: string
110
+ output: string
111
+ format: string
112
+ path: string
113
+ key?: string
114
+ style?: string
115
+
116
+ // special cases for RDF
117
+ 'rdf-format'?: string
118
+ 'rdf-preview'?: string
119
+ 'rdf-url'?: string
120
+ 'rdf-type'?: string
121
+ 'rdf-template'?: string
122
+ 'rdf-license'?: string
123
+ 'rdf-educationalLevel'?: string
124
+ },
125
+ json
52
126
  ) {
53
127
  let doc = {}
54
128
 
@@ -96,29 +170,7 @@ export async function exporter(
96
170
  doc = await licenseInformation(doc, argument, baseURL)
97
171
  doc = await jsonld.compact(doc, 'http://schema.org')
98
172
 
99
- if (argument['rdf-format'] === 'n-quads') {
100
- const nquads = await jsonld.toRDF(doc, { format: 'application/n-quads' })
101
- if (argument['rdf-preview']) {
102
- console.log(nquads)
103
- } else {
104
- fs.writeFile(argument.output + '.nq', nquads, function (err) {
105
- if (err) console.error(err)
106
- })
107
- }
108
- } else {
109
- doc = clean(doc)
110
- if (argument['rdf-preview']) {
111
- console.log(JSON.stringify(doc, null, 2))
112
- } else {
113
- fs.writeFile(
114
- argument.output + '.jsonld',
115
- JSON.stringify(doc, null, 2),
116
- function (err) {
117
- if (err) console.error(err)
118
- }
119
- )
120
- }
121
- }
173
+ return doc
122
174
  }
123
175
 
124
176
  /**
@@ -1,4 +1,5 @@
1
1
  import * as helper from './helper'
2
+ import * as RDF from './rdf'
2
3
 
3
4
  const scormPackager = require('@liascript/simple-scorm-packager')
4
5
  const path = require('path')
@@ -51,11 +52,20 @@ export async function exporter(
51
52
  ';'
52
53
  )
53
54
 
55
+ const jsonLD = await RDF.script(argument, json)
56
+
54
57
  if (argument['scorm-iframe']) {
55
- await helper.iframe(tmpPath, 'start.html', argument.readme, argument.style)
58
+ await helper.iframe(
59
+ tmpPath,
60
+ 'start.html',
61
+ argument.readme,
62
+ jsonLD,
63
+ argument.style
64
+ )
56
65
  }
57
66
 
58
67
  try {
68
+ index = helper.inject(jsonLD, index)
59
69
  await helper.writeFile(path.join(tmpPath, 'index.html'), index)
60
70
  } catch (e) {
61
71
  console.warn(e)
@@ -1,5 +1,7 @@
1
1
  import * as helper from './helper'
2
2
 
3
+ import * as RDF from './rdf'
4
+
3
5
  const scormPackager = require('@liascript/simple-scorm-packager')
4
6
  const path = require('path')
5
7
  const fs = require('fs-extra')
@@ -50,11 +52,20 @@ export async function exporter(
50
52
  ';'
51
53
  )
52
54
 
55
+ const jsonLD = await RDF.script(argument, json)
56
+
53
57
  if (argument['scorm-iframe']) {
54
- await helper.iframe(tmpPath, 'start.html', argument.readme, argument.style)
58
+ await helper.iframe(
59
+ tmpPath,
60
+ 'start.html',
61
+ argument.readme,
62
+ jsonLD,
63
+ argument.style
64
+ )
55
65
  }
56
66
 
57
67
  try {
68
+ index = helper.inject(jsonLD, index)
58
69
  await helper.writeFile(path.join(tmpPath, 'index.html'), index)
59
70
  } catch (e) {
60
71
  console.warn(e)
package/src/export/web.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as helper from './helper'
2
+ import * as RDF from './rdf'
2
3
 
3
4
  const path = require('path')
4
5
  const fs = require('fs-extra')
@@ -16,6 +17,15 @@ export async function exporter(
16
17
  'web-iframe'?: boolean
17
18
  'web-indexeddb'?: boolean
18
19
  'web-zip'?: boolean
20
+
21
+ // special cases for RDF
22
+ 'rdf-format'?: string
23
+ 'rdf-preview'?: string
24
+ 'rdf-url'?: string
25
+ 'rdf-type'?: string
26
+ 'rdf-template'?: string
27
+ 'rdf-license'?: string
28
+ 'rdf-educationalLevel'?: string
19
29
  },
20
30
  json: any
21
31
  ) {
@@ -109,6 +119,8 @@ export async function exporter(
109
119
  console.warn('could not add image')
110
120
  }
111
121
 
122
+ const jsonLD = await RDF.script(argument, json)
123
+
112
124
  try {
113
125
  if (argument['web-iframe']) {
114
126
  await helper.writeFile(path.join(tmpPath, 'start.html'), index)
@@ -116,10 +128,14 @@ export async function exporter(
116
128
  tmpPath,
117
129
  'index.html',
118
130
  argument.readme,
131
+ jsonLD,
119
132
  argument.style,
120
133
  'start.html'
121
134
  )
122
135
  } else {
136
+ index = helper.inject(jsonLD, index)
137
+ index = helper.prettify(index)
138
+
123
139
  await helper.writeFile(path.join(tmpPath, 'index.html'), index)
124
140
  }
125
141
  } catch (e) {