Info endpoint /cms/

This commit is contained in:
Ral 2021-12-28 23:41:25 +01:00
parent 3b94bb3fc4
commit 960b3f9a28
12 changed files with 159 additions and 18 deletions

File diff suppressed because one or more lines are too long

18
public/cms/index.html Normal file
View File

@ -0,0 +1,18 @@
<!doctype html><html lang=en>
<head>
<meta charset=utf-8>
<meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no">
<title>rC3 NOWHERE</title>
<link href=/fork-awesome/css/fork-awesome.min.css rel=stylesheet type=text/css>
<link rel=stylesheet href=https://infobeamer.montage2.de/cms.min.82b6edb09ee1e67820c146ec17a3715d828149d79b6d6c7da84279be1934d777.css>
<script src=https://infobeamer.montage2.de/js/config.817bdeb42b1436e077bf46365a2e3906e9b2b21c82cdce825ed0f2740693cc6a.js integrity="sha256-gXvetCsUNuB3v0Y2Wi45BumyshyCzc6CXtDydAaTzGo="></script>
</head>
<body>
<main id=main>
</main>
<script src=https://infobeamer.montage2.de/js/moment/moment.min.73de4254959530e4d1d9bec586379184f96b4953dacf9cd5e5e2bdd7bfeceef7.js integrity="sha256-c95CVJWVMOTR2b7FhjeRhPlrSVPaz5zV5eK917/s7vc="></script>
<script src=https://infobeamer.montage2.de/js/preact/preact.min.0c204e20934f1e09cfe86fbcf1d069d842f988fc71efe3a923021c08892c71c8.js integrity="sha256-DCBOIJNPHgnP6G+88dBp2EL5iPxx7+OpIwIcCIksccg="></script>
<script src=https://infobeamer.montage2.de/js/htm/htm.80e39afe20fd61183412eda89efa10532d57945e6364642aceacd50eb2384b4b.js integrity="sha256-gOOa/iD9YRg0Eu2onvoQUy1XlF5jZGQqzqzVDrI4S0s="></script>
<script src=https://infobeamer.montage2.de/main.b95b770378f5aa404878194a2a67b6ff6ac77b6ab6f98f536485ed4719f3b7ea.js integrity="sha256-uVt3A3j1qkBIeBlKKme2/2rHe2q2+Y9TZIXtRxnzt+o=" type=module></script>
</body>
</html>

View File

@ -4,8 +4,8 @@
<meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no">
<title>rC3 NOWHERE</title>
<link href=/fork-awesome/css/fork-awesome.min.css rel=stylesheet type=text/css>
<link rel=stylesheet href=https://infobeamer.montage2.de/hashtag.min.aba4dc9d7533f7bdf247773a3d7d6f4a14294b3831d7c5cf1ad28abe660fe0b4.css>
<script src=https://infobeamer.montage2.de/js/config.0f4d0d28e4cf21f765f0b1911e185b73399aa76b4db102fc085df728a4e0c8fe.js integrity="sha256-D00NKOTPIfdl8LGRHhhbczmap2tNsQL8CF33KKTgyP4="></script>
<link rel=stylesheet href=https://infobeamer.montage2.de/hashtag.min.210a4b181230691ab2e54ee91c2473ca230b4b00cb44aee9c33158cb0ccaf8e5.css>
<script src=https://infobeamer.montage2.de/js/config.817bdeb42b1436e077bf46365a2e3906e9b2b21c82cdce825ed0f2740693cc6a.js integrity="sha256-gXvetCsUNuB3v0Y2Wi45BumyshyCzc6CXtDydAaTzGo="></script>
</head>
<body>
<main id=main>
@ -13,6 +13,6 @@
<script src=https://infobeamer.montage2.de/js/moment/moment.min.73de4254959530e4d1d9bec586379184f96b4953dacf9cd5e5e2bdd7bfeceef7.js integrity="sha256-c95CVJWVMOTR2b7FhjeRhPlrSVPaz5zV5eK917/s7vc="></script>
<script src=https://infobeamer.montage2.de/js/preact/preact.min.0c204e20934f1e09cfe86fbcf1d069d842f988fc71efe3a923021c08892c71c8.js integrity="sha256-DCBOIJNPHgnP6G+88dBp2EL5iPxx7+OpIwIcCIksccg="></script>
<script src=https://infobeamer.montage2.de/js/htm/htm.80e39afe20fd61183412eda89efa10532d57945e6364642aceacd50eb2384b4b.js integrity="sha256-gOOa/iD9YRg0Eu2onvoQUy1XlF5jZGQqzqzVDrI4S0s="></script>
<script src=https://infobeamer.montage2.de/main.26b1d4baa3f43353da48cd43f5172a32be15fd60774274e8daeddc774588a554.js integrity="sha256-JrHUuqP0M1PaSM1D9RcqMr4V/WB3QnTo2u3cd0WIpVQ=" type=module></script>
<script src=https://infobeamer.montage2.de/main.b95b770378f5aa404878194a2a67b6ff6ac77b6ab6f98f536485ed4719f3b7ea.js integrity="sha256-uVt3A3j1qkBIeBlKKme2/2rHe2q2+Y9TZIXtRxnzt+o=" type=module></script>
</body>
</html>

