2022-01-14 17:56:42 +01:00
import { UTXOEngine } from "./engine.js" ;
import { markdownTable } from "https://cdn.skypack.dev/markdown-table@3?dts" ;
2022-01-03 08:48:00 +01:00
2022-01-14 17:56:42 +01:00
const utxo = new UTXOEngine ( { silent : true } ) ;
await utxo . init ( ) ;
2022-01-03 08:48:00 +01:00
// get 2022
2022-01-14 17:56:42 +01:00
const entry = utxo . entries [ "22" ] ;
2022-01-01 06:09:06 +01:00
// SPEAKERS
2022-01-14 17:56:42 +01:00
const speakers = entry . specs . speakers ;
const sortedSpeakers = speakers . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ;
const tracks = entry . specs . tracks ;
2022-01-01 08:28:44 +01:00
const methods = {
// SPEAKERS - table
2022-01-14 17:56:42 +01:00
async speakersTableGen ( ) {
const speakersTableArr = [ [ "Jméno" , "Organizace" ] ] ;
2022-01-03 07:06:57 +01:00
for ( const speaker of sortedSpeakers ) {
2022-01-14 17:56:42 +01:00
const name = ` ** ${ speaker . name } ** ` ;
speakersTableArr . push ( [
( speaker . twitter
? ` [ ${ name } ](https://twitter.com/ ${ speaker . twitter } ) `
: name ) + ( speaker . nickname ? ` ( ${ speaker . nickname } ) ` : "" ) ,
speaker . orgs ? speaker . orgs . trim ( ) : "" ,
] ) ;
2022-01-01 08:28:44 +01:00
}
2022-01-14 17:56:42 +01:00
const speakersTable =
` Celkem přednášejících: ** ${ speakers . length } ** \n \n _(abecedně)_ \n \n ` +
markdownTable ( speakersTableArr ) ;
2022-01-01 08:28:44 +01:00
//console.log(speakersTable)
2022-01-14 17:56:42 +01:00
return speakersTable ;
2022-01-01 08:28:44 +01:00
} ,
// SPEAKERS - leads
2022-01-14 17:56:42 +01:00
async speakersLeadsGen ( ) {
const speakersLeadsArr = [ ] ;
for ( const speaker of sortedSpeakers . filter ( ( speaker ) => speaker . lead ) ) {
const orgs = speaker . orgs ? ` \n * ${ speaker . orgs . trim ( "\n" ) } ` : "" ;
const socials = [ ] ;
2022-01-01 08:28:44 +01:00
if ( speaker . twitter ) {
2022-01-14 17:56:42 +01:00
socials . push (
` Twitter: [@ ${ speaker . twitter } ](https://twitter.com/ ${ speaker . twitter } ) ` ,
) ;
2022-01-01 08:28:44 +01:00
}
if ( speaker . web ) {
2022-01-14 17:56:42 +01:00
socials . push (
` Web: [ ${
speaker . web . name ? speaker . web . name : speaker . name
} ] ( $ { speaker . web . url } ) ` ,
) ;
2022-01-01 08:28:44 +01:00
}
2022-01-14 17:56:42 +01:00
const img =
` ![](https://spec.utxo.cz/22/photos/speakers/ ${ speaker . id } -sm.png) ` ;
const item =
` ### ${ img } ${ speaker . name } \n \n * ${ speaker . bio . trim ( ) } ${ orgs } \n * ${
socials . join ( ", " )
} ` ;
speakersLeadsArr . push ( item ) ;
2022-01-01 08:28:44 +01:00
}
2022-01-14 17:56:42 +01:00
const speakersLeads = ` _(abecedně)_ \n \n ` + speakersLeadsArr . join ( "\n\n" ) ;
2022-01-01 08:28:44 +01:00
//console.log(speakersLeads)
2022-01-14 17:56:42 +01:00
return speakersLeads ;
2022-01-01 08:28:44 +01:00
} ,
// SPEAKERS - write file
2022-01-14 17:56:42 +01:00
async speakersBuild ( ) {
const speakersDocFile = "./docs/prednasejici.md" ;
const speakersText = await Deno . readTextFile ( speakersDocFile ) ;
let output = speakersText ;
output = output . replace (
/## Významní hosté([\s\S]+)## Seznam/m ,
` ## Významní hosté \n \n ${ await methods . speakersLeadsGen ( ) } \n \n ## Seznam ` ,
) ;
output = output . replace (
/## Seznam všech přednášejících([\s\S]+)### Datový/m ,
` ## Seznam všech přednášejících \n \n ${ await methods
. speakersTableGen ( ) } \ n \ n # # # Datový ` ,
) ;
await Deno . writeTextFile ( speakersDocFile , output ) ;
2022-01-01 10:04:14 +01:00
} ,
// TRACKS
2022-01-14 17:56:42 +01:00
async tracksGen ( ) {
const output = [ ] ;
2022-01-01 10:04:14 +01:00
for ( const track of tracks ) {
2022-01-14 17:56:42 +01:00
output . push (
` <details> \n \n <summary> ${ track . name } </summary> \n \n ${ track . examples . trim ( ) } \n \n </details> ` ,
) ;
2022-01-01 10:04:14 +01:00
}
2022-01-14 17:56:42 +01:00
return ` Přednášky a workshopy budou rozděleny do ** ${ tracks . length } tématických programových sekcí**. Níže naleznete jejich přehled a relevantní příklady. \n \n ` +
output . join ( "\n\n" ) ;
2022-01-01 10:04:14 +01:00
} ,
2022-01-14 17:56:42 +01:00
async tracksBuild ( ) {
const sourceFile = "./docs/hlavni-program.md" ;
const sourceText = await Deno . readTextFile ( sourceFile ) ;
let output = sourceText ;
output = output . replace (
/## Programové sekce([\s\S]+)## Časová/m ,
` ## Programové sekce \n \n ${ await methods . tracksGen ( ) } \n \n ## Časová ` ,
) ;
await Deno . writeTextFile ( sourceFile , output ) ;
2022-01-07 09:57:42 +01:00
} ,
// FAQs
2022-01-14 17:56:42 +01:00
async faqsGen ( ) {
const output = [ ] ;
2022-01-07 09:57:42 +01:00
for ( const item of entry . specs . faqs ) {
2022-01-14 17:56:42 +01:00
output . push (
` <details> \n \n <summary> ${ item . question . trim ( ) } </summary> \n \n ${ item . answer . trim ( ) } \n \n </details> ` ,
) ;
2022-01-07 09:57:42 +01:00
}
2022-01-14 17:56:42 +01:00
return output . join ( "\n\n" ) ;
2022-01-07 09:57:42 +01:00
} ,
2022-01-14 17:56:42 +01:00
async faqsBuild ( ) {
const docFile = "./docs/faq.md" ;
const docText = await Deno . readTextFile ( docFile ) ;
const faqs = await this . faqsGen ( ) ;
let output = docText ;
output = output . replace ( /# FAQ[\s\S]+/m , ` # FAQ \n \n ${ faqs } \n ` ) ;
2022-01-07 09:57:42 +01:00
// TODO replace
2022-01-14 17:56:42 +01:00
await Deno . writeTextFile ( docFile , output ) ;
2022-01-14 17:31:55 +01:00
} ,
// PARTNERS
2022-01-14 17:56:42 +01:00
async partnersGen ( type = "community" ) {
const arr = [ [ "Název" , "Popis" ] ] ;
for ( const item of entry . specs . partners . filter ( ( p ) => p . type === type ) ) {
arr . push ( [
` [** ${ item . name } **]( ${
item . twitter ? "https://twitter.com/" + item . twitter : item . web ? . url
} ) ` ,
item . desc ,
] ) ;
2022-01-14 17:31:55 +01:00
}
2022-01-14 17:56:42 +01:00
const table = markdownTable ( arr ) ;
return table ;
2022-01-14 17:31:55 +01:00
} ,
2022-01-14 17:56:42 +01:00
async partnersBuild ( ) {
const docFile = "./docs/partneri.md" ;
const docText = await Deno . readTextFile ( docFile ) ;
let output = docText ;
output = output . replace (
/## Spolupracující komunity([\s\S]+)## Mediální/m ,
` ## Spolupracující komunity \n \n ${ await methods . partnersGen (
"community" ,
) } \ n \ n # # Mediální ` ,
) ;
output = output . replace (
/## Mediální partneři([\s\S]+)/m ,
` ## Mediální partneři \n \n ${ await methods . partnersGen ( "medium" ) } \n \n ` ,
) ;
await Deno . writeTextFile ( docFile , output ) ;
const docFile2 = "./docs/sponzori.md" ;
const docText2 = await Deno . readTextFile ( docFile2 ) ;
let output2 = docText2 ;
output2 = output2 . replace (
/## Seznam sponzorů([\s\S]+)/m ,
` ## Seznam sponzorů \n \n ${ await methods . partnersGen ( "sponsor" ) } \n \n ` ,
) ;
await Deno . writeTextFile ( docFile2 , output2 ) ;
} ,
} ;
2022-01-01 06:09:06 +01:00
2022-01-01 08:28:44 +01:00
if ( ! Deno . args [ 0 ] ) {
2022-01-14 17:56:42 +01:00
await methods . speakersBuild ( ) ;
await methods . tracksBuild ( ) ;
await methods . faqsBuild ( ) ;
await methods . partnersBuild ( ) ;
console . log ( "done" ) ;
2022-01-01 08:28:44 +01:00
} else {
2022-01-14 17:56:42 +01:00
console . log ( await methods [ Deno . args [ 0 ] ] ( Deno . args [ 1 ] ) ) ;
2022-01-01 08:28:44 +01:00
}