-
Notifications
You must be signed in to change notification settings - Fork 0
/
layout.js
121 lines (92 loc) · 4.04 KB
/
layout.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const { apiCall } = require('./helpers')
const airtable_key = process.env.AIRTABLE_KEY
const content = require("./content")
module.exports = async function (lang, index=false) {
let c // c = content
if (lang === "en") {
c = content.en
}
if (lang === "ru") {
c = content.ru
}
// generate_content
const content_otd = async () => {
// test // const response = await apiCall("https://jsonplaceholder.typicode.com/todos/1", "GET")
try {
const response = await apiCall("https://api.airtable.com/v0/"+c.airtable_base_id+"/Table%201?maxRecords=1&view=Grid%20view", "GET", null, { authorization_key: airtable_key })
// console.log("response", response)
const ytVideoURL = response.records[0].fields.url
const embedYTurl = ytVideoURL.replace("watch?v=", "embed/")
// console.log(embedYTurl)
return embedYTurl
}
catch (err) {
console.log("err", err)
}
// while developing
// return "https://www.youtube.com/embed/Cqm0hbXf2d0"
}
// // to get lit-html extension highlighting you can do
// function html(string) {
// return string
// }
// html``
return /*html*/ String.raw`
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>${c.title}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href=${index ? "styles.css" : "../styles.css"}>
</head>
<body>
<div style="text-align: center;">
<div>
<a href="/en"> EN </a> | <a href="/ru"> RU </a>
</div>
<h1 style="font-size: 20px;">${c.title}</h1>
<p>${c.automatic}</p>
<p>${c.video_update_time}</p>
<div class="outer-embed-wrapper">
<div class="embed-container">
<iframe src="${await content_otd()}" frameBorder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowFullScreen></iframe>
<!-- Embedly has it without recomnded and more similar videos -->
<!-- <iframe class="embedly-embed" src="//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FCqm0hbXf2d0%3Ffeature%3Doembed&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DCqm0hbXf2d0&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FCqm0hbXf2d0%2Fhqdefault.jpg&key=internal&type=text%2Fhtml&schema=youtube" width="500" height="281" scrolling="no" frameborder="0" allow="autoplay; fullscreen" allowfullscreen="true"></iframe> -->
</div>
</div>
<p>${c.subtitles_info}</p>
<h2 style="font-size: 15px;">
<div>
<a href="https://calendar.google.com/event?action=TEMPLATE&tmeid=NWtoZTFmYmtsaHFyOTFtMWk1N2tsNWY4YjJfMjAxOTAyMjFUMTcwMDAwWiBhYmR0M2lxam5ndGdhazlzZThxZGx1bGY1a0Bn&tmsrc=abdt3iqjngtgak9se8qdlulf5k%40group.calendar.google.com&scp=ALL" target="_blank">
<img style="border-radius: 5px;" src=${index ? c.save_to_g_calendar_img : "../"+c.save_to_g_calendar_img} />
</a>
</div>
<!-- or a material btn -->
<!-- <button class="btn blue" type="button"><span>Save</span></button> -->
<!-- SAVE -->
${c.save_to_g_calendar_txt}
</h2>
<h2 style="font-size: 15px;">${c.encouragement}</h2>
<div>. . .</div>
<br>
<div class="links">
<div>
<a href=${c.yt_list_url} target="_blank"> ${c.yt_list} </a>
</div>
<div>
<a href=${c.past_videos_url} target="_blank"> ${c.past_videos} </a>
</div>
<div>
<a><a href="https://github.com/zalab-co?utf8=%E2%9C%93&q=hypatia" target="_blank"> ${c.oss} </a>
</div>
<div>
<a><a href="https://www.zalab.co" target="_blank"> ${c.madeBy} </a>
</div>
</div>
</div>
</body>
</html>
`;
};