View File

@ -4,8 +4,8 @@
<meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no">
<title>rC3 NOWHERE</title>
<link href=/fork-awesome/css/fork-awesome.min.css rel=stylesheet type=text/css>
<link rel=stylesheet href=https://infobeamer.montage2.de/main.min.8c46a60c4117ea24e891ed52e735a7bb23e66937736be164743ff786b2c836b2.css>
<script src=https://infobeamer.montage2.de/js/config.0f4d0d28e4cf21f765f0b1911e185b73399aa76b4db102fc085df728a4e0c8fe.js integrity="sha256-D00NKOTPIfdl8LGRHhhbczmap2tNsQL8CF33KKTgyP4="></script>
<link rel=stylesheet href=https://infobeamer.montage2.de/main.min.2bff15f19297e3f97fbde58195288bc7035285c53ef8f0c673ce787a4bd4cf6b.css>
<script src=https://infobeamer.montage2.de/js/config.817bdeb42b1436e077bf46365a2e3906e9b2b21c82cdce825ed0f2740693cc6a.js integrity="sha256-gXvetCsUNuB3v0Y2Wi45BumyshyCzc6CXtDydAaTzGo="></script>
</head>
<body>
<main id=main>
@ -13,6 +13,6 @@
<script src=https://infobeamer.montage2.de/js/moment/moment.min.73de4254959530e4d1d9bec586379184f96b4953dacf9cd5e5e2bdd7bfeceef7.js integrity="sha256-c95CVJWVMOTR2b7FhjeRhPlrSVPaz5zV5eK917/s7vc="></script>
<script src=https://infobeamer.montage2.de/js/preact/preact.min.0c204e20934f1e09cfe86fbcf1d069d842f988fc71efe3a923021c08892c71c8.js integrity="sha256-DCBOIJNPHgnP6G+88dBp2EL5iPxx7+OpIwIcCIksccg="></script>
<script src=https://infobeamer.montage2.de/js/htm/htm.80e39afe20fd61183412eda89efa10532d57945e6364642aceacd50eb2384b4b.js integrity="sha256-gOOa/iD9YRg0Eu2onvoQUy1XlF5jZGQqzqzVDrI4S0s="></script>
<script src=https://infobeamer.montage2.de/main.26b1d4baa3f43353da48cd43f5172a32be15fd60774274e8daeddc774588a554.js integrity="sha256-JrHUuqP0M1PaSM1D9RcqMr4V/WB3QnTo2u3cd0WIpVQ=" type=module></script>
<script src=https://infobeamer.montage2.de/main.b95b770378f5aa404878194a2a67b6ff6ac77b6ab6f98f536485ed4719f3b7ea.js integrity="sha256-uVt3A3j1qkBIeBlKKme2/2rHe2q2+Y9TZIXtRxnzt+o=" type=module></script>
</body>
</html>

