@liascript/exporter 2.6.7--0.11.1 → 2.6.9--0.11.1
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 +2 -1
- package/package.json +1 -1
- package/src/export/project.ts +58 -9
- package/src/index.ts +9 -3
package/package.json
CHANGED
package/src/export/project.ts
CHANGED
|
@@ -125,14 +125,26 @@ export async function exporter(
|
|
|
125
125
|
let subItemList: any[] = []
|
|
126
126
|
|
|
127
127
|
for (let j = 0; j < course.collection.length; j++) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
if (course.collection[j].link) {
|
|
129
|
+
subCards += `<div class='col-sm-6 col-md-4 col-lg-3 ${
|
|
130
|
+
course.grid ? 'mb-3' : ''
|
|
131
|
+
}'>
|
|
132
|
+
${toLinkCard(argument, course.collection[j], true)}
|
|
133
|
+
</div>`
|
|
134
|
+
} else {
|
|
135
|
+
let { html, json } = await toCard(
|
|
136
|
+
argument,
|
|
137
|
+
course.collection[j],
|
|
138
|
+
true
|
|
139
|
+
)
|
|
140
|
+
subCards += `<div class='col-sm-6 col-md-4 col-lg-3 ${
|
|
141
|
+
course.grid ? 'mb-3' : ''
|
|
142
|
+
}'>
|
|
132
143
|
${html}
|
|
133
144
|
</div>`
|
|
134
145
|
|
|
135
|
-
|
|
146
|
+
subItemList.push(json)
|
|
147
|
+
}
|
|
136
148
|
}
|
|
137
149
|
|
|
138
150
|
const itemListElement = {
|
|
@@ -169,6 +181,8 @@ export async function exporter(
|
|
|
169
181
|
</div>`
|
|
170
182
|
} else if (course.html) {
|
|
171
183
|
cards += "<div class='col-12'>" + course.html + '</div>'
|
|
184
|
+
} else if (course.link) {
|
|
185
|
+
cards += "<div class='col'>" + toLinkCard(argument, course) + '</div>'
|
|
172
186
|
} else {
|
|
173
187
|
let { html, json } = await toCard(argument, course)
|
|
174
188
|
cards += "<div class='col'>" + html + '</div>'
|
|
@@ -362,6 +376,38 @@ function hash(url: string) {
|
|
|
362
376
|
return value.startsWith('-') ? '0' + value.slice(1) : value
|
|
363
377
|
}
|
|
364
378
|
|
|
379
|
+
function toLinkCard(
|
|
380
|
+
argument: any,
|
|
381
|
+
course: any,
|
|
382
|
+
small: boolean = false
|
|
383
|
+
): string {
|
|
384
|
+
if (course.arguments) {
|
|
385
|
+
argument = course.arguments.reduce((a, b) => {
|
|
386
|
+
return { ...a, ...b }
|
|
387
|
+
}, argument)
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
let tags = []
|
|
391
|
+
|
|
392
|
+
const tagList = course.tags || tags
|
|
393
|
+
for (let i = 0; i < tagList.length; i++) {
|
|
394
|
+
Categories.add(tagList[i].toLowerCase())
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
let comment = course.title ? course.comment : course.comment || course.link
|
|
398
|
+
|
|
399
|
+
return card(
|
|
400
|
+
small,
|
|
401
|
+
'',
|
|
402
|
+
course.title || '',
|
|
403
|
+
comment || '',
|
|
404
|
+
tagList,
|
|
405
|
+
{},
|
|
406
|
+
course.logo,
|
|
407
|
+
course.link
|
|
408
|
+
)
|
|
409
|
+
}
|
|
410
|
+
|
|
365
411
|
async function toCard(
|
|
366
412
|
argument: any,
|
|
367
413
|
course: any,
|
|
@@ -551,7 +597,8 @@ function card(
|
|
|
551
597
|
ims?: string
|
|
552
598
|
apk?: string
|
|
553
599
|
},
|
|
554
|
-
img_url?: string
|
|
600
|
+
img_url?: string,
|
|
601
|
+
link?: string
|
|
555
602
|
): string {
|
|
556
603
|
let image = ''
|
|
557
604
|
|
|
@@ -578,10 +625,10 @@ function card(
|
|
|
578
625
|
|
|
579
626
|
if (tags.length > 0) {
|
|
580
627
|
for (let i = 0; i < tags.length; i++) {
|
|
581
|
-
tag_list += `<span class="badge rounded-pill bg-light text-dark">${tags[i]}</span>`
|
|
628
|
+
tag_list += `<span style="display: inline; white-space: break-spaces;" class="badge rounded-pill bg-light text-dark">${tags[i]}</span>`
|
|
582
629
|
}
|
|
583
630
|
|
|
584
|
-
tag_list = `<
|
|
631
|
+
tag_list = `<p>${tag_list}</p>`
|
|
585
632
|
}
|
|
586
633
|
|
|
587
634
|
if (small && comment) {
|
|
@@ -644,7 +691,9 @@ function card(
|
|
|
644
691
|
.join('|')}">
|
|
645
692
|
${image}
|
|
646
693
|
<div class="card-body" style="transform: rotate(0);">
|
|
647
|
-
<a href="https://liascript.github.io/course
|
|
694
|
+
<a href="${link ? '' : 'https://liascript.github.io/course/?'}${
|
|
695
|
+
link || url
|
|
696
|
+
}" target="_blank" class="link-dark stretched-link">
|
|
648
697
|
<h${small ? 6 : 5} class="card-title">${title}</h${small ? 6 : 5}>
|
|
649
698
|
</a>
|
|
650
699
|
<p class="card-text">${comment}</p>
|
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.9--0.11.1')
|
|
26
26
|
} else if (argv.h || argv.help) {
|
|
27
27
|
help()
|
|
28
28
|
} else if (argv.i || argv.input) {
|
|
@@ -144,8 +144,14 @@ async function run(argument) {
|
|
|
144
144
|
|
|
145
145
|
if (collection) {
|
|
146
146
|
const next = PROJECT.getNext(collection)
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
|
|
148
|
+
if (next === null) {
|
|
149
|
+
PROJECT.exporter(argument, collection)
|
|
150
|
+
} else {
|
|
151
|
+
console.warn('loading:', next)
|
|
152
|
+
|
|
153
|
+
app.ports.input.send([format, next])
|
|
154
|
+
}
|
|
149
155
|
}
|
|
150
156
|
} else if (!helper.isURL(argument.input)) {
|
|
151
157
|
const data = fs.readFileSync(argument.input, 'utf8')
|