first commit - WIP: lib functions + fixtures + tests
This commit is contained in:
commit
b5888ebf4c
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
node_modules/
|
89
lib/json-to-html.js
Normal file
89
lib/json-to-html.js
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
|
||||||
|
module.exports = function(json) {
|
||||||
|
const html = json.map(getHTML).join('\n\n')
|
||||||
|
return html
|
||||||
|
}
|
||||||
|
|
||||||
|
function getHTML(slideData) {
|
||||||
|
let video = audio = ''
|
||||||
|
if (!slideData.title) slideData.title = ''
|
||||||
|
title = `
|
||||||
|
<div class="title">
|
||||||
|
${slideData.title}
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
if (slideData.video) {
|
||||||
|
video = getVideoHtml(slideData.video)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slideData.audio) {
|
||||||
|
audio = getAudioHtml(slideData.audio)
|
||||||
|
}
|
||||||
|
|
||||||
|
const duration = `data-duration="${slideData.duration ? slideData.duration : 5}"`
|
||||||
|
return `
|
||||||
|
<div class="slide" ${duration}>
|
||||||
|
${title}
|
||||||
|
${video}
|
||||||
|
${audio}
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
function getVideoHtml(videoData) {
|
||||||
|
let urls = []
|
||||||
|
let volume = ''
|
||||||
|
if (typeof(videoData) === 'string') {
|
||||||
|
urls.push(videoData)
|
||||||
|
} else { // video is an object
|
||||||
|
if (videoData.hasOwnProperty('url')) {
|
||||||
|
urls.push(videoData.url)
|
||||||
|
} else if (videoData.hasOwnProperty('zoom')) {
|
||||||
|
urls = videoData.zoom
|
||||||
|
}
|
||||||
|
if (videoData.volume) {
|
||||||
|
volume = `data-volume="${videoData.volume}"`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const urlsHtml = urls.map((url, index) => {
|
||||||
|
return `data-url_${index}="${makeEmbed(url)}"`
|
||||||
|
}).join('\n')
|
||||||
|
return `
|
||||||
|
<div class="video" ${urlsHtml} ${volume}> </div>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAudioHtml(audioData) {
|
||||||
|
let url = continueStr = volume = ''
|
||||||
|
|
||||||
|
// short circuit to return an empty div if audioData is null or not an object
|
||||||
|
// this is useful for user to specify empty audio track to cause existing
|
||||||
|
// audio to pause
|
||||||
|
if (!audioData || !(typeof(audioData === 'object'))) {
|
||||||
|
return `<div class="audio></div>`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (audioData.url) {
|
||||||
|
url = `data-url="${makeEmbed(audioData.url)}"`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (audioData.volume) {
|
||||||
|
volume = `data-volume="${audioData.volume}"`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (audioData['continue']) {
|
||||||
|
continueStr = `data-continue="true"`
|
||||||
|
}
|
||||||
|
|
||||||
|
return `
|
||||||
|
<div class="audio" ${url} ${volume} ${continueStr}></div>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeEmbed(url) {
|
||||||
|
if (!url.endsWith('#embed')) {
|
||||||
|
return `${url}#embed`
|
||||||
|
} else {
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
}
|
7
lib/yaml-to-json.js
Normal file
7
lib/yaml-to-json.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
const YAML = require('yamljs')
|
||||||
|
|
||||||
|
module.exports = function(yamlTxt) {
|
||||||
|
const arr = yamlTxt.split('\n\n')
|
||||||
|
const data = arr.map(o => YAML.parse(o))
|
||||||
|
return data
|
||||||
|
}
|
21
package.json
Normal file
21
package.json
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"name": "player-yaml-html",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Convert playlist YAML-ish documents to JSON -> HTML",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://code.with.camp/sanj/player-yaml-html"
|
||||||
|
},
|
||||||
|
"author": "CAMP",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"yamljs": "^0.3.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"tape": "^4.9.0"
|
||||||
|
}
|
||||||
|
}
|
539
test/fixtures/expected-html.html
vendored
Normal file
539
test/fixtures/expected-html.html
vendored
Normal file
|
@ -0,0 +1,539 @@
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
FROM JANTA COLONY TO JANTA COLONY
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
At first, three stories from the year 1950 in Bombay
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="2">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
ONE
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="3">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AFL/0,0,6580,3763#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="8">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
The Greater Bombay Tenant's Association is formed in April 1950
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AFL/0,0,6580,3763#embed"
|
||||||
|
data-url_1="https://pad.ma/documents/AFL/1933,24,3578,977#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="15">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
It demands the "rationing" of living space in Bombay
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AFL/1933,24,3578,977#embed"
|
||||||
|
data-url_1="https://pad.ma/documents/AFL/1568,1461,3352,2401#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="audio" data-volume="0.05" data-continue="true"></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="15">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
One week later, 250 people removed from Mahim causeway
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/ADZ/0,0,6554,5409#embed"
|
||||||
|
data-url_1="https://pad.ma/documents/ADZ/3836,2088,6401,3440#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="4">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
occupy Samudra Mahal in Worli
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AEA#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AEB#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="10">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
It is reoccupied one day later.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AED/381,0,6178,3090#embed"
|
||||||
|
data-url_1="https://pad.ma/documents/AED/1088,4231,4018,5776#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="8">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
5 days after that, a govt. conference on the "squatter issue" was held.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AEE/278,3664,3352,5477#embed"
|
||||||
|
data-url_1="https://pad.ma/documents/AEE/778,5104,2231,6034#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
It refers to the 1949 survey of homeless done by TISS as its main source.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="10">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
Three months later, a proposal is made to create a "Poor Man's Colony" in Mankhurd.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AEK/0,0,6671,6170#embed"
|
||||||
|
data-url_1="https://pad.ma/documents/AEK/0,2620,2925,4162#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
For 4,000 families, "Between Sion and Trombay"
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AEK/0,2620,2925,4162#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
In an area known as Manbudruk, in Farsi, big brother of Mankhurd.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AEP/0,0,1538,1378#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
In another year the squatter population has doubled to 75,000
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AEZ/916,3015,6633,6030#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="8">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
On December there are evictions of 1,700 huts at Sion Circle, out of which 500 moved to Mankhurd.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AEZ/916,3015,6633,6030#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
The following year there are many people who refuse to be transported to Mankhurd.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AEW/0,0,4024,3608#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
On a national level, in 1954 Nehru had decided he was against paying compensation in such cases.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AFA/0,0,1830,1302#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="9">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
A better idea, he is quoted in TOI, is "to burn them".
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AFB/0,0,1856,1306#embed"
|
||||||
|
data-url_1="https://pad.ma/documents/AFB/706,653,1834,1306#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="3">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="6">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
Meanwhile in April 1950, the limits of Bombay city have been officially extended.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AHX#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="10">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AEL/853,169,5855,2620#embed"
|
||||||
|
data-url_1="https://pad.ma/documents/AEL/830,2505,5832,4956#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="3">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
OK, Lets watch a three minute version of Raj Kapoor's Sree 420
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://indiancine.ma/AKDP/player/BFS#embed" data-volume="0.6"> </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://indiancine.ma/AKDP/player/BFR#embed" data-volume="0.6"> </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="10">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
Abbas
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AFC/0,926,1866,2154#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
In Mani Kaul Satah se Uthata
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://indiancine.ma/VEW/player/CLW#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
In Guru Dutt's first film. Mr and Mrs 55
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://indiancine.ma/AKCY/player/EZ#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
This is Shastri Nagar, Bandra, where 16 years later Anand Patwardhan would shoot Hamara Shehar.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://indiancine.ma/AKBH/player/DV#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://indiancine.ma/AKBH/player/DX#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
Cut to: Vidhu Vinod Chopra's first film, on Mankhurd Children's Home.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://indiancine.ma/AMGS/player/IV#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="6">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
A Deonar Farm Road rumour: One Evening in the mid-fifties, Homi Bhabha, Raj Kapoor and Jamshedji Tata were having tea. With Nehru.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="audio" data-url="https://indiancine.ma/AKBH/player/EC#embed" data-volume="0.5" data-continue="true"></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="10">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
All three shared their cultural, scientific and industrial vision with Nehru, who gave them in turn land for RK Studios, BARC and TISS.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="5">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AIA/0,56,2448,1688#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="10">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AEG/0,1327,3493,3311#embed"
|
||||||
|
data-url_1="https://pad.ma/documents/AEG/202,0,3752,1983#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="8">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AEI/851,0,5596,2652#embed"
|
||||||
|
data-url_1="https://pad.ma/documents/AEI/0,0,6096,5303#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="slide" data-duration="7">
|
||||||
|
|
||||||
|
<div class="title">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="video" data-url_0="https://pad.ma/documents/AEJ/0,0,5691,5296#embed" > </div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
244
test/fixtures/expected-json.json
vendored
Normal file
244
test/fixtures/expected-json.json
vendored
Normal file
|
@ -0,0 +1,244 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"title": "FROM JANTA COLONY TO JANTA COLONY",
|
||||||
|
"duration": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "At first, three stories from the year 1950 in Bombay",
|
||||||
|
"duration": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": null,
|
||||||
|
"duration": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "ONE",
|
||||||
|
"duration": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://pad.ma/documents/AFL/0,0,6580,3763",
|
||||||
|
"duration": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": {
|
||||||
|
"zoom": [
|
||||||
|
"https://pad.ma/documents/AFL/0,0,6580,3763",
|
||||||
|
"https://pad.ma/documents/AFL/1933,24,3578,977"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"title": "The Greater Bombay Tenant's Association is formed in April 1950",
|
||||||
|
"duration": 8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": {
|
||||||
|
"zoom": [
|
||||||
|
"https://pad.ma/documents/AFL/1933,24,3578,977",
|
||||||
|
"https://pad.ma/documents/AFL/1568,1461,3352,2401"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"title": "It demands the \"rationing\" of living space in Bombay",
|
||||||
|
"audio": {
|
||||||
|
"url": null,
|
||||||
|
"volume": 0.05,
|
||||||
|
"continue": true
|
||||||
|
},
|
||||||
|
"duration": 15
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": {
|
||||||
|
"zoom": [
|
||||||
|
"https://pad.ma/documents/ADZ/0,0,6554,5409",
|
||||||
|
"https://pad.ma/documents/ADZ/3836,2088,6401,3440"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"title": "One week later, 250 people removed from Mahim causeway",
|
||||||
|
"duration": 15
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://pad.ma/documents/AEA",
|
||||||
|
"title": "occupy Samudra Mahal in Worli",
|
||||||
|
"duration": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://pad.ma/documents/AEB",
|
||||||
|
"duration": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": {
|
||||||
|
"zoom": [
|
||||||
|
"https://pad.ma/documents/AED/381,0,6178,3090",
|
||||||
|
"https://pad.ma/documents/AED/1088,4231,4018,5776"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"title": "It is reoccupied one day later.",
|
||||||
|
"duration": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": {
|
||||||
|
"zoom": [
|
||||||
|
"https://pad.ma/documents/AEE/278,3664,3352,5477",
|
||||||
|
"https://pad.ma/documents/AEE/778,5104,2231,6034"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"title": "5 days after that, a govt. conference on the \"squatter issue\" was held.",
|
||||||
|
"duration": 8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "It refers to the 1949 survey of homeless done by TISS as its main source.",
|
||||||
|
"duration": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": {
|
||||||
|
"zoom": [
|
||||||
|
"https://pad.ma/documents/AEK/0,0,6671,6170",
|
||||||
|
"https://pad.ma/documents/AEK/0,2620,2925,4162"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"title": "Three months later, a proposal is made to create a \"Poor Man's Colony\" in Mankhurd.",
|
||||||
|
"duration": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://pad.ma/documents/AEK/0,2620,2925,4162",
|
||||||
|
"title": "For 4,000 families, \"Between Sion and Trombay\"",
|
||||||
|
"duration": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://pad.ma/documents/AEP/0,0,1538,1378",
|
||||||
|
"title": "In an area known as Manbudruk, in Farsi, big brother of Mankhurd.",
|
||||||
|
"duration": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://pad.ma/documents/AEZ/916,3015,6633,6030",
|
||||||
|
"title": "In another year the squatter population has doubled to 75,000",
|
||||||
|
"duration": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://pad.ma/documents/AEZ/916,3015,6633,6030",
|
||||||
|
"title": "On December there are evictions of 1,700 huts at Sion Circle, out of which 500 moved to Mankhurd.",
|
||||||
|
"duration": 8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://pad.ma/documents/AEW/0,0,4024,3608",
|
||||||
|
"title": "The following year there are many people who refuse to be transported to Mankhurd."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://pad.ma/documents/AFA/0,0,1830,1302",
|
||||||
|
"title": "On a national level, in 1954 Nehru had decided he was against paying compensation in such cases.",
|
||||||
|
"duration": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": {
|
||||||
|
"zoom": [
|
||||||
|
"https://pad.ma/documents/AFB/0,0,1856,1306",
|
||||||
|
"https://pad.ma/documents/AFB/706,653,1834,1306"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"title": "A better idea, he is quoted in TOI, is \"to burn them\".",
|
||||||
|
"duration": 9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": null,
|
||||||
|
"duration": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://pad.ma/documents/AHX",
|
||||||
|
"title": "Meanwhile in April 1950, the limits of Bombay city have been officially extended.",
|
||||||
|
"duration": 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": {
|
||||||
|
"zoom": [
|
||||||
|
"https://pad.ma/documents/AEL/853,169,5855,2620",
|
||||||
|
"https://pad.ma/documents/AEL/830,2505,5832,4956"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"title": null,
|
||||||
|
"duration": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": null,
|
||||||
|
"duration": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": {
|
||||||
|
"url": "https://indiancine.ma/AKDP/player/BFS",
|
||||||
|
"volume": 0.6
|
||||||
|
},
|
||||||
|
"title": "OK, Lets watch a three minute version of Raj Kapoor's Sree 420"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": {
|
||||||
|
"url": "https://indiancine.ma/AKDP/player/BFR",
|
||||||
|
"volume": 0.6
|
||||||
|
},
|
||||||
|
"title": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://pad.ma/documents/AFC/0,926,1866,2154",
|
||||||
|
"title": "Abbas",
|
||||||
|
"duration": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://indiancine.ma/VEW/player/CLW",
|
||||||
|
"title": "In Mani Kaul Satah se Uthata"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://indiancine.ma/AKCY/player/EZ",
|
||||||
|
"title": "In Guru Dutt's first film. Mr and Mrs 55"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://indiancine.ma/AKBH/player/DV",
|
||||||
|
"title": "This is Shastri Nagar, Bandra, where 16 years later Anand Patwardhan would shoot Hamara Shehar."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://indiancine.ma/AKBH/player/DX",
|
||||||
|
"title": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://indiancine.ma/AMGS/player/IV",
|
||||||
|
"title": "Cut to: Vidhu Vinod Chopra's first film, on Mankhurd Children's Home."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "A Deonar Farm Road rumour: One Evening in the mid-fifties, Homi Bhabha, Raj Kapoor and Jamshedji Tata were having tea. With Nehru.",
|
||||||
|
"duration": 6,
|
||||||
|
"audio": {
|
||||||
|
"url": "https://indiancine.ma/AKBH/player/EC",
|
||||||
|
"volume": 0.5,
|
||||||
|
"continue": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "All three shared their cultural, scientific and industrial vision with Nehru, who gave them in turn land for RK Studios, BARC and TISS.",
|
||||||
|
"duration": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://pad.ma/documents/AIA/0,56,2448,1688",
|
||||||
|
"title": null,
|
||||||
|
"duration": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": {
|
||||||
|
"zoom": [
|
||||||
|
"https://pad.ma/documents/AEG/0,1327,3493,3311",
|
||||||
|
"https://pad.ma/documents/AEG/202,0,3752,1983"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"title": null,
|
||||||
|
"duration": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": {
|
||||||
|
"zoom": [
|
||||||
|
"https://pad.ma/documents/AEI/851,0,5596,2652",
|
||||||
|
"https://pad.ma/documents/AEI/0,0,6096,5303"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"title": null,
|
||||||
|
"duration": 8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"video": "https://pad.ma/documents/AEJ/0,0,5691,5296",
|
||||||
|
"title": null,
|
||||||
|
"duration": 7
|
||||||
|
}
|
||||||
|
]
|
179
test/fixtures/playlist.yml
vendored
Normal file
179
test/fixtures/playlist.yml
vendored
Normal file
|
@ -0,0 +1,179 @@
|
||||||
|
title: FROM JANTA COLONY TO JANTA COLONY
|
||||||
|
duration: 5
|
||||||
|
|
||||||
|
title: At first, three stories from the year 1950 in Bombay
|
||||||
|
duration: 5
|
||||||
|
|
||||||
|
title:
|
||||||
|
duration: 2
|
||||||
|
|
||||||
|
title: ONE
|
||||||
|
duration: 5
|
||||||
|
|
||||||
|
video: https://pad.ma/documents/AFL/0,0,6580,3763
|
||||||
|
duration: 3
|
||||||
|
|
||||||
|
video:
|
||||||
|
zoom:
|
||||||
|
- https://pad.ma/documents/AFL/0,0,6580,3763
|
||||||
|
- https://pad.ma/documents/AFL/1933,24,3578,977
|
||||||
|
|
||||||
|
title: The Greater Bombay Tenant's Association is formed in April 1950
|
||||||
|
duration: 8
|
||||||
|
|
||||||
|
video:
|
||||||
|
zoom:
|
||||||
|
- https://pad.ma/documents/AFL/1933,24,3578,977
|
||||||
|
- https://pad.ma/documents/AFL/1568,1461,3352,2401
|
||||||
|
title: It demands the "rationing" of living space in Bombay
|
||||||
|
audio:
|
||||||
|
url:
|
||||||
|
volume: 0.05
|
||||||
|
continue: true
|
||||||
|
duration: 15
|
||||||
|
|
||||||
|
video:
|
||||||
|
zoom:
|
||||||
|
- https://pad.ma/documents/ADZ/0,0,6554,5409
|
||||||
|
- https://pad.ma/documents/ADZ/3836,2088,6401,3440
|
||||||
|
title: One week later, 250 people removed from Mahim causeway
|
||||||
|
duration: 15
|
||||||
|
|
||||||
|
video: https://pad.ma/documents/AEA
|
||||||
|
title: occupy Samudra Mahal in Worli
|
||||||
|
duration: 4
|
||||||
|
|
||||||
|
video: https://pad.ma/documents/AEB
|
||||||
|
duration: 5
|
||||||
|
|
||||||
|
video:
|
||||||
|
zoom:
|
||||||
|
- https://pad.ma/documents/AED/381,0,6178,3090
|
||||||
|
- https://pad.ma/documents/AED/1088,4231,4018,5776
|
||||||
|
title: It is reoccupied one day later.
|
||||||
|
duration: 10
|
||||||
|
|
||||||
|
video:
|
||||||
|
zoom:
|
||||||
|
- https://pad.ma/documents/AEE/278,3664,3352,5477
|
||||||
|
- https://pad.ma/documents/AEE/778,5104,2231,6034
|
||||||
|
title: 5 days after that, a govt. conference on the "squatter issue" was held.
|
||||||
|
duration: 8
|
||||||
|
|
||||||
|
title: It refers to the 1949 survey of homeless done by TISS as its main source.
|
||||||
|
duration: 5
|
||||||
|
|
||||||
|
video:
|
||||||
|
zoom:
|
||||||
|
- https://pad.ma/documents/AEK/0,0,6671,6170
|
||||||
|
- https://pad.ma/documents/AEK/0,2620,2925,4162
|
||||||
|
title: Three months later, a proposal is made to create a "Poor Man's Colony" in Mankhurd.
|
||||||
|
duration: 10
|
||||||
|
|
||||||
|
video: https://pad.ma/documents/AEK/0,2620,2925,4162
|
||||||
|
title: For 4,000 families, "Between Sion and Trombay"
|
||||||
|
duration: 5
|
||||||
|
|
||||||
|
video: https://pad.ma/documents/AEP/0,0,1538,1378
|
||||||
|
title: In an area known as Manbudruk, in Farsi, big brother of Mankhurd.
|
||||||
|
duration: 5
|
||||||
|
|
||||||
|
video: https://pad.ma/documents/AEZ/916,3015,6633,6030
|
||||||
|
title: In another year the squatter population has doubled to 75,000
|
||||||
|
duration: 5
|
||||||
|
|
||||||
|
video: https://pad.ma/documents/AEZ/916,3015,6633,6030
|
||||||
|
title: On December there are evictions of 1,700 huts at Sion Circle, out of which 500 moved to Mankhurd.
|
||||||
|
duration: 8
|
||||||
|
|
||||||
|
video: https://pad.ma/documents/AEW/0,0,4024,3608
|
||||||
|
title: The following year there are many people who refuse to be transported to Mankhurd.
|
||||||
|
|
||||||
|
video: https://pad.ma/documents/AFA/0,0,1830,1302
|
||||||
|
title: On a national level, in 1954 Nehru had decided he was against paying compensation in such cases.
|
||||||
|
duration: 5
|
||||||
|
|
||||||
|
video:
|
||||||
|
zoom:
|
||||||
|
- https://pad.ma/documents/AFB/0,0,1856,1306
|
||||||
|
- https://pad.ma/documents/AFB/706,653,1834,1306
|
||||||
|
title: A better idea, he is quoted in TOI, is "to burn them".
|
||||||
|
duration: 9
|
||||||
|
|
||||||
|
title:
|
||||||
|
duration: 3
|
||||||
|
|
||||||
|
video: https://pad.ma/documents/AHX
|
||||||
|
title: Meanwhile in April 1950, the limits of Bombay city have been officially extended.
|
||||||
|
duration: 6
|
||||||
|
|
||||||
|
video:
|
||||||
|
zoom:
|
||||||
|
- https://pad.ma/documents/AEL/853,169,5855,2620
|
||||||
|
- https://pad.ma/documents/AEL/830,2505,5832,4956
|
||||||
|
title:
|
||||||
|
duration: 10
|
||||||
|
|
||||||
|
title:
|
||||||
|
duration: 3
|
||||||
|
|
||||||
|
video:
|
||||||
|
url: https://indiancine.ma/AKDP/player/BFS
|
||||||
|
volume: 0.6
|
||||||
|
title: OK, Lets watch a three minute version of Raj Kapoor's Sree 420
|
||||||
|
|
||||||
|
video:
|
||||||
|
url: https://indiancine.ma/AKDP/player/BFR
|
||||||
|
volume: 0.6
|
||||||
|
title:
|
||||||
|
|
||||||
|
video: https://pad.ma/documents/AFC/0,926,1866,2154
|
||||||
|
title: Abbas
|
||||||
|
duration: 10
|
||||||
|
|
||||||
|
video: https://indiancine.ma/VEW/player/CLW
|
||||||
|
title: In Mani Kaul Satah se Uthata
|
||||||
|
|
||||||
|
video: https://indiancine.ma/AKCY/player/EZ
|
||||||
|
title: In Guru Dutt's first film. Mr and Mrs 55
|
||||||
|
|
||||||
|
video: https://indiancine.ma/AKBH/player/DV
|
||||||
|
title: This is Shastri Nagar, Bandra, where 16 years later Anand Patwardhan would shoot Hamara Shehar.
|
||||||
|
|
||||||
|
video: https://indiancine.ma/AKBH/player/DX
|
||||||
|
title:
|
||||||
|
|
||||||
|
video: https://indiancine.ma/AMGS/player/IV
|
||||||
|
title: Cut to: Vidhu Vinod Chopra's first film, on Mankhurd Children's Home.
|
||||||
|
|
||||||
|
title: A Deonar Farm Road rumour: One Evening in the mid-fifties, Homi Bhabha, Raj Kapoor and Jamshedji Tata were having tea. With Nehru.
|
||||||
|
duration: 6
|
||||||
|
audio:
|
||||||
|
url: https://indiancine.ma/AKBH/player/EC
|
||||||
|
volume: 0.5
|
||||||
|
continue: true
|
||||||
|
|
||||||
|
title: All three shared their cultural, scientific and industrial vision with Nehru, who gave them in turn land for RK Studios, BARC and TISS.
|
||||||
|
duration: 10
|
||||||
|
|
||||||
|
video: https://pad.ma/documents/AIA/0,56,2448,1688
|
||||||
|
title:
|
||||||
|
duration: 5
|
||||||
|
|
||||||
|
video:
|
||||||
|
zoom:
|
||||||
|
- https://pad.ma/documents/AEG/0,1327,3493,3311
|
||||||
|
- https://pad.ma/documents/AEG/202,0,3752,1983
|
||||||
|
title:
|
||||||
|
duration: 10
|
||||||
|
|
||||||
|
video:
|
||||||
|
zoom:
|
||||||
|
- https://pad.ma/documents/AEI/851,0,5596,2652
|
||||||
|
- https://pad.ma/documents/AEI/0,0,6096,5303
|
||||||
|
title:
|
||||||
|
duration: 8
|
||||||
|
|
||||||
|
video: https://pad.ma/documents/AEJ/0,0,5691,5296
|
||||||
|
title:
|
||||||
|
duration: 7
|
29
test/index.js
Normal file
29
test/index.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
const tape = require('tape')
|
||||||
|
const path = require('path')
|
||||||
|
const fs = require('fs')
|
||||||
|
const yamlToJson = require('../lib/yaml-to-json')
|
||||||
|
const jsonToHtml = require('../lib/json-to-html')
|
||||||
|
|
||||||
|
|
||||||
|
tape('test yaml to json', assert => {
|
||||||
|
const txt = fs.readFileSync(path.join(__dirname, 'fixtures', 'playlist.yml'), 'utf8')
|
||||||
|
const jsonData = yamlToJson(txt)
|
||||||
|
const expectedJson = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures', 'expected-json.json'), 'utf8'))
|
||||||
|
assert.deepEqual(jsonData, expectedJson, 'json parsed as expected')
|
||||||
|
// console.log(JSON.stringify(jsonData, null, 2))
|
||||||
|
assert.end()
|
||||||
|
})
|
||||||
|
|
||||||
|
tape('test json to html', assert => {
|
||||||
|
const jsonData = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures', 'expected-json.json'), 'utf8'))
|
||||||
|
const html = jsonToHtml(jsonData)
|
||||||
|
const expectedHtml = fs.readFileSync(path.join(__dirname, 'fixtures', 'expected-html.html'), 'utf8')
|
||||||
|
assert.equal(html.trim(), expectedHtml.trim(), 'html as expected')
|
||||||
|
assert.end()
|
||||||
|
})
|
||||||
|
|
||||||
|
// const filename = process.argv[1]
|
||||||
|
|
||||||
|
// const yamlTxt = fs.readFileSync(filename, 'utf-8')
|
||||||
|
|
||||||
|
// console.log(jsonToHtml(yamlToJson(yamlTxt)))
|
Loading…
Reference in New Issue
Block a user