View File

@ -9,7 +9,9 @@
window.infoBeamerConfig.set("mastodonURL", "/toots-rc3-chaos.social.json");
window.infoBeamerConfig.set("mastodonFetchInterval", 120);
window.infoBeamerConfig.set("musicURL", "/music.json");
window.infoBeamerConfig.set("musicFetchInterval", 1);
window.infoBeamerConfig.set("musicFetchInterval", 60);
window.infoBeamerConfig.set("cmsURL", "/cms.json");
window.infoBeamerConfig.set("cmsFetchInterval", 300);
console.log("Info Beamer Configuration: ");
console.log(window.infoBeamerConfig);
})();

View File

@ -16,6 +16,8 @@
var default_profile_image_url = () => "./nounicorn.png";
var social_limiter = (tweets, toots) => {
let posts = tweets.concat(toots);
console.log("Number tweets (unfiltered): " + tweets.length);
console.log("Number toots (unfiltered): " + toots.length);
let maxAge = (p) => Date.parse(p.time) >= Date.now() - postMaxAge;
let recentPosts = posts.filter(maxAge);
let byDate = (fst, snd) => Date.parse(fst.time) - Date.parse(snd.time);
@ -146,6 +148,9 @@
}
return musicB;
};
var cms_filter = (data) => {
return data.assets.filter((a) => a.filetype === "image");
};
// ns-hugo:/home/raoul-web/rc3_2021/html-infobeamer-content/assets/js/dom.js
var html = htm.bind(preact.h);
@ -155,6 +160,10 @@
var urgent = 5 * 60 * 1e3;
var stale = 3 * 5 * 60 * 1e3;
var lapse = 5 * 1e3;
var maxImageAge = 15 * 1e3;
var freshImage = 4 * 1e3;
var staleImage = 4 * 1e3;
var cmsBaseUrl = "https://infobeamer-cms.c3voc.de/";
var talk_day = (talk) => {
const lut = {
1: "I",
@ -446,16 +455,109 @@
</div>`;
return inner;
};
var random_integer = (n) => Math.floor(Math.random() * n);
var image_dom_element = () => document.getElementById("imageItem");
var image_index = () => {
const el = image_dom_element();
return el !== null ? Number.parseInt(el.dataset.index) : -1;
};
var image_birth_time = () => {
const el = image_dom_element();
return el !== null ? el.dataset.birth : 0;
};
var image_age = (time) => time - image_birth_time();
var cms_age_class = (index, age) => {
const direction = index % 2 === 0 ? "left" : "right";
let oldness;
if (age <= freshImage) {
oldness = "fresh";
} else if (age >= maxImageAge - staleImage) {
oldness = "stale";
} else {
oldness = "";
}
return oldness + " " + direction;
};
var cms_item_url = (item) => cmsBaseUrl + item.url;
var cms_item_author = (item) => item.user;
var cms_meta_dom = (item, index, age) => {
let inner = html`
<div class="cms">
<div class="meta-box">
<div class="meta ${cms_age_class(index, age)}">
<div class="line1">
<span>
<span class="icon">
<span class="fa fa-file-image-o"></span>
</span>
<span class="header">Community Advertisement</span>
<span> by </span><span class="author">${cms_item_author(item)}</span>
</span>
</div>
<div class="line2">
<span>Upload own content at: </span>
<span>https://infobeamer-cms.c3voc.de/</span>
</div>
</div>
</div>
</div>`;
return inner;
};
var cms_image_dom = (item) => html`<img class="cms-image" src=${cms_item_url(item)} />`;
var cms_item_dom = (item, index, birth, age) => {
return html`
<div class="item ${cms_age_class(index, age)}" data-index=${index} data-birth=${birth} id="imageItem">
${cms_image_dom(item)}
</div>`;
};
var cms_content_dom = (item, index, birth, age) => {
return html`
<div class="cms">
<div class="content">
<div class="items">
${cms_item_dom(item, index, birth, age)}
</div>
</div>
</div>`;
};
var cms_dom = (items, time) => {
let inner;
if (items.length > 0) {
let age = image_age(time);
let item;
let index;
let birth;
if (age > maxImageAge) {
index = random_integer(items.length);
item = items.at(index);
birth = time;
age = 0;
} else {
index = image_index();
item = items.at(index);
birth = image_birth_time();
}
inner = html`
${cms_content_dom(item, index, birth, age)}
${cms_meta_dom(item, index, age)}
`;
} else {
inner = html``;
}
return inner;
};
function update_main_slide(data, time) {
let schedule = data.futureSchedule;
let runningEvent = data.runningEvent;
let music = data.music;
let postings = data.posts;
let cms = data.cms;
let inner = html`
${schedule_dom(schedule, time)}
${hashtag_dom(runningEvent)}
${music_playing_now_dom(music, time)}
${social_container_dom(postings)}
${cms_dom(cms, time)}
`;
const anchorElId = "main";
const el = document.getElementById(anchorElId);
@ -467,6 +569,7 @@
var musicData = [];
var twitterData = [];
var mastodonData = [];
var cmsData = [];
if (window.Worker) {
const workerBaseURL = window.infoBeamerConfig.get("workerBaseURL");
const fetchWorkerCode = workerBaseURL + "js/generic_fetch_worker.js";
@ -533,6 +636,22 @@
update_screen();
}
};
const cmsWorker = new Worker(fetchWorkerCode);
const cmsType = "CMS";
const cmsURL = window.infoBeamerConfig.get("cmsURL");
const cmsFetchInterval = window.infoBeamerConfig.get("cmsFetchInterval");
cmsWorker.postMessage({
fetchType: cmsType,
fetchURL: cmsURL,
fetchInterval: cmsFetchInterval
});
cmsWorker.onmessage = function(e) {
if (e.data.msgType === cmsType) {
cmsData = cms_filter(e.data.json);
console.log(cmsData);
update_screen();
}
};
} else {
console.log("Your browser doesn't support web workers.");
}
@ -544,7 +663,8 @@
futureSchedule: future_events(scheduleData, now),
runningEvent: running_event(scheduleData, now),
music: musicData,
posts: social_limiter(twitterData, mastodonData)
posts: social_limiter(twitterData, mastodonData),
cms: cmsData
}, now);
}
function main_loop() {

View File

@ -4,8 +4,8 @@
<meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no">
<title>rC3 NOWHERE</title>
<link href=/fork-awesome/css/fork-awesome.min.css rel=stylesheet type=text/css>
<link rel=stylesheet href=https://infobeamer.montage2.de/music_and_posts.min.20d57941e9d02defd0fe76dd43c265dc2cec4620c03d3cdaa9242a6db1710099.css>
<script src=https://infobeamer.montage2.de/js/config.0f4d0d28e4cf21f765f0b1911e185b73399aa76b4db102fc085df728a4e0c8fe.js integrity="sha256-D00NKOTPIfdl8LGRHhhbczmap2tNsQL8CF33KKTgyP4="></script>
<link rel=stylesheet href=https://infobeamer.montage2.de/music_and_posts.min.2ef379d059820a7aa8b66411626dd27949edd4538d1b3a32ccb631dce61b1287.css>
<script src=https://infobeamer.montage2.de/js/config.817bdeb42b1436e077bf46365a2e3906e9b2b21c82cdce825ed0f2740693cc6a.js integrity="sha256-gXvetCsUNuB3v0Y2Wi45BumyshyCzc6CXtDydAaTzGo="></script>
</head>
<body>
<main id=main>
@ -13,6 +13,6 @@
<script src=https://infobeamer.montage2.de/js/moment/moment.min.73de4254959530e4d1d9bec586379184f96b4953dacf9cd5e5e2bdd7bfeceef7.js integrity="sha256-c95CVJWVMOTR2b7FhjeRhPlrSVPaz5zV5eK917/s7vc="></script>
<script src=https://infobeamer.montage2.de/js/preact/preact.min.0c204e20934f1e09cfe86fbcf1d069d842f988fc71efe3a923021c08892c71c8.js integrity="sha256-DCBOIJNPHgnP6G+88dBp2EL5iPxx7+OpIwIcCIksccg="></script>
<script src=https://infobeamer.montage2.de/js/htm/htm.80e39afe20fd61183412eda89efa10532d57945e6364642aceacd50eb2384b4b.js integrity="sha256-gOOa/iD9YRg0Eu2onvoQUy1XlF5jZGQqzqzVDrI4S0s="></script>
<script src=https://infobeamer.montage2.de/main.26b1d4baa3f43353da48cd43f5172a32be15fd60774274e8daeddc774588a554.js integrity="sha256-JrHUuqP0M1PaSM1D9RcqMr4V/WB3QnTo2u3cd0WIpVQ=" type=module></script>
<script src=https://infobeamer.montage2.de/main.b95b770378f5aa404878194a2a67b6ff6ac77b6ab6f98f536485ed4719f3b7ea.js integrity="sha256-uVt3A3j1qkBIeBlKKme2/2rHe2q2+Y9TZIXtRxnzt+o=" type=module></script>
</body>
</html>

View File

@ -4,8 +4,8 @@
<meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no">
<title>rC3 NOWHERE</title>
<link href=/fork-awesome/css/fork-awesome.min.css rel=stylesheet type=text/css>
<link rel=stylesheet href=https://infobeamer.montage2.de/music.min.87d29aa288b144e1e3f6a8fdd8a20376fe1a7c32c8860803fb522145e46617d0.css>
<script src=https://infobeamer.montage2.de/js/config.0f4d0d28e4cf21f765f0b1911e185b73399aa76b4db102fc085df728a4e0c8fe.js integrity="sha256-D00NKOTPIfdl8LGRHhhbczmap2tNsQL8CF33KKTgyP4="></script>
<link rel=stylesheet href=https://infobeamer.montage2.de/music.min.d9b39d87a2831c3a80de9fe3d696ac9204b2a39148b51ead43a1579540f11850.css>
<script src=https://infobeamer.montage2.de/js/config.817bdeb42b1436e077bf46365a2e3906e9b2b21c82cdce825ed0f2740693cc6a.js integrity="sha256-gXvetCsUNuB3v0Y2Wi45BumyshyCzc6CXtDydAaTzGo="></script>
</head>
<body>
<main id=main>
@ -13,6 +13,6 @@
<script src=https://infobeamer.montage2.de/js/moment/moment.min.73de4254959530e4d1d9bec586379184f96b4953dacf9cd5e5e2bdd7bfeceef7.js integrity="sha256-c95CVJWVMOTR2b7FhjeRhPlrSVPaz5zV5eK917/s7vc="></script>
<script src=https://infobeamer.montage2.de/js/preact/preact.min.0c204e20934f1e09cfe86fbcf1d069d842f988fc71efe3a923021c08892c71c8.js integrity="sha256-DCBOIJNPHgnP6G+88dBp2EL5iPxx7+OpIwIcCIksccg="></script>
<script src=https://infobeamer.montage2.de/js/htm/htm.80e39afe20fd61183412eda89efa10532d57945e6364642aceacd50eb2384b4b.js integrity="sha256-gOOa/iD9YRg0Eu2onvoQUy1XlF5jZGQqzqzVDrI4S0s="></script>
<script src=https://infobeamer.montage2.de/main.26b1d4baa3f43353da48cd43f5172a32be15fd60774274e8daeddc774588a554.js integrity="sha256-JrHUuqP0M1PaSM1D9RcqMr4V/WB3QnTo2u3cd0WIpVQ=" type=module></script>
<script src=https://infobeamer.montage2.de/main.b95b770378f5aa404878194a2a67b6ff6ac77b6ab6f98f536485ed4719f3b7ea.js integrity="sha256-uVt3A3j1qkBIeBlKKme2/2rHe2q2+Y9TZIXtRxnzt+o=" type=module></script>
</body>
</html>