lib-songbeamer
v1.1.0
Published
transforming SongBeamer Song-Files and Ablaufplan-Files
Downloads
15
Readme
Lib-Songbeamer
A Module for transforming SongBeamer Song-Files and Ablaufplan-Files into JSON and Back
PSA
This Module was written for a specific purpose:
- Load all Ablaufplan-Files in a Folder into JSON, in order to perform some stuff with the json.
All other Things (write back to file, songs) were put in for "completion"-reasons.
Still expect much stuff to be missing.
But i am looking forward to improve this, so write them issues, or even butter:
Make some Pull-Requests :-)
Installation
... is as simple as npm install lib-songbeamer
Usage
First, require the Module:
const songbeamer = require('lib-songbeamer')
Then you may perform the following actions:
Read in a Song-File (.sng) into json
songbeamer.song2JSON('examples/song.sng', function (err, json) {
if (err) {
console.error(err)
} else {
// Do Something with the JSON
}
})
Read in an Ablaufplan-File (.col) into json
songbeamer.ablauf2JSON('examples/ablaufplan.col', function (err, json) {
if (err) {
console.error(err)
} else {
// Do Something with the JSON
}
})
Write Some JSON into a Song-File (.sng)
songbeamer.json2Song(json, 'examples/song.sng', function (err) {
if (err) {
console.error(err)
} else {
// All was good
}
})
Remember: The JSON must be fitting (see Documentation>JSON)
Write Some JSON into an Ablaufplan-File (.col)
songbeamer.json2Ablauf(json, 'examples/ablaufplan.col', function (err) {
if (err) {
console.error(err)
} else {
// All was good
}
})
Remember: The JSON must be fitting (see Documentation>JSON)
Dependencies
None.
Documentation for Developers
Here be Some Infos to make this even better.
Libs
ClassDiagram:
Can be found in docs/classdiagram.png
Also as editable plantUML-File.
JSDOC. See also HTML Version @ docs/jsdoc/index.html
index
Packs the libs
Requires: module:song, module:ablauf, module:fs
Version: 1.0
Author: Dominik Sigmund
index.song2JSON(file, callback) 
Read in Song-File and callback a json
Kind: static method of index
Returns: Nothing
| Param | Type | Description | | --- | --- | --- | | file | string | Path to a Song-File | | callback | jsonSongCallback | A Callback with an error or the Json |
index.ablauf2JSON(file, callback) 
Read in Ablaufplan-File and callback a json
Kind: static method of index
Returns: Nothing
| Param | Type | Description | | --- | --- | --- | | file | string | Path to a Ablaufplan-File | | callback | jsonAblaufCallback | A Callback with an error or the Json |
index.json2Song(object, file, callback) 
Read in JSON, Write to File and callback possible Errors
Kind: static method of index
Returns: Nothing
| Param | Type | Description | | --- | --- | --- | | object | object | A JSON-Song-Object | | file | string | Path to a Song-File | | callback | errorCallback | A Callback with an error or nothing |
index.json2Ablauf(object, file, callback) 
Read in JSON, Write to File and callback possible Errors
Kind: static method of index
Returns: Nothing
| Param | Type | Description | | --- | --- | --- | | object | object | A JSON-Ablaufplan-Object | | file | string | Path to an Ablaufplan-File | | callback | errorCallback | A Callback with an error or nothing |
song
Gets Json from and json to song-files
Version: 1.0
Author: Dominik Sigmund
- song
- static
- inner
- ~isCaption(text)  bool
song.toJSON(data, callback) 
Get Json from a string
Kind: static method of song
Returns: Nothing
| Param | Type | Description | | --- | --- | --- | | data | string | String as delivered by fs.readFile | | callback | jsonCallback | A Callback with an error or the Json |
song.toFile(json, callback) 
Write Json to a File String
Kind: static method of song
Returns: Nothing
| Param | Type | Description | | --- | --- | --- | | json | object | String as delivered by fs.readFile | | callback | stringCallback | A Callback with an error or the String as delivered to fs.writeFile |
song~isCaption(text)  bool
Checks if a string is a caption (Vers, Bridge, Chorus, ...)
Kind: inner method of song
Returns: bool - - True, if is a caption, else false
| Param | Type | Description | | --- | --- | --- | | text | string | A Line of Text |
ablaufplan
Gets Json from and json to Ablaufplan-files
Version: 1.0
Author: Dominik Sigmund
- ablauf
- static
- inner
- ~regex 
- ~clean(text)  String
- ~color2Hex(color)  string
- ~hex2Color(hex)  string
- ~getType(caption, filename)  string
- ~colourNameToHex(colour)  string
ablauf.toFile(json, callback) 
Write Json to a File String
Kind: static method of ablauf
Returns: Nothing
| Param | Type | Description | | --- | --- | --- | | json | object | String as delivered by fs.readFile | | callback | stringCallback | A Callback with an error or the String as delivered to fs.writeFile |
ablauf~regex 
Get Json from a string
Kind: inner constant of ablauf
Returns: Nothing
| Param | Type | Description | | --- | --- | --- | | data | string | String as delivered by fs.readFile | | callback | jsonCallback | A Callback with an error or the Json |
ablauf~clean(text)  String
Removes Strange Symbols from the Text for a better json
Kind: inner method of ablauf
Returns: String - - A cleaner bit of Text
| Param | Type | Description | | --- | --- | --- | | text | string | A Bite of Text |
ablauf~color2Hex(color)  string
Takes Color Information and returns a css-hex-representation
Kind: inner method of ablauf
Returns: string - - A clean hex-rep
| Param | Type | Description | | --- | --- | --- | | color | string | Some weird color (string, windows decimal, ...) |
ablauf~hex2Color(hex)  string
Takes a Hex-Color and makes a windows-decimal-color out of it.
Kind: inner method of ablauf
Returns: string - - Windows Decimal Color
| Param | Type | Description | | --- | --- | --- | | hex | string | A Hex Color |
ablauf~getType(caption, filename)  string
Guesses the Type of the Item
Kind: inner method of ablauf
Returns: string - - Type, may be: song, video, powerpoint, sermon, unknown
| Param | Type | Description | | --- | --- | --- | | caption | string | The Caption of the item | | filename | string | The Filename of the item |
ablauf~colourNameToHex(colour)  string
Takes a cssColor-Name and returns the hex-value or an empty string
Kind: inner method of ablauf
Returns: string - - A Hex-Color or an empty String
| Param | Type | Description | | --- | --- | --- | | colour | string | A ColourName |
Tests
The Tests are written using the assert-class and can be found in the tests-folder
You may use your favorite Test-Runner to do them yourself.
My Commandline is as follows:
istanbul cover _mocha -- tests/*.js -R mochawesome
Results
Coverage: docs/coverage/lcov-report/index.html Mochawesome-Report: docs/mochawesome-report/index.html
JSON
Here are the Schema-Files of the JSON-Objects
Song
{
"definitions": {},
"$schema": "http://json-schema.org/draft-06/schema#",
"$id": "http://lib-songbeamer.com/song.json",
"type": "object",
"properties": {
"slides": {
"$id": "/properties/slides",
"type": "array",
"items": {
"$id": "/properties/slides/items",
"type": "object",
"properties": {
"lines": {
"$id": "/properties/slides/items/properties/lines",
"type": "array",
"items": {
"$id": "/properties/slides/items/properties/lines/items",
"type": "string",
"title": "The 0 Schema",
"description": "A Line of Song-Text",
"default": "",
"examples": [
"Our Father everlasting,"
]
}
},
"caption": {
"$id": "/properties/slides/items/properties/caption",
"type": "string",
"title": "The Caption Schema",
"description": "The Caption of a Slide.",
"default": "",
"examples": [
"Verse 1"
]
}
}
}
},
"LangCount": {
"$id": "/properties/LangCount",
"type": "string",
"title": "The Langcount Schema",
"description": "How many Languages are there",
"default": "",
"examples": [
"2"
]
},
"Title": {
"$id": "/properties/Title",
"type": "string",
"title": "The Title Schema",
"description": "Original Title of the Song",
"default": "",
"examples": [
"This I Believe (The Creed)"
]
},
"Editor": {
"$id": "/properties/Editor",
"type": "string",
"title": "The Editor Schema",
"description": "How was this created.",
"default": "",
"examples": [
"SongBeamer 4.14a"
]
},
"Version": {
"$id": "/properties/Version",
"type": "string",
"title": "The Version Schema",
"description": "Version of this Song.",
"default": "",
"examples": [
"3"
]
},
"TitleFormat": {
"$id": "/properties/TitleFormat",
"type": "string",
"title": "The Titleformat Schema",
"description": "How the Title is formatted",
"default": "",
"examples": [
"U"
]
},
"BackgroundImage": {
"$id": "/properties/BackgroundImage",
"type": "string",
"title": "The Backgroundimage Schema",
"description": "Path to the bg-image",
"default": "",
"examples": [
"bgvideos://Blanko f�r Songbeamer-1.jpg"
]
},
"(c)": {
"$id": "/properties/(c)",
"type": "string",
"title": "The (c) Schema",
"description": "Copyrights",
"default": "",
"examples": [
"Hillsong Worship"
]
},
"Translation": {
"$id": "/properties/Translation",
"type": "string",
"title": "The Translation Schema",
"description": "Name of the translators",
"default": "",
"examples": [
"Martin Bruch & Dennis Strehl"
]
},
"Author": {
"$id": "/properties/Author",
"type": "string",
"title": "The Author Schema",
"description": "Name of the Text-Author.",
"default": "",
"examples": [
"Ben Fielding & Matthew Crocker"
]
},
"Melody": {
"$id": "/properties/Melody",
"type": "string",
"title": "The Melody Schema",
"description": "Name of the Melody-Author.",
"default": "",
"examples": [
"Ben Fielding & Matthew Crocker"
]
},
"TitleLang2": {
"$id": "/properties/TitleLang2",
"type": "string",
"title": "The Titlelang2 Schema",
"description": "Second Title in different Language",
"default": "",
"examples": [
"Das glaube ich"
]
},
"VerseOrder": {
"$id": "/properties/VerseOrder",
"type": "string",
"title": "The Verseorder Schema",
"description": "Order of Slides, by captions",
"default": "",
"examples": [
"Verse 1,Chorus,Verse 2,Chorus,Bridge,Chorus"
]
}
}
}
Ablaufplan
{
"definitions": {},
"$schema": "http://json-schema.org/draft-06/schema#",
"$id": "http://lib-songbeamer.com/ablauf.json",
"type": "object",
"properties": {
"title": {
"$id": "/properties/title",
"type": "string",
"title": "The Title Schema",
"description": "The Title of the Ablaufplan",
"default": "",
"examples": [
"examples/ablaufplan.col"
]
},
"items": {
"$id": "/properties/items",
"type": "array",
"items": {
"$id": "/properties/items/items",
"type": "object",
"properties": {
"filename": {
"$id": "/properties/items/items/properties/filename",
"type": "string",
"title": "The Filename Schema",
"description": "Filename of an Item. May be Empty if no File",
"default": "",
"examples": [
"..\\..\\Vorspann\\Vorspann 31.12.2017.ppt"
]
},
"caption": {
"$id": "/properties/items/items/properties/caption",
"type": "string",
"title": "The Caption Schema",
"description": "The Caption, as seen in the Songbeamer",
"default": "",
"examples": [
"Vorspann 31.12.2017"
]
},
"color": {
"$id": "/properties/items/items/properties/color",
"type": "string",
"title": "The Color Schema",
"description": "The Color of the Item",
"default": "",
"examples": [
"#000000"
]
},
"type": {
"$id": "/properties/items/items/properties/type",
"type": "string",
"title": "The Type Schema",
"description": "The guessed Type.",
"default": "",
"examples": [
"powerpoint"
]
}
}
}
}
}
}
Authors
- Dominik Sigmund [email protected]
License
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to http://unlicense.org/