~mehdix/manquotes

cf94601d690cf7e318c5cc54a4156debcfc0ee74 — Mehdi Sadeghi 3 years ago c99d0e3
Add templates.
4 files changed, 35 insertions(+), 39 deletions(-)

M gen.py
M index.html
M quote.html
A templates/base.html
M gen.py => gen.py +9 -7
@@ 4,7 4,8 @@ from datetime import datetime as dt
import yaml
import jinja2
import shutil

import pathlib
from jinja2 import Environment, FileSystemLoader

def cli():
    # Get site config


@@ 15,29 16,30 @@ def cli():

    # Make one page per quote
    with open('quote.html', 'r') as tfile:
        template = jinja2.Template(tfile.read())
        template = Environment(loader=FileSystemLoader('templates')).from_string(tfile.read())
        gen_pages(config, template, quotes)

    # Make the index page
    with open('index.html', 'r') as tfile:
        template = jinja2.Template(tfile.read())
        template = Environment(loader=FileSystemLoader('templates')).from_string(tfile.read())
        gen_page(config, 'index.html', template, {'quotes': quotes})

    with open('feed.xml', 'r') as tfile:
        template = jinja2.Template(tfile.read())
        template = Environment(loader=FileSystemLoader('templates')).from_string(tfile.read())
        gen_page(config, 'feed.xml', template, {'quotes': quotes})

    with open('feed.xsl', 'r') as tfile:
        template = jinja2.Template(tfile.read())
        template = Environment(loader=FileSystemLoader('templates')).from_string(tfile.read())
        gen_page(config, 'feed.xsl', template, {})

    shutil.copytree('assets', config['outdir'], dirs_exist_ok=True)


def site_config():
    return {'title': 'Man Quotes',
            'author': 'Mehdi Sadeghi',
            'email': 'mehdi@mehdix.org',
            #'url': 'https://qoutes.mehdix.org',
            'url': 'http://localhost:8888',
            'url': 'https://mehdix.org/~mx/manquotes/',
            'favicon': 'favicion.ico',
            'outdir': '_site',
            'time': dt.utcnow().isoformat()}

M index.html => index.html +3 -18
@@ 1,20 1,8 @@
<!DOCTYPE html>
<html lang="en" prefix="og: https://ogp.me/ns#" class="h-100">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <!-- Bootstrap CSS -->
  <link rel="stylesheet" href="bootstrap-4.6.0.min.css">
  <link hreflang="en" rel=alternate type=application/atom+xml title="Quotes feed" href="{{ site.url }}/feed.xml">
  <link rel="icon" href="data:;base64,iVBORw0KGgo=">
  <title>{{ site.title }}</title>
</head>
{% include "base.html" %}

{% block body %}
<body class="d-flex flex-column h-100">

  <main class="flex-shrink-0">

    <div class="container">
      <h1 class="mt-5">Man Quotes</h1>
      <p class="lead">A collection of quotes I have encountered while wandering through manpages.</p>


@@ 27,7 15,6 @@
        </blockquote>
      </article>
      {% endfor %}

    </div>
  </main>



@@ 36,6 23,4 @@
      <span class="text-muted"><a href="mailto:mehdi@mehdix.org">Mehdi Sadeghi</a> @ 2021</span>
    </div>
  </footer>

</body>
</html>
{% endblock %}

M quote.html => quote.html +5 -14
@@ 1,22 1,13 @@
<!DOCTYPE html>
<html lang="en" prefix="og: https://ogp.me/ns#" class="h-100">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <!-- Bootstrap CSS -->
  <link rel="stylesheet" href="bootstrap-4.6.0.min.css">
  <link hreflang="en" rel=alternate type=application/atom+xml title="Quotes feed" href="{{ site.url }}/feed.xml">
  <link rel="icon" href="data:;base64,iVBORw0KGgo=">
  <title>{{ site.title }}</title>
</head>
{% include "base.html" %}

{% block body %}
<body class="h-100 d-flex text-center text-white bg-dark" style="align-items:center">
  <div class="container">
    <blockquote class="blockquote">
      <p class="mb-0">{{ quote.quote }}</p>
      <p class="mb-0 display-4">{{ quote.quote }}</p>
      <footer class="blockquote-footer">{{ quote.author }} in <cite title="{{quote.source}}">{{quote.source}}</cite></footer>
    </blockquote>
  </div>
</body>
</html>
{% endblock %}


A templates/base.html => templates/base.html +18 -0
@@ 0,0 1,18 @@
<!DOCTYPE html>
<html lang="en" prefix="og: https://ogp.me/ns#" class="h-100">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <!-- Bootstrap CSS -->
  <link rel="stylesheet" href="bootstrap-4.6.0.min.css">
  <link hreflang="en" rel=alternate type=application/atom+xml title="Quotes feed" href="{{ site.url }}/feed.xml">
  <link rel="icon" href="data:;base64,iVBORw0KGgo=">
  <title>{{ site.title }}</title>
</head>

{% block body %}
{% endblock %}

</body>
</html>