fix missing source information. Add a few improvements to the default template.

This commit is contained in:
Gonçalo Valério 2021-05-01 19:17:17 +01:00
parent 01c00e1503
commit 4d2cc2501a
Signed by: dethos
GPG Key ID: DF557F2BDCC2445E
3 changed files with 100 additions and 42 deletions

View File

@ -113,8 +113,8 @@ async function fetchAndHydrate(feed) {
let contentFeed = await parser.parseString(content) let contentFeed = await parser.parseString(content)
for (let item of contentFeed.items) { for (let item of contentFeed.items) {
item.source_title = feed.source_title item.source_title = contentFeed.title
item.source_link = feed.link item.source_link = contentFeed.link
} }
console.log( console.log(
`[fetchAndHydrate] Finished fetch feed: ${feed}. ${contentFeed.items.length} items gathered`, `[fetchAndHydrate] Finished fetch feed: ${feed}. ${contentFeed.items.length} items gathered`,

View File

@ -6,6 +6,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{page_title}}</title> <title>{{page_title}}</title>
<meta property="og:title" content="{{page_title}}" />
<meta property="og:description" content="{{page_description}}" />
<link rel="alternate" type="application/rss+xml" title="Planet RSS feed" href="/rss" /> <link rel="alternate" type="application/rss+xml" title="Planet RSS feed" href="/rss" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous"> integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
@ -13,30 +15,43 @@
<body> <body>
<nav class="navbar navbar-expand-lg navbar-light bg-light"> <nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container"> <div class="container-fluid">
<a class="navbar-brand" href="#">{{page_title}}</a> <a class="navbar-brand" href="#">{{page_title}}</a>
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="https://github.com/dethos/worker-planet">
Source Code
</a>
</li>
</ul>
</div> </div>
</nav> </nav>
<main class="container"> <main class="container d-grid">
<div class="row"> {{#each items}}
{{#each items}} <div class="row p-2">
<article> <article>
<h2><a href="{{link}}">{{title}}</a></h2> <div class="card">
<p> <div class="card-body">
<small>Date: {{pubDate}}</small><br> <h2 class="card-title"><a href="{{link}}">{{title}}</a></h2>
<small>Source: <a href="{{source_link}}">{{source_title}}</a></small> <p class="card-subtitle mb-2 text-muted">
</p> <small>Date: {{pubDate}}</small><br>
<small>Source: <a href="{{source_link}}">{{source_title}}</a></small>
</p>
{{{content}}} {{{content}}}
</div>
</div>
</article> </article>
{{/each}}
</div> </div>
{{/each}}
</main> </main>
<footer class="container"> <footer class="footer mt-auto py-3 bg-light">
<p>All rights belong to the respective authors.</p> <div class="container-fluid">
<p> <p class="text-muted">
<a href="#">Back to top</a> All rights belong to the original authors.
</p> <a class="float-end" href="#">Back to top</a>
</p>
</div>
</footer> </footer>
</body> </body>

View File

@ -19,7 +19,7 @@ templates['list_posts'] = template({
} }
return ( return (
' <article>\n <h2><a href="' + ' <div class="row p-2">\n <article>\n <div class="card">\n <div class="card-body">\n <h2 class="card-title"><a href="' +
alias4( alias4(
((helper = ((helper =
(helper = (helper =
@ -33,8 +33,8 @@ templates['list_posts'] = template({
hash: {}, hash: {},
data: data, data: data,
loc: { loc: {
start: { line: 24, column: 21 }, start: { line: 35, column: 44 },
end: { line: 24, column: 29 }, end: { line: 35, column: 52 },
}, },
}) })
: helper), : helper),
@ -53,13 +53,13 @@ templates['list_posts'] = template({
hash: {}, hash: {},
data: data, data: data,
loc: { loc: {
start: { line: 24, column: 31 }, start: { line: 35, column: 54 },
end: { line: 24, column: 40 }, end: { line: 35, column: 63 },
}, },
}) })
: helper), : helper),
) + ) +
'</a></h2>\n <p>\n <small>Date: ' + '</a></h2>\n <p class="card-subtitle mb-2 text-muted">\n <small>Date: ' +
alias4( alias4(
((helper = ((helper =
(helper = (helper =
@ -74,13 +74,13 @@ templates['list_posts'] = template({
hash: {}, hash: {},
data: data, data: data,
loc: { loc: {
start: { line: 26, column: 23 }, start: { line: 37, column: 27 },
end: { line: 26, column: 34 }, end: { line: 37, column: 38 },
}, },
}) })
: helper), : helper),
) + ) +
'</small><br>\n <small>Source: <a href="' + '</small><br>\n <small>Source: <a href="' +
alias4( alias4(
((helper = ((helper =
(helper = (helper =
@ -96,8 +96,8 @@ templates['list_posts'] = template({
hash: {}, hash: {},
data: data, data: data,
loc: { loc: {
start: { line: 27, column: 34 }, start: { line: 38, column: 38 },
end: { line: 27, column: 49 }, end: { line: 38, column: 53 },
}, },
}) })
: helper), : helper),
@ -118,13 +118,13 @@ templates['list_posts'] = template({
hash: {}, hash: {},
data: data, data: data,
loc: { loc: {
start: { line: 27, column: 51 }, start: { line: 38, column: 55 },
end: { line: 27, column: 67 }, end: { line: 38, column: 71 },
}, },
}) })
: helper), : helper),
) + ) +
'</a></small>\n </p>\n\n ' + '</a></small>\n </p>\n\n ' +
((stack1 = ((stack1 =
((helper = ((helper =
(helper = (helper =
@ -139,14 +139,14 @@ templates['list_posts'] = template({
hash: {}, hash: {},
data: data, data: data,
loc: { loc: {
start: { line: 30, column: 8 }, start: { line: 41, column: 12 },
end: { line: 30, column: 21 }, end: { line: 41, column: 25 },
}, },
}) })
: helper)) != null : helper)) != null
? stack1 ? stack1
: '') + : '') +
'\n </article>\n' '\n </div>\n </div>\n </article>\n </div>\n'
) )
}, },
compiler: [8, '>= 4.3.0'], compiler: [8, '>= 4.3.0'],
@ -188,7 +188,7 @@ templates['list_posts'] = template({
}) })
: helper), : helper),
) + ) +
'</title>\n <link rel="alternate" type="application/rss+xml" title="Planet RSS feed" href="/rss" />\n <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet"\n integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">\n</head>\n\n<body>\n <nav class="navbar navbar-expand-lg navbar-light bg-light">\n <div class="container">\n <a class="navbar-brand" href="#">' + '</title>\n <meta property="og:title" content="' +
alias4( alias4(
((helper = ((helper =
(helper = (helper =
@ -203,13 +203,56 @@ templates['list_posts'] = template({
hash: {}, hash: {},
data: data, data: data,
loc: { loc: {
start: { line: 17, column: 39 }, start: { line: 9, column: 37 },
end: { line: 17, column: 53 }, end: { line: 9, column: 51 },
}, },
}) })
: helper), : helper),
) + ) +
'</a>\n </div>\n </nav>\n <main class="container">\n <div class="row">\n' + '" />\n <meta property="og:description" content="' +
alias4(
((helper =
(helper =
lookupProperty(helpers, 'page_description') ||
(depth0 != null
? lookupProperty(depth0, 'page_description')
: depth0)) != null
? helper
: alias2),
typeof helper === alias3
? helper.call(alias1, {
name: 'page_description',
hash: {},
data: data,
loc: {
start: { line: 10, column: 43 },
end: { line: 10, column: 63 },
},
})
: helper),
) +
'" />\n <link rel="alternate" type="application/rss+xml" title="Planet RSS feed" href="/rss" />\n <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet"\n integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">\n</head>\n\n<body>\n <nav class="navbar navbar-expand-lg navbar-light bg-light">\n <div class="container-fluid">\n <a class="navbar-brand" href="#">' +
alias4(
((helper =
(helper =
lookupProperty(helpers, 'page_title') ||
(depth0 != null ? lookupProperty(depth0, 'page_title') : depth0)) !=
null
? helper
: alias2),
typeof helper === alias3
? helper.call(alias1, {
name: 'page_title',
hash: {},
data: data,
loc: {
start: { line: 19, column: 39 },
end: { line: 19, column: 53 },
},
})
: helper),
) +
'</a>\n <ul class="navbar-nav ms-auto">\n <li class="nav-item">\n <a class="nav-link active" aria-current="page" href="https://github.com/dethos/worker-planet">\n Source Code\n </a>\n </li>\n </ul>\n </div>\n </nav>\n <main class="container d-grid">\n' +
((stack1 = lookupProperty(helpers, 'each').call( ((stack1 = lookupProperty(helpers, 'each').call(
alias1, alias1,
depth0 != null ? lookupProperty(depth0, 'items') : depth0, depth0 != null ? lookupProperty(depth0, 'items') : depth0,
@ -220,14 +263,14 @@ templates['list_posts'] = template({
inverse: container.noop, inverse: container.noop,
data: data, data: data,
loc: { loc: {
start: { line: 22, column: 6 }, start: { line: 30, column: 4 },
end: { line: 32, column: 15 }, end: { line: 46, column: 13 },
}, },
}, },
)) != null )) != null
? stack1 ? stack1
: '') + : '') +
' </div>\n </main>\n <footer class="container">\n <p>All rights belong to the respective authors.</p>\n <p>\n <a href="#">Back to top</a>\n </p>\n </footer>\n</body>\n\n</html>\n' ' </main>\n <footer class="footer mt-auto py-3 bg-light">\n <div class="container-fluid">\n <p class="text-muted">\n All rights belong to the original authors.\n <a class="float-end" href="#">Back to top</a>\n </p>\n </div>\n </footer>\n</body>\n\n</html>\n'
) )
}, },
useData: true, useData: true,