Skip to content

Commit b982370

Browse files
authored
➕ merge pull request #140 from devmount/qr-youtube
QR codes for YouTube links
2 parents 94c5264 + 15ada90 commit b982370

2 files changed

Lines changed: 67 additions & 27 deletions

File tree

src/views/SetlistShow.vue

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,12 @@ export default {
627627
footer: {
628628
font: 'FiraSans',
629629
fontSize: 8,
630-
margin: [ 0, 30, 0, 0 ]
630+
margin: [ 0, 20, 0, 0 ]
631+
},
632+
qr: {
633+
font: 'FiraMono',
634+
fontSize: 8,
635+
alignment: 'right'
631636
}
632637
}
633638
};
@@ -665,12 +670,12 @@ export default {
665670
];
666671
},
667672
getPdfSongsheets () {
668-
var sheets = [];
673+
let sheets = [];
669674
for (const key in this.setlist.songs) {
670675
if (this.setlist.songs.hasOwnProperty(key) && this.setlist.songs[key].id in this.songs) {
671676
const song = this.songs[this.setlist.songs[key].id];
672677
// handle song content parts
673-
var content = [];
678+
let content = [];
674679
let parts = this.parsedContent(
675680
song.content,
676681
song.customTuning ? song.customTuningDelta : 0,
@@ -702,7 +707,31 @@ export default {
702707
});
703708
}
704709
});
705-
var meta = [
710+
// create footer
711+
let footer = [{
712+
// imprint with ccli#, author names and (c) year publisher
713+
width: '*',
714+
style: 'footer',
715+
text: [
716+
song.note ? this.$t('field.note') + ':\n' + song.note + '\n\n' : '',
717+
song.ccli ? 'CCLI Song Nr.: ' + song.ccli + '\n' : '',
718+
song.authors ? song.authors + '\n' : '',
719+
'\u00A9 ' + (song.year ? song.year + ' ' : '') + song.publisher
720+
]
721+
}];
722+
if (song.youtube) {
723+
footer.push({
724+
// QR code for YouTube link
725+
width: '140',
726+
margin: [ 0, 20, 0, 0 ],
727+
stack: [
728+
{ text: 'https://youtu.be/' + song.youtube, style: 'qr' },
729+
{ qr: 'https://youtu.be/' + song.youtube, fit: '90', style: 'qr', margin: [ 0, 5, 0, 0 ] }
730+
]
731+
});
732+
}
733+
// put songsheet together
734+
let songsheet = [
706735
// song title [tuning] with a line beneath
707736
{ text: song.title.toUpperCase(), style: 'header' },
708737
{ canvas: [{ type: 'line', x1: 0, y1: 0, x2: 505, y2: 0, lineWidth: .5 }] },
@@ -713,22 +742,13 @@ export default {
713742
margin: [ 0, 4, 0, 0 ]
714743
},
715744
content,
716-
// footer with ccli#, author names and (c) year publisher
717-
{
718-
text: [
719-
song.note ? this.$t('field.note') + ':\n' + song.note + '\n\n' : '',
720-
song.ccli ? 'CCLI Song Nr.: ' + song.ccli + '\n' : '',
721-
song.authors ? song.authors + '\n' : '',
722-
'\u00A9 ' + (song.year ? song.year + ' ' : '') + song.publisher
723-
],
724-
style: 'footer'
725-
}
745+
{ columnGap: 8, columns: footer }
726746
];
727747
// add page break after every song exept for the last
728748
if (this.setlist.songs.length > 0 && key < this.setlist.songs.length-1) {
729-
meta.push({ text: '', pageBreak: 'after', style: 'code' });
749+
songsheet.push({ text: '', pageBreak: 'after', style: 'code' });
730750
}
731-
sheets = sheets.concat(meta);
751+
sheets = sheets.concat(songsheet);
732752
}
733753
}
734754
return sheets;

src/views/SongShow.vue

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,11 @@ export default {
427427
font: 'FiraSans',
428428
fontSize: 8,
429429
margin: [ 0, 20, 0, 0 ]
430+
},
431+
qr: {
432+
font: 'FiraMono',
433+
fontSize: 8,
434+
alignment: 'right'
430435
}
431436
}
432437
};
@@ -441,7 +446,8 @@ export default {
441446
// prepare song content for PDF export
442447
getPdfSongContent () {
443448
// handle all song parts
444-
var content = [], parts = this.parsedContent(this.song.content, this.tuning, this.chords, false);
449+
let content = [];
450+
let parts = this.parsedContent(this.song.content, this.tuning, this.chords, false);
445451
parts.forEach((part) => {
446452
if (part.type == 'v' && part.number != '0') {
447453
content.push({
@@ -468,22 +474,36 @@ export default {
468474
});
469475
}
470476
});
477+
// create footer
478+
let footer = [{
479+
// imprint with ccli#, author names and (c) year publisher
480+
width: '*',
481+
style: 'copyright',
482+
text: [
483+
this.song.note ? this.$t('field.note') + ':\n' + this.song.note + '\n\n' : '',
484+
this.song.ccli ? 'CCLI Song Nr.: ' + this.song.ccli + '\n' : '',
485+
this.song.authors ? this.song.authors + '\n' : '',
486+
'\u00A9 ' + (this.song.year ? this.song.year + ' ' : '') + this.song.publisher
487+
]
488+
}];
489+
if (this.song.youtube) {
490+
footer.push({
491+
// QR code for YouTube link
492+
width: '140',
493+
margin: [ 0, 20, 0, 0 ],
494+
stack: [
495+
{ text: 'https://youtu.be/' + this.song.youtube, style: 'qr' },
496+
{ qr: 'https://youtu.be/' + this.song.youtube, fit: '90', style: 'qr', margin: [ 0, 5, 0, 0 ] }
497+
]
498+
});
499+
}
471500
// return array with song data ready for pdfMake
472501
return [
473502
// song title [tuning] with a line beneath
474503
{ text: this.song.title.toUpperCase() + (this.tuning ? ' [' + this.keyScale()[(12 + this.keyScale().indexOf(this.song.tuning) + (this.tuning % 12)) % 12] + ']' : ''), style: 'header' },
475504
{ canvas: [{ type: 'line', x1: 0, y1: 0, x2: 505, y2: 0, lineWidth: .5 }] },
476505
content,
477-
// imprint with ccli#, author names and (c) year publisher
478-
{
479-
style: 'copyright',
480-
text: [
481-
this.song.note ? this.$t('field.note') + ':\n' + this.song.note + '\n\n' : '',
482-
this.song.ccli ? 'CCLI Song Nr.: ' + this.song.ccli + '\n' : '',
483-
this.song.authors ? this.song.authors + '\n' : '',
484-
'\u00A9 ' + (this.song.year ? this.song.year + ' ' : '') + this.song.publisher
485-
]
486-
}
506+
{ columnGap: 8, columns: footer }
487507
];
488508
}
489509
},

0 commit comments

Comments
 (0)