Transform "info.yaml" into "info.json"
I'm planning (low-priority) to rewrite the info.yaml files (previously maintained by @Midgard) into JSON files. I can't maintain the YAML, they already broke since month without I was able to notice and I can't work with them while I can with JSON files. So here is a thread on what I plan to do.
🍏 Reasons:
-
Supported: PHP supports natively JSON format while YAML require an extension.
-
I can do it: I have now skill to retrieve infos from JSON files to the website, I'm still maintaining the website at 99% so it matters.
-
Less format, unifying technologies: We already use JSON for the API, the lang file and I started to migrate all website and tools around it. Better to not multiply the format/parser/decoders imo.
-
Avoid merge conflicts: This is not about YAML vs JSON but about the current design of info.yaml: it redoes the mistake of centralising the translator credits as I did previously on the README.md at the root of episodes in a single file. I already explored this, I already dissolved this, and info.yaml brings it back. In my experiences; in the worst case the file is ignored because not in translator directory (and so this infos about credits of translation have to be manually added later, impossible to maintain for me) and in best case the translators changes it but it produce merge collisions at any MR... I plan to move a single JSON file dedicated to that into the lang/fr or lang/en directory.
🍍 Cons to know about JSON vs YAML:
-
No code comments possible by default... So, no embed documentation/tips/format possible.
-
Formated with parenthesis and quote while Yaml looks simpliers to write for humans.
🍌 Redesign proposal
info.json
(located at the root of the episodes folders, eg: ep28_TheFestivities/info.json):
{
"original-language": "en",
"supporters": "XXX",
"published": "YYYY-MM-DD",
"pluxmlID": "XXX",
"background-color": "#FFFFFF"
"software": "html string",
"credits": {
"art": "html string",
"scenario": "html string",
"contributions": "html string"
}
}
translation.json
(located at the root of the lang folders, eg: ep28_TheFestivities/lang/en ):
{
"translation": "html string",
"contributions": "html string",
"software": "html string"
}
Changes compared to the Yaml:
-
I'm dropping the "id" and "serial" from info.yaml; the name of the folder (eg. ep23_Take-a-Chance) contains already a number.
-
I'm keeping "original-language" but into a single word.
-
"financial supporters:" will now be "supporters" and have only the final number (detailing by platform was a lot of extra work for me to count name one by one before merging them).
-
I'm adding "pluxmlID" (might be "online-ID") will help at retrieving the URL on the website (peppercarrot.com/article/) for my CMS.
-
I keep "credits" but only as a table of strings with three constant sub-infos: "art", "scenario" and "contributions".
-
I keep "software" but only as a single string.
-
I drop the "Note" of the episode (a first comment I write about it on the blog), it's a personal note and belong to the blog, imo.
-
I add "background-color"; a new key for artistic purpose.
-
I add a new
translation.json
at the root of each lang (eg: ep28_TheFestivities/lang/en) with key for translation credits (main translation effort), "contributions" (corrections, edit, enhancements) and software of translator. I plan to add this file empty by default everywhere and call for a general maintainance of each translator.
🥑 What the purpose?
The purpose here is to add details to the API (episodes-v1.json at root here https://www.peppercarrot.com/0_sources/episodes-v1.json ) with this files, it is already possible to enter any folders of episodes and lang. Think about this system as a flat file JSON database for other project: e-reader, the official website, a book project, etc... It might also ease at removing the AUTHORS.md file, and generate it dynamically, and make more accurate credits (or create an "attribution generator" for the website?).
🍓 Contributions
If this topic interest you and you have feedback, expertize or ideas (or arguments against); I'll be happy to discuss and modify the design. I'll not start this until... until I find time (and episodes production will be the priority). I'm also open to any script on how to convert (or ease the process) automagically and convert a lot from YAML to JSON.