configuration on par with python
This commit is contained in:
parent
1e5c859ae8
commit
cce198c06e
|
@ -1,40 +1,38 @@
|
||||||
config = {
|
config = {
|
||||||
"r/DankMemes": {
|
"TIFU": {
|
||||||
"link":"https://reddit.com/r/dankmemes/.rss?sort=hot",
|
"link": "https://reddit.com/r/TIFU/.rss?sort=hot"
|
||||||
"limit": 5
|
},
|
||||||
},
|
"BuzzFeed - India": {
|
||||||
"BuzzFeed - India": {
|
"link":"https://www.buzzfeed.com/in.xml",
|
||||||
"link":"https://www.buzzfeed.com/in.xml",
|
"summary":true,
|
||||||
"limit": 5
|
"limit":2
|
||||||
},
|
},
|
||||||
"New Yorker":{
|
"New Yorker": {
|
||||||
"link":"http://www.newyorker.com/feed/news",
|
"link":"https://www.newyorker.com/feed/news",
|
||||||
"limit": 5
|
},
|
||||||
|
"The Hindu: Sports":{
|
||||||
|
"link":"https://www.thehindu.com/sport/feeder/default.rss",
|
||||||
|
},
|
||||||
|
"The Hindu: National News":{
|
||||||
|
"link":"https://www.thehindu.com/news/national/feeder/default.rss",
|
||||||
|
},
|
||||||
|
"r/Jokes":{
|
||||||
|
"link":"https://reddit.com/r/Jokes/hot/.rss?sort=hot",
|
||||||
|
"ignore": ["repost","discord"]
|
||||||
},
|
},
|
||||||
"Vox":{
|
"Vox":{
|
||||||
"link":"https://www.vox.com/rss/index.xml",
|
"link":"https://www.vox.com/rss/index.xml",
|
||||||
"limit": 3
|
"limit": 3
|
||||||
},
|
|
||||||
"The Hindu: Sports":{
|
|
||||||
"link":"https://www.thehindu.com/sport/feeder/default.rss",
|
|
||||||
"limit":5
|
|
||||||
},
|
|
||||||
"The Hindu: National News":{
|
|
||||||
"link":"https://www.thehindu.com/news/national/feeder/default.rss",
|
|
||||||
"limit": 5
|
|
||||||
},
|
|
||||||
"r/Jokes":{
|
|
||||||
"link":"https://reddit.com/r/Jokes/hot/.rss?sort=hot",
|
|
||||||
"limit":5
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config_extra = {
|
config_extra = {
|
||||||
"Responsive-Images": true,
|
"Responsive-Images": true,
|
||||||
"direct-link": true,
|
"direct-link": false,
|
||||||
"show-date":true,
|
"show-date":true,
|
||||||
"left-column":true,
|
"left-column":true,
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"limit": 5
|
"limit": 5,
|
||||||
|
"summary": true
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,16 +19,6 @@
|
||||||
<div class="list-group pb-4" id="contents"></div>
|
<div class="list-group pb-4" id="contents"></div>
|
||||||
|
|
||||||
<div id="feed">
|
<div id="feed">
|
||||||
<!--
|
|
||||||
<div class="card bg-dark text-white">
|
|
||||||
<img class="card-img" src=".../100px270/#55595c:#373a3c/text:Card image" alt="Card image">
|
|
||||||
<div class="card-img-overlay">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
|
||||||
<p class="card-text">Last updated 3 mins ago</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
</div></div>
|
</div></div>
|
||||||
</main>
|
</main>
|
||||||
<script type="text/javascript" src="./config.json"></script>
|
<script type="text/javascript" src="./config.json"></script>
|
||||||
|
@ -37,17 +27,24 @@
|
||||||
|
|
||||||
const feeds = config // Edit config.json
|
const feeds = config // Edit config.json
|
||||||
|
|
||||||
// Note: some RSS feeds can't be loaded in the browser due to CORS security.
|
|
||||||
// To get around this, you can use a proxy
|
|
||||||
const CORS_PROXY = "https://cors-anywhere.herokuapp.com/"
|
|
||||||
|
|
||||||
//let parser = new RSSParser();
|
const CORS_PROXY = "https://cors-anywhere.herokuapp.com/"
|
||||||
var contents_title = document.createElement("h2")
|
var contents_title = document.createElement("h2")
|
||||||
contents_title.textContent = "Contents"
|
contents_title.textContent = "Contents"
|
||||||
contents_title.classList.add("pb-1")
|
contents_title.classList.add("pb-1")
|
||||||
document.getElementById("contents").appendChild(contents_title)
|
document.getElementById("contents").appendChild(contents_title)
|
||||||
|
|
||||||
async function myfunc(key){
|
async function myfunc(key){
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
var contents = document.createElement("a")
|
var contents = document.createElement("a")
|
||||||
contents.href = "#" + key
|
contents.href = "#" + key
|
||||||
contents.classList.add("list-group-item","list-group-item-action")
|
contents.classList.add("list-group-item","list-group-item-action")
|
||||||
|
@ -66,7 +63,19 @@ async function myfunc(key){
|
||||||
parser.parseURL(CORS_PROXY + feeds[key]["link"], function(err, feed) {
|
parser.parseURL(CORS_PROXY + feeds[key]["link"], function(err, feed) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
feed.items.forEach(function(entry) {
|
feed.items.forEach(function(entry) {
|
||||||
if (countPosts < feeds[key]["limit"]) {
|
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) {
|
||||||
|
|
||||||
var node = document.createElement("div");
|
var node = document.createElement("div");
|
||||||
node.classList.add("card","mb-3");
|
node.classList.add("card","mb-3");
|
||||||
var row = document.createElement("div")
|
var row = document.createElement("div")
|
||||||
|
@ -92,7 +101,10 @@ async function myfunc(key){
|
||||||
node_body.classList.add("card-body")
|
node_body.classList.add("card-body")
|
||||||
|
|
||||||
node_content = document.createElement("p")
|
node_content = document.createElement("p")
|
||||||
node_content.innerHTML = entry.content
|
|
||||||
|
if (show_summary){
|
||||||
|
node_content.innerHTML = entry.content
|
||||||
|
}
|
||||||
node_content.classList.add("card-text")
|
node_content.classList.add("card-text")
|
||||||
|
|
||||||
if (config_extra["direct-link"]){
|
if (config_extra["direct-link"]){
|
||||||
|
@ -132,22 +144,15 @@ async function myfunc(key){
|
||||||
row.appendChild(right_col)
|
row.appendChild(right_col)
|
||||||
|
|
||||||
node.appendChild(row)
|
node.appendChild(row)
|
||||||
//node_body.appendChild(node_date)
|
|
||||||
//node.appendChild(node_body)
|
|
||||||
document.getElementById(key).appendChild(node)
|
document.getElementById(key).appendChild(node)
|
||||||
/*console.log(entry.title + ':' + entry.link);
|
|
||||||
console.log(entry.pubDate)*/
|
|
||||||
//console.log(entry.author)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
countPosts+=1
|
countPosts+=1
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (config_extra["Responsive-Images"]){
|
if (config_extra["Responsive-Images"]){
|
||||||
var inputs = document.getElementsByTagName('img')
|
var inputs = document.getElementsByTagName('img')
|
||||||
console.log(inputs)
|
|
||||||
for(var i = 0; i < inputs.length; i++) {
|
for(var i = 0; i < inputs.length; i++) {
|
||||||
inputs[i].classList.add("img-fluid")
|
inputs[i].classList.add("img-fluid")
|
||||||
}
|
}
|
||||||
|
@ -160,17 +165,8 @@ async function myfunc(key){
|
||||||
(async () => {
|
(async () => {
|
||||||
for(var key in feeds) {
|
for(var key in feeds) {
|
||||||
let result = await myfunc(key);
|
let result = await myfunc(key);
|
||||||
console.log(result)
|
|
||||||
}})();
|
}})();
|
||||||
|
|
||||||
/*
|
|
||||||
var inputs = document.getElementsByTagName('img');
|
|
||||||
for(var i = 0; i < inputs.length; i++) {
|
|
||||||
inputs[i].classList.add("img-fluid")
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<noscript>Uh Oh! Your browser does not support JavaScript or JavaScript is currently disabled. Please enable JavaScript or switch to a different browser.</noscript>
|
<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>
|
</body></html>
|
Loading…
Reference in New Issue