From 8f1fac325b7083bf2a5c72dc6e8126cc284e23ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Wed, 5 Jun 2024 16:53:46 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9E=95=20OpenLP=20service=20list=20expor?= =?UTF-8?q?t=20for=20setlists?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/package-lock.json | 11 ++++ frontend/package.json | 1 + frontend/src/locales/de.json | 1 + frontend/src/utils.js | 38 +++++++++++- frontend/src/views/SetlistShow.vue | 93 +++++++++++++++++++++++++++++- frontend/src/views/SongShow.vue | 34 +---------- 6 files changed, 142 insertions(+), 36 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 6bc579ef..1c61b4c3 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -14,6 +14,7 @@ "@vuepic/vue-datepicker": "^8.1.1", "@vueuse/core": "^10.2.1", "@vueuse/math": "^10.2.1", + "@zip.js/zip.js": "^2.7.45", "chart.js": "^4.0.1", "date-fns": "^3.2.0", "firebase": "^10.0.0", @@ -1884,6 +1885,16 @@ } } }, + "node_modules/@zip.js/zip.js": { + "version": "2.7.45", + "resolved": "https://registry.npmjs.org/@zip.js/zip.js/-/zip.js-2.7.45.tgz", + "integrity": "sha512-Mm2EXF33DJQ/3GWWEWeP1UCqzpQ5+fiMvT3QWspsXY05DyqqxWu7a9awSzU4/spHMHVFrTjani1PR0vprgZpow==", + "engines": { + "bun": ">=0.7.0", + "deno": ">=1.0.0", + "node": ">=16.5.0" + } + }, "node_modules/ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", diff --git a/frontend/package.json b/frontend/package.json index 7a2122b4..76c640a1 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -35,6 +35,7 @@ "@vuepic/vue-datepicker": "^8.1.1", "@vueuse/core": "^10.2.1", "@vueuse/math": "^10.2.1", + "@zip.js/zip.js": "^2.7.45", "chart.js": "^4.0.1", "date-fns": "^3.2.0", "firebase": "^10.0.0", diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index b7845012..ec942ec7 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -38,6 +38,7 @@ "filetypeSng": "SongBeamer-Datei [.sng]", "filetypeTxt": "Text-Datei [.txt]", "filetypeXml": "OpenLyrics-Datei [.xml]", + "filetypeOsz": "OpenLP Service [.osz]", "formatMarkdown": "Als Markdown formatiert", "formatPlain": "Reines Textformat", "formatSlack": "Für Slack formatiert", diff --git a/frontend/src/utils.js b/frontend/src/utils.js index 8267249e..82d89a02 100644 --- a/frontend/src/utils.js +++ b/frontend/src/utils.js @@ -187,9 +187,9 @@ const parsedContent = (content, tuning, showChords, twoColumns) => { }; // file download -const download = (data, filename) => { +const download = (data, filename, isBlob = false) => { var a = document.createElement('a'); - var file = new Blob([data], { type:'text/plain;charset=UTF-8' }); + var file = isBlob ? data : new Blob([data], { type:'text/plain;charset=UTF-8' }); // IE10+ if (window.navigator.msSaveOrOpenBlob) { window.navigator.msSaveOrOpenBlob(file, filename); @@ -330,6 +330,39 @@ const browserPrefersDark = () => { // trigger mailto const mailto = (address) => window.location.href = 'mailto:' + address; +// build OpenLyrics XML for given song +const openLyricsXML = (song, version, locales = [], allTags = null) => { + const timestamp = (new Date()).toISOString().slice(0, -5); + const title = `${song.title}`; + const subtitle = song.subtitle ? `${song.subtitle}` : ''; + const year = song.year ? `${song.year}` : ''; + const copyright = song.year || song.publisher + ? '' + song.year + ' ' + song.publisher.replace(/(?:\r\n|\r|\n)/g, '; ') + '' + : ''; + const ccli = song.ccli ? `${song.ccli}` : ''; + const authors = song.authors + ? '' + song.authors.split('|').map(a => `${a.trim()}`).join('') + '' + : ''; + const tags = song.tags && locales && allTags + ? '' + song.tags.map( + tag => locales.map(l =>`${allTags[tag][l] ?? tag.key}`).join('') + ).join('') + '' + : ''; + const lyrics = parsedContent(song.content, song.tuning, false, false).map(p => { + const num = p.number > 0 ? p.number : '1'; + return `` + p.content.replace(/\n/g, "
") + '
' + }).join(''); + + return ` + + + ${title}${subtitle} + ${copyright}${year}${ccli}${authors}${tags} + + ${lyrics} + `; +}; + export { keyScale, userRoles, @@ -347,4 +380,5 @@ export { sortTags, browserPrefersDark, mailto, + openLyricsXML, } diff --git a/frontend/src/views/SetlistShow.vue b/frontend/src/views/SetlistShow.vue index 38c8dfe9..3eaae920 100644 --- a/frontend/src/views/SetlistShow.vue +++ b/frontend/src/views/SetlistShow.vue @@ -141,6 +141,13 @@ {{ t('button.exportSetlistSheets') }} + @@ -458,7 +465,7 @@