A => .build.yml +20 -0
@@ 1,20 @@
+image: archlinux
+packages:
+ - python
+ - python-jinja
+ - python-yaml
+sources:
+ - git@git.sr.ht:~mehdix/manquotes
+environment:
+ deploy: srht@manquotes.mehdix.org
+secrets:
+ - fc4d69da-0af3-4601-a108-385a1b8d8613
+ - ec3002a0-7d2d-46fd-b629-39135ac61d2c
+tasks:
+ - build: |
+ cd manquotes
+ python y2w.py
+ - deploy: |
+ cd manquotes
+ sshopts="ssh -o StrictHostKeyChecking=no"
+ rsync --rsh="$sshopts" -rP _site $deploy:/var/www/manquotes.mehdix.org/
A => LICENSE +27 -0
@@ 1,27 @@
+Copyright 2021 Mehdi Sadeghi <mehdi@mehdix.org>
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors
+may be used to endorse or promote products derived from this software without
+specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
A => README.md +2 -0
@@ 1,2 @@
+# Manquotes
+A collection of interesting quotes from manpages.
A => favicon.ico +0 -0
A => feed.xml +32 -0
@@ 1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xml" href="{{site.url}}/feed.xsl" ?>
+
+<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en" >
+
+ <link rel="alternate" type="text/html" href="{{ site.url }}" hreflang="en" />
+ <link rel="self" type="application/atom+xml" href="{{ site.url }}/feed.xml" />
+
+ <id>{{ site.url }}</id>
+ <title type="text" xml:lang="en">{{ site.title }}</title>
+ <updated>{{ site.time }}</updated>
+
+ <author>
+ <name>{{ site.author }}</name>
+ <email>{{ site.email }}</email>
+ <uri>{{ site.url }}</uri>
+ </author>
+
+ {% for post in quotes %}
+ <entry>
+ <id>{{site.url}}/{{ post.url }}</id>
+ <title>{{ post.source }}</title>
+ <updated>{{ post.date }}</updated>
+ <link rel="alternate" type="text/html" href="{{ post.url }}"/>
+ <content type="html">
+ <div>{{ post.quote}}</div>
+ </content>
+ <summary>{{ post.quote }}</summary>
+ </entry>
+ {% endfor %}
+
+</feed>
A => feed.xsl +33 -0
@@ 1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:atom="http://www.w3.org/2005/Atom"
+ exclude-result-prefixes="atom">
+
+ <xsl:template match="/">
+ <html dir="auto" xmlns="http://www.w3.org/1999/xhtml">
+ <body style="margin:auto;display:grid;width:540px;font-family:Arial;background-color:#EEEEEE;grid-gap:19px">
+ <h1><strong>Man Quotes</strong></h1>
+ <xsl:apply-templates select="atom:feed/atom:entry"/>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template match="atom:entry">
+ <div xmlns="http://www.w3.org/1999/xhtml">
+ <div style="background-color:teal;color:white;padding:4px;">
+ <span style="font-weight:bold">
+ <strong><xsl:value-of select="atom:title"/></strong>
+ </span>
+ <xsl:text></xsl:text>
+ <xsl:value-of select="atom:author"/>
+ </div>
+ <div style="margin-right:20px;margin-bottom:1em;font-size:10pt">
+ <b><xsl:value-of select="atom:published"/></b>
+ <p><xsl:value-of select="atom:summary" disable-output-escaping="yes"/></p>
+ </div>
+ </div>
+ </xsl:template>
+
+</xsl:stylesheet>
A => gen.py +62 -0
@@ 1,62 @@
+"""Generate static pages out of YAML files."""
+import os
+from datetime import datetime as dt
+import yaml
+import jinja2
+
+
+def cli():
+ # Get site config
+ config = site_config()
+
+ # Read the quotes
+ quotes = read_quotes('quotes.yml')
+
+ # Make one page per quote
+ with open('quote.html', 'r') as tfile:
+ template = jinja2.Template(tfile.read())
+ gen_pages(config, template, quotes)
+
+ # Make the index page
+ with open('index.html', 'r') as tfile:
+ template = jinja2.Template(tfile.read())
+ gen_page(config, 'index.html', template, {'quotes': quotes})
+
+ with open('feed.xml', 'r') as tfile:
+ template = jinja2.Template(tfile.read())
+ gen_page(config, 'feed.xml', template, {'quotes': quotes})
+
+ with open('feed.xsl', 'r') as tfile:
+ template = jinja2.Template(tfile.read())
+ gen_page(config, 'feed.xsl', template, {})
+
+def site_config():
+ return {'title': 'Man Quotes',
+ 'author': 'Mehdi Sadeghi',
+ 'email': 'mehdi@mehdix.org',
+ #'url': 'https://qoutes.mehdix.org',
+ 'url': 'http://localhost:8000',
+ 'favicon': 'favicion.ico',
+ 'outdir': '_site',
+ 'time': dt.utcnow().isoformat()}
+
+
+def read_quotes(filename):
+ with open(filename, 'r') as quotes:
+ return list(yaml.safe_load_all(quotes))
+
+
+def gen_pages(config, template, posts):
+ for idx, post in enumerate(posts):
+ post['url'] = 'q{}.html'.format(idx)
+ gen_page(
+ config, 'q{}.html'.format(idx), template, {'quote': post})
+
+
+def gen_page(config, outfile, template, data):
+ with open(os.path.join(config['outdir'], outfile), 'w') as out:
+ out.write(template.render(site=config, **data))
+
+
+if __name__ == '__main__':
+ cli()
A => index.html +54 -0
@@ 1,54 @@
+<!DOCTYPE html>
+<html dir="auto" lang="en" prefix="og: https://ogp.me/ns#">
+<head>
+<title>{{ site.title }}</title>
+<link hreflang="en" rel=alternate type=application/atom+xml title="Quotes feed" href="{{ site.url }}/feed.xml">
+<style>
+header, nav, main {
+ margin: 0;
+ padding: 5px;
+ background-color: lightgray;
+}
+
+article > h1 {
+ margin: 10px;
+ padding: 5px;
+}
+
+article {
+ background: white;
+}
+
+article > h2, p {
+ margin: 4px;
+ font-size: 90%;
+}
+</style>
+</head>
+
+<body>
+
+<header>
+<h1>Man Quotes</h1>
+<p> A collection of quotes I have encountered while wandering through manpages.</p>
+</header>
+
+<nav>
+<a href="{{ site.url }}/feed.xml">Atom Feed</a>
+</nav>
+
+<main>
+{% for quote in quotes %}
+<article>
+ <h2><a href="{{ quote.url }}">From {{quote.source}} by {{ quote.author }}</a></h2>
+ <blockquote><pre>{{ quote.quote }}</pre></blockquote>
+</article>
+{% endfor %}
+</main>
+
+<footer>
+ <p>Maintainer: Mehdi Sadeghi <<a href="mailto:mehdi@mehdix.org">mehdi@mehdix.org</a>></p>
+</footer>
+
+</body>
+</html>
A => quote.html +45 -0
@@ 1,45 @@
+<!DOCTYPE html>
+<html dir="auto" lang="en" prefix="og: https://ogp.me/ns#">
+<head>
+<title>{{ site.title }}</title>
+<link hreflang="en" rel=alternate type=application/atom+xml title="Quotes feed" href="{{ site.url }}/feed.xml">
+<style>
+main, article {
+ margin: 0;
+ padding: 5px;
+ background-color: lightgray;
+}
+
+section > h1 {
+ margin: 10px;
+ padding: 5px;
+}
+
+section {
+ padding: 5px;
+ background: white;
+}
+
+section > h2, p {
+ margin: 4px;
+ font-size: 90%;
+}
+</style>
+</head>
+
+<body>
+<main>
+<article>
+<h2><a href="{{ quote.url }}">From {{quote.source}}</a></h2>
+<section>
+<blockquote><pre>{{ quote.quote }}</pre></blockquote>
+—<cite>{{quote.author}}</cite>
+
+</section>
+</article>
+</main>
+<footer>
+ <p>Maintainer: Mehdi Sadeghi <<a href="mailto:mehdi@mehdix.org">mehdi@mehdix.org</a>></p>
+</footer>
+</body>
+</html>
A => quotes.yml +23 -0
@@ 1,23 @@
+---
+author: Juergen Weigert, Tony Nugent
+source: xxd manpage
+date: 2021-01-30T19:06:00+00:00
+quote: >
+ The tools weirdness matches its creators brain. Use entirely at your own risk. Copy files. Trace it. Become a wizard.
+
+
+ Distribute freely and credit me,
+ make money and share with me,
+ lose money and don't ask me.
+---
+author: Hungry Hacker
+source: Some Cool Package
+date: 2021-01-31T19:06:00+00:00
+quote: >-
+ Some cool text some hungry hacker once wrote.
+---
+author: Luz!
+source: Some Cool Package
+date: 2021-01-31T19:06:00+00:00
+quote: >-
+ Something, no matter what!