Daily-Dose/real-time/index.html

206 lines
6.8 KiB
HTML
Raw Normal View History

2020-12-01 14:45:12 +00:00
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>
News Now
</title>
<!--
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">-->
<link rel="stylesheet" href="./css/bootstrap.min.css">
</head>
<body>
<h1 align="center" class="display-1">News Now</h1>
<main>
<div class="container">
2020-12-12 11:24:25 +00:00
<section>
<div class="list-group pb-4" id="contents"></div>
</section>
<section>
<div class="pb-4">
<a href="#configuration" id="configuration-button" class="btn btn-info invisible" data-toggle="collapse">Show Configuration</a>
<div id="configuration" class="collapse"></div>
</section>
<section>
<div id="feed"></div>
</srction>
</div>
2020-12-01 14:45:12 +00:00
</main>
<script type="text/javascript" src="./config.json"></script>
<script src="./js/rss-parser.js"></script>
<script>
const feeds = config // Edit config.json
2020-12-01 17:28:57 +00:00
const CORS_PROXY = "https://cors-anywhere.herokuapp.com/"
2020-12-01 14:45:12 +00:00
var contents_title = document.createElement("h2")
contents_title.textContent = "Contents"
contents_title.classList.add("pb-1")
document.getElementById("contents").appendChild(contents_title)
async function myfunc(key){
2020-12-01 17:28:57 +00:00
var count_lim = feeds[key]["limit"]
var count_lim = (count_lim === undefined) ? config_extra["defaults"]["limit"] : count_lim
var show_summary = feeds[key]["summary"]
var show_summary = (show_summary === undefined) ? config_extra["defaults"]["summary"] : show_summary
var ignore_tags = feeds[key]["ignore"]
var ignore_tags = (ignore_tags === undefined) ? [] : ignore_tags
2020-12-12 11:24:25 +00:00
var extra_keys = feeds[key]["extra_keys"]
var extra_keys = (extra_keys === undefined) ? false : extra_keys
2020-12-01 14:45:12 +00:00
var contents = document.createElement("a")
contents.href = "#" + key
contents.classList.add("list-group-item","list-group-item-action")
contents.textContent = key
document.getElementById("contents").appendChild(contents)
var feed_div = document.createElement("div")
feed_div.id = key
feed_div.setAttribute("id", key);
var title = document.createElement("h2");
title.textContent = "From " + key;
title.classList.add("pb-1")
feed_div.appendChild(title)
document.getElementById("feed").appendChild(feed_div)
var parser = new RSSParser();
var countPosts = 0
2020-12-01 14:47:05 +00:00
parser.parseURL(CORS_PROXY + feeds[key]["link"], function(err, feed) {
2020-12-01 14:45:12 +00:00
if (err) throw err;
feed.items.forEach(function(entry) {
2020-12-01 17:28:57 +00:00
if (countPosts < count_lim) {
var skip = false
for(var i = 0; i < ignore_tags.length; i++) {
if (entry.title.includes(ignore_tags[i])){
var skip = true
} else if (entry.content.includes(ignore_tags[i])){
var skip = true
}
}
if (!skip) {
2020-12-01 14:45:12 +00:00
var node = document.createElement("div");
node.classList.add("card","mb-3");
var row = document.createElement("div")
row.classList.add("row","no-gutters")
if (config_extra["left-column"]){
var left_col = document.createElement("div")
left_col.classList.add("col-md-2")
var left_col_body = document.createElement("div")
left_col_body.classList.add("card-body")
}
var right_col = document.createElement("div")
if (config_extra["left-column"]){
right_col.classList.add("col-md-10")
}
var node_title = document.createElement("h5")
node_title.classList.add("card-header")
node_title.innerHTML = entry.title
node_body = document.createElement("div")
node_body.classList.add("card-body")
node_content = document.createElement("p")
2020-12-01 17:28:57 +00:00
if (show_summary){
node_content.innerHTML = entry.content
}
2020-12-01 14:45:12 +00:00
node_content.classList.add("card-text")
if (config_extra["direct-link"]){
node_link = document.createElement("p")
node_link.classList.add("card-text")
node_link.innerHTML = "<b>Link:</b> <a href='" + entry.link +"'>Direct Link</a>"
if (config_extra["left-column"]){
left_col_body.appendChild(node_link)
} else {
node_content.appendChild(node_link)
}
}
if (config_extra["show-date"]){
node_date = document.createElement("p")
node_date.classList.add("card-text")
node_date.innerHTML = "<p><b>Date: </b>" + entry.pubDate + "</p>"
if (config_extra["left-column"]){
left_col_body.appendChild(node_date)
} else {
node_content.appendChild(node_date)
}
}
2020-12-12 11:24:25 +00:00
if (extra_keys != false){
for(var i = 0; i < extra_keys.length; i++) {
node_extra = document.createElement("p")
node_extra.classList.add("card-text")
node_extra.innerHTML = entry[extra_keys[i]]
if (config_extra["left-column"]){
left_col_body.appendChild(node_extra)
} else {
node_content.appendChild(node_extra)
}
}
}
2020-12-01 14:45:12 +00:00
node.appendChild(node_title)
node_body.appendChild(node_content)
right_col.appendChild(node_body)
if (config_extra["left-column"]){
left_col.appendChild(left_col_body)
row.appendChild(left_col)
}
row.appendChild(right_col)
node.appendChild(row)
document.getElementById(key).appendChild(node)
countPosts+=1
}
2020-12-01 17:28:57 +00:00
}
2020-12-01 14:45:12 +00:00
})
if (config_extra["Responsive-Images"]){
var inputs = document.getElementsByTagName('img')
for(var i = 0; i < inputs.length; i++) {
inputs[i].classList.add("img-fluid")
}
}
})
return true
}
(async () => {
for(var key in feeds) {
let result = await myfunc(key);
2020-12-12 11:24:25 +00:00
}
config_el = document.getElementById("configuration")
config_el.innerHTML = "<h3> Feeds </h3> <pre>" + JSON.stringify(feeds,null,2) + "</pre> <h2> Misc </h2> <pre>" + JSON.stringify(config_extra,null,2) + "</pre>"
if (config_extra["show_configuration"]) {
config_button = document.getElementById("configuration-button");
config_button.classList.remove("invisible")
}
2020-12-01 14:45:12 +00:00
2020-12-12 11:24:25 +00:00
})();
2020-12-01 14:45:12 +00:00
</script>
2020-12-12 11:24:25 +00:00
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
2020-12-01 14:45:12 +00:00
<noscript>Uh Oh! Your browser does not support JavaScript or JavaScript is currently disabled. Please enable JavaScript or switch to a different browser.</noscript>
</body></html>