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)
for (let item of contentFeed.items) {
item.source_title = feed.source_title
item.source_link = feed.link
item.source_title = contentFeed.title
item.source_link = contentFeed.link
}
console.log(
`[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 name="viewport" content="width=device-width, initial-scale=1.0">
<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 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">
@ -13,30 +15,43 @@
<body>
<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>
<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>
</nav>
<main class="container">
<div class="row">
{{#each items}}
<main class="container d-grid">
{{#each items}}
<div class="row p-2">
<article>
<h2><a href="{{link}}">{{title}}</a></h2>
<p>
<small>Date: {{pubDate}}</small><br>
<small>Source: <a href="{{source_link}}">{{source_title}}</a></small>
</p>
<div class="card">
<div class="card-body">
<h2 class="card-title"><a href="{{link}}">{{title}}</a></h2>
<p class="card-subtitle mb-2 text-muted">
<small>Date: {{pubDate}}</small><br>
<small>Source: <a href="{{source_link}}">{{source_title}}</a></small>
</p>
{{{content}}}
{{{content}}}
</div>
</div>
</article>
{{/each}}
</div>
{{/each}}
</main>
<footer class="container">
<p>All rights belong to the respective authors.</p>
<p>
<a href="#">Back to top</a>
</p>
<footer class="footer mt-auto py-3 bg-light">
<div class="container-fluid">
<p class="text-muted">
All rights belong to the original authors.
<a class="float-end" href="#">Back to top</a>
</p>
</div>
</footer>
</body>

View File

@ -19,7 +19,7 @@ templates['list_posts'] = template({
}
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(
((helper =
(helper =
@ -33,8 +33,8 @@ templates['list_posts'] = template({
hash: {},
data: data,
loc: {
start: { line: 24, column: 21 },
end: { line: 24, column: 29 },
start: { line: 35, column: 44 },
end: { line: 35, column: 52 },
},
})
: helper),
@ -53,13 +53,13 @@ templates['list_posts'] = template({
hash: {},
data: data,
loc: {
start: { line: 24, column: 31 },
end: { line: 24, column: 40 },
start: { line: 35, column: 54 },
end: { line: 35, column: 63 },
},
})
: helper),
) +
'</a></h2>\n <p>\n <small>Date: ' +
'</a></h2>\n <p class="card-subtitle mb-2 text-muted">\n <small>Date: ' +
alias4(
((helper =
(helper =
@ -74,13 +74,13 @@ templates['list_posts'] = template({
hash: {},
data: data,
loc: {
start: { line: 26, column: 23 },
end: { line: 26, column: 34 },
start: { line: 37, column: 27 },
end: { line: 37, column: 38 },
},
})
: helper),
) +
'</small><br>\n <small>Source: <a href="' +
'</small><br>\n <small>Source: <a href="' +
alias4(
((helper =
(helper =
@ -96,8 +96,8 @@ templates['list_posts'] = template({
hash: {},
data: data,
loc: {
start: { line: 27, column: 34 },
end: { line: 27, column: 49 },
start: { line: 38, column: 38 },
end: { line: 38, column: 53 },
},
})
: helper),
@ -118,13 +118,13 @@ templates['list_posts'] = template({
hash: {},
data: data,
loc: {
start: { line: 27, column: 51 },
end: { line: 27, column: 67 },
start: { line: 38, column: 55 },
end: { line: 38, column: 71 },
},
})
: helper),
) +
'</a></small>\n </p>\n\n ' +
'</a></small>\n </p>\n\n ' +
((stack1 =
((helper =
(helper =
@ -139,14 +139,14 @@ templates['list_posts'] = template({
hash: {},
data: data,
loc: {
start: { line: 30, column: 8 },
end: { line: 30, column: 21 },
start: { line: 41, column: 12 },
end: { line: 41, column: 25 },
},
})
: helper)) != null
? stack1
: '') +
'\n </article>\n'
'\n </div>\n </div>\n </article>\n </div>\n'
)
},
compiler: [8, '>= 4.3.0'],
@ -188,7 +188,7 @@ templates['list_posts'] = template({
})
: 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(
((helper =
(helper =
@ -203,13 +203,56 @@ templates['list_posts'] = template({
hash: {},
data: data,
loc: {
start: { line: 17, column: 39 },
end: { line: 17, column: 53 },
start: { line: 9, column: 37 },
end: { line: 9, column: 51 },
},
})
: 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(
alias1,
depth0 != null ? lookupProperty(depth0, 'items') : depth0,
@ -220,14 +263,14 @@ templates['list_posts'] = template({
inverse: container.noop,
data: data,
loc: {
start: { line: 22, column: 6 },
end: { line: 32, column: 15 },
start: { line: 30, column: 4 },
end: { line: 46, column: 13 },
},
},
)) != null
? 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,