handle atom feed

This commit is contained in:
Solene Rapenne 2022-12-03 10:49:52 +01:00
parent d222656ad8
commit 6db443342a
2 changed files with 213 additions and 134 deletions

View File

@ -6,7 +6,7 @@
];
website = {
url = "https://webzine.snowflake.ovh/";
url = "https://webzine.snowflake.ovh";
style = builtins.readFile ./style.html;
header = ''
<header>
@ -25,6 +25,7 @@ in
''
${pkgs.busybox}/bin/mkdir -p $out/static
${pkgs.busybox}/bin/cp ${index_generator}/* $out/
${pkgs.busybox}/bin/cp ${atom}/* $out/
${pkgs.busybox}/bin/cp -fr $src/* $out/static/
''
+ (
@ -46,13 +47,13 @@ in
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="alternate" type="application/rss+xml" href="${website.url}/atom.xml">
<meta property="og:title" content="NixOS webzine ${issue.number}" />
<link rel="icon" type="image/png" sizes="32x32" href="/static/NixOS_logo.svg">
<link rel="icon" type="image/png" sizes="16x16" href="/static/NixOS_logo.svg">
<meta property="og:description" content="Webzine created by volunteers who are passionate about the NixOS project development." />
<link rel="alternate" type="application/rss+xml" href="${website.url}/atom.xml">
<meta property="og:title" content="NixOS webzine issue ${issue.number}" />
<meta property="og:url" content="${website.url}/issue-${issue.number}.html" />
<meta property="og:image" content="${website.url}/images/logo.png" />
<meta property="og:image" content="${website.url}/static/NixOS_logo.svg" />
<meta property="og:type" content="website" />
<meta property="og:locale" content="en_EN" />
<title>NixOS webzine ${issue.number}</title>
@ -86,7 +87,7 @@ in
then ''
<article id="tips">
<div class="snowflakes" aria-hidden="true"> </div>
<h2>Tips</h2>
<h2>Nix Tips</h2>
${issue.tips}
</article>
''
@ -132,6 +133,24 @@ in
else ""
}
<!-- EVENTS -->
${
if (builtins.length issue.events) != 0
then ''
<article id="events">
<div class="snowflakes" aria-hidden="true"> </div>
<h2>Events</h2>
<ul>
${pkgs.lib.concatStringsSep "\n" (builtins.map (item: ''
<li>${item.text} [<a href="${item.url}" class="permalink">link</a>]</li>
'')
issue.events)}
</ul>
</article>
''
else ""
}
<!-- REDACTION -->
${
if issue.editors != ""
@ -175,17 +194,17 @@ in
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="apple-touch-icon" sizes="180x180" href="/static/NixOS_logo.svg">
<link rel="icon" type="image/png" sizes="32x32" href="/static/NixOS_logo.svg">
<link rel="icon" type="image/png" sizes="16x16" href="/static/NixOS_logo.svg">
<link rel="alternate" type="application/rss+xml" href="${website.url}/atom.xml">
<meta property="og:title" content="NixOS webzine" />
<meta property="og:description" content="Webzine created by volunteers who are passionate about the NixOS project development." />
<meta property="og:url" content="${website.url}/index.html" />
<meta property="og:image" content="${website.url}/images/logo.png" />
<meta property="og:image" content="${website.url}/static/NixOS_logo.svg" />
<meta property="og:type" content="website" />
<meta property="og:locale" content="en_EN" />
<title>NixOS webzine index</title>
<title>NixOS webzine homepage</title>
${website.style}
</head>
@ -226,9 +245,23 @@ in
</ul>
</article>
<article id="learn">
<h2>Learn NixOS</h2>
<p>New to NixOS? Want to learn more about it?</p>
<ul>
<li><a class="permalink" href="https://nixos.org">NixOS official website</a></li>
<li><a class="permalink" href="https://search.nixos.org/packages">Package search engine</a></li>
<li><a class="permalink" href="https://nixos.org/manual/nixos/stable/">The NixOS manual</a></li>
<li><a class="permalink" href="https://nixos.org/manual/nixpkgs/stable/">nixpkgs manual</a></li>
<li><a class="permalink" href="https://nixos.org/manual/nix/stable/">nix package manager manual</a></li>
<li><a class="permalink" href="https://nix.dev/">Learn the nix language on nix.dev</a></li>
<li><a class="permalink" href="https://nixos.org/guides/nix-pills/">Learn how nix works on nix-pills</a></li>
</ul>
</article>
<article id="contribute">
<h2>How to contribute</h2>
<p>If you want to contribute to the Webzine, from a simple contribution suggesting a link or a news to a large or regular contribution, we do all the work publicly with Git.
<p>If you want to contribute to the Webzine, from a simple to a regular contribution, we do all the work publicly with Git.
<a class="permalink" href="https://tildegit.org/solene/nixos-webzine/">Link to the Git repository.</a>
</p>
</article>
@ -242,4 +275,46 @@ in
</body>
</html>
'';
atom = pkgs.writeTextDir "atom.xml" ''
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>${website.url}</id>
<title>NixOS Webzine</title>
<icon>${website.url}/static/NixOS_logo.svg</icon>
<link rel="alternate" type="text/html" href="${website.url}/" />
<link rel="self" type="application/atom+xml" href="${website.url}/atom.xml" />
<author>
<name>NixOS Webzine contributors</name>
</author>
<updated>${let last_issue = import (builtins.head (pkgs.lib.lists.reverseList issues)); in last_issue.date}T00:00:00Z</updated>
${pkgs.lib.concatStringsSep "\n" (builtins.map (element: let
issue = import element;
in ''
<entry>
<title type="text">Issue #${issue.number}</title>
<id>tag:${website.url},2022:${issue.number}</id>
<updated>${issue.date}T00:00:00Z</updated>
<link rel="alternate" type="text/html" href="${website.url}/issue-${issue.number}.html" />
<summary type="html">
<![CDATA[
${
if (builtins.length issue.news) != 0
then ''
<ul>
${pkgs.lib.concatStringsSep "\n" (builtins.map (item: ''
<li>${item}</li>
'')
issue.news)}
</ul>
''
else ""
}
]]>
</summary>
</entry>
'') (pkgs.lib.lists.reverseList issues))}
</feed>'';
}

View File

@ -1,145 +1,149 @@
<style>
#title {
text-align: center;
font-size:3em;
font-weight:bold;
margin: 0.75em auto;
text-shadow: 2px 2px 2px grey;
}
#title {
text-align: center;
font-size:3em;
font-weight:bold;
margin: 0.75em auto;
text-shadow: 2px 2px 2px grey;
}
#title a span img {
border: none;
width: 60px;
padding: 0;
margin-right: 10px;
}
#title a span img {
border: none;
width: 60px;
padding: 0;
margin-right: 10px;
}
#title a {
text-decoration: none;
}
#title a {
text-decoration: none;
}
#banner {
border-top: .2em double black;
border-bottom: .2em double black;
padding: .5em;
margin-bottom: 2em;
text-align:center;
display: flex;
justify-content: space-between;
}
#banner {
border-top: .2em double black;
border-bottom: .2em double black;
padding: .5em;
margin-bottom: 2em;
text-align:center;
display: flex;
justify-content: space-between;
}
.snowflakes {
margin: auto;
text-align: center;
}
.snowflakes {
margin: auto;
text-align: center;
}
.permalink {
color: blue;
text-decoration: underline;
}
.permalink {
color: blue;
text-decoration: underline;
}
a {
color: black;
text-decoration: underline;
}
a {
color: black;
text-decoration: underline;
}
.permalink::after { content: " ↩"; }
.permalink:hover { color: darkblue; }
.permalink::after { content: " ↩"; }
.permalink:hover { color: darkblue; }
h1 {
font-size: 1.5em;
line-height: 0.9em;
}
h1 {
font-size: 1.5em;
line-height: 0.9em;
}
p {
text-align: justify;
text-justify: auto;
}
p {
text-align: justify;
text-justify: auto;
}
pre {
overflow: scroll;
}
figure {
text-align: center;
}
html, body {
font-size: 1.1em;
font-family:serif;
background-color: #fff;
}
pre {
overflow: scroll;
}
body {
margin: 1em auto;
padding-left: 30px;
padding-right: 30px;
padding-bottom: 30px;
max-width: 900px;
border: 1px solid #111;
background-color: #eee;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
line-height: 1.5;
}
html, body {
font-size: 1.1em;
font-family:serif;
background-color: #fff;
}
img {
max-width: 100%;
height: auto;
margin: auto;
border: 3px solid black;
padding: .25em;
}
body {
margin: 1em auto;
padding-left: 30px;
padding-right: 30px;
padding-bottom: 30px;
max-width: 900px;
border: 1px solid #111;
background-color: #eee;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
line-height: 1.5;
}
ul {
padding-left: .5em;
}
img {
max-width: 100%;
height: auto;
margin: auto;
border: 3px solid black;
padding: .25em;
}
blockquote {
position: relative;
padding-top: 1rem;
padding-bottom: 2.2rem;
}
ul {
padding-left: .5em;
}
blockquote:before,
blockquote:after {
position: absolute;
font-size: 4rem;
color: rgba(128,128,128,0.5);
}
blockquote {
position: relative;
padding-top: 1rem;
padding-bottom: 2.2rem;
}
blockquote:before {
content: open-quote;
left: -1rem;
top: -1.5rem;
}
blockquote:before,
blockquote:after {
position: absolute;
font-size: 4rem;
color: rgba(128,128,128,0.5);
}
blockquote:after {
content: close-quote;
text-align: right;
width: 100%;
}
blockquote:before {
content: open-quote;
left: -1rem;
top: -1.5rem;
}
cite {
font-size: smaller;
text-align: right;
width: 100%;
display: block;
}
blockquote:after {
content: close-quote;
text-align: right;
width: 100%;
}
code {
background-color: #8DF;
padding-left: 3px;
padding-right: 3px;
}
cite {
font-size: smaller;
text-align: right;
width: 100%;
display: block;
}
@media print {
body { background-color:white; max-width:100%;}
}
code {
background-color: #8DF;
padding-left: 3px;
padding-right: 3px;
}
@media (prefers-color-scheme: dark) {
body { color: #ccc; background-color: #222; }
html { background-color: black; }
.permalink { color: deepskyblue; }
img { border-color: #ccc; }
#banner { border-color:#ccc; }
a { color: #ccc; }
code { background-color: black; color: lightgreen; }
.permalink:hover { color: plum; }
}
@media print {
body { background-color:white; max-width:100%;}
}
@media (prefers-color-scheme: dark) {
body { color: #ccc; background-color: #222; }
html { background-color: black; }
.permalink { color: deepskyblue; }
img { border-color: #ccc; }
#banner { border-color:#ccc; }
a { color: #ccc; }
code { background-color: black; color: lightgreen; }
.permalink:hover { color: plum; }
}
</style>