Add direct links to categories
This commit is contained in:
parent
331e4c206a
commit
3ccff54fa4
60
index.js
60
index.js
@ -33,36 +33,41 @@ function processInput (section, chair, category, audience, abbreviation,
|
||||
* The resulting markup is written to ./result.txt.
|
||||
*/
|
||||
function createHTML() {
|
||||
let resultString = ''
|
||||
const recordsBySection = groupBy(records, x => x.section)
|
||||
let resultString = ''
|
||||
let sections = Array.from(['Informatik', 'Angewandte Informatik', 'Wirtschaftsinformatik'])
|
||||
.filter(section => recordsBySection.has(section))
|
||||
|
||||
Array.from(['Informatik', 'Angewandte Informatik', 'Wirtschaftsinformatik'])
|
||||
.forEach(function (section) {
|
||||
if (recordsBySection.has(section)) {
|
||||
resultString += `<h1>${section}</h1>\n`
|
||||
sections.forEach(function (section) {
|
||||
resultString += `<a
|
||||
style="display: inline-block; padding: .5rem; border: 1px solid lightgray; border-radius: 2px; box-shadow: 0px 1px 2px rgba(0,0,0,0.3);"
|
||||
href="#${convertToID(section)}">${section}</a>\n`
|
||||
})
|
||||
|
||||
let recordsByChair = groupBy(recordsBySection.get(section), x => x.chair)
|
||||
let chairs = [...recordsByChair.keys()].sort()
|
||||
chairs.forEach(function (chair) {
|
||||
resultString += `<h3>${chair}</h3>\n`
|
||||
sections.forEach(function (section) {
|
||||
resultString += `<h1 id="${convertToID(section)}">${section}</h1>\n`
|
||||
|
||||
let recordsByCategory = groupBy(recordsByChair.get(chair), x => x.category)
|
||||
let categories = [...recordsByCategory.keys()].sort()
|
||||
categories.forEach(function (category) {
|
||||
let recordsByChair = groupBy(recordsBySection.get(section), x => x.chair)
|
||||
let chairs = [...recordsByChair.keys()].sort()
|
||||
chairs.forEach(function (chair) {
|
||||
resultString += `<h3>${chair}</h3>\n`
|
||||
|
||||
recordsByCategory.get(category).forEach(function (cur) {
|
||||
resultString += `<div style="border: 1px solid lightgray; box-shadow: 0px 2px 4px rgba(0,0,0,0.3); padding: 1rem; margin-bottom: 1rem;"><h5>${category}`
|
||||
resultString += cur.abbreviation ? ` ${cur.abbreviation}` : ''
|
||||
resultString += `: ${cur.topic} (${cur.audience})</h5>\n`
|
||||
resultString += `<p><strong>Kurzbeschreibung:</strong> ${cur.description}</p>\n`
|
||||
resultString += `<p><strong>Anmeldefrist</strong>: ${cur.deadline}</p>\n`
|
||||
resultString += `<p><strong>Weitere Informationen und Anmeldung:</strong> `
|
||||
resultString += cur.link.startsWith('http') ? `<br/><a href="${cur.link}">${cur.link}</a>` : cur.link
|
||||
resultString += `</p></div>\n`
|
||||
})
|
||||
})
|
||||
let recordsByCategory = groupBy(recordsByChair.get(chair), x => x.category)
|
||||
let categories = [...recordsByCategory.keys()].sort()
|
||||
categories.forEach(function (category) {
|
||||
|
||||
recordsByCategory.get(category).forEach(function (cur) {
|
||||
resultString += `<div style="border: 1px solid lightgray; box-shadow: 0px 2px 4px rgba(0,0,0,0.3); padding: 1rem; margin-bottom: 1rem;"><h5>${category}`
|
||||
resultString += cur.abbreviation ? ` ${cur.abbreviation}` : ''
|
||||
resultString += `: ${cur.topic} (${cur.audience})</h5>\n`
|
||||
resultString += `<p><strong>Kurzbeschreibung:</strong> ${cur.description}</p>\n`
|
||||
resultString += `<p><strong>Anmeldefrist</strong>: ${cur.deadline}</p>\n`
|
||||
resultString += `<p><strong>Weitere Informationen und Anmeldung:</strong> `
|
||||
resultString += cur.link.startsWith('http') ? `<br/><a href="${cur.link}">${cur.link}</a>` : cur.link
|
||||
resultString += `</p></div>\n`
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
fs.writeFileSync('result.txt', resultString)
|
||||
@ -93,3 +98,10 @@ function groupBy(list, keyGetter) {
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to ID-compatible string by replacing non-word characters with dashes.
|
||||
*/
|
||||
function convertToID(string) {
|
||||
return string.replace(/\W/g, '-')
